This commit is contained in:
Deepak Prajapati 2025-10-04 20:00:12 +08:00 committed by GitHub
commit a40834d64c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 4 deletions

View File

@ -133,7 +133,20 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
chunk.runtime chunk.runtime
); );
if (used) { if (used) {
if (otherUnused || used !== exportInfo.name) { if (used === "default" && exportInfo.name === "default") {
instructions.push(
Template.asString([
"if (typeof module.default !== 'undefined') {",
Template.indent([
`${external}.default = module.default;`
]),
"} else {",
Template.indent([`${external} = module;`]),
"}"
])
);
handledNames.push(exportInfo.name);
} else if (otherUnused || used !== exportInfo.name) {
instructions.push( instructions.push(
`${external}${propertyAccess([ `${external}${propertyAccess([
used used
@ -172,9 +185,24 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
} else { } else {
instructions.push( instructions.push(
Template.asString([ Template.asString([
"Object.keys(module).forEach(function(key) {", "if (typeof module.default !== 'undefined') {",
Template.indent([`${external}[key] = module[key];`]), Template.indent([
"});" "Object.keys(module).forEach(function(key) {",
Template.indent([
`${external}[key] = module[key];`
]),
"});"
]),
"} else {",
Template.indent([
`${external} = module;`,
"Object.keys(module).forEach(function(key) {",
Template.indent([
`${external}[key] = module[key];`
]),
"});"
]),
"}"
]) ])
); );
} }