You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/vite/src/node/plugins/resolve.ts
+15-4Lines changed: 15 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -447,15 +447,26 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin {
447
447
load(id){
448
448
if(id.startsWith(browserExternalId)){
449
449
if(isProduction){
450
-
return`export default {}`
450
+
// return `export default {}`
451
+
// The rolldown missing export is always error level, it will break build.
452
+
// So here using the cjs module to avoid it.
453
+
return`module.exports = {}`
451
454
}else{
452
455
id=id.slice(browserExternalId.length+1)
456
+
// The rolldown using esbuild interop helper, so here copy the proxy module from https://github.com/vitejs/vite/blob/main/packages/vite/src/node/optimizer/esbuildDepPlugin.ts#L259
453
457
return`\
454
-
export default new Proxy({}, {
458
+
module.exports = Object.create(new Proxy({}, {
455
459
get(_, key) {
456
-
throw new Error(\`Module "${id}" has been externalized for browser compatibility. Cannot access "${id}.\${key}" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.\`)
460
+
if (
461
+
key !== '__esModule' &&
462
+
key !== '__proto__' &&
463
+
key !== 'constructor' &&
464
+
key !== 'splice'
465
+
) {
466
+
throw new Error(\`Module "${id}" has been externalized for browser compatibility. Cannot access "${id}.\${key}" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.\`)
0 commit comments