Skip to content

Commit

Permalink
fix bug with incorrectly emitted modules
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed May 27, 2018
1 parent 7ebe12d commit ae8d674
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/optimize/SideEffectsFlagPlugin.js
Expand Up @@ -107,7 +107,10 @@ class SideEffectsFlagPlugin {
const map = pair[1];
for (const reason of module.reasons) {
const dep = reason.dependency;
if (dep instanceof HarmonyImportSpecifierDependency) {
if (
dep instanceof HarmonyImportSpecifierDependency &&
!dep.namespaceObjectAsContext
) {
const mapping = map.get(dep.id);
if (mapping) {
dep.redirectedModule = mapping.module;
Expand Down
19 changes: 19 additions & 0 deletions test/__snapshots__/StatsTestCases.test.js.snap
Expand Up @@ -2062,6 +2062,25 @@ Child
ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./first.js (referenced with import())"
`;

exports[`StatsTestCases should print correct stats for side-effects-simple-unused 1`] = `
"Hash: 0cb74fac5f3c1b7f2150
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
main.js 2.94 KiB 0 [emitted] main
Entrypoint main = main.js
[0] ./node_modules/pmodule/b.js 69 bytes [built]
[no exports used]
[1] ./node_modules/pmodule/a.js 60 bytes [built]
[no exports used]
[2] ./index.js + 2 modules 158 bytes {0} [built]
| ./index.js 55 bytes [built]
| ./node_modules/pmodule/index.js 75 bytes [built]
| [only some exports used: default]
| ./node_modules/pmodule/c.js 28 bytes [built]
| [only some exports used: z]"
`;

exports[`StatsTestCases should print correct stats for simple 1`] = `
"Hash: 1843cc9aed8366594774
Time: Xms
Expand Down
3 changes: 3 additions & 0 deletions test/statsCases/side-effects-simple-unused/index.js
@@ -0,0 +1,3 @@
import def, { z } from "pmodule";

console.log(def, z);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions test/statsCases/side-effects-simple-unused/webpack.config.js
@@ -0,0 +1,8 @@
module.exports = {
mode: "production",
entry: "./index",
stats: {
nestedModules: true,
usedExports: true
}
};

0 comments on commit ae8d674

Please sign in to comment.