Cannot `import "vite/modulepreload-polyfill"`
morfert opened this issue · 3 comments
After upgrading to 0.3.6
and adding the following line to assests\vue\index.js
.
import "vite/modulepreload-polyfill";
I get the following error.
[vite] Internal server error: Missing "./modulepreload-polyfill" specifier in "vite" package
Plugin: vite:import-analysis
File: D:/my_project/assets/vue/index.js
at e (file:///D:/my_project/assets/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:47597:25)
at n (file:///D:/my_project/assets/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:47597:627)
at o (file:///D:/my_project/assets/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:47597:1297)
at resolveExportsOrImports (file:///D:/my_project/assets/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:48287:20)
at resolveDeepImport (file:///D:/my_project/assets/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:48306:31)
at tryNodeResolve (file:///D:/my_project/assets/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:48031:20)
at Context.resolveId (file:///D:/my_project/assets/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:47781:28)
at async Object.resolveId (file:///D:/my_project/assets/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:51063:32)
at async TransformContext.resolve (file:///D:/my_project/assets/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:50754:23)
at async normalizeUrl (file:///D:/my_project/assets/node_modules/.pnpm/vite@5.2.11/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:66119:34)
If I comment out the import
the error is gone and vite works.
Cannot seem to find anything about this in the vite issues.
Hmm I found recommendation to include it in the vite documentation. It seems to be working nicely on my machine. Will try to troubleshoot it, any tips how to reproduce? Does it happen on a fresh install for you as well?
@morfert I did some digging. According to Vite source code vite/modulepreload-polyfill
is a "special" import enabled by vite plugin. To have that plugin installed we need to have build.modulePreload.polyfill == true
or undefined. I'll fix it in a moment!
Thanks for the report 😍 and please let me know if next version will have it fixed (You'll have to manually remove modulePreload: { polyfill: false }
line from vite.config.js`)
I upgraded to live_vue 0.3.7
and commented out the following from vite.config.js
.
// assets/vite.config.js
// modulePreload: { polyfill: false },
Now there are no errors even with the following import in assets/vue/index.js
.
// assets/vue/index.js
import "vite/modulepreload-polyfill";
Cheers 👍.