mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: do not error on null exports in ESM loader (#37024)
Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>
This commit is contained in:
@@ -51,7 +51,7 @@ index bfee280212fc4d85b2b0a92ac79d898de3cb5ab3..a79cec8d82b439202ecf40b3d55b7570
|
||||
}
|
||||
}
|
||||
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
|
||||
index 6f25b2e67ab77613c6ed63c227bb875d5461f45f..d1527b859bbea15fdf30622fc8f2700bde5b4591 100644
|
||||
index 6f25b2e67ab77613c6ed63c227bb875d5461f45f..010fa8f78a21a8146879849e2e887332e2694e51 100644
|
||||
--- a/lib/internal/modules/esm/translators.js
|
||||
+++ b/lib/internal/modules/esm/translators.js
|
||||
@@ -154,7 +154,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
|
||||
@@ -63,15 +63,19 @@ index 6f25b2e67ab77613c6ed63c227bb875d5461f45f..d1527b859bbea15fdf30622fc8f2700b
|
||||
[...exportNames] : ['default', ...exportNames];
|
||||
|
||||
return new ModuleWrap(url, undefined, namesWithDefault, function() {
|
||||
@@ -173,7 +173,7 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
|
||||
@@ -173,9 +173,9 @@ translators.set('commonjs', async function commonjsStrategy(url, source,
|
||||
}
|
||||
}
|
||||
|
||||
- for (const exportName of exportNames) {
|
||||
- if (!ObjectPrototypeHasOwnProperty(exports, exportName) ||
|
||||
- exportName === 'default')
|
||||
+ for (const exportName of namesWithDefault) {
|
||||
if (!ObjectPrototypeHasOwnProperty(exports, exportName) ||
|
||||
exportName === 'default')
|
||||
+ if (exportName === 'default' ||
|
||||
+ !ObjectPrototypeHasOwnProperty(exports, exportName))
|
||||
continue;
|
||||
// We might trigger a getter -> dont fail.
|
||||
let value;
|
||||
diff --git a/lib/internal/url.js b/lib/internal/url.js
|
||||
index 2a4ffefe2450708af61e09d7a9530bec1c15d922..9a1c49df14e8b3cef7e66789242a625c6afb3ca9 100644
|
||||
--- a/lib/internal/url.js
|
||||
|
||||
Reference in New Issue
Block a user