mirror of https://github.com/webpack/webpack.git
fix some cases where undefined modules are used
This commit is contained in:
parent
daa2c3808e
commit
9e4c259cce
|
@ -340,15 +340,17 @@ CommonJsExportRequireDependency.Template = class CommonJsExportRequireDependency
|
||||||
weak: dep.weak,
|
weak: dep.weak,
|
||||||
runtimeRequirements
|
runtimeRequirements
|
||||||
});
|
});
|
||||||
const ids = dep.getIds(moduleGraph);
|
if (importedModule) {
|
||||||
const usedImported = moduleGraph
|
const ids = dep.getIds(moduleGraph);
|
||||||
.getExportsInfo(importedModule)
|
const usedImported = moduleGraph
|
||||||
.getUsedName(ids, runtime);
|
.getExportsInfo(importedModule)
|
||||||
if (usedImported) {
|
.getUsedName(ids, runtime);
|
||||||
const comment = equals(usedImported, ids)
|
if (usedImported) {
|
||||||
? ""
|
const comment = equals(usedImported, ids)
|
||||||
: Template.toNormalComment(propertyAccess(ids)) + " ";
|
? ""
|
||||||
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
: Template.toNormalComment(propertyAccess(ids)) + " ";
|
||||||
|
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
|
@ -108,15 +108,17 @@ CommonJsFullRequireDependency.Template = class CommonJsFullRequireDependencyTemp
|
||||||
weak: dep.weak,
|
weak: dep.weak,
|
||||||
runtimeRequirements
|
runtimeRequirements
|
||||||
});
|
});
|
||||||
const ids = dep.names;
|
if (importedModule) {
|
||||||
const usedImported = moduleGraph
|
const ids = dep.names;
|
||||||
.getExportsInfo(importedModule)
|
const usedImported = moduleGraph
|
||||||
.getUsedName(ids, runtime);
|
.getExportsInfo(importedModule)
|
||||||
if (usedImported) {
|
.getUsedName(ids, runtime);
|
||||||
const comment = equals(usedImported, ids)
|
if (usedImported) {
|
||||||
? ""
|
const comment = equals(usedImported, ids)
|
||||||
: Template.toNormalComment(propertyAccess(ids)) + " ";
|
? ""
|
||||||
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
: Template.toNormalComment(propertyAccess(ids)) + " ";
|
||||||
|
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
source.replace(dep.range[0], dep.range[1] - 1, requireExpr);
|
source.replace(dep.range[0], dep.range[1] - 1, requireExpr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,7 +282,10 @@ HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
|
||||||
}
|
}
|
||||||
|
|
||||||
const importStatement = dep.getImportStatement(false, templateContext);
|
const importStatement = dep.getImportStatement(false, templateContext);
|
||||||
if (templateContext.moduleGraph.isAsync(referencedModule)) {
|
if (
|
||||||
|
referencedModule &&
|
||||||
|
templateContext.moduleGraph.isAsync(referencedModule)
|
||||||
|
) {
|
||||||
templateContext.initFragments.push(
|
templateContext.initFragments.push(
|
||||||
new ConditionalInitFragment(
|
new ConditionalInitFragment(
|
||||||
importStatement[0],
|
importStatement[0],
|
||||||
|
|
Loading…
Reference in New Issue