-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
fix: __vite__mapDeps
code injection
#15732
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6118a17
fix: fix `__vite__mapDeps` injected into a wrong position
hi-ogawa 013be31
test: tweak
hi-ogawa 32aad3d
chore: comment
hi-ogawa abaaefd
refactor: minor
hi-ogawa 6a1a4d2
Merge branch 'main' into fix-mapDepsCode-append
hi-ogawa 7e714e1
chore: prepend __vite__mapDeps
hi-ogawa 3e7e896
test: snapshot
hi-ogawa 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// hashbang is injected via rollupOptions.output.banner | ||
|
||
import('./dynamic/dynamic-foo') | ||
|
||
console.log('after preload dynamic hashbang') |
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 |
---|---|---|
|
@@ -12,9 +12,17 @@ export default defineConfig({ | |
rollupOptions: { | ||
output: { | ||
manualChunks(name) { | ||
if (name.includes('after-preload-dynamic')) { | ||
if (name.endsWith('after-preload-dynamic.js')) { | ||
return 'after-preload-dynamic' | ||
} | ||
if (name.endsWith('after-preload-dynamic-hashbang.js')) { | ||
return 'after-preload-dynamic-hashbang' | ||
} | ||
}, | ||
banner(chunk) { | ||
if (chunk.name.endsWith('after-preload-dynamic-hashbang')) { | ||
return '#!/usr/bin/env node' | ||
} | ||
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used $ pnpm -C playground/js-sourcemap build
> @vitejs/test-js-sourcemap@0.0.0 build /home/hiroshi/code/others/vite/playground/js-sourcemap
> vite build
vite v5.1.3 building for production...
✓ 7 modules transformed.
x Build failed in 56ms
error during build:
RollupError: Expected ident
at error (file:///home/hiroshi/code/others/vite/node_modules/.pnpm/rollup@4.2.0/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
at nodeConverters (file:///home/hiroshi/code/others/vite/node_modules/.pnpm/rollup@4.2.0/node_modules/rollup/dist/es/shared/parseAst.js:2072:9)
at convertNode (file:///home/hiroshi/code/others/vite/node_modules/.pnpm/rollup@4.2.0/node_modules/rollup/dist/es/shared/parseAst.js:957:12)
at convertProgram (file:///home/hiroshi/code/others/vite/node_modules/.pnpm/rollup@4.2.0/node_modules/rollup/dist/es/shared/parseAst.js:948:48)
at parseAstAsync (file:///home/hiroshi/code/others/vite/node_modules/.pnpm/rollup@4.2.0/node_modules/rollup/dist/es/shared/parseAst.js:2138:20)
at Module.tryParseAsync (file:///home/hiroshi/code/others/vite/node_modules/.pnpm/rollup@4.2.0/node_modules/rollup/dist/es/shared/node-entry.js:13357:21)
at Module.setSource (file:///home/hiroshi/code/others/vite/node_modules/.pnpm/rollup@4.2.0/node_modules/rollup/dist/es/shared/node-entry.js:12953:35)
at ModuleLoader.addModuleSource (file:///home/hiroshi/code/others/vite/node_modules/.pnpm/rollup@4.2.0/node_modules/rollup/dist/es/shared/node-entry.js:17580:13)
ELIFECYCLE Command failed with exit code 1. |
||
}, | ||
}, | ||
}, | ||
|
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.
if
fileDeps.length == 0
, maybe we do not need execs.prependLeft
orprepend
because sometimes
__vite__mapDeps
is not usedI can't find how to remove the configuration of
__vite__mapDeps
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.
We can use
[]
instead of__vite__mapDeps([${renderedDeps.join(',')}])
ifrenderedDeps.length
is 0. Then, we can skip injecting__vite__mapDeps
. Contributions are welcome 👍