fix bug with incorrectly emitted modules

This commit is contained in:
Tobias Koppers 2018-05-27 21:47:58 +02:00
parent 7ebe12dde1
commit ae8d6741d7
9 changed files with 54 additions and 1 deletions

View File

@ -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;

View File

@ -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

View File

@ -0,0 +1,3 @@
import def, { z } from "pmodule";
console.log(def, z);

View File

@ -0,0 +1,5 @@
var a = "a";
var b = "b";
var c = "c";
export { a, b, c };

View File

@ -0,0 +1,5 @@
var x = "x";
var y = "y";
export { x, y };
export { z } from "./c";

View File

@ -0,0 +1,3 @@
var z = "z";
export { z };

View File

@ -0,0 +1,4 @@
export * from "./a";
export { x, y, z } from "./b";
export default "def";

View File

@ -0,0 +1,3 @@
{
"sideEffects": false
}

View File

@ -0,0 +1,8 @@
module.exports = {
mode: "production",
entry: "./index",
stats: {
nestedModules: true,
usedExports: true
}
};