Closed s-h-a-d-o-w closed 1 year ago
Should work in the latest release (5.0.0)
What a coincidence, thanks for releasing it! Unfortunately, it doesn't seem to work.
I hope the following context can shed some light on the problem:
main.js has changed from
(async()=>{await import('http://localhost:5173/./src/main.js')})();
to
(async()=>{
await import("http://localhost:5173/@vite/client");
await import("http://localhost:5173/./src/main.js")
}
)();
@vite/client
contains:
import "/node_modules/vite/dist/client/env.mjs";
// ...
node_modules/vite/dist/client/env.mjs
contains:
const context = (() => {
if (typeof globalThis !== 'undefined') {
return globalThis;
}
else if (typeof self !== 'undefined') {
return self;
}
else if (typeof window !== 'undefined') {
return window;
}
else {
return Function('return this')();
}
})();
// assign defines
const defines = {};
Object.keys(defines).forEach((key) => {
const segments = key.split('.');
let target = context;
for (let i = 0; i < segments.length; i++) {
const segment = segments[i];
if (i === segments.length - 1) {
target[segment] = defines[key];
}
else {
target = target[segment] || (target[segment] = {});
}
}
});
// sourcemap
Should that defines
variable there maybe contain the values I defined instead of an empty object?
Actually, this time, it was my fault. 😅
For some reason, I had define
within the rollup options. 🤦
vite doesn't replace defines in dev. Resulting in errors such as
ReferenceError: process is not defined
.Presumably, wherever those globals are defined - it can't be reached by e.g. content scripts.
Are you aware of a solution to this?