-
-
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
import_meta.glob is not a function
(updating vite@2.3.4
-> vite@2.3.5
)
#3617
Comments
I'm guessing this is related to the breaking change evanw/esbuild#660 introduced in |
So it's a down-/up-stream bug 😅 |
😀
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. |
@brillout it looks like a spelling error,make sure you are not using If not, it is better to give a reproduction |
@ygj6 It's not a spelling error. Reproductionyarn create vite-plugin-ssr
cd vite-ssr-project/
yarn
yarn dev Go to localhost:3000 and click on the counter => page is interactive. (You have yarn install vite@2.3.5 Click on the counter => it doesn't work and the browser throws the aforementioned error. |
|
The issue happens in esbuild >= 0.12.4.
|
The client is not transpiled to CommonJS. If you look at By a matter of fact this is a bug and regression, since everything works with |
Sorry for misreading the file path. Here's the workaround:
|
Caused by this evanw/esbuild#277 |
Vite may help work around this issue by overwriting the TypeScript target when invoking esbuild. But I'm not sure if it is the right thing to do. Sure overwriting the TypeScript target does no harm and is very likely to be backward-compatible in Vite. Shipping TypeScript source files in an npm package may not be a good practice IMO. |
On why shipping pure TS packages (or to say, exposing pure TS files for users to import) is a bad idea:
|
I changed Still no luck; the same error is thrown in the browser. The file // Vite resolves globs with micromatch: https://github.com/micromatch/micromatch
// Pattern `*([a-zA-Z0-9])` is an Extglob: https://github.com/micromatch/micromatch#extglobs
export const pageFiles = {
//@ts-ignore
'.page': import.meta.glob('/**/*.page.*([a-zA-Z0-9])'),
//@ts-ignore
'.page.client': import.meta.glob('/**/*.page.client.*([a-zA-Z0-9])'),
//@ts-ignore
'.page.route': import.meta.glob('/**/*.page.route.*([a-zA-Z0-9])')
};
//# sourceMappingURL=pageFiles.client.js.map But Vite still transforms it to // node_modules/vite-plugin-ssr/dist/esm/page-files/pageFiles.client.js
var import_meta = {};
var pageFiles = {
".page": import_meta.glob("/**/*.page.*([a-zA-Z0-9])"),
".page.client": import_meta.glob("/**/*.page.client.*([a-zA-Z0-9])"),
".page.route": import_meta.glob("/**/*.page.route.*([a-zA-Z0-9])")
}; Same reproduction steps as above. (Use So it does seem like a Vite bug. (Btw thanks for your suggestion to not publish TypeScript code; it makes a lot of sense and I'm glad to now pbulish ESM instead.) |
🤔 It's still the As a workaround, you can add |
You are right, changing the Yea it's quite unexpected to have Thank you for your helpful answers, I appreciate it. I guess we can close this ticket since it's more a esbuild bug / DX problem. |
This issue has been locked since it has been closed for more than 14 days. If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion. |
The latest release
2.3.5
breaksvite-plugin-ssr
and the browser throwsUncaught TypeError: import_meta.glob is not a function
.I'm looking at what change may have led to that.
The text was updated successfully, but these errors were encountered: