vite: `import_meta.glob is not a function` (updating `vite@2.3.4` -> `vite@2.3.5`)
The latest release 2.3.5
breaks vite-plugin-ssr
and the browser throws Uncaught TypeError: import_meta.glob is not a function
.
I’m looking at what change may have led to that.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (15 by maintainers)
Commits related to this issue
- dual publish CJS + ESM (vitejs/vite#3617, fix #85) — committed to vikejs/vike by brillout 3 years ago
- fix: define ESM build in tsconfig.ts instead of CLI (vitejs/vite#3617, fix #85) — committed to vikejs/vike by brillout 3 years ago
🤔 It’s still the
tsconfig.json
issue.esbuild
uses its target to transpile.js
files too. I think I need to file an issue to esbuild. This will cause much confusion.As a workaround, you can add
tsconfig.json
to.npmignore
to avoid it being published on npm; or better, use thefiles
field inpackage.json
to only publish the necessary files.The client is not transpiled to CommonJS. If you look at
node_modules/.vite/vite-plugin-ssr_client.js
(after running the reproduction steps) you’ll see ES Modules, as expected.By a matter of fact this is a bug and regression, since everything works with
vite@2.3.4
. Not sure if it only affectsvite-plugin-ssr
butimport.meta.glob
is not being processed as it should.😀
I’m not sure if it’s an esbuild bug, since it’s an expected breaking change. I’ll try to find some time this week to dig more what’s going on.