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,
|
||||
runtimeRequirements
|
||||
});
|
||||
const ids = dep.getIds(moduleGraph);
|
||||
const usedImported = moduleGraph
|
||||
.getExportsInfo(importedModule)
|
||||
.getUsedName(ids, runtime);
|
||||
if (usedImported) {
|
||||
const comment = equals(usedImported, ids)
|
||||
? ""
|
||||
: Template.toNormalComment(propertyAccess(ids)) + " ";
|
||||
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
||||
if (importedModule) {
|
||||
const ids = dep.getIds(moduleGraph);
|
||||
const usedImported = moduleGraph
|
||||
.getExportsInfo(importedModule)
|
||||
.getUsedName(ids, runtime);
|
||||
if (usedImported) {
|
||||
const comment = equals(usedImported, ids)
|
||||
? ""
|
||||
: Template.toNormalComment(propertyAccess(ids)) + " ";
|
||||
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
|
|
|
@ -108,15 +108,17 @@ CommonJsFullRequireDependency.Template = class CommonJsFullRequireDependencyTemp
|
|||
weak: dep.weak,
|
||||
runtimeRequirements
|
||||
});
|
||||
const ids = dep.names;
|
||||
const usedImported = moduleGraph
|
||||
.getExportsInfo(importedModule)
|
||||
.getUsedName(ids, runtime);
|
||||
if (usedImported) {
|
||||
const comment = equals(usedImported, ids)
|
||||
? ""
|
||||
: Template.toNormalComment(propertyAccess(ids)) + " ";
|
||||
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
||||
if (importedModule) {
|
||||
const ids = dep.names;
|
||||
const usedImported = moduleGraph
|
||||
.getExportsInfo(importedModule)
|
||||
.getUsedName(ids, runtime);
|
||||
if (usedImported) {
|
||||
const comment = equals(usedImported, ids)
|
||||
? ""
|
||||
: Template.toNormalComment(propertyAccess(ids)) + " ";
|
||||
requireExpr += `${comment}${propertyAccess(usedImported)}`;
|
||||
}
|
||||
}
|
||||
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);
|
||||
if (templateContext.moduleGraph.isAsync(referencedModule)) {
|
||||
if (
|
||||
referencedModule &&
|
||||
templateContext.moduleGraph.isAsync(referencedModule)
|
||||
) {
|
||||
templateContext.initFragments.push(
|
||||
new ConditionalInitFragment(
|
||||
importStatement[0],
|
||||
|
|
Loading…
Reference in New Issue