Skip to content

Commit 995ceab

Browse files
committed
WIP7
1 parent 140af04 commit 995ceab

File tree

20 files changed

+14
-176
lines changed

20 files changed

+14
-176
lines changed

lib/Chunk.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ class Chunk {
239239
chunkGroup.insertChunk(newChunk, this);
240240
newChunk.addGroup(chunkGroup);
241241
}
242-
console.log("Chunk.split", this.name, newChunk.name, Array.from(this._groups, g => g.chunks.map(c => c.name)));
243242
}
244243

245244
isEmpty() {
@@ -254,14 +253,10 @@ class Chunk {
254253
}
255254

256255
canBeIntegrated(otherChunk) {
257-
if(otherChunk.isInitial()) {
256+
if(this.isInitial() !== otherChunk.isInitial())
257+
return false;
258+
if(this.hasEntryModule() || otherChunk.hasEntryModule())
258259
return false;
259-
}
260-
if(this.isInitial()) {
261-
if(otherChunk.getNumberOfParents() !== 1 || otherChunk.getParents()[0] !== this) {
262-
return false;
263-
}
264-
}
265260
return true;
266261
}
267262

lib/webworker/WebWorkerMainTemplatePlugin.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ const Template = require("../Template");
88

99
class WebWorkerMainTemplatePlugin {
1010
apply(mainTemplate) {
11+
const needChunkOnDemandLoadingCode = chunk => {
12+
for(const chunkGroup of chunk.groupsIterable) {
13+
if(chunkGroup.getNumberOfChildren() > 0) return true;
14+
}
15+
return false;
16+
};
1117
mainTemplate.hooks.localVars.tap("WebWorkerMainTemplatePlugin", (source, chunk) => {
12-
if(chunk.getNumberOfChunks() > 0) {
18+
if(needChunkOnDemandLoadingCode(chunk)) {
1319
return Template.asString([
1420
source,
1521
"",
@@ -47,7 +53,7 @@ class WebWorkerMainTemplatePlugin {
4753
]);
4854
});
4955
mainTemplate.hooks.bootstrap.tap("WebWorkerMainTemplatePlugin", (source, chunk, hash) => {
50-
if(chunk.getNumberOfChunks() > 0) {
56+
if(needChunkOnDemandLoadingCode(chunk)) {
5157
const chunkCallbackName = mainTemplate.outputOptions.chunkCallbackName;
5258
const globalObject = mainTemplate.outputOptions.globalObject;
5359
return Template.asString([

test/HotTestCases.test.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const path = require("path");
55
const fs = require("fs");
66
const vm = require("vm");
77
const Test = require("mocha/lib/test");
8-
const ExtractTextPlugin = require("extract-text-webpack-plugin");
98
const checkArrayExpectation = require("./checkArrayExpectation");
109

1110
const webpack = require("../lib/webpack");
@@ -52,20 +51,13 @@ describe("HotTestCases", () => {
5251
test: /\.js$/,
5352
loader: path.join(__dirname, "hotCases", "fake-update-loader.js"),
5453
enforce: "pre"
55-
}, {
56-
test: /\.css$/,
57-
use: ExtractTextPlugin.extract({
58-
fallback: "style-loader",
59-
use: "css-loader"
60-
})
6154
});
6255
if(!options.target) options.target = "async-node";
6356
if(!options.plugins) options.plugins = [];
6457
options.plugins.push(
6558
new webpack.HotModuleReplacementPlugin(),
6659
new webpack.NamedModulesPlugin(),
67-
new webpack.LoaderOptionsPlugin(fakeUpdateLoaderOptions),
68-
new ExtractTextPlugin("bundle.css")
60+
new webpack.LoaderOptionsPlugin(fakeUpdateLoaderOptions)
6961
);
7062
if(!options.recordsPath) options.recordsPath = recordsPath;
7163
const compiler = webpack(options);

test/Stats.unittest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe("Stats", () => {
8888
errors: ["firstError"],
8989
warnings: [],
9090
assets: [],
91-
entrypoints: {},
91+
entrypoints: new Map(),
9292
chunks: [],
9393
modules: [],
9494
children: [],

test/configCases/extract-text/issue-14/base.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/configCases/extract-text/issue-14/index.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/configCases/extract-text/issue-14/styleA.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/configCases/extract-text/issue-14/styleB.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/configCases/extract-text/issue-14/webpack.config.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/configCases/records/issue-2991/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ it("should write relative paths to records", function() {
2525
"byName": {
2626
"main": 0
2727
},
28-
"byBlocks": {},
28+
"bySource": {},
2929
"usedIds": {
3030
"0": 0
3131
}

test/statsCases/separate-css-bundle/a/file.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/statsCases/separate-css-bundle/a/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/statsCases/separate-css-bundle/b/file.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/statsCases/separate-css-bundle/b/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/statsCases/separate-css-bundle/expected.txt

Lines changed: 0 additions & 35 deletions
This file was deleted.

test/statsCases/separate-css-bundle/webpack.config.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

test/watchCases/plugins/extract-text-plugin/0/index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/watchCases/plugins/extract-text-plugin/0/style.css

Whitespace-only changes.

test/watchCases/plugins/extract-text-plugin/1/style.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/watchCases/plugins/extract-text-plugin/webpack.config.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)