mirror of https://github.com/webpack/webpack.git
fix bug with incorrectly emitted modules
This commit is contained in:
parent
7ebe12dde1
commit
ae8d6741d7
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
import def, { z } from "pmodule";
|
||||
|
||||
console.log(def, z);
|
||||
5
test/statsCases/side-effects-simple-unused/node_modules/pmodule/a.js
generated
vendored
Normal file
5
test/statsCases/side-effects-simple-unused/node_modules/pmodule/a.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var a = "a";
|
||||
var b = "b";
|
||||
var c = "c";
|
||||
|
||||
export { a, b, c };
|
||||
5
test/statsCases/side-effects-simple-unused/node_modules/pmodule/b.js
generated
vendored
Normal file
5
test/statsCases/side-effects-simple-unused/node_modules/pmodule/b.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var x = "x";
|
||||
var y = "y";
|
||||
|
||||
export { x, y };
|
||||
export { z } from "./c";
|
||||
3
test/statsCases/side-effects-simple-unused/node_modules/pmodule/c.js
generated
vendored
Normal file
3
test/statsCases/side-effects-simple-unused/node_modules/pmodule/c.js
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var z = "z";
|
||||
|
||||
export { z };
|
||||
4
test/statsCases/side-effects-simple-unused/node_modules/pmodule/index.js
generated
vendored
Normal file
4
test/statsCases/side-effects-simple-unused/node_modules/pmodule/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export * from "./a";
|
||||
export { x, y, z } from "./b";
|
||||
|
||||
export default "def";
|
||||
3
test/statsCases/side-effects-simple-unused/node_modules/pmodule/package.json
generated
vendored
Normal file
3
test/statsCases/side-effects-simple-unused/node_modules/pmodule/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"sideEffects": false
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
module.exports = {
|
||||
mode: "production",
|
||||
entry: "./index",
|
||||
stats: {
|
||||
nestedModules: true,
|
||||
usedExports: true
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue