Skip to content

Commit ae8d674

Browse files
committed
fix bug with incorrectly emitted modules
1 parent 7ebe12d commit ae8d674

File tree

9 files changed

+54
-1
lines changed

9 files changed

+54
-1
lines changed

lib/optimize/SideEffectsFlagPlugin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ class SideEffectsFlagPlugin {
107107
const map = pair[1];
108108
for (const reason of module.reasons) {
109109
const dep = reason.dependency;
110-
if (dep instanceof HarmonyImportSpecifierDependency) {
110+
if (
111+
dep instanceof HarmonyImportSpecifierDependency &&
112+
!dep.namespaceObjectAsContext
113+
) {
111114
const mapping = map.get(dep.id);
112115
if (mapping) {
113116
dep.redirectedModule = mapping.module;

test/__snapshots__/StatsTestCases.test.js.snap

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,25 @@ Child
20622062
ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./first.js (referenced with import())"
20632063
`;
20642064

2065+
exports[`StatsTestCases should print correct stats for side-effects-simple-unused 1`] = `
2066+
"Hash: 0cb74fac5f3c1b7f2150
2067+
Time: Xms
2068+
Built at: Thu Jan 01 1970 00:00:00 GMT
2069+
Asset Size Chunks Chunk Names
2070+
main.js 2.94 KiB 0 [emitted] main
2071+
Entrypoint main = main.js
2072+
[0] ./node_modules/pmodule/b.js 69 bytes [built]
2073+
[no exports used]
2074+
[1] ./node_modules/pmodule/a.js 60 bytes [built]
2075+
[no exports used]
2076+
[2] ./index.js + 2 modules 158 bytes {0} [built]
2077+
| ./index.js 55 bytes [built]
2078+
| ./node_modules/pmodule/index.js 75 bytes [built]
2079+
| [only some exports used: default]
2080+
| ./node_modules/pmodule/c.js 28 bytes [built]
2081+
| [only some exports used: z]"
2082+
`;
2083+
20652084
exports[`StatsTestCases should print correct stats for simple 1`] = `
20662085
"Hash: 1843cc9aed8366594774
20672086
Time: Xms
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import def, { z } from "pmodule";
2+
3+
console.log(def, z);

test/statsCases/side-effects-simple-unused/node_modules/pmodule/a.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/statsCases/side-effects-simple-unused/node_modules/pmodule/b.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/statsCases/side-effects-simple-unused/node_modules/pmodule/c.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/statsCases/side-effects-simple-unused/node_modules/pmodule/index.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/statsCases/side-effects-simple-unused/node_modules/pmodule/package.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
mode: "production",
3+
entry: "./index",
4+
stats: {
5+
nestedModules: true,
6+
usedExports: true
7+
}
8+
};

0 commit comments

Comments
 (0)