-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESM support #784
ESM support #784
Conversation
implements auth0#783
@@ -0,0 +1,11 @@ | |||
import { createRequire } from 'module'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that is makes much difference, but could you change this to:
import mod from './index.js';
export const { ManagementClient, AuthenticationClient } = mod;
export default { ManagementClient, AuthenticationClient }
(and check it still fixes your issue)
This works for Node 19 and looks a bit simpler - also i don't think we need the doc (I should probably remove this from the other index too)
@@ -3,6 +3,7 @@ | |||
"version": "3.1.2", | |||
"description": "SDK for Auth0 API v2", | |||
"main": "src/index.js", | |||
"module": "src/index.mjs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use conditional exports for this, I believe module
is the "old" way of specifying esm exports for bundlers, and the standard node way is exports
"module": "src/index.mjs", | |
"exports": { | |
"import": "./src/index.mjs", | |
"require": "./src/index.js" | |
}, |
(and also check that it resolves your issue - thanks!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it makes sense to use exports...however it will require a major version update for this library if you are following semver rules. I went with the more conservative route of adding "module" but if you are willing to push a major version update, then we can switch it to exports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @btakita - possibly a stupid question - why do you think it would be a breaking change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it has to do with preventing any other entry points besides those defined in "exports". found in https://nodejs.org/api/packages.html#package-entry-points
I suppose that if all of the modules in the package were defined within exports, then it may not be a breaking change. I'm not sure though. I'll look more into an authoritative source on whether it would still be a breaking change if all modules in the package were defined in exports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, I didn't know that - let's stick with "module"
then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @btakita
I'm still having issues with the auth0 package when I deploy to an AWS lambda using serverless framework and webpack.
This is the error
|
Hi @langell - we didn't add package exports because this would have been a breaking change. You probably need to do something like |
ok I'll give that a try, thanks for the speedy response :-) |
@adamjmcgrath, do you have a roadmap date for when you will release the package exports? |
@langell - I don't have a timeline I'm afraid Although looking at your stacktrace again, I don't think this is the issue as |
@adamjmcgrath, I'll get you the details later today. I will be able to duplicate this locally I think |
fixes #783
Changes
Please describe both what is changing and why this is important. Include:
References
Please include relevant links supporting this change such as a:
Testing
Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.
Checklist