Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not add tree-shaken variables to namespaces when inlining dynamic imports #5047

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Chunk.ts
Expand Up @@ -1367,7 +1367,9 @@ export default class Chunk {
if (!this.outputOptions.preserveModules && this.includedNamespaces.has(module)) {
const memberVariables = module.namespace.getMemberVariables();
for (const variable of Object.values(memberVariables)) {
moduleImports.add(variable);
if (variable.included) {
moduleImports.add(variable);
}
}
}
for (let variable of moduleImports) {
Expand Down
2 changes: 1 addition & 1 deletion src/Module.ts
Expand Up @@ -452,7 +452,7 @@ export default class Module {
) {
for (const exportName of [...this.getReexports(), ...this.getExports()]) {
const [exportedVariable] = this.getVariableForExportName(exportName);
if (exportedVariable) {
if (exportedVariable?.included) {
dependencyVariables.add(exportedVariable);
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/form/samples/inline-with-reexport/_config.js
@@ -0,0 +1,8 @@
module.exports = defineTest({
description: 'handles inlining dynamic imports when the imported module contains reexports',
options: {
output: {
inlineDynamicImports: true
}
}
});
5 changes: 5 additions & 0 deletions test/form/samples/inline-with-reexport/_expected.js
@@ -0,0 +1,5 @@
Promise.resolve().then(function () { return a; });

var a = /*#__PURE__*/Object.freeze({
__proto__: null
});
1 change: 1 addition & 0 deletions test/form/samples/inline-with-reexport/a.js
@@ -0,0 +1 @@
export { b } from './b.js';
1 change: 1 addition & 0 deletions test/form/samples/inline-with-reexport/b.js
@@ -0,0 +1 @@
export const b = 42;
1 change: 1 addition & 0 deletions test/form/samples/inline-with-reexport/main.js
@@ -0,0 +1 @@
import('./a.js');