Dynamic glob imports does not work with vite
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v14.16.0
- Nuxt Version:
3.0.0-27265876.3cd4494
- Package Manager:
npm@7.17.0
- Bundler:
Vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
Describe the bug
Unpredictable dynamic imports like import(
~/data/${name}json)` does not work with vite (dev-bundler)
Reproduction
https://stackblitz.com/edit/github-obezmd?file=app.vue
Additional context
As a workaround, one can use webpack using vite: false
in nuxt.config
.
Missing implementation is here but we probably need more to fix this.
Logs
Cannot read properties of undefined (reading 'stubModule')
at __instantiateModule__ (file://./.nuxt/dist/server/server.mjs:1771:11)
at __ssrLoadModule__ (file://./.nuxt/dist/server/server.mjs:1762:25)
at ssrImport (file://./.nuxt/dist/server/server.mjs:1787:13)
at ssrDynamicImport (file://./.nuxt/dist/server/server.mjs:1798:12)
at eval (file://./.nuxt/dist/server/server.mjs:1678:70)
at Module.withAsyncContext (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7295:21)
at setup (file://./.nuxt/dist/server/server.mjs:1678:47)
at _sfc_main.setup (file://./.nuxt/dist/server/server.mjs:1708:23)
at callWithErrorHandling (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:6615:22)
at setupStatefulComponent (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:6241:29)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:23 (6 by maintainers)
Top Results From Across the Web
Features
You can NOT use variables or expressions in them. Dynamic Import #. Similar to glob import, Vite also supports dynamic import with variables....
Read more >Glob Imports in Vite - A Vue.js Lesson From our ...
In this lesson, we learn how to import multiple modules at one time using a glob pattern. Matched modules can be imported either...
Read more >vite & react import images dynamically from public url
First you need to adjust the path that you pass to the import.meta.glob function. Specify a path relative to the file that this...
Read more >Problem configuring dynamic page importing with Vite and ...
I'm working on an app with AdonisJS as a backend, Inertia , Vue 3 and Vite to bundle assets. The problem is, I...
Read more >vite-plugin-dynamic-import
vite -plugin-dynamic-import. TypeScript icon, indicating that this package has built-in type declarations. 1.2.4 • Public • Published a month ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there is any update on this issue because i have the same problem
Now, I try to use vite-plugin-dynamic-import to resolve this problem.
But in the end, I hope it can be integrated into vite.
2022-07-28
You may got the following error.
ERROR Unexpected token (1:0)