-
-
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
Preload code not passing through rollup #9016
Comments
Preload helper does not have a extension.
So if you don't include '' to this extension config, @rollup/plugin-babel will skip the helper.
|
Thanks, I added |
IMO Vite should have |
I'm not sure if helpers should have the But maybe the better way is to have |
I think the babel of output code will generate more code because it will duplicate core-js modules and runtime code for all output files. And I have two problems with @vitejs/plugin-legacy:
|
That's because
SvelteKit had transitioned to just a Vite plugin, so perhaps it could work now too. That issue was written when SvelteKit had full control over Vite. |
|
I've checked rollup/plugins repo. It seems most of the virtual modules has a extension. https://github.com/rollup/plugins/blob/985cf4c422896ac2b21279f0f99db9d281ef73c2/packages/babel/src/constants.js#L8 I think this will make it more easy to handle these in general. export default function preloadPolyfillPlugin() {
return {
name: 'preload-polyfill-plugin',
resolveId(id) {
if (id === 'vite/modulepreload-polyfill') {
return '\0vite/modulepreload-polyfill.js'
}
},
load(id) {
if (id === '\0vite/modulepreload-polyfill.js') {
return // TODO
}
}
}
} |
vite/packages/plugin-legacy/src/index.ts Lines 353 to 402 in 519f7de
And yes, plugin-legacy does not have an option to control babel finely.
|
Interesting. I think it's still risky to expect virtual modules in general to have an extension though, but thanks for the pointer. Maybe we could consider adding extensions for Vite too.
You're right, I forgot that plugin-legacy skips esbuild. In that case babel would be handling syntax transform then via plugin-legacy's |
Added this issue to the Vite 5 milestone. I think it may be a good idea to add an extension to all resolved internal virtual modules and see how things work there 👍🏼 |
@sapphi-red would you explain why this would be a breaking change? Are downstream projects relying on the resolved id for our internal virtual modules? |
I put that label in case someone didn't expect internal modules not to be transformed by |
Describe the bug
I added a rollup plugin to vite config, but it turned out that it does not affect the preload code. The bundle has mixed code - passed through rollup and not passed through rollup. Could you make preload code go through rollup too?
See the bundle:
dist/assets/index.02199377.js
Additional: If this issue will resolved, then this pull request is no longer needed.
Reproduction
see my repo here
dist/assets/index.[hash].js
fileSystem Info
Used Package Manager
pnpm
Logs
Logs
Validations
The text was updated successfully, but these errors were encountered: