Compare commits

...

2 Commits

Author SHA1 Message Date
Deepak Prajapati a40834d64c
Merge bd51be4493 into 9f98d803c0 2025-10-04 20:00:12 +08:00
Deepak Prajapati bd51be4493 fix: resolve SystemJS default import undefined issue
- Add conditional check for module.default property in SystemLibraryPlugin
- Handle both ES6 modules (with default property) and SystemJS modules (without default property)
- Fixes issue where default imports returned undefined instead of module object
- Maintains backward compatibility with existing functionality
- Resolves #19950
2025-10-03 02:51:08 +05:30
1 changed files with 32 additions and 4 deletions

View File

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