-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
feat!: migrate to ESM #8178
Merged
feat!: migrate to ESM #8178
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b65773c
chore: migrate to esm
antfu ce8b9cc
chore: update
antfu 2302063
chore: update
antfu ab204d0
feat: patch cjs context
antfu 63012c5
fix: tests
antfu f8ce0e6
chore: update
antfu 0f81c98
fix: make `formatPostcssSourceMap` async and fix css-sourcemap error
antfu cc58a9b
fix: build dual format for `splitVendorChunk`
antfu 5bea908
chore: lint
antfu 0738eb9
chore: update
antfu 19292a3
chore: update
antfu 9f8c74c
chore: update
antfu 0e1da14
chore: rename file
antfu de67745
chore: fix tests
antfu aa07d3f
chore: format
antfu 96622ca
chore: cleanup
antfu 28e9a34
chore: use ts for rollup config
antfu 0f1e540
chore: update
antfu 1140920
chore: Merge branch 'main' into feat/esm
antfu 1cd5be8
chore: Merge branch 'main' into feat/esm
antfu e481971
chore: deps
antfu 8252f19
fix: proxy `loadConfigFromFile`
antfu 439fef7
fix: stricten exports
antfu e9bccb6
chore: try expose terser entry
antfu 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
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
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
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
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
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
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,32 @@ | ||
/* eslint-disable no-restricted-globals */ | ||
|
||
// type utils | ||
module.exports.defineConfig = (config) => config | ||
|
||
// proxy cjs utils (sync functions) | ||
Object.assign(module.exports, require('./dist/node-cjs/publicUtils.cjs')) | ||
|
||
// async functions, can be redirect from ESM build | ||
const asyncFunctions = [ | ||
'build', | ||
'createServer', | ||
'preview', | ||
'transformWithEsbuild', | ||
'resolveConfig', | ||
'optimizeDeps', | ||
'formatPostcssSourceMap' | ||
] | ||
asyncFunctions.forEach((name) => { | ||
module.exports[name] = (...args) => | ||
import('./dist/node/index.js').then((i) => i[name](...args)) | ||
}) | ||
|
||
// some sync functions are marked not supported due to their complexity and uncommon usage | ||
const unsupportedCJS = ['resolvePackageEntry', 'resolvePackageData'] | ||
unsupportedCJS.forEach((name) => { | ||
module.exports[name] = () => { | ||
throw new Error( | ||
`"${name}" is not supported in CJS build of Vite 3.\nPlease use ESM or dynamic imports \`const { ${name} } = await import('vite')\`.` | ||
) | ||
} | ||
}) |
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
Oops, something went wrong.
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.
I think we could remove these 2 fields since Vite 3 supports Node 14+, Node 12+ supports
exports
field andexports
takes priority thanmain
andmodule
so Node.js will never reach these 2 fields.