Skip to content

Commit dc0e1ec

Browse files
committed
Merge branch 'master' into prefetch-from-entry
2 parents db668b7 + fe3ca80 commit dc0e1ec

File tree

75 files changed

+1005
-1197
lines changed

Some content is hidden

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

75 files changed

+1005
-1197
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ root = true
22

33
[*]
44
indent_style = tab
5-
indent_size = 4
5+
indent_size = 2
66
charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
9-
max_line_length = 233
9+
max_line_length = 80
1010

1111
[.prettierrc]
1212
indent_style = space

declarations.d.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ declare module "@webassemblyjs/ast" {
3636
ModuleImport?: (p: NodePath<ModuleImport>) => void;
3737
ModuleExport?: (p: NodePath<ModuleExport>) => void;
3838
Start?: (p: NodePath<Start>) => void;
39+
Global?: (p: NodePath<Global>) => void;
3940
}
4041
);
4142
export class NodePath<T> {
@@ -60,16 +61,33 @@ declare module "@webassemblyjs/ast" {
6061
}
6162
export class ModuleExport extends Node {
6263
name: string;
64+
descr: {
65+
type: string;
66+
exportType: string;
67+
id?: Identifier;
68+
};
6369
}
6470
export class ModuleExportDescr extends Node {}
6571
export class IndexLiteral extends Node {}
66-
export class NumberLiteral extends Node {}
72+
export class NumberLiteral extends Node {
73+
value: number;
74+
raw: string;
75+
}
6776
export class FloatLiteral extends Node {}
68-
export class Global extends Node {}
77+
export class GlobalType extends Node {
78+
valtype: string;
79+
}
80+
export class Global extends Node {
81+
init: Instruction[];
82+
globalType: GlobalType;
83+
}
6984
export class FuncParam extends Node {
7085
valtype: string;
7186
}
72-
export class Instruction extends Node {}
87+
export class Instruction extends Node {
88+
id: string;
89+
args: NumberLiteral[];
90+
}
7391
export class CallInstruction extends Instruction {}
7492
export class ObjectInstruction extends Instruction {}
7593
export class Func extends Node {

lib/AsyncDependencyToInitialChunkError.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ class AsyncDependencyToInitialChunkError extends WebpackError {
1616
* @param {TODO} loc location of dependency
1717
*/
1818
constructor(chunkName, module, loc) {
19-
super();
19+
super(
20+
`It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`
21+
);
2022

2123
this.name = "AsyncDependencyToInitialChunkError";
22-
this.message = `It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`;
2324
this.module = module;
24-
this.origin = module;
25-
this.originLoc = loc;
25+
this.loc = loc;
2626

2727
Error.captureStackTrace(this, this.constructor);
2828
}

lib/CaseSensitiveModulesWarning.js

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,60 @@ const WebpackError = require("./WebpackError");
88

99
/** @typedef {import("./Module")} Module */
1010

11+
/**
12+
* @param {Module[]} modules the modules to be sorted
13+
* @returns {Module[]} sorted version of original modules
14+
*/
15+
const sortModules = modules => {
16+
return modules.slice().sort((a, b) => {
17+
a = a.identifier();
18+
b = b.identifier();
19+
/* istanbul ignore next */
20+
if (a < b) return -1;
21+
/* istanbul ignore next */
22+
if (a > b) return 1;
23+
/* istanbul ignore next */
24+
return 0;
25+
});
26+
};
27+
28+
/**
29+
* @param {Module[]} modules each module from throw
30+
* @returns {string} each message from provided moduels
31+
*/
32+
const createModulesListMessage = modules => {
33+
return modules
34+
.map(m => {
35+
let message = `* ${m.identifier()}`;
36+
const validReasons = m.reasons.filter(reason => reason.module);
37+
38+
if (validReasons.length > 0) {
39+
message += `\n Used by ${validReasons.length} module(s), i. e.`;
40+
message += `\n ${validReasons[0].module.identifier()}`;
41+
}
42+
return message;
43+
})
44+
.join("\n");
45+
};
46+
1147
class CaseSensitiveModulesWarning extends WebpackError {
1248
/**
1349
* Creates an instance of CaseSensitiveModulesWarning.
1450
* @param {Module[]} modules modules that were detected
1551
*/
1652
constructor(modules) {
17-
super();
18-
19-
this.name = "CaseSensitiveModulesWarning";
20-
const sortedModules = this._sort(modules);
21-
const modulesList = this._moduleMessages(sortedModules);
22-
this.message = `There are multiple modules with names that only differ in casing.
53+
const sortedModules = sortModules(modules);
54+
const modulesList = createModulesListMessage(sortedModules);
55+
super(`There are multiple modules with names that only differ in casing.
2356
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
2457
Use equal casing. Compare these module identifiers:
25-
${modulesList}`;
58+
${modulesList}`);
2659

60+
this.name = "CaseSensitiveModulesWarning";
2761
this.origin = this.module = sortedModules[0];
2862

2963
Error.captureStackTrace(this, this.constructor);
3064
}
31-
32-
/**
33-
* @private
34-
* @param {Module[]} modules the modules to be sorted
35-
* @returns {Module[]} sorted version of original modules
36-
*/
37-
_sort(modules) {
38-
return modules.slice().sort((a, b) => {
39-
a = a.identifier();
40-
b = b.identifier();
41-
/* istanbul ignore next */
42-
if (a < b) return -1;
43-
/* istanbul ignore next */
44-
if (a > b) return 1;
45-
/* istanbul ignore next */
46-
return 0;
47-
});
48-
}
49-
50-
/**
51-
* @private
52-
* @param {Module[]} modules each module from throw
53-
* @returns {string} each message from provided moduels
54-
*/
55-
_moduleMessages(modules) {
56-
return modules
57-
.map(m => {
58-
let message = `* ${m.identifier()}`;
59-
const validReasons = m.reasons.filter(reason => reason.module);
60-
61-
if (validReasons.length > 0) {
62-
message += `\n Used by ${validReasons.length} module(s), i. e.`;
63-
message += `\n ${validReasons[0].module.identifier()}`;
64-
}
65-
return message;
66-
})
67-
.join("\n");
68-
}
6965
}
7066

7167
module.exports = CaseSensitiveModulesWarning;

lib/CommentCompilationWarning.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
4+
*/
5+
"use strict";
6+
7+
const WebpackError = require("./WebpackError");
8+
9+
class CommentCompilationWarning extends WebpackError {
10+
constructor(message, module, loc) {
11+
super(message);
12+
13+
this.name = "CommentCompilationWarning";
14+
15+
this.module = module;
16+
this.loc = loc;
17+
18+
Error.captureStackTrace(this, this.constructor);
19+
}
20+
}
21+
22+
module.exports = CommentCompilationWarning;

lib/Compilation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ class Compilation extends Tapable {
487487

488488
const errorAndCallback = err => {
489489
err.origin = module;
490+
err.dependencies = dependencies;
490491
this.errors.push(err);
491492
if (bail) {
492493
callback(err);
@@ -531,7 +532,7 @@ class Compilation extends Tapable {
531532
if (err) {
532533
semaphore.release();
533534
return errorOrWarningAndCallback(
534-
new ModuleNotFoundError(module, err, dependencies)
535+
new ModuleNotFoundError(module, err)
535536
);
536537
}
537538
if (!dependentModule) {

lib/EntryModuleNotFoundError.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ const WebpackError = require("./WebpackError");
88

99
class EntryModuleNotFoundError extends WebpackError {
1010
constructor(err) {
11-
super();
11+
super("Entry module not found: " + err);
1212

1313
this.name = "EntryModuleNotFoundError";
14-
this.message = "Entry module not found: " + err;
1514
this.details = err.details;
1615
this.error = err;
1716

lib/HarmonyLinkingError.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ const WebpackError = require("./WebpackError");
88
module.exports = class HarmonyLinkingError extends WebpackError {
99
/** @param {string} message Error message */
1010
constructor(message) {
11-
super();
11+
super(message);
1212
this.name = "HarmonyLinkingError";
13-
this.message = message;
1413
this.hideStack = true;
1514

1615
Error.captureStackTrace(this, this.constructor);

lib/ModuleBuildError.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,32 @@ const { cutOffLoaderExecution } = require("./ErrorHelpers");
99

1010
class ModuleBuildError extends WebpackError {
1111
constructor(module, err) {
12-
super();
13-
14-
this.name = "ModuleBuildError";
15-
this.message = "Module build failed: ";
12+
let message = "Module build failed: ";
13+
let details = undefined;
1614
if (err !== null && typeof err === "object") {
1715
if (typeof err.stack === "string" && err.stack) {
1816
var stack = cutOffLoaderExecution(err.stack);
1917
if (!err.hideStack) {
20-
this.message += stack;
18+
message += stack;
2119
} else {
22-
this.details = stack;
20+
details = stack;
2321
if (typeof err.message === "string" && err.message) {
24-
this.message += err.message;
22+
message += err.message;
2523
} else {
26-
this.message += err;
24+
message += err;
2725
}
2826
}
2927
} else if (typeof err.message === "string" && err.message) {
30-
this.message += err.message;
28+
message += err.message;
3129
} else {
32-
this.message += err;
30+
message += err;
3331
}
3432
}
33+
34+
super(message);
35+
36+
this.name = "ModuleBuildError";
37+
this.details = details;
3538
this.module = module;
3639
this.error = err;
3740

lib/ModuleDependencyError.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"use strict";
66

77
const WebpackError = require("./WebpackError");
8-
const formatLocation = require("./formatLocation");
98

109
/** @typedef {import("./Module")} Module */
1110

@@ -17,15 +16,15 @@ class ModuleDependencyError extends WebpackError {
1716
* @param {TODO} loc location of dependency
1817
*/
1918
constructor(module, err, loc) {
20-
super();
19+
super(err.message);
2120

2221
this.name = "ModuleDependencyError";
23-
this.message = `${formatLocation(loc)} ${err.message}`;
2422
this.details = err.stack
2523
.split("\n")
2624
.slice(1)
2725
.join("\n");
28-
this.origin = this.module = module;
26+
this.module = module;
27+
this.loc = loc;
2928
this.error = err;
3029

3130
Error.captureStackTrace(this, this.constructor);

lib/ModuleDependencyWarning.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
"use strict";
66

77
const WebpackError = require("./WebpackError");
8-
const formatLocation = require("./formatLocation");
98

109
module.exports = class ModuleDependencyWarning extends WebpackError {
1110
constructor(module, err, loc) {
12-
super();
11+
super(err.message);
1312

1413
this.name = "ModuleDependencyWarning";
15-
this.message = `${formatLocation(loc)} ${err.message}`;
1614
this.details = err.stack
1715
.split("\n")
1816
.slice(1)
1917
.join("\n");
20-
this.origin = this.module = module;
18+
this.module = module;
19+
this.loc = loc;
2120
this.error = err;
2221

2322
Error.captureStackTrace(this, this.constructor);

lib/ModuleError.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ const { cleanUp } = require("./ErrorHelpers");
99

1010
class ModuleError extends WebpackError {
1111
constructor(module, err) {
12-
super();
12+
super(err && typeof err === "object" && err.message ? err.message : err);
1313

1414
this.name = "ModuleError";
1515
this.module = module;
16-
this.message =
17-
err && typeof err === "object" && err.message ? err.message : err;
1816
this.error = err;
1917
this.details =
2018
err && typeof err === "object" && err.stack

lib/ModuleNotFoundError.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77
const WebpackError = require("./WebpackError");
88

99
class ModuleNotFoundError extends WebpackError {
10-
constructor(module, err, dependencies) {
11-
super();
10+
constructor(module, err) {
11+
super("Module not found: " + err);
1212

1313
this.name = "ModuleNotFoundError";
14-
this.message = "Module not found: " + err;
1514
this.details = err.details;
1615
this.missing = err.missing;
1716
this.module = module;
18-
this.origin = module;
19-
this.dependencies = dependencies;
2017
this.error = err;
2118

2219
Error.captureStackTrace(this, this.constructor);

0 commit comments

Comments
 (0)