webpack 4.14.0 → 4.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/webpack.js +7 -2
- package/lib/AsyncDependenciesBlock.js +44 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/Chunk.js +53 -3
- package/lib/ChunkGroup.js +1 -1
- package/lib/ChunkTemplate.js +14 -2
- package/lib/CommentCompilationWarning.js +2 -2
- package/lib/Compilation.js +435 -34
- package/lib/Compiler.js +57 -4
- package/lib/ContextModule.js +3 -15
- package/lib/DelegatedModule.js +9 -1
- package/lib/DependenciesBlock.js +36 -3
- package/lib/DependenciesBlockVariable.js +22 -0
- package/lib/Dependency.js +25 -4
- package/lib/DllEntryPlugin.js +4 -1
- package/lib/DynamicEntryPlugin.js +21 -1
- package/lib/EntryOptionPlugin.js +12 -0
- package/lib/ExtendedAPIPlugin.js +8 -4
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/GraphHelpers.js +2 -1
- package/lib/HotModuleReplacement.runtime.js +8 -5
- package/lib/HotModuleReplacementPlugin.js +114 -116
- package/lib/MainTemplate.js +19 -4
- package/lib/Module.js +9 -3
- package/lib/ModuleReason.js +8 -0
- package/lib/MultiEntryPlugin.js +25 -3
- package/lib/NormalModule.js +5 -23
- package/lib/RuleSet.js +3 -3
- package/lib/SingleEntryPlugin.js +14 -0
- package/lib/Stats.js +2 -1
- package/lib/Template.js +4 -1
- package/lib/UmdMainTemplatePlugin.js +12 -12
- package/lib/WebpackError.js +4 -0
- package/lib/WebpackOptionsDefaulter.js +3 -0
- package/lib/WebpackOptionsValidationError.js +0 -1
- package/lib/compareLocations.js +13 -17
- package/lib/debug/ProfilingPlugin.js +5 -7
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +4 -6
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +0 -2
- package/lib/dependencies/LoaderDependency.js +3 -0
- package/lib/dependencies/LoaderPlugin.js +3 -1
- package/lib/dependencies/ModuleDependency.js +3 -0
- package/lib/dependencies/MultiEntryDependency.js +5 -0
- package/lib/dependencies/SingleEntryDependency.js +3 -0
- package/lib/node/NodeMainTemplateAsync.runtime.js +1 -1
- package/lib/optimize/ConcatenatedModule.js +1 -0
- package/lib/optimize/SplitChunksPlugin.js +142 -2
- package/lib/util/Semaphore.js +12 -0
- package/lib/util/SetHelpers.js +4 -4
- package/lib/util/SortableSet.js +1 -1
- package/lib/util/createHash.js +15 -0
- package/lib/util/deterministicGrouping.js +251 -0
- package/lib/util/identifier.js +27 -0
- package/lib/wasm/WasmMainTemplatePlugin.js +10 -4
- package/lib/wasm/WebAssemblyGenerator.js +12 -12
- package/lib/wasm/WebAssemblyInInitialChunkError.js +88 -0
- package/lib/wasm/WebAssemblyModulesPlugin.js +28 -0
- package/lib/webpack.web.js +2 -2
- package/package.json +8 -7
- package/schemas/WebpackOptions.json +37 -1
package/lib/Compiler.js
CHANGED
|
@@ -27,38 +27,83 @@ const RequestShortener = require("./RequestShortener");
|
|
|
27
27
|
const { makePathsRelative } = require("./util/identifier");
|
|
28
28
|
const ConcurrentCompilationError = require("./ConcurrentCompilationError");
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {Object} CompilationParams
|
|
32
|
+
* @property {NormalModuleFactory} normalModuleFactory
|
|
33
|
+
* @property {ContextModuleFactory} contextModuleFactory
|
|
34
|
+
* @property {Set<string>} compilationDependencies
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/** @typedef {string|string[]} EntryValues */
|
|
38
|
+
/** @typedef {Record<string, EntryValues>} EntryOptionValues */
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @callback EntryOptionValuesFunction
|
|
42
|
+
* @returns {EntryOptionValues | EntryValues} the computed value
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/** @typedef {EntryOptionValuesFunction | EntryOptionValues | EntryValues} EntryOptions */
|
|
46
|
+
|
|
30
47
|
class Compiler extends Tapable {
|
|
31
48
|
constructor(context) {
|
|
32
49
|
super();
|
|
33
50
|
this.hooks = {
|
|
51
|
+
/** @type {SyncBailHook<Compilation>} */
|
|
34
52
|
shouldEmit: new SyncBailHook(["compilation"]),
|
|
53
|
+
/** @type {AsyncSeriesHook<Stats>} */
|
|
35
54
|
done: new AsyncSeriesHook(["stats"]),
|
|
55
|
+
/** @type {AsyncSeriesHook<>} */
|
|
36
56
|
additionalPass: new AsyncSeriesHook([]),
|
|
37
|
-
|
|
38
|
-
|
|
57
|
+
/** @type {AsyncSeriesHook<Compiler>} */
|
|
58
|
+
beforeRun: new AsyncSeriesHook(["compiler"]),
|
|
59
|
+
/** @type {AsyncSeriesHook<Compiler>} */
|
|
60
|
+
run: new AsyncSeriesHook(["compiler"]),
|
|
61
|
+
/** @type {AsyncSeriesHook<Compilation>} */
|
|
39
62
|
emit: new AsyncSeriesHook(["compilation"]),
|
|
63
|
+
/** @type {AsyncSeriesHook<Compilation>} */
|
|
40
64
|
afterEmit: new AsyncSeriesHook(["compilation"]),
|
|
65
|
+
|
|
66
|
+
/** @type {SyncHook<Compilation, CompilationParams>} */
|
|
41
67
|
thisCompilation: new SyncHook(["compilation", "params"]),
|
|
68
|
+
/** @type {SyncHook<Compilation, CompilationParams>} */
|
|
42
69
|
compilation: new SyncHook(["compilation", "params"]),
|
|
70
|
+
/** @type {SyncHook<NormalModuleFactory>} */
|
|
43
71
|
normalModuleFactory: new SyncHook(["normalModuleFactory"]),
|
|
72
|
+
/** @type {SyncHook<ContextModuleFactory>} */
|
|
44
73
|
contextModuleFactory: new SyncHook(["contextModulefactory"]),
|
|
74
|
+
|
|
75
|
+
/** @type {AsyncSeriesHook<CompilationParams>} */
|
|
45
76
|
beforeCompile: new AsyncSeriesHook(["params"]),
|
|
77
|
+
/** @type {SyncHook<CompilationParams>} */
|
|
46
78
|
compile: new SyncHook(["params"]),
|
|
79
|
+
/** @type {AsyncParallelHook<Compilation>} */
|
|
47
80
|
make: new AsyncParallelHook(["compilation"]),
|
|
81
|
+
/** @type {AsyncSeriesHook<Compilation>} */
|
|
48
82
|
afterCompile: new AsyncSeriesHook(["compilation"]),
|
|
83
|
+
|
|
84
|
+
/** @type {AsyncSeriesHook<Compiler>} */
|
|
49
85
|
watchRun: new AsyncSeriesHook(["compiler"]),
|
|
86
|
+
/** @type {SyncHook<Error>} */
|
|
50
87
|
failed: new SyncHook(["error"]),
|
|
88
|
+
/** @type {SyncHook<string, string>} */
|
|
51
89
|
invalid: new SyncHook(["filename", "changeTime"]),
|
|
90
|
+
/** @type {SyncHook} */
|
|
52
91
|
watchClose: new SyncHook([]),
|
|
53
92
|
|
|
54
93
|
// TODO the following hooks are weirdly located here
|
|
55
94
|
// TODO move them for webpack 5
|
|
95
|
+
/** @type {SyncHook} */
|
|
56
96
|
environment: new SyncHook([]),
|
|
97
|
+
/** @type {SyncHook} */
|
|
57
98
|
afterEnvironment: new SyncHook([]),
|
|
99
|
+
/** @type {SyncHook<Compiler>} */
|
|
58
100
|
afterPlugins: new SyncHook(["compiler"]),
|
|
101
|
+
/** @type {SyncHook<Compiler>} */
|
|
59
102
|
afterResolvers: new SyncHook(["compiler"]),
|
|
103
|
+
/** @type {SyncBailHook<string, EntryOptions>} */
|
|
60
104
|
entryOption: new SyncBailHook(["context", "entry"])
|
|
61
105
|
};
|
|
106
|
+
|
|
62
107
|
this._pluginCompat.tap("Compiler", options => {
|
|
63
108
|
switch (options.name) {
|
|
64
109
|
case "additional-pass":
|
|
@@ -75,19 +120,26 @@ class Compiler extends Tapable {
|
|
|
75
120
|
}
|
|
76
121
|
});
|
|
77
122
|
|
|
123
|
+
/** @type {string=} */
|
|
78
124
|
this.name = undefined;
|
|
125
|
+
/** @type {Compilation=} */
|
|
79
126
|
this.parentCompilation = undefined;
|
|
127
|
+
/** @type {string} */
|
|
80
128
|
this.outputPath = "";
|
|
129
|
+
|
|
81
130
|
this.outputFileSystem = null;
|
|
82
131
|
this.inputFileSystem = null;
|
|
83
132
|
|
|
133
|
+
/** @type {string|null} */
|
|
84
134
|
this.recordsInputPath = null;
|
|
135
|
+
/** @type {string|null} */
|
|
85
136
|
this.recordsOutputPath = null;
|
|
86
137
|
this.records = {};
|
|
87
|
-
|
|
138
|
+
/** @type {Map<string, number>} */
|
|
88
139
|
this.fileTimestamps = new Map();
|
|
140
|
+
/** @type {Map<string, number>} */
|
|
89
141
|
this.contextTimestamps = new Map();
|
|
90
|
-
|
|
142
|
+
/** @type {ResolverFactory} */
|
|
91
143
|
this.resolverFactory = new ResolverFactory();
|
|
92
144
|
|
|
93
145
|
// TODO remove in webpack 5
|
|
@@ -136,6 +188,7 @@ class Compiler extends Tapable {
|
|
|
136
188
|
|
|
137
189
|
this.requestShortener = new RequestShortener(context);
|
|
138
190
|
|
|
191
|
+
/** @type {boolean} */
|
|
139
192
|
this.running = false;
|
|
140
193
|
}
|
|
141
194
|
|
package/lib/ContextModule.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Author Tobias Koppers @sokra
|
|
4
4
|
*/
|
|
5
5
|
"use strict";
|
|
6
|
-
const path = require("path");
|
|
7
6
|
const util = require("util");
|
|
8
7
|
const { OriginalSource, RawSource } = require("webpack-sources");
|
|
9
8
|
const Module = require("./Module");
|
|
10
9
|
const AsyncDependenciesBlock = require("./AsyncDependenciesBlock");
|
|
11
10
|
const Template = require("./Template");
|
|
11
|
+
const contextify = require("./util/identifier").contextify;
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("./dependencies/ContextElementDependency")} ContextElementDependency */
|
|
14
14
|
|
|
@@ -63,18 +63,6 @@ class ContextModule extends Module {
|
|
|
63
63
|
return regexString.substring(1, regexString.length - 1);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
contextify(context, request) {
|
|
67
|
-
return request
|
|
68
|
-
.split("!")
|
|
69
|
-
.map(subrequest => {
|
|
70
|
-
let rp = path.relative(context, subrequest);
|
|
71
|
-
if (path.sep === "\\") rp = rp.replace(/\\/g, "/");
|
|
72
|
-
if (rp.indexOf("../") !== 0) rp = "./" + rp;
|
|
73
|
-
return rp;
|
|
74
|
-
})
|
|
75
|
-
.join("!");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
66
|
_createIdentifier() {
|
|
79
67
|
let identifier = this.context;
|
|
80
68
|
if (this.options.resourceQuery) {
|
|
@@ -155,7 +143,7 @@ class ContextModule extends Module {
|
|
|
155
143
|
}
|
|
156
144
|
|
|
157
145
|
libIdent(options) {
|
|
158
|
-
let identifier =
|
|
146
|
+
let identifier = contextify(options.context, this.context);
|
|
159
147
|
if (this.options.mode) {
|
|
160
148
|
identifier += ` ${this.options.mode}`;
|
|
161
149
|
}
|
|
@@ -163,7 +151,7 @@ class ContextModule extends Module {
|
|
|
163
151
|
identifier += " recursive";
|
|
164
152
|
}
|
|
165
153
|
if (this.options.addon) {
|
|
166
|
-
identifier += ` ${
|
|
154
|
+
identifier += ` ${contextify(options.context, this.options.addon)}`;
|
|
167
155
|
}
|
|
168
156
|
if (this.options.regExp) {
|
|
169
157
|
identifier += ` ${this.prettyRegExp(this.options.regExp + "")}`;
|
package/lib/DelegatedModule.js
CHANGED
|
@@ -11,6 +11,8 @@ const WebpackMissingModule = require("./dependencies/WebpackMissingModule");
|
|
|
11
11
|
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
|
12
12
|
const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDependency");
|
|
13
13
|
|
|
14
|
+
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
|
15
|
+
|
|
14
16
|
class DelegatedModule extends Module {
|
|
15
17
|
constructor(sourceRequest, data, type, userRequest, originalRequest) {
|
|
16
18
|
super("javascript/dynamic", null);
|
|
@@ -22,6 +24,9 @@ class DelegatedModule extends Module {
|
|
|
22
24
|
this.userRequest = userRequest;
|
|
23
25
|
this.originalRequest = originalRequest;
|
|
24
26
|
this.delegateData = data;
|
|
27
|
+
|
|
28
|
+
// Build info
|
|
29
|
+
this.delegatedSourceDependency = undefined;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
libIdent(options) {
|
|
@@ -48,7 +53,10 @@ class DelegatedModule extends Module {
|
|
|
48
53
|
this.built = true;
|
|
49
54
|
this.buildMeta = Object.assign({}, this.delegateData.buildMeta);
|
|
50
55
|
this.buildInfo = {};
|
|
51
|
-
this.
|
|
56
|
+
this.delegatedSourceDependency = new DelegatedSourceDependency(
|
|
57
|
+
this.sourceRequest
|
|
58
|
+
);
|
|
59
|
+
this.addDependency(this.delegatedSourceDependency);
|
|
52
60
|
this.addDependency(
|
|
53
61
|
new DelegatedExportsDependency(this, this.delegateData.exports || true)
|
|
54
62
|
);
|
package/lib/DependenciesBlock.js
CHANGED
|
@@ -8,23 +8,39 @@ const DependenciesBlockVariable = require("./DependenciesBlockVariable");
|
|
|
8
8
|
|
|
9
9
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
10
10
|
/** @typedef {import("./Dependency")} Dependency */
|
|
11
|
+
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
12
|
+
/** @typedef {import("./DependenciesBlockVariable")} DependenciesBlockVariable */
|
|
13
|
+
/** @typedef {(d: Dependency) => boolean} DependencyFilterFunction */
|
|
14
|
+
/** @typedef {import("./util/createHash").Hash} Hash */
|
|
11
15
|
|
|
12
16
|
class DependenciesBlock {
|
|
13
17
|
constructor() {
|
|
14
18
|
/** @type {Dependency[]} */
|
|
15
19
|
this.dependencies = [];
|
|
20
|
+
/** @type {AsyncDependenciesBlock[]} */
|
|
16
21
|
this.blocks = [];
|
|
22
|
+
/** @type {DependenciesBlockVariable[]} */
|
|
17
23
|
this.variables = [];
|
|
18
|
-
// TODO remove this line, it's wrong
|
|
19
|
-
/** @type {ChunkGroup=} */
|
|
20
|
-
this.chunkGroup = undefined;
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Adds a DependencyBlock to DependencyBlock relationship.
|
|
28
|
+
* This is used for when a Module has a AsyncDependencyBlock tie (for code-splitting)
|
|
29
|
+
*
|
|
30
|
+
* @param {AsyncDependenciesBlock} block block being added
|
|
31
|
+
* @returns {void}
|
|
32
|
+
*/
|
|
23
33
|
addBlock(block) {
|
|
24
34
|
this.blocks.push(block);
|
|
25
35
|
block.parent = this;
|
|
26
36
|
}
|
|
27
37
|
|
|
38
|
+
/**
|
|
39
|
+
* @param {string} name name of dependency
|
|
40
|
+
* @param {string} expression expression string for variable
|
|
41
|
+
* @param {Dependency[]} dependencies dependency instances tied to variable
|
|
42
|
+
* @returns {void}
|
|
43
|
+
*/
|
|
28
44
|
addVariable(name, expression, dependencies) {
|
|
29
45
|
for (let v of this.variables) {
|
|
30
46
|
if (v.name === name && v.expression === expression) {
|
|
@@ -36,10 +52,19 @@ class DependenciesBlock {
|
|
|
36
52
|
);
|
|
37
53
|
}
|
|
38
54
|
|
|
55
|
+
/**
|
|
56
|
+
* @param {Dependency} dependency dependency being tied to block.
|
|
57
|
+
* This is an "edge" pointing to another "node" on module graph.
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
39
60
|
addDependency(dependency) {
|
|
40
61
|
this.dependencies.push(dependency);
|
|
41
62
|
}
|
|
42
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @param {Dependency} dependency dependency being removed
|
|
66
|
+
* @returns {void}
|
|
67
|
+
*/
|
|
43
68
|
removeDependency(dependency) {
|
|
44
69
|
const idx = this.dependencies.indexOf(dependency);
|
|
45
70
|
if (idx >= 0) {
|
|
@@ -47,6 +72,10 @@ class DependenciesBlock {
|
|
|
47
72
|
}
|
|
48
73
|
}
|
|
49
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @param {Hash} hash the hash used to track dependencies, from "crypto" module
|
|
77
|
+
* @returns {void}
|
|
78
|
+
*/
|
|
50
79
|
updateHash(hash) {
|
|
51
80
|
for (const dep of this.dependencies) dep.updateHash(hash);
|
|
52
81
|
for (const block of this.blocks) block.updateHash(hash);
|
|
@@ -63,6 +92,10 @@ class DependenciesBlock {
|
|
|
63
92
|
for (const block of this.blocks) block.unseal();
|
|
64
93
|
}
|
|
65
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @param {DependencyFilterFunction} filter filter function for dependencies, gets passed all dependency ties from current instance
|
|
97
|
+
* @returns {boolean} returns boolean for filter
|
|
98
|
+
*/
|
|
66
99
|
hasDependencies(filter) {
|
|
67
100
|
if (filter) {
|
|
68
101
|
for (const dep of this.dependencies) {
|
|
@@ -6,13 +6,30 @@
|
|
|
6
6
|
|
|
7
7
|
const { RawSource, ReplaceSource } = require("webpack-sources");
|
|
8
8
|
|
|
9
|
+
/** @typedef {import("./Dependency")} Dependency */
|
|
10
|
+
/** @typedef {import("./Dependency").DependencyTemplate} DependencyTemplate */
|
|
11
|
+
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
12
|
+
/** @typedef {import("./util/createHash").Hash} Hash */
|
|
13
|
+
/** @typedef {(d: Dependency) => boolean} DependencyFilterFunction */
|
|
14
|
+
/** @typedef {Map<Function, DependencyTemplate>} DependencyTemplates */
|
|
15
|
+
|
|
9
16
|
class DependenciesBlockVariable {
|
|
17
|
+
/**
|
|
18
|
+
* Creates an instance of DependenciesBlockVariable.
|
|
19
|
+
* @param {string} name name of DependenciesBlockVariable
|
|
20
|
+
* @param {string} expression expression string
|
|
21
|
+
* @param {Dependency[]=} dependencies dependencies tied to this varaiable
|
|
22
|
+
*/
|
|
10
23
|
constructor(name, expression, dependencies) {
|
|
11
24
|
this.name = name;
|
|
12
25
|
this.expression = expression;
|
|
13
26
|
this.dependencies = dependencies || [];
|
|
14
27
|
}
|
|
15
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @param {Hash} hash hash for instance to update
|
|
31
|
+
* @returns {void}
|
|
32
|
+
*/
|
|
16
33
|
updateHash(hash) {
|
|
17
34
|
hash.update(this.name);
|
|
18
35
|
hash.update(this.expression);
|
|
@@ -21,6 +38,11 @@ class DependenciesBlockVariable {
|
|
|
21
38
|
}
|
|
22
39
|
}
|
|
23
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @param {DependencyTemplates} dependencyTemplates Dependency constructors and templates Map.
|
|
43
|
+
* @param {RuntimeTemplate} runtimeTemplate runtimeTemplate to generate expression souce
|
|
44
|
+
* @returns {ReplaceSource} returns constructed source for expression via templates
|
|
45
|
+
*/
|
|
24
46
|
expressionSource(dependencyTemplates, runtimeTemplate) {
|
|
25
47
|
const source = new ReplaceSource(new RawSource(this.expression));
|
|
26
48
|
for (const dep of this.dependencies) {
|
package/lib/Dependency.js
CHANGED
|
@@ -7,22 +7,43 @@
|
|
|
7
7
|
const compareLocations = require("./compareLocations");
|
|
8
8
|
const DependencyReference = require("./dependencies/DependencyReference");
|
|
9
9
|
|
|
10
|
-
/** @typedef {
|
|
10
|
+
/** @typedef {import("./Module")} Module */
|
|
11
|
+
/** @typedef {import("webpack-sources").Source} Source */
|
|
12
|
+
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {Object} DependencyTemplate
|
|
16
|
+
* @property {function(Dependency, Source, RuntimeTemplate, Map<Function, DependencyTemplate>): void} apply
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** @typedef {Object} SourcePosition
|
|
11
20
|
* @property {number} column
|
|
12
21
|
* @property {number} line
|
|
13
22
|
*/
|
|
14
23
|
|
|
15
|
-
/** @typedef {Object}
|
|
16
|
-
* @property {
|
|
17
|
-
* @property {
|
|
24
|
+
/** @typedef {Object} RealDependencyLocation
|
|
25
|
+
* @property {SourcePosition} start
|
|
26
|
+
* @property {SourcePosition} end
|
|
27
|
+
* @property {number=} index
|
|
18
28
|
*/
|
|
19
29
|
|
|
30
|
+
/** @typedef {Object} SynteticDependencyLocation
|
|
31
|
+
* @property {string} name
|
|
32
|
+
* @property {number} index
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/** @typedef {SynteticDependencyLocation|RealDependencyLocation} DependencyLocation */
|
|
36
|
+
|
|
20
37
|
class Dependency {
|
|
21
38
|
constructor() {
|
|
39
|
+
/** @type {Module|null} */
|
|
22
40
|
this.module = null;
|
|
23
41
|
// TODO remove in webpack 5
|
|
42
|
+
/** @type {boolean} */
|
|
24
43
|
this.weak = false;
|
|
44
|
+
/** @type {boolean} */
|
|
25
45
|
this.optional = false;
|
|
46
|
+
/** @type {DependencyLocation} */
|
|
26
47
|
this.loc = undefined;
|
|
27
48
|
}
|
|
28
49
|
|
package/lib/DllEntryPlugin.js
CHANGED
|
@@ -36,7 +36,10 @@ class DllEntryPlugin {
|
|
|
36
36
|
new DllEntryDependency(
|
|
37
37
|
this.entries.map((e, idx) => {
|
|
38
38
|
const dep = new SingleEntryDependency(e);
|
|
39
|
-
dep.loc =
|
|
39
|
+
dep.loc = {
|
|
40
|
+
name: this.name,
|
|
41
|
+
index: idx
|
|
42
|
+
};
|
|
40
43
|
return dep;
|
|
41
44
|
}),
|
|
42
45
|
this.name
|
|
@@ -10,12 +10,23 @@ const MultiModuleFactory = require("./MultiModuleFactory");
|
|
|
10
10
|
const MultiEntryPlugin = require("./MultiEntryPlugin");
|
|
11
11
|
const SingleEntryPlugin = require("./SingleEntryPlugin");
|
|
12
12
|
|
|
13
|
+
/** @typedef {import("./Compiler")} Compiler */
|
|
14
|
+
/** @typedef {import("./Compiler").EntryOptionValuesFunction} EntryOptionValuesFunction */
|
|
15
|
+
|
|
13
16
|
class DynamicEntryPlugin {
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} context the context path
|
|
19
|
+
* @param {EntryOptionValuesFunction} entry the entry value
|
|
20
|
+
*/
|
|
14
21
|
constructor(context, entry) {
|
|
15
22
|
this.context = context;
|
|
16
23
|
this.entry = entry;
|
|
17
24
|
}
|
|
18
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @param {Compiler} compiler the compiler instance
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
19
30
|
apply(compiler) {
|
|
20
31
|
compiler.hooks.compilation.tap(
|
|
21
32
|
"DynamicEntryPlugin",
|
|
@@ -36,6 +47,11 @@ class DynamicEntryPlugin {
|
|
|
36
47
|
compiler.hooks.make.tapAsync(
|
|
37
48
|
"DynamicEntryPlugin",
|
|
38
49
|
(compilation, callback) => {
|
|
50
|
+
/**
|
|
51
|
+
* @param {string|string[]} entry entry value or array of entry values
|
|
52
|
+
* @param {string} name name of entry
|
|
53
|
+
* @returns {Promise<any>} returns the promise resolving the Compilation#addEntry function
|
|
54
|
+
*/
|
|
39
55
|
const addEntry = (entry, name) => {
|
|
40
56
|
const dep = DynamicEntryPlugin.createDependency(entry, name);
|
|
41
57
|
return new Promise((resolve, reject) => {
|
|
@@ -63,7 +79,11 @@ class DynamicEntryPlugin {
|
|
|
63
79
|
}
|
|
64
80
|
|
|
65
81
|
module.exports = DynamicEntryPlugin;
|
|
66
|
-
|
|
82
|
+
/**
|
|
83
|
+
* @param {string|string[]} entry entry value or array of entry paths
|
|
84
|
+
* @param {string} name name of entry
|
|
85
|
+
* @returns {SingleEntryDependency|MultiEntryDependency} returns dep
|
|
86
|
+
*/
|
|
67
87
|
DynamicEntryPlugin.createDependency = (entry, name) => {
|
|
68
88
|
if (Array.isArray(entry)) {
|
|
69
89
|
return MultiEntryPlugin.createDependency(entry, name);
|
package/lib/EntryOptionPlugin.js
CHANGED
|
@@ -8,6 +8,14 @@ const SingleEntryPlugin = require("./SingleEntryPlugin");
|
|
|
8
8
|
const MultiEntryPlugin = require("./MultiEntryPlugin");
|
|
9
9
|
const DynamicEntryPlugin = require("./DynamicEntryPlugin");
|
|
10
10
|
|
|
11
|
+
/** @typedef {import("./Compiler")} Compiler */
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} context context path
|
|
15
|
+
* @param {string | string[]} item entry array or single path
|
|
16
|
+
* @param {string} name entry key name
|
|
17
|
+
* @returns {SingleEntryPlugin | MultiEntryPlugin} returns either a single or multi entry plugin
|
|
18
|
+
*/
|
|
11
19
|
const itemToPlugin = (context, item, name) => {
|
|
12
20
|
if (Array.isArray(item)) {
|
|
13
21
|
return new MultiEntryPlugin(context, item, name);
|
|
@@ -16,6 +24,10 @@ const itemToPlugin = (context, item, name) => {
|
|
|
16
24
|
};
|
|
17
25
|
|
|
18
26
|
module.exports = class EntryOptionPlugin {
|
|
27
|
+
/**
|
|
28
|
+
* @param {Compiler} compiler the compiler instance one is tapping into
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
19
31
|
apply(compiler) {
|
|
20
32
|
compiler.hooks.entryOption.tap("EntryOptionPlugin", (context, entry) => {
|
|
21
33
|
if (typeof entry === "string" || Array.isArray(entry)) {
|
package/lib/ExtendedAPIPlugin.js
CHANGED
|
@@ -10,12 +10,16 @@ const ParserHelpers = require("./ParserHelpers");
|
|
|
10
10
|
const NullFactory = require("./NullFactory");
|
|
11
11
|
|
|
12
12
|
const REPLACEMENTS = {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// eslint-disable-next-line camelcase
|
|
14
|
+
__webpack_hash__: "__webpack_require__.h",
|
|
15
|
+
// eslint-disable-next-line camelcase
|
|
16
|
+
__webpack_chunkname__: "__webpack_require__.cn"
|
|
15
17
|
};
|
|
16
18
|
const REPLACEMENT_TYPES = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
// eslint-disable-next-line camelcase
|
|
20
|
+
__webpack_hash__: "string",
|
|
21
|
+
// eslint-disable-next-line camelcase
|
|
22
|
+
__webpack_chunkname__: "string"
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
class ExtendedAPIPlugin {
|
|
@@ -64,7 +64,7 @@ class ExternalModuleFactoryPlugin {
|
|
|
64
64
|
asyncFlag = true;
|
|
65
65
|
if (i >= externals.length) return callback();
|
|
66
66
|
handleExternals(externals[i++], handleExternalsAndCallback);
|
|
67
|
-
} while (!asyncFlag);
|
|
67
|
+
} while (!asyncFlag);
|
|
68
68
|
asyncFlag = false;
|
|
69
69
|
};
|
|
70
70
|
|
package/lib/GraphHelpers.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
3
3
|
/** @typedef {import("./Module")} Module */
|
|
4
4
|
/** @typedef {import("./DependenciesBlock")} DependenciesBlock */
|
|
5
|
+
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @param {ChunkGroup} chunkGroup the ChunkGroup to connect
|
|
@@ -47,7 +48,7 @@ const disconnectChunkAndModule = (chunk, module) => {
|
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
|
-
* @param {
|
|
51
|
+
* @param {AsyncDependenciesBlock} depBlock DepBlock being tied to ChunkGroup
|
|
51
52
|
* @param {ChunkGroup} chunkGroup ChunkGroup being tied to DepBlock
|
|
52
53
|
* @returns {void}
|
|
53
54
|
*/
|
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
/*global $hash$ $requestTimeout$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */
|
|
6
6
|
module.exports = function() {
|
|
7
7
|
var hotApplyOnUpdate = true;
|
|
8
|
-
|
|
8
|
+
// eslint-disable-next-line no-unused-vars
|
|
9
|
+
var hotCurrentHash = $hash$;
|
|
9
10
|
var hotRequestTimeout = $requestTimeout$;
|
|
10
11
|
var hotCurrentModuleData = {};
|
|
11
|
-
var hotCurrentChildModule;
|
|
12
|
-
|
|
13
|
-
var
|
|
12
|
+
var hotCurrentChildModule;
|
|
13
|
+
// eslint-disable-next-line no-unused-vars
|
|
14
|
+
var hotCurrentParents = [];
|
|
15
|
+
// eslint-disable-next-line no-unused-vars
|
|
16
|
+
var hotCurrentParentsTemp = [];
|
|
14
17
|
|
|
15
18
|
// eslint-disable-next-line no-unused-vars
|
|
16
19
|
function hotCreateRequire(moduleId) {
|
|
@@ -199,8 +202,8 @@ module.exports = function() {
|
|
|
199
202
|
});
|
|
200
203
|
hotUpdate = {};
|
|
201
204
|
/*foreachInstalledChunks*/
|
|
205
|
+
// eslint-disable-next-line no-lone-blocks
|
|
202
206
|
{
|
|
203
|
-
// eslint-disable-line no-lone-blocks
|
|
204
207
|
/*globals chunkId */
|
|
205
208
|
hotEnsureUpdateChunk(chunkId);
|
|
206
209
|
}
|