Skip to content

Commit adf43eb

Browse files
committed
Merge branch 'master' into handle-module-name-conflicts
2 parents bd80cac + 81b726a commit adf43eb

482 files changed

Lines changed: 6567 additions & 5036 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: true,
3-
plugins: ["prettier", "node"],
3+
plugins: ["prettier", "node", "jest"],
44
extends: ["eslint:recommended", "plugin:node/recommended", "plugin:prettier/recommended"],
55
env: {
66
node: true,
@@ -13,7 +13,6 @@ module.exports = {
1313
"prettier/prettier": "error",
1414
"no-undef": "error",
1515
"no-extra-semi": "error",
16-
"semi": "error",
1716
"no-template-curly-in-string": "error",
1817
"no-caller": "error",
1918
"no-control-regex": "off",
@@ -56,7 +55,7 @@ module.exports = {
5655
{
5756
files: ["test/**/*.js"],
5857
env: {
59-
mocha: true,
58+
"jest/globals": true
6059
}
6160
}
6261
]

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ matrix:
1717
env: NO_WATCH_TESTS=1 JOB_PART=lint
1818
- os: linux
1919
node_js: "8"
20-
env: NO_WATCH_TESTS=1 JOB_PART=integration
20+
env: NO_WATCH_TESTS=1 JEST=--maxWorkers=2 JOB_PART=integration
2121
- os: linux
2222
node_js: "8"
2323
env: NO_WATCH_TESTS=1 JOB_PART=unit
2424
- os: linux
2525
node_js: "6"
26-
env: NO_WATCH_TESTS=1 JOB_PART=integration
26+
env: NO_WATCH_TESTS=1 JEST=--runInBand JOB_PART=integration
2727
- os: osx
2828
node_js: "8"
29-
env: NO_WATCH_TESTS=1 JOB_PART=integration
29+
env: NO_WATCH_TESTS=1 JEST=--maxWorkers=2 JOB_PART=integration
3030
allow_failures:
3131
- os: osx
3232
fast_finish: true

appveyor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ environment:
1616
job_part: unit
1717
- nodejs_version: 8
1818
job_part: integration
19+
jest: --maxWorkers=2
1920
- nodejs_version: 6
2021
job_part: integration
22+
jest: --runInBand
2123

2224
install:
2325
- ps: Install-Product node $env:nodejs_version x64
@@ -35,5 +37,6 @@ test_script:
3537
- node --version
3638
- npm --version
3739
- yarn --version
40+
- cmd: set JEST=%jest%
3841
- cmd: npm run appveyor:%job_part%
3942
- cmd: npm install -g codecov && codecov -F %job_part%

declarations.d.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,23 @@ declare namespace NodeJS {
99
}
1010

1111
// There are no typings for chrome-trace-event
12-
declare module 'chrome-trace-event' {
12+
declare module "chrome-trace-event" {
1313
interface Event {
14-
name: string
15-
id?: number
16-
cat: string[]
17-
args?: Object
14+
name: string;
15+
id?: number;
16+
cat: string[];
17+
args?: Object;
1818
}
1919

2020
export class Tracer {
21-
constructor(options: {
22-
noStream: boolean
23-
})
24-
pipe(stream: NodeJS.WritableStream) : void
25-
instantEvent(event: Event) : void
26-
counter: number
21+
constructor(options: { noStream: boolean });
22+
pipe(stream: NodeJS.WritableStream): void;
23+
instantEvent(event: Event): void;
24+
counter: number;
2725
trace: {
28-
begin(event: Event) : void
29-
end(event: Event) : void
30-
}
26+
begin(event: Event): void;
27+
end(event: Event): void;
28+
};
3129
}
3230
}
3331

lib/Chunk.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Chunk {
5050
this.ids = null;
5151
this.debugId = debugId++;
5252
this.name = name;
53+
this.preventIntegration = false;
5354
this.entryModule = undefined;
5455
this._modules = new SortableSet(undefined, sortByIdentifier);
5556
this._groups = new SortableSet(undefined, sortById);
@@ -265,6 +266,9 @@ class Chunk {
265266
}
266267
return true;
267268
};
269+
270+
if (this.preventIntegration || otherChunk.preventIntegration) return false;
271+
268272
if (this.hasRuntime() !== otherChunk.hasRuntime()) {
269273
if (this.hasRuntime()) {
270274
return isAvailable(this, otherChunk);

lib/Stats.js

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ class Stats {
100100
const optionOrLocalFallback = (v, def) =>
101101
typeof v !== "undefined"
102102
? v
103-
: typeof options.all !== "undefined" ? options.all : def;
103+
: typeof options.all !== "undefined"
104+
? options.all
105+
: def;
104106

105107
const testAgainstGivenOption = item => {
106108
if (typeof item === "string") {
@@ -135,6 +137,10 @@ class Stats {
135137
const showBuiltAt = optionOrLocalFallback(options.builtAt, true);
136138
const showAssets = optionOrLocalFallback(options.assets, true);
137139
const showEntrypoints = optionOrLocalFallback(options.entrypoints, true);
140+
const showChunkGroups = optionOrLocalFallback(
141+
options.chunkGroups,
142+
!forToString
143+
);
138144
const showChunks = optionOrLocalFallback(options.chunks, !forToString);
139145
const showChunkModules = optionOrLocalFallback(options.chunkModules, true);
140146
const showChunkOrigins = optionOrLocalFallback(
@@ -262,7 +268,9 @@ class Stats {
262268
text += `chunk ${e.chunk.name || e.chunk.id}${
263269
e.chunk.hasRuntime()
264270
? " [entry]"
265-
: e.chunk.canBeInitial() ? " [initial]" : ""
271+
: e.chunk.canBeInitial()
272+
? " [initial]"
273+
: ""
266274
}\n`;
267275
}
268276
if (e.file) {
@@ -396,15 +404,15 @@ class Stats {
396404
obj.assets.sort(sortByField(sortAssets));
397405
}
398406

399-
if (showEntrypoints) {
400-
obj.entrypoints = {};
401-
for (const keyValuePair of compilation.entrypoints) {
407+
const fnChunkGroup = groupMap => {
408+
const obj = {};
409+
for (const keyValuePair of groupMap) {
402410
const name = keyValuePair[0];
403-
const ep = keyValuePair[1];
404-
const children = ep.getChildrenByOrders();
405-
obj.entrypoints[name] = {
406-
chunks: ep.chunks.map(c => c.id),
407-
assets: ep.chunks.reduce(
411+
const cg = keyValuePair[1];
412+
const children = cg.getChildrenByOrders();
413+
obj[name] = {
414+
chunks: cg.chunks.map(c => c.id),
415+
assets: cg.chunks.reduce(
408416
(array, c) => array.concat(c.files || []),
409417
[]
410418
),
@@ -436,9 +444,19 @@ class Stats {
436444
}, Object.create(null))
437445
};
438446
if (showPerformance) {
439-
obj.entrypoints[name].isOverSizeLimit = ep.isOverSizeLimit;
447+
obj[name].isOverSizeLimit = cg.isOverSizeLimit;
440448
}
441449
}
450+
451+
return obj;
452+
};
453+
454+
if (showEntrypoints) {
455+
obj.entrypoints = fnChunkGroup(compilation.entrypoints);
456+
}
457+
458+
if (showChunkGroups) {
459+
obj.namedChunkGroups = fnChunkGroup(compilation.namedChunkGroups);
442460
}
443461

444462
const fnModule = module => {
@@ -866,22 +884,23 @@ class Stats {
866884
colors.normal(obj.filteredAssets !== 1 ? " assets" : " asset");
867885
newline();
868886
}
869-
if (obj.entrypoints) {
870-
for (const name of Object.keys(obj.entrypoints)) {
871-
const ep = obj.entrypoints[name];
872-
colors.normal("Entrypoint ");
887+
888+
const processChunkGroups = (namedGroups, prefix) => {
889+
for (const name of Object.keys(namedGroups)) {
890+
const cg = namedGroups[name];
891+
colors.normal(`${prefix} `);
873892
colors.bold(name);
874-
if (ep.isOverSizeLimit) {
893+
if (cg.isOverSizeLimit) {
875894
colors.normal(" ");
876895
colors.yellow("[big]");
877896
}
878897
colors.normal(" =");
879-
for (const asset of ep.assets) {
898+
for (const asset of cg.assets) {
880899
colors.normal(" ");
881900
colors.green(asset);
882901
}
883-
for (const name of Object.keys(ep.childAssets)) {
884-
const assets = ep.childAssets[name];
902+
for (const name of Object.keys(cg.childAssets)) {
903+
const assets = cg.childAssets[name];
885904
if (assets && assets.length > 0) {
886905
colors.normal(" ");
887906
colors.magenta(`(${name}:`);
@@ -894,7 +913,25 @@ class Stats {
894913
}
895914
newline();
896915
}
916+
};
917+
918+
if (obj.entrypoints) {
919+
processChunkGroups(obj.entrypoints, "Entrypoint");
897920
}
921+
922+
if (obj.namedChunkGroups) {
923+
let outputChunkGroups = obj.namedChunkGroups;
924+
if (obj.entrypoints) {
925+
outputChunkGroups = Object.keys(outputChunkGroups)
926+
.filter(name => !obj.entrypoints[name])
927+
.reduce((result, name) => {
928+
result[name] = obj.namedChunkGroups[name];
929+
return result;
930+
}, {});
931+
}
932+
processChunkGroups(outputChunkGroups, "Chunk Group");
933+
}
934+
898935
const modulesByIdentifier = {};
899936
if (obj.modules) {
900937
for (const module of obj.modules) {
@@ -1260,6 +1297,7 @@ class Stats {
12601297
case "verbose":
12611298
return {
12621299
entrypoints: true,
1300+
chunkGroups: true,
12631301
modules: false,
12641302
chunks: true,
12651303
chunkModules: true,
@@ -1278,6 +1316,7 @@ class Stats {
12781316
case "detailed":
12791317
return {
12801318
entrypoints: true,
1319+
chunkGroups: true,
12811320
chunks: true,
12821321
chunkModules: false,
12831322
chunkOrigins: true,

lib/WebpackOptionsApply.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ class WebpackOptionsApply extends OptionsApply {
235235
"MappingURL=[url]\n*/"
236236
: legacy
237237
? "\n/*\n//@ source" + "MappingURL=[url]\n*/"
238-
: modern ? "\n//# source" + "MappingURL=[url]" : null;
238+
: modern
239+
? "\n//# source" + "MappingURL=[url]"
240+
: null;
239241
let Plugin = evalWrapped
240242
? EvalSourceMapDevToolPlugin
241243
: SourceMapDevToolPlugin;
@@ -259,7 +261,9 @@ class WebpackOptionsApply extends OptionsApply {
259261
? "\n//@ sourceURL=[url]\n//# sourceURL=[url]"
260262
: legacy
261263
? "\n//@ sourceURL=[url]"
262-
: modern ? "\n//# sourceURL=[url]" : null;
264+
: modern
265+
? "\n//# sourceURL=[url]"
266+
: null;
263267
new EvalDevToolModulePlugin({
264268
sourceUrlComment: comment,
265269
moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,

lib/optimize/ConcatenatedModule.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,12 @@ class ConcatenatedModule extends Module {
576576
moduleToInfoMap
577577
)
578578
);
579+
580+
// Must use full identifier in our cache here to ensure that the source
581+
// is updated should our dependencies list change.
579582
innerDependencyTemplates.set(
580583
"hash",
581-
innerDependencyTemplates.get("hash") + this.rootModule.identifier()
584+
innerDependencyTemplates.get("hash") + this.identifier()
582585
);
583586

584587
// Generate source code and analyse scopes

lib/optimize/RuntimeChunkPlugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module.exports = class RuntimeChunkPlugin {
2525
name = name(entrypoint);
2626
}
2727
const newChunk = compilation.addChunk(name);
28+
newChunk.preventIntegration = true;
2829
entrypoint.unshiftChunk(newChunk);
2930
newChunk.addGroup(entrypoint);
3031
entrypoint.setRuntimeChunk(newChunk);

lib/optimize/SplitChunksPlugin.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,15 @@ module.exports = class SplitChunksPlugin {
291291
minSize:
292292
cacheGroupSource.minSize !== undefined
293293
? cacheGroupSource.minSize
294-
: cacheGroupSource.enforce ? 0 : this.options.minSize,
294+
: cacheGroupSource.enforce
295+
? 0
296+
: this.options.minSize,
295297
minChunks:
296298
cacheGroupSource.minChunks !== undefined
297299
? cacheGroupSource.minChunks
298-
: cacheGroupSource.enforce ? 1 : this.options.minChunks,
300+
: cacheGroupSource.enforce
301+
? 1
302+
: this.options.minChunks,
299303
maxAsyncRequests:
300304
cacheGroupSource.maxAsyncRequests !== undefined
301305
? cacheGroupSource.maxAsyncRequests

0 commit comments

Comments
 (0)