未验证 提交 27d560ed 编写于 作者: L Lukas Taegert-Atkinson 提交者: GitHub

Fix crash when using inlineDynamicImports with no-treeshake (#4104)

上级 df3b2a5e
......@@ -362,17 +362,18 @@ export default class Module {
}
necessaryDependencies.add(variable.module!);
}
if (this.options.treeshake && this.info.hasModuleSideEffects !== 'no-treeshake') {
this.addRelevantSideEffectDependencies(
relevantDependencies,
necessaryDependencies,
alwaysCheckedDependencies
);
} else {
if (!this.options.treeshake || this.info.hasModuleSideEffects === 'no-treeshake') {
for (const dependency of this.dependencies) {
relevantDependencies.add(dependency);
if (dependency instanceof ExternalModule || dependency.isIncluded()) {
relevantDependencies.add(dependency);
}
}
}
this.addRelevantSideEffectDependencies(
relevantDependencies,
necessaryDependencies,
alwaysCheckedDependencies
);
for (const dependency of necessaryDependencies) {
relevantDependencies.add(dependency);
}
......
const MAGIC_ENTRY = 'main';
module.exports = {
description: 'handles inlining dynamic imports when treeshaking is disabled for modules (#4098)',
options: {
input: MAGIC_ENTRY,
output: {
inlineDynamicImports: true
},
plugins: [
{
name: 'magic-modules',
buildStart() {
this.emitFile({ type: 'chunk', id: './dep.js' });
},
async resolveId(source) {
if (source === MAGIC_ENTRY) {
return { id: source, moduleSideEffects: 'no-treeshake' };
}
return null;
},
async load(id) {
if (id !== MAGIC_ENTRY) return null;
return `import {foo} from './reexport.js';assert.strictEqual(foo, 1);`;
}
}
]
}
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册