webpack 3.5.2 → 3.5.6
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 +567 -567
- package/bin/config-yargs.js +1 -1
- package/bin/convert-argv.js +4 -4
- package/lib/Compilation.js +178 -144
- package/lib/Compiler.js +17 -17
- package/lib/ContextModuleFactory.js +6 -6
- package/lib/HotModuleReplacement.runtime.js +602 -594
- package/lib/Module.js +250 -248
- package/lib/NormalModule.js +556 -555
- package/lib/OptionsDefaulter.js +73 -71
- package/lib/Parser.js +10 -10
- package/lib/SourceMapDevToolPlugin.js +209 -207
- package/lib/Template.js +176 -166
- package/lib/UmdMainTemplatePlugin.js +6 -6
- package/lib/WebpackOptionsDefaulter.js +129 -115
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +285 -286
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +124 -121
- package/lib/dependencies/HarmonyModulesHelpers.js +85 -85
- package/lib/optimize/ConcatenatedModule.js +814 -807
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +9 -0
- package/lib/util/Semaphore.js +32 -0
- package/lib/webpack.js +119 -118
- package/package.json +1 -1
- package/schemas/webpackOptionsSchema.json +5 -0
package/lib/Template.js
CHANGED
@@ -1,166 +1,176 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
const Tapable = require("tapable");
|
8
|
-
const ConcatSource = require("webpack-sources").ConcatSource;
|
9
|
-
|
10
|
-
const START_LOWERCASE_ALPHABET_CODE = "a".charCodeAt(0);
|
11
|
-
const START_UPPERCASE_ALPHABET_CODE = "A".charCodeAt(0);
|
12
|
-
const DELTA_A_TO_Z = "z".charCodeAt(0) - START_LOWERCASE_ALPHABET_CODE + 1;
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
static
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
}
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
if(
|
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
|
-
var
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
var
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
var
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const Tapable = require("tapable");
|
8
|
+
const ConcatSource = require("webpack-sources").ConcatSource;
|
9
|
+
|
10
|
+
const START_LOWERCASE_ALPHABET_CODE = "a".charCodeAt(0);
|
11
|
+
const START_UPPERCASE_ALPHABET_CODE = "A".charCodeAt(0);
|
12
|
+
const DELTA_A_TO_Z = "z".charCodeAt(0) - START_LOWERCASE_ALPHABET_CODE + 1;
|
13
|
+
const FUNCTION_CONTENT_REGEX = /^function\s?\(\)\s?\{\n?|\n?\}$/g;
|
14
|
+
const INDENT_MULTILINE_REGEX = /^\t/mg;
|
15
|
+
const IDENTIFIER_NAME_REPLACE_REGEX = /^[^a-zA-Z$_]/;
|
16
|
+
const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-zA-Z0-9$_]/g;
|
17
|
+
const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g;
|
18
|
+
const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
|
19
|
+
|
20
|
+
module.exports = class Template extends Tapable {
|
21
|
+
constructor(outputOptions) {
|
22
|
+
super();
|
23
|
+
this.outputOptions = outputOptions || {};
|
24
|
+
}
|
25
|
+
|
26
|
+
static getFunctionContent(fn) {
|
27
|
+
return fn.toString().replace(FUNCTION_CONTENT_REGEX, "").replace(INDENT_MULTILINE_REGEX, "");
|
28
|
+
}
|
29
|
+
|
30
|
+
static toIdentifier(str) {
|
31
|
+
if(typeof str !== "string") return "";
|
32
|
+
return str.replace(IDENTIFIER_NAME_REPLACE_REGEX, "_").replace(IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX, "_");
|
33
|
+
}
|
34
|
+
|
35
|
+
static toPath(str) {
|
36
|
+
if(typeof str !== "string") return "";
|
37
|
+
return str.replace(PATH_NAME_NORMALIZE_REPLACE_REGEX, "-").replace(MATCH_PADDED_HYPHENS_REPLACE_REGEX, "");
|
38
|
+
}
|
39
|
+
|
40
|
+
// map number to a single character a-z, A-Z or <_ + number> if number is too big
|
41
|
+
static numberToIdentifer(n) {
|
42
|
+
// lower case
|
43
|
+
if(n < DELTA_A_TO_Z) return String.fromCharCode(START_LOWERCASE_ALPHABET_CODE + n);
|
44
|
+
|
45
|
+
// upper case
|
46
|
+
n -= DELTA_A_TO_Z;
|
47
|
+
if(n < DELTA_A_TO_Z) return String.fromCharCode(START_UPPERCASE_ALPHABET_CODE + n);
|
48
|
+
|
49
|
+
// fall back to _ + number
|
50
|
+
n -= DELTA_A_TO_Z;
|
51
|
+
return "_" + n;
|
52
|
+
}
|
53
|
+
|
54
|
+
indent(str) {
|
55
|
+
if(Array.isArray(str)) {
|
56
|
+
return str.map(this.indent.bind(this)).join("\n");
|
57
|
+
} else {
|
58
|
+
str = str.trimRight();
|
59
|
+
if(!str) return "";
|
60
|
+
var ind = (str[0] === "\n" ? "" : "\t");
|
61
|
+
return ind + str.replace(/\n([^\n])/g, "\n\t$1");
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
prefix(str, prefix) {
|
66
|
+
if(Array.isArray(str)) {
|
67
|
+
str = str.join("\n");
|
68
|
+
}
|
69
|
+
str = str.trim();
|
70
|
+
if(!str) return "";
|
71
|
+
const ind = (str[0] === "\n" ? "" : prefix);
|
72
|
+
return ind + str.replace(/\n([^\n])/g, "\n" + prefix + "$1");
|
73
|
+
}
|
74
|
+
|
75
|
+
asString(str) {
|
76
|
+
if(Array.isArray(str)) {
|
77
|
+
return str.join("\n");
|
78
|
+
}
|
79
|
+
return str;
|
80
|
+
}
|
81
|
+
|
82
|
+
getModulesArrayBounds(modules) {
|
83
|
+
if(!modules.every(moduleIdIsNumber))
|
84
|
+
return false;
|
85
|
+
var maxId = -Infinity;
|
86
|
+
var minId = Infinity;
|
87
|
+
modules.forEach(function(module) {
|
88
|
+
if(maxId < module.id) maxId = module.id;
|
89
|
+
if(minId > module.id) minId = module.id;
|
90
|
+
});
|
91
|
+
if(minId < 16 + ("" + minId).length) {
|
92
|
+
// add minId x ',' instead of 'Array(minId).concat(...)'
|
93
|
+
minId = 0;
|
94
|
+
}
|
95
|
+
var objectOverhead = modules.map(function(module) {
|
96
|
+
var idLength = (module.id + "").length;
|
97
|
+
return idLength + 2;
|
98
|
+
}).reduce(function(a, b) {
|
99
|
+
return a + b;
|
100
|
+
}, -1);
|
101
|
+
var arrayOverhead = minId === 0 ? maxId : 16 + ("" + minId).length + maxId;
|
102
|
+
return arrayOverhead < objectOverhead ? [minId, maxId] : false;
|
103
|
+
}
|
104
|
+
|
105
|
+
renderChunkModules(chunk, moduleTemplate, dependencyTemplates, prefix) {
|
106
|
+
if(!prefix) prefix = "";
|
107
|
+
var source = new ConcatSource();
|
108
|
+
if(chunk.getNumberOfModules() === 0) {
|
109
|
+
source.add("[]");
|
110
|
+
return source;
|
111
|
+
}
|
112
|
+
var removedModules = chunk.removedModules;
|
113
|
+
var allModules = chunk.mapModules(function(module) {
|
114
|
+
return {
|
115
|
+
id: module.id,
|
116
|
+
source: moduleTemplate.render(module, dependencyTemplates, chunk)
|
117
|
+
};
|
118
|
+
});
|
119
|
+
if(removedModules && removedModules.length > 0) {
|
120
|
+
removedModules.forEach(function(id) {
|
121
|
+
allModules.push({
|
122
|
+
id: id,
|
123
|
+
source: "false"
|
124
|
+
});
|
125
|
+
});
|
126
|
+
}
|
127
|
+
var bounds = this.getModulesArrayBounds(allModules);
|
128
|
+
|
129
|
+
if(bounds) {
|
130
|
+
// Render a spare array
|
131
|
+
var minId = bounds[0];
|
132
|
+
var maxId = bounds[1];
|
133
|
+
if(minId !== 0) source.add("Array(" + minId + ").concat(");
|
134
|
+
source.add("[\n");
|
135
|
+
var modules = {};
|
136
|
+
allModules.forEach(function(module) {
|
137
|
+
modules[module.id] = module;
|
138
|
+
});
|
139
|
+
for(var idx = minId; idx <= maxId; idx++) {
|
140
|
+
var module = modules[idx];
|
141
|
+
if(idx !== minId) source.add(",\n");
|
142
|
+
source.add("/* " + idx + " */");
|
143
|
+
if(module) {
|
144
|
+
source.add("\n");
|
145
|
+
source.add(module.source);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
source.add("\n" + prefix + "]");
|
149
|
+
if(minId !== 0) source.add(")");
|
150
|
+
} else {
|
151
|
+
// Render an object
|
152
|
+
source.add("{\n");
|
153
|
+
allModules
|
154
|
+
.sort(stringifyIdSortPredicate)
|
155
|
+
.forEach(function(module, idx) {
|
156
|
+
if(idx !== 0) source.add(",\n");
|
157
|
+
source.add(`\n/***/ ${JSON.stringify(module.id)}:\n`);
|
158
|
+
source.add(module.source);
|
159
|
+
});
|
160
|
+
source.add("\n\n" + prefix + "}");
|
161
|
+
}
|
162
|
+
return source;
|
163
|
+
}
|
164
|
+
};
|
165
|
+
|
166
|
+
function stringifyIdSortPredicate(a, b) {
|
167
|
+
var aId = a.id + "";
|
168
|
+
var bId = b.id + "";
|
169
|
+
if(aId < bId) return -1;
|
170
|
+
if(aId > bId) return 1;
|
171
|
+
return 0;
|
172
|
+
}
|
173
|
+
|
174
|
+
function moduleIdIsNumber(module) {
|
175
|
+
return typeof module.id === "number";
|
176
|
+
}
|
@@ -41,7 +41,7 @@ class UmdMainTemplatePlugin {
|
|
41
41
|
|
42
42
|
apply(compilation) {
|
43
43
|
const mainTemplate = compilation.mainTemplate;
|
44
|
-
compilation.templatesPlugin("render-with-entry",
|
44
|
+
compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
|
45
45
|
let externals = chunk.getModules().filter(m => m.external);
|
46
46
|
const optionalExternals = [];
|
47
47
|
let requiredExternals = [];
|
@@ -172,19 +172,19 @@ class UmdMainTemplatePlugin {
|
|
172
172
|
" }\n"
|
173
173
|
) +
|
174
174
|
"})(this, function(" + externalsArguments(externals) + ") {\nreturn ", "webpack/universalModuleDefinition"), source, ";\n})");
|
175
|
-
}
|
176
|
-
mainTemplate.plugin("global-hash-paths",
|
175
|
+
});
|
176
|
+
mainTemplate.plugin("global-hash-paths", (paths) => {
|
177
177
|
if(this.names.root) paths = paths.concat(this.names.root);
|
178
178
|
if(this.names.amd) paths = paths.concat(this.names.amd);
|
179
179
|
if(this.names.commonjs) paths = paths.concat(this.names.commonjs);
|
180
180
|
return paths;
|
181
|
-
}
|
182
|
-
mainTemplate.plugin("hash",
|
181
|
+
});
|
182
|
+
mainTemplate.plugin("hash", (hash) => {
|
183
183
|
hash.update("umd");
|
184
184
|
hash.update(`${this.names.root}`);
|
185
185
|
hash.update(`${this.names.amd}`);
|
186
186
|
hash.update(`${this.names.commonjs}`);
|
187
|
-
}
|
187
|
+
});
|
188
188
|
}
|
189
189
|
}
|
190
190
|
|
@@ -1,115 +1,129 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
const OptionsDefaulter = require("./OptionsDefaulter");
|
8
|
-
const Template = require("./Template");
|
9
|
-
|
10
|
-
class WebpackOptionsDefaulter extends OptionsDefaulter {
|
11
|
-
constructor() {
|
12
|
-
super();
|
13
|
-
this.set("devtool", false);
|
14
|
-
this.set("cache", true);
|
15
|
-
|
16
|
-
this.set("context", process.cwd());
|
17
|
-
this.set("target", "web");
|
18
|
-
|
19
|
-
this.set("module
|
20
|
-
this.set("module.
|
21
|
-
this.set("module.
|
22
|
-
this.set("module.
|
23
|
-
this.set("module.
|
24
|
-
this.set("module.
|
25
|
-
this.set("module.
|
26
|
-
this.set("module.
|
27
|
-
this.set("module.
|
28
|
-
this.set("module.
|
29
|
-
this.set("module.
|
30
|
-
this.set("module.
|
31
|
-
this.set("module.
|
32
|
-
|
33
|
-
this.set("module.unsafeCache", true);
|
34
|
-
|
35
|
-
this.set("output", "call", (value, options) => {
|
36
|
-
if(typeof value === "string") {
|
37
|
-
return {
|
38
|
-
filename: value
|
39
|
-
};
|
40
|
-
} else if(typeof value !== "object") {
|
41
|
-
return {};
|
42
|
-
} else {
|
43
|
-
return value;
|
44
|
-
}
|
45
|
-
});
|
46
|
-
this.set("output.filename", "[name].js");
|
47
|
-
this.set("output.chunkFilename", "make", (options) => {
|
48
|
-
const filename = options.output.filename;
|
49
|
-
return filename.indexOf("[name]") >= 0 ? filename.replace("[name]", "[id]") : "[id]." + filename;
|
50
|
-
});
|
51
|
-
this.set("output.library", "");
|
52
|
-
this.set("output.hotUpdateFunction", "make", (options) => {
|
53
|
-
return Template.toIdentifier("webpackHotUpdate" + options.output.library);
|
54
|
-
});
|
55
|
-
this.set("output.jsonpFunction", "make", (options) => {
|
56
|
-
return Template.toIdentifier("webpackJsonp" + options.output.library);
|
57
|
-
});
|
58
|
-
this.set("output.libraryTarget", "var");
|
59
|
-
this.set("output.path", process.cwd());
|
60
|
-
this.set("output.sourceMapFilename", "[file].map[query]");
|
61
|
-
this.set("output.hotUpdateChunkFilename", "[id].[hash].hot-update.js");
|
62
|
-
this.set("output.hotUpdateMainFilename", "[hash].hot-update.json");
|
63
|
-
this.set("output.crossOriginLoading", false);
|
64
|
-
this.set("output.chunkLoadTimeout", 120000);
|
65
|
-
this.set("output.hashFunction", "md5");
|
66
|
-
this.set("output.hashDigest", "hex");
|
67
|
-
this.set("output.hashDigestLength", 20);
|
68
|
-
this.set("output.devtoolLineToLine", false);
|
69
|
-
this.set("output.strictModuleExceptionHandling", false);
|
70
|
-
|
71
|
-
this.set("node", {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
this.set("node.
|
79
|
-
|
80
|
-
this.set("
|
81
|
-
this.set("
|
82
|
-
this.set("
|
83
|
-
|
84
|
-
this.set("
|
85
|
-
|
86
|
-
this.set("
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
this.set("
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
this.set("resolve.
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
this.set("
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
}
|
114
|
-
|
115
|
-
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const OptionsDefaulter = require("./OptionsDefaulter");
|
8
|
+
const Template = require("./Template");
|
9
|
+
|
10
|
+
class WebpackOptionsDefaulter extends OptionsDefaulter {
|
11
|
+
constructor() {
|
12
|
+
super();
|
13
|
+
this.set("devtool", false);
|
14
|
+
this.set("cache", true);
|
15
|
+
|
16
|
+
this.set("context", process.cwd());
|
17
|
+
this.set("target", "web");
|
18
|
+
|
19
|
+
this.set("module", "call", value => Object.assign({}, value));
|
20
|
+
this.set("module.unknownContextRequest", ".");
|
21
|
+
this.set("module.unknownContextRegExp", false);
|
22
|
+
this.set("module.unknownContextRecursive", true);
|
23
|
+
this.set("module.unknownContextCritical", true);
|
24
|
+
this.set("module.exprContextRequest", ".");
|
25
|
+
this.set("module.exprContextRegExp", false);
|
26
|
+
this.set("module.exprContextRecursive", true);
|
27
|
+
this.set("module.exprContextCritical", true);
|
28
|
+
this.set("module.wrappedContextRegExp", /.*/);
|
29
|
+
this.set("module.wrappedContextRecursive", true);
|
30
|
+
this.set("module.wrappedContextCritical", false);
|
31
|
+
this.set("module.strictExportPresence", false);
|
32
|
+
this.set("module.strictThisContextOnImports", false);
|
33
|
+
this.set("module.unsafeCache", true);
|
34
|
+
|
35
|
+
this.set("output", "call", (value, options) => {
|
36
|
+
if(typeof value === "string") {
|
37
|
+
return {
|
38
|
+
filename: value
|
39
|
+
};
|
40
|
+
} else if(typeof value !== "object") {
|
41
|
+
return {};
|
42
|
+
} else {
|
43
|
+
return Object.assign({}, value);
|
44
|
+
}
|
45
|
+
});
|
46
|
+
this.set("output.filename", "[name].js");
|
47
|
+
this.set("output.chunkFilename", "make", (options) => {
|
48
|
+
const filename = options.output.filename;
|
49
|
+
return filename.indexOf("[name]") >= 0 ? filename.replace("[name]", "[id]") : "[id]." + filename;
|
50
|
+
});
|
51
|
+
this.set("output.library", "");
|
52
|
+
this.set("output.hotUpdateFunction", "make", (options) => {
|
53
|
+
return Template.toIdentifier("webpackHotUpdate" + options.output.library);
|
54
|
+
});
|
55
|
+
this.set("output.jsonpFunction", "make", (options) => {
|
56
|
+
return Template.toIdentifier("webpackJsonp" + options.output.library);
|
57
|
+
});
|
58
|
+
this.set("output.libraryTarget", "var");
|
59
|
+
this.set("output.path", process.cwd());
|
60
|
+
this.set("output.sourceMapFilename", "[file].map[query]");
|
61
|
+
this.set("output.hotUpdateChunkFilename", "[id].[hash].hot-update.js");
|
62
|
+
this.set("output.hotUpdateMainFilename", "[hash].hot-update.json");
|
63
|
+
this.set("output.crossOriginLoading", false);
|
64
|
+
this.set("output.chunkLoadTimeout", 120000);
|
65
|
+
this.set("output.hashFunction", "md5");
|
66
|
+
this.set("output.hashDigest", "hex");
|
67
|
+
this.set("output.hashDigestLength", 20);
|
68
|
+
this.set("output.devtoolLineToLine", false);
|
69
|
+
this.set("output.strictModuleExceptionHandling", false);
|
70
|
+
|
71
|
+
this.set("node", "call", value => {
|
72
|
+
if(typeof value === "boolean") {
|
73
|
+
return value;
|
74
|
+
} else {
|
75
|
+
return Object.assign({}, value);
|
76
|
+
}
|
77
|
+
});
|
78
|
+
this.set("node.console", false);
|
79
|
+
this.set("node.process", true);
|
80
|
+
this.set("node.global", true);
|
81
|
+
this.set("node.Buffer", true);
|
82
|
+
this.set("node.setImmediate", true);
|
83
|
+
this.set("node.__filename", "mock");
|
84
|
+
this.set("node.__dirname", "mock");
|
85
|
+
|
86
|
+
this.set("performance", "call", value => {
|
87
|
+
if(typeof value === "boolean") {
|
88
|
+
return value;
|
89
|
+
} else {
|
90
|
+
return Object.assign({}, value);
|
91
|
+
}
|
92
|
+
});
|
93
|
+
this.set("performance.maxAssetSize", 250000);
|
94
|
+
this.set("performance.maxEntrypointSize", 250000);
|
95
|
+
this.set("performance.hints", false);
|
96
|
+
|
97
|
+
this.set("resolve", "call", value => Object.assign({}, value));
|
98
|
+
this.set("resolve.unsafeCache", true);
|
99
|
+
this.set("resolve.modules", ["node_modules"]);
|
100
|
+
this.set("resolve.extensions", [".js", ".json"]);
|
101
|
+
this.set("resolve.mainFiles", ["index"]);
|
102
|
+
this.set("resolve.aliasFields", "make", (options) => {
|
103
|
+
if(options.target === "web" || options.target === "webworker")
|
104
|
+
return ["browser"];
|
105
|
+
else
|
106
|
+
return [];
|
107
|
+
});
|
108
|
+
this.set("resolve.mainFields", "make", (options) => {
|
109
|
+
if(options.target === "web" || options.target === "webworker")
|
110
|
+
return ["browser", "module", "main"];
|
111
|
+
else
|
112
|
+
return ["module", "main"];
|
113
|
+
});
|
114
|
+
this.set("resolve.cacheWithContext", "make", (options) => {
|
115
|
+
return Array.isArray(options.resolve.plugins) && options.resolve.plugins.length > 0;
|
116
|
+
});
|
117
|
+
|
118
|
+
this.set("resolveLoader", "call", value => Object.assign({}, value));
|
119
|
+
this.set("resolveLoader.unsafeCache", true);
|
120
|
+
this.set("resolveLoader.mainFields", ["loader", "main"]);
|
121
|
+
this.set("resolveLoader.extensions", [".js", ".json"]);
|
122
|
+
this.set("resolveLoader.mainFiles", ["index"]);
|
123
|
+
this.set("resolveLoader.cacheWithContext", "make", (options) => {
|
124
|
+
return Array.isArray(options.resolveLoader.plugins) && options.resolveLoader.plugins.length > 0;
|
125
|
+
});
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
module.exports = WebpackOptionsDefaulter;
|