-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 module support #884
Open
btakita
wants to merge
1
commit into
auth0:master
Choose a base branch
from
btakita:issues/655
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+10
−0
Open
esm module support #884
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createRequire } from 'module'; | ||
const require = createRequire(import.meta.url); | ||
export const verify = require('./verify.js'); | ||
export const sign = require('./sign.js'); | ||
export const JsonWebTokenError = require('./lib/JsonWebTokenError.js'); | ||
export const NotBeforeError = require('./lib/NotBeforeError.js'); | ||
export const TokenExpiredError = require('./lib/TokenExpiredError.js'); | ||
export const decode = require('./decode'); | ||
export default { verify, sign, JsonWebTokenError, NotBeforeError, TokenExpiredError, decode } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 tested this locally with node and bundler rollup/webpack/esbuild, all works fine.
rollup
rollup use condition
['default', 'module', 'import']
, so it will resolve to./index.js
.Previous rollup config with node-resolve and cjs plugins will still work. rollup without these plugins was broken and still be broken.
webpack support this out-of-box
I'm not sure what's its condition, but at least it include
module
and resolve toindex.js
esbuild
a little bit complex here.
--platform=node
, it will use condition['default', 'import', 'node', 'module']
or['default', 'require', 'node', 'module']
(depend on source code), so the only important thing is to put"module": "./index.js",
in the top ofexports
object, otherwise esbuild will resolve to conditionimport.node
(index.mjs
).(yes,
exports
as json field are ordered, bundlers or runtime will try to resolve from top to end)--platform=node
is not given, condition won't includenode
, and it can only resolve tomodule
orrequire
, that'sindex.js
.vite
vite doesn't use
node
condition.Summary
don't add
package.json#module
, useexports
with conditions.So no bundler's behavior will change, what's broken is still broken, and now nodejs can have a better esm support from this package