webpack 4.8.2 → 4.9.2
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/README.md +95 -52
- package/bin/webpack.js +128 -43
- package/lib/AmdMainTemplatePlugin.js +10 -0
- package/lib/AsyncDependencyToInitialChunkError.js +12 -2
- package/lib/BannerPlugin.js +115 -101
- package/lib/CaseSensitiveModulesWarning.js +20 -2
- package/lib/Chunk.js +1 -0
- package/lib/ChunkGroup.js +465 -465
- package/lib/ChunkRenderError.js +8 -0
- package/lib/ChunkTemplate.js +71 -71
- package/lib/Compilation.js +1 -1
- package/lib/Compiler.js +2 -1
- package/lib/ContextModule.js +8 -8
- package/lib/DllPlugin.js +3 -1
- package/lib/DllReferencePlugin.js +2 -1
- package/lib/Entrypoint.js +54 -54
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +115 -115
- package/lib/ExportPropertyMainTemplatePlugin.js +13 -0
- package/lib/Generator.js +52 -52
- package/lib/HotModuleReplacement.runtime.js +633 -633
- package/lib/JsonParser.js +2 -1
- package/lib/LibManifestPlugin.js +9 -0
- package/lib/LibraryTemplatePlugin.js +66 -33
- package/lib/MainTemplate.js +468 -468
- package/lib/Module.js +3 -3
- package/lib/ModuleDependencyError.js +12 -2
- package/lib/NormalModuleFactory.js +5 -3
- package/lib/Parser.js +27 -23
- package/lib/ProgressPlugin.js +1 -1
- package/lib/RecordIdsPlugin.js +3 -1
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/SetVarMainTemplatePlugin.js +12 -0
- package/lib/SourceMapDevToolPlugin.js +11 -13
- package/lib/Template.js +289 -290
- package/lib/UmdMainTemplatePlugin.js +67 -32
- package/lib/WebpackError.js +8 -2
- package/lib/compareLocations.js +20 -0
- package/lib/debug/ProfilingPlugin.js +416 -416
- package/lib/dependencies/ContextDependencyHelpers.js +142 -142
- package/lib/dependencies/WebpackMissingModule.js +2 -2
- package/lib/optimize/RemoveEmptyChunksPlugin.js +42 -40
- package/lib/optimize/RuntimeChunkPlugin.js +9 -5
- package/lib/optimize/SplitChunksPlugin.js +195 -124
- package/lib/util/Queue.js +46 -46
- package/lib/util/SetHelpers.js +48 -48
- package/lib/util/SortableSet.js +106 -106
- package/lib/util/StackedSetMap.js +128 -128
- package/lib/util/cachedMerge.js +13 -0
- package/lib/util/identifier.js +5 -0
- package/lib/util/objectToMap.js +16 -16
- package/lib/wasm/WebAssemblyGenerator.js +280 -280
- package/lib/wasm/WebAssemblyParser.js +79 -79
- package/lib/web/JsonpMainTemplatePlugin.js +2 -2
- package/package.json +21 -17
- package/schemas/WebpackOptions.json +12 -1
- package/schemas/plugins/BannerPlugin.json +96 -85
- package/schemas/plugins/DllPlugin.json +4 -0
package/lib/BannerPlugin.js
CHANGED
@@ -1,101 +1,115 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
|
6
|
-
"use strict";
|
7
|
-
|
8
|
-
const { ConcatSource } = require("webpack-sources");
|
9
|
-
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
10
|
-
const Template = require("./Template");
|
11
|
-
|
12
|
-
const validateOptions = require("schema-utils");
|
13
|
-
const schema = require("../schemas/plugins/BannerPlugin.json");
|
14
|
-
|
15
|
-
const wrapComment = str => {
|
16
|
-
if (!str.includes("\n")) return Template.toComment(str);
|
17
|
-
return `/*!\n * ${str
|
18
|
-
.replace(/\*\//g, "* /")
|
19
|
-
.split("\n")
|
20
|
-
.join("\n * ")}\n */`;
|
21
|
-
};
|
22
|
-
|
23
|
-
class BannerPlugin {
|
24
|
-
constructor(options) {
|
25
|
-
if (arguments.length > 1)
|
26
|
-
throw new Error(
|
27
|
-
"BannerPlugin only takes one argument (pass an options object)"
|
28
|
-
);
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
options
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const { ConcatSource } = require("webpack-sources");
|
9
|
+
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
10
|
+
const Template = require("./Template");
|
11
|
+
|
12
|
+
const validateOptions = require("schema-utils");
|
13
|
+
const schema = require("../schemas/plugins/BannerPlugin.json");
|
14
|
+
|
15
|
+
const wrapComment = str => {
|
16
|
+
if (!str.includes("\n")) return Template.toComment(str);
|
17
|
+
return `/*!\n * ${str
|
18
|
+
.replace(/\*\//g, "* /")
|
19
|
+
.split("\n")
|
20
|
+
.join("\n * ")}\n */`;
|
21
|
+
};
|
22
|
+
|
23
|
+
class BannerPlugin {
|
24
|
+
constructor(options) {
|
25
|
+
if (arguments.length > 1) {
|
26
|
+
throw new Error(
|
27
|
+
"BannerPlugin only takes one argument (pass an options object)"
|
28
|
+
);
|
29
|
+
}
|
30
|
+
|
31
|
+
validateOptions(schema, options, "Banner Plugin");
|
32
|
+
|
33
|
+
if (typeof options === "string" || typeof options === "function") {
|
34
|
+
options = {
|
35
|
+
banner: options
|
36
|
+
};
|
37
|
+
}
|
38
|
+
|
39
|
+
this.options = options || {};
|
40
|
+
|
41
|
+
if (typeof options.banner === "function") {
|
42
|
+
const getBanner = this.options.banner;
|
43
|
+
this.banner = this.options.raw
|
44
|
+
? getBanner
|
45
|
+
: data => wrapComment(getBanner(data));
|
46
|
+
} else {
|
47
|
+
const banner = this.options.raw
|
48
|
+
? this.options.banner
|
49
|
+
: wrapComment(this.options.banner);
|
50
|
+
this.banner = () => banner;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
apply(compiler) {
|
55
|
+
const options = this.options;
|
56
|
+
const banner = this.banner;
|
57
|
+
const matchObject = ModuleFilenameHelpers.matchObject.bind(
|
58
|
+
undefined,
|
59
|
+
options
|
60
|
+
);
|
61
|
+
|
62
|
+
compiler.hooks.compilation.tap("BannerPlugin", compilation => {
|
63
|
+
compilation.hooks.optimizeChunkAssets.tap("BannerPlugin", chunks => {
|
64
|
+
for (const chunk of chunks) {
|
65
|
+
if (options.entryOnly && !chunk.canBeInitial()) {
|
66
|
+
continue;
|
67
|
+
}
|
68
|
+
|
69
|
+
for (const file of chunk.files) {
|
70
|
+
if (!matchObject(file)) {
|
71
|
+
continue;
|
72
|
+
}
|
73
|
+
|
74
|
+
let basename;
|
75
|
+
let query = "";
|
76
|
+
let filename = file;
|
77
|
+
const hash = compilation.hash;
|
78
|
+
const querySplit = filename.indexOf("?");
|
79
|
+
|
80
|
+
if (querySplit >= 0) {
|
81
|
+
query = filename.substr(querySplit);
|
82
|
+
filename = filename.substr(0, querySplit);
|
83
|
+
}
|
84
|
+
|
85
|
+
const lastSlashIndex = filename.lastIndexOf("/");
|
86
|
+
|
87
|
+
if (lastSlashIndex === -1) {
|
88
|
+
basename = filename;
|
89
|
+
} else {
|
90
|
+
basename = filename.substr(lastSlashIndex + 1);
|
91
|
+
}
|
92
|
+
|
93
|
+
const data = {
|
94
|
+
hash,
|
95
|
+
chunk,
|
96
|
+
filename,
|
97
|
+
basename,
|
98
|
+
query
|
99
|
+
};
|
100
|
+
|
101
|
+
const comment = compilation.getPath(banner(data), data);
|
102
|
+
|
103
|
+
compilation.assets[file] = new ConcatSource(
|
104
|
+
comment,
|
105
|
+
"\n",
|
106
|
+
compilation.assets[file]
|
107
|
+
);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
});
|
111
|
+
});
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
module.exports = BannerPlugin;
|
@@ -6,7 +6,13 @@
|
|
6
6
|
|
7
7
|
const WebpackError = require("./WebpackError");
|
8
8
|
|
9
|
-
|
9
|
+
/** @typedef {import("./Module")} Module */
|
10
|
+
|
11
|
+
class CaseSensitiveModulesWarning extends WebpackError {
|
12
|
+
/**
|
13
|
+
* Creates an instance of CaseSensitiveModulesWarning.
|
14
|
+
* @param {Module[]} modules modules that were detected
|
15
|
+
*/
|
10
16
|
constructor(modules) {
|
11
17
|
super();
|
12
18
|
|
@@ -23,6 +29,11 @@ ${modulesList}`;
|
|
23
29
|
Error.captureStackTrace(this, this.constructor);
|
24
30
|
}
|
25
31
|
|
32
|
+
/**
|
33
|
+
* @private
|
34
|
+
* @param {Module[]} modules the modules to be sorted
|
35
|
+
* @returns {Module[]} sorted version of original modules
|
36
|
+
*/
|
26
37
|
_sort(modules) {
|
27
38
|
return modules.slice().sort((a, b) => {
|
28
39
|
a = a.identifier();
|
@@ -36,6 +47,11 @@ ${modulesList}`;
|
|
36
47
|
});
|
37
48
|
}
|
38
49
|
|
50
|
+
/**
|
51
|
+
* @private
|
52
|
+
* @param {Module[]} modules each module from throw
|
53
|
+
* @returns {string} each message from provided moduels
|
54
|
+
*/
|
39
55
|
_moduleMessages(modules) {
|
40
56
|
return modules
|
41
57
|
.map(m => {
|
@@ -50,4 +66,6 @@ ${modulesList}`;
|
|
50
66
|
})
|
51
67
|
.join("\n");
|
52
68
|
}
|
53
|
-
}
|
69
|
+
}
|
70
|
+
|
71
|
+
module.exports = CaseSensitiveModulesWarning;
|