Closed korbinzhao closed 1 month ago
The global
is being shadowed from https://github.com/vitejs/vite/blob/e1fb0fa27097566c8fa5e792f965c29fc050b837/packages/vite/src/node/ssr/ssrModuleLoader.ts#L216
Internally Vite would generate code like this:
function (global, ...) {
const global = "asd";
Object.defineProperty(__vite_ssr_exports__, "global", { enumerable: true, configurable: true, get(){ return global }});
__vite_ssr_exports__.default = {
global: global
};
}
Which causes the issue because global
can't be re-declared. Perhaps Vite needs to rewrite the internal global
declaration to avoid the error.
I have encountered the same problem, checking if there is' global 'in your i18n. It has been tormenting me all afternoon, and it is actually this problem
Describe the bug
Error happened in a ssr vite react project while importing a json file as below:
index.tsx
test.json
The error message is :
Reproduction
https://github.com/korbinzhao/template-ssr-react-streaming-ts/blob/bug/ssr_json_global/src/App.tsx#L4
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
No response
Validations