mirror of https://github.com/webpack/webpack.git
flag modules in dlls without entryOnly with side-effects to keep them
This commit is contained in:
parent
1e2634fdd8
commit
06fcc0ad12
|
|
@ -40,6 +40,10 @@ class FlagAllModulesAsUsedPlugin {
|
||||||
const exportsInfo = moduleGraph.getExportsInfo(module);
|
const exportsInfo = moduleGraph.getExportsInfo(module);
|
||||||
exportsInfo.setUsedInUnknownWay(runtime);
|
exportsInfo.setUsedInUnknownWay(runtime);
|
||||||
moduleGraph.addExtraReason(module, this.explanation);
|
moduleGraph.addExtraReason(module, this.explanation);
|
||||||
|
if (module.factoryMeta === undefined) {
|
||||||
|
module.factoryMeta = {};
|
||||||
|
}
|
||||||
|
module.factoryMeta.sideEffectFree = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
export default "d";
|
export default "d";
|
||||||
console.log.bind(console);
|
|
||||||
|
|
|
||||||
|
|
@ -4,39 +4,39 @@ import { x2, y1 } from "../0-create-dll/e";
|
||||||
import { B } from "../0-create-dll/h";
|
import { B } from "../0-create-dll/h";
|
||||||
import { A } from "../0-create-dll/h1";
|
import { A } from "../0-create-dll/h1";
|
||||||
|
|
||||||
it("should load a module from dll", function() {
|
it("should load a module from dll", function () {
|
||||||
expect(require("../0-create-dll/a")).toBe("a");
|
expect(require("../0-create-dll/a")).toBe("a");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should load a module of non-default type without extension from dll", function() {
|
it("should load a module of non-default type without extension from dll", function () {
|
||||||
expect(require("../0-create-dll/f")).toBe("f");
|
expect(require("../0-create-dll/f")).toBe("f");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should load an async module from dll", function(done) {
|
it("should load an async module from dll", function (done) {
|
||||||
require("../0-create-dll/b")()
|
require("../0-create-dll/b")()
|
||||||
.then(function(c) {
|
.then(function (c) {
|
||||||
expect(c).toEqual(nsObj({ default: "c" }));
|
expect(c).toEqual(nsObj({ default: "c" }));
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(done);
|
.catch(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should load an harmony module from dll (default export)", function() {
|
it("should load an harmony module from dll (default export)", function () {
|
||||||
expect(d).toBe("d");
|
expect(d).toBe("d");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should load an harmony module from dll (star export)", function() {
|
it("should load an harmony module from dll (star export)", function () {
|
||||||
expect(x1).toBe(123);
|
expect(x1).toBe(123);
|
||||||
expect(x2).toBe(123);
|
expect(x2).toBe(123);
|
||||||
expect(y1).toBe(456);
|
expect(y1).toBe(456);
|
||||||
expect(y2).toBe(456);
|
expect(y2).toBe(456);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should load a module with loader applied", function() {
|
it("should load a module with loader applied", function () {
|
||||||
expect(require("../0-create-dll/g.abc.js")).toBe("number");
|
expect(require("../0-create-dll/g.abc.js")).toBe("number");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should give modules the correct ids", function() {
|
it("should give modules the correct ids", function () {
|
||||||
expect(
|
expect(
|
||||||
Object.keys(__webpack_modules__)
|
Object.keys(__webpack_modules__)
|
||||||
.filter(m => !m.startsWith("../.."))
|
.filter(m => !m.startsWith("../.."))
|
||||||
|
|
@ -51,16 +51,16 @@ it("should give modules the correct ids", function() {
|
||||||
"../0-create-dll/f.jsx",
|
"../0-create-dll/f.jsx",
|
||||||
"../0-create-dll/g.abc.js",
|
"../0-create-dll/g.abc.js",
|
||||||
"../0-create-dll/h.js",
|
"../0-create-dll/h.js",
|
||||||
"../0-create-dll/hb.js",
|
"../0-create-dll/h1.js",
|
||||||
"./index.js",
|
"./index.js",
|
||||||
"dll-reference ../0-create-dll/dll.js"
|
"dll-reference ../0-create-dll/dll.js"
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not crash on side-effect-free modules", function() {
|
it("should not crash on side-effect-free modules", function () {
|
||||||
expect(B).toBe("B");
|
expect(B).toBe("B");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to reference side-effect-free reexport-only module", function() {
|
it("should be able to reference side-effect-free reexport-only module", function () {
|
||||||
expect(A).toBe("A");
|
expect(A).toBe("A");
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue