webpack 2.2.0-rc.6 → 2.2.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/README.md +39 -63
- package/bin/webpack.js +3 -3
- package/buildin/harmony-module.js +0 -6
- package/buildin/module.js +0 -2
- package/lib/APIPlugin.js +2 -8
- package/lib/AsyncDependenciesBlock.js +46 -55
- package/lib/ChunkTemplate.js +25 -26
- package/lib/CompatibilityPlugin.js +49 -46
- package/lib/Compilation.js +279 -138
- package/lib/Compiler.js +5 -2
- package/lib/ConstPlugin.js +2 -6
- package/lib/DefinePlugin.js +9 -27
- package/lib/EnvironmentPlugin.js +25 -9
- package/lib/EvalDevToolModulePlugin.js +15 -10
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +24 -18
- package/lib/ExtendedAPIPlugin.js +1 -6
- package/lib/FlagDependencyExportsPlugin.js +72 -79
- package/lib/FlagInitialModulesAsUsedPlugin.js +17 -13
- package/lib/FunctionModulePlugin.js +17 -11
- package/lib/HotModuleReplacementPlugin.js +3 -13
- package/lib/HotUpdateChunkTemplate.js +21 -22
- package/lib/JsonpTemplatePlugin.js +15 -11
- package/lib/LibManifestPlugin.js +1 -1
- package/lib/LoaderTargetPlugin.js +14 -10
- package/lib/MainTemplate.js +193 -191
- package/lib/MultiWatching.js +16 -14
- package/lib/NoEmitOnErrorsPlugin.js +14 -11
- package/lib/NodeStuffPlugin.js +6 -30
- package/lib/NormalModuleFactory.js +2 -2
- package/lib/NormalModuleReplacementPlugin.js +36 -31
- package/lib/Parser.js +11 -8
- package/lib/ParserHelpers.js +19 -5
- package/lib/ProvidePlugin.js +2 -6
- package/lib/RequestShortener.js +49 -47
- package/lib/RequireJsStuffPlugin.js +5 -20
- package/lib/RuleSet.js +28 -20
- package/lib/SourceMapDevToolPlugin.js +1 -1
- package/lib/Template.js +133 -132
- package/lib/compareLocations.js +9 -8
- package/lib/dependencies/AMDPlugin.js +111 -115
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +157 -154
- package/lib/dependencies/CommonJsPlugin.js +81 -85
- package/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +73 -75
- package/lib/dependencies/ContextDependencyTemplateAsId.js +21 -18
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +23 -29
- package/lib/dependencies/CriticalDependencyWarning.js +13 -8
- package/lib/dependencies/{HarmonyCompatiblilityDependency.js → HarmonyCompatibilityDependency.js} +3 -3
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +2 -2
- package/lib/dependencies/HarmonyModulesPlugin.js +51 -49
- package/lib/dependencies/ImportParserPlugin.js +31 -28
- package/lib/dependencies/ImportPlugin.js +28 -24
- package/lib/dependencies/LocalModule.js +17 -13
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +15 -17
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +15 -17
- package/lib/dependencies/RequireContextPlugin.js +59 -57
- package/lib/dependencies/RequireEnsurePlugin.js +22 -26
- package/lib/dependencies/RequireIncludePlugin.js +18 -23
- package/lib/dependencies/RequireResolveDependencyParserPlugin.js +59 -56
- package/lib/dependencies/SystemPlugin.js +34 -36
- package/lib/dependencies/WebpackMissingModule.js +10 -18
- package/lib/node/NodeTargetPlugin.js +8 -5
- package/lib/node/NodeWatchFileSystem.js +54 -53
- package/lib/optimize/CommonsChunkPlugin.js +163 -166
- package/lib/optimize/RemoveParentModulesPlugin.js +36 -27
- package/lib/validateSchema.js +18 -18
- package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +22 -20
- package/package.json +13 -7
@@ -2,15 +2,19 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
6
|
-
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
class LoaderTargetPlugin {
|
8
|
+
constructor(target) {
|
9
|
+
this.target = target;
|
10
|
+
}
|
11
|
+
|
12
|
+
apply(compiler) {
|
13
|
+
let target = this.target;
|
14
|
+
compiler.plugin("compilation", (compilation) => {
|
15
|
+
compilation.plugin("normal-module-loader", (loaderContext) => loaderContext.target = target);
|
16
|
+
});
|
17
|
+
}
|
7
18
|
}
|
19
|
+
|
8
20
|
module.exports = LoaderTargetPlugin;
|
9
|
-
LoaderTargetPlugin.prototype.apply = function(compiler) {
|
10
|
-
var target = this.target;
|
11
|
-
compiler.plugin("compilation", function(compilation) {
|
12
|
-
compilation.plugin("normal-module-loader", function(loaderContext) {
|
13
|
-
loaderContext.target = target;
|
14
|
-
});
|
15
|
-
});
|
16
|
-
};
|
package/lib/MainTemplate.js
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const ConcatSource = require("webpack-sources").ConcatSource;
|
8
|
+
const OriginalSource = require("webpack-sources").OriginalSource;
|
9
|
+
const PrefixSource = require("webpack-sources").PrefixSource;
|
10
|
+
const Template = require("./Template");
|
9
11
|
|
10
12
|
// require function shortcuts:
|
11
13
|
// __webpack_require__.s = the module id of the entry point
|
@@ -21,214 +23,214 @@ var Template = require("./Template");
|
|
21
23
|
// __webpack_require__.oe = the uncatched error handler for the webpack runtime
|
22
24
|
// __webpack_require__.nc = the script nonce
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
26
|
+
module.exports = class MainTemplate extends Template {
|
27
|
+
constructor(outputOptions) {
|
28
|
+
super(outputOptions);
|
29
|
+
this.plugin("startup", (source, chunk, hash) => {
|
30
|
+
let buf = [];
|
31
|
+
if(chunk.entryModule) {
|
32
|
+
buf.push("// Load entry module and return exports");
|
33
|
+
buf.push("return " + this.renderRequireFunctionForModule(hash, chunk, JSON.stringify(chunk.entryModule.id)) +
|
34
|
+
"(" + this.requireFn + ".s = " + JSON.stringify(chunk.entryModule.id) + ");");
|
35
|
+
}
|
36
|
+
return this.asString(buf);
|
37
|
+
});
|
38
|
+
this.plugin("render", (bootstrapSource, chunk, hash, moduleTemplate, dependencyTemplates) => {
|
39
|
+
let source = new ConcatSource();
|
40
|
+
source.add("/******/ (function(modules) { // webpackBootstrap\n");
|
41
|
+
source.add(new PrefixSource("/******/", bootstrapSource));
|
42
|
+
source.add("/******/ })\n");
|
43
|
+
source.add("/************************************************************************/\n");
|
44
|
+
source.add("/******/ (");
|
45
|
+
let modules = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates, "/******/ ");
|
46
|
+
source.add(this.applyPluginsWaterfall("modules", modules, chunk, hash, moduleTemplate, dependencyTemplates));
|
47
|
+
source.add(")");
|
48
|
+
return source;
|
49
|
+
});
|
50
|
+
this.plugin("local-vars", (source, chunk, hash) => {
|
51
|
+
return this.asString([
|
52
|
+
source,
|
53
|
+
"// The module cache",
|
54
|
+
"var installedModules = {};"
|
55
|
+
]);
|
56
|
+
});
|
57
|
+
this.plugin("require", (source, chunk, hash) => {
|
58
|
+
return this.asString([
|
59
|
+
source,
|
60
|
+
"// Check if module is in cache",
|
61
|
+
"if(installedModules[moduleId])",
|
62
|
+
this.indent("return installedModules[moduleId].exports;"),
|
63
|
+
"",
|
64
|
+
"// Create a new module (and put it into the cache)",
|
65
|
+
"var module = installedModules[moduleId] = {",
|
66
|
+
this.indent(this.applyPluginsWaterfall("module-obj", "", chunk, hash, "moduleId")),
|
67
|
+
"};",
|
68
|
+
"",
|
69
|
+
this.asString(outputOptions.strictModuleExceptionHandling ? [
|
70
|
+
"// Execute the module function",
|
71
|
+
"var threw = true;",
|
72
|
+
"try {",
|
73
|
+
this.indent([
|
74
|
+
"modules[moduleId].call(module.exports, module, module.exports, " + this.renderRequireFunctionForModule(hash, chunk, "moduleId") + ");",
|
75
|
+
"threw = false;"
|
76
|
+
]),
|
77
|
+
"} finally {",
|
78
|
+
this.indent([
|
79
|
+
"if(threw) delete installedModules[moduleId];"
|
80
|
+
]),
|
81
|
+
"}"
|
82
|
+
] : [
|
83
|
+
"// Execute the module function",
|
71
84
|
"modules[moduleId].call(module.exports, module, module.exports, " + this.renderRequireFunctionForModule(hash, chunk, "moduleId") + ");",
|
72
|
-
"threw = false;"
|
73
85
|
]),
|
74
|
-
"
|
86
|
+
"",
|
87
|
+
"// Flag the module as loaded",
|
88
|
+
"module.l = true;",
|
89
|
+
"",
|
90
|
+
"// Return the exports of the module",
|
91
|
+
"return module.exports;"
|
92
|
+
]);
|
93
|
+
});
|
94
|
+
this.plugin("module-obj", (source, chunk, hash, varModuleId) => {
|
95
|
+
return this.asString([
|
96
|
+
"i: moduleId,",
|
97
|
+
"l: false,",
|
98
|
+
"exports: {}"
|
99
|
+
]);
|
100
|
+
});
|
101
|
+
this.plugin("require-extensions", (source, chunk, hash) => {
|
102
|
+
let buf = [];
|
103
|
+
if(chunk.chunks.length > 0) {
|
104
|
+
buf.push("// This file contains only the entry chunk.");
|
105
|
+
buf.push("// The chunk loading function for additional chunks");
|
106
|
+
buf.push(this.requireFn + ".e = function requireEnsure(chunkId) {");
|
107
|
+
buf.push(this.indent(this.applyPluginsWaterfall("require-ensure", "throw new Error('Not chunk loading available');", chunk, hash, "chunkId")));
|
108
|
+
buf.push("};");
|
109
|
+
}
|
110
|
+
buf.push("");
|
111
|
+
buf.push("// expose the modules object (__webpack_modules__)");
|
112
|
+
buf.push(this.requireFn + ".m = modules;");
|
113
|
+
|
114
|
+
buf.push("");
|
115
|
+
buf.push("// expose the module cache");
|
116
|
+
buf.push(this.requireFn + ".c = installedModules;");
|
117
|
+
|
118
|
+
buf.push("");
|
119
|
+
buf.push("// identity function for calling harmony imports with the correct context");
|
120
|
+
buf.push(this.requireFn + ".i = function(value) { return value; };");
|
121
|
+
|
122
|
+
buf.push("");
|
123
|
+
buf.push("// define getter function for harmony exports");
|
124
|
+
buf.push(this.requireFn + ".d = function(exports, name, getter) {");
|
125
|
+
buf.push(this.indent([
|
126
|
+
"if(!" + this.requireFn + ".o(exports, name)) {",
|
75
127
|
this.indent([
|
76
|
-
"
|
128
|
+
"Object.defineProperty(exports, name, {",
|
129
|
+
this.indent([
|
130
|
+
"configurable: false,",
|
131
|
+
"enumerable: true,",
|
132
|
+
"get: getter"
|
133
|
+
]),
|
134
|
+
"});"
|
77
135
|
]),
|
78
136
|
"}"
|
79
|
-
]
|
80
|
-
"// Execute the module function",
|
81
|
-
"modules[moduleId].call(module.exports, module, module.exports, " + this.renderRequireFunctionForModule(hash, chunk, "moduleId") + ");",
|
82
|
-
]),
|
83
|
-
"",
|
84
|
-
"// Flag the module as loaded",
|
85
|
-
"module.l = true;",
|
86
|
-
"",
|
87
|
-
"// Return the exports of the module",
|
88
|
-
"return module.exports;"
|
89
|
-
]);
|
90
|
-
});
|
91
|
-
this.plugin("module-obj", function(source, chunk, hash, varModuleId) {
|
92
|
-
return this.asString([
|
93
|
-
"i: moduleId,",
|
94
|
-
"l: false,",
|
95
|
-
"exports: {}"
|
96
|
-
]);
|
97
|
-
});
|
98
|
-
this.plugin("require-extensions", function(source, chunk, hash) {
|
99
|
-
var buf = [];
|
100
|
-
if(chunk.chunks.length > 0) {
|
101
|
-
buf.push("// This file contains only the entry chunk.");
|
102
|
-
buf.push("// The chunk loading function for additional chunks");
|
103
|
-
buf.push(this.requireFn + ".e = function requireEnsure(chunkId) {");
|
104
|
-
buf.push(this.indent(this.applyPluginsWaterfall("require-ensure", "throw new Error('Not chunk loading available');", chunk, hash, "chunkId")));
|
137
|
+
]));
|
105
138
|
buf.push("};");
|
106
|
-
}
|
107
|
-
buf.push("");
|
108
|
-
buf.push("// expose the modules object (__webpack_modules__)");
|
109
|
-
buf.push(this.requireFn + ".m = modules;");
|
110
139
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
buf.push("// identity function for calling harmony imports with the correct context");
|
117
|
-
buf.push(this.requireFn + ".i = function(value) { return value; };");
|
118
|
-
|
119
|
-
buf.push("");
|
120
|
-
buf.push("// define getter function for harmony exports");
|
121
|
-
buf.push(this.requireFn + ".d = function(exports, name, getter) {");
|
122
|
-
buf.push(this.indent([
|
123
|
-
"if(!" + this.requireFn + ".o(exports, name)) {",
|
124
|
-
this.indent([
|
125
|
-
"Object.defineProperty(exports, name, {",
|
140
|
+
buf.push("");
|
141
|
+
buf.push("// getDefaultExport function for compatibility with non-harmony modules");
|
142
|
+
buf.push(this.requireFn + ".n = function(module) {");
|
143
|
+
buf.push(this.indent([
|
144
|
+
"var getter = module && module.__esModule ?",
|
126
145
|
this.indent([
|
127
|
-
"
|
128
|
-
"
|
129
|
-
"get: getter"
|
146
|
+
"function getDefault() { return module['default']; } :",
|
147
|
+
"function getModuleExports() { return module; };"
|
130
148
|
]),
|
131
|
-
"
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
buf.push("};");
|
149
|
+
this.requireFn + ".d(getter, 'a', getter);",
|
150
|
+
"return getter;"
|
151
|
+
]));
|
152
|
+
buf.push("};");
|
136
153
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
this.requireFn + ".
|
147
|
-
|
148
|
-
|
149
|
-
buf.push("};");
|
154
|
+
buf.push("");
|
155
|
+
buf.push("// Object.prototype.hasOwnProperty.call");
|
156
|
+
buf.push(this.requireFn + ".o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };");
|
157
|
+
|
158
|
+
let publicPath = this.getPublicPath({
|
159
|
+
hash: hash
|
160
|
+
});
|
161
|
+
buf.push("");
|
162
|
+
buf.push("// __webpack_public_path__");
|
163
|
+
buf.push(this.requireFn + ".p = " + JSON.stringify(publicPath) + ";");
|
164
|
+
return this.asString(buf);
|
165
|
+
});
|
150
166
|
|
151
|
-
|
152
|
-
|
153
|
-
buf.push(this.requireFn + ".o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };");
|
167
|
+
this.requireFn = "__webpack_require__";
|
168
|
+
}
|
154
169
|
|
155
|
-
|
156
|
-
|
157
|
-
|
170
|
+
render(hash, chunk, moduleTemplate, dependencyTemplates) {
|
171
|
+
let buf = [];
|
172
|
+
buf.push(this.applyPluginsWaterfall("bootstrap", "", chunk, hash, moduleTemplate, dependencyTemplates));
|
173
|
+
buf.push(this.applyPluginsWaterfall("local-vars", "", chunk, hash));
|
174
|
+
buf.push("");
|
175
|
+
buf.push("// The require function");
|
176
|
+
buf.push("function " + this.requireFn + "(moduleId) {");
|
177
|
+
buf.push(this.indent(this.applyPluginsWaterfall("require", "", chunk, hash)));
|
178
|
+
buf.push("}");
|
179
|
+
buf.push("");
|
180
|
+
buf.push(this.asString(this.applyPluginsWaterfall("require-extensions", "", chunk, hash)));
|
158
181
|
buf.push("");
|
159
|
-
buf.push("
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
MainTemplate.prototype.constructor = MainTemplate;
|
168
|
-
MainTemplate.prototype.requireFn = "__webpack_require__";
|
169
|
-
MainTemplate.prototype.render = function(hash, chunk, moduleTemplate, dependencyTemplates) {
|
170
|
-
var buf = [];
|
171
|
-
buf.push(this.applyPluginsWaterfall("bootstrap", "", chunk, hash, moduleTemplate, dependencyTemplates));
|
172
|
-
buf.push(this.applyPluginsWaterfall("local-vars", "", chunk, hash));
|
173
|
-
buf.push("");
|
174
|
-
buf.push("// The require function");
|
175
|
-
buf.push("function " + this.requireFn + "(moduleId) {");
|
176
|
-
buf.push(this.indent(this.applyPluginsWaterfall("require", "", chunk, hash)));
|
177
|
-
buf.push("}");
|
178
|
-
buf.push("");
|
179
|
-
buf.push(this.asString(this.applyPluginsWaterfall("require-extensions", "", chunk, hash)));
|
180
|
-
buf.push("");
|
181
|
-
buf.push(this.asString(this.applyPluginsWaterfall("startup", "", chunk, hash)));
|
182
|
-
var source = this.applyPluginsWaterfall("render", new OriginalSource(this.prefix(buf, " \t") + "\n", "webpack/bootstrap " + hash), chunk, hash, moduleTemplate, dependencyTemplates);
|
183
|
-
if(chunk.hasEntryModule()) {
|
184
|
-
source = this.applyPluginsWaterfall("render-with-entry", source, chunk, hash);
|
182
|
+
buf.push(this.asString(this.applyPluginsWaterfall("startup", "", chunk, hash)));
|
183
|
+
let source = this.applyPluginsWaterfall("render", new OriginalSource(this.prefix(buf, " \t") + "\n", "webpack/bootstrap " + hash), chunk, hash, moduleTemplate, dependencyTemplates);
|
184
|
+
if(chunk.hasEntryModule()) {
|
185
|
+
source = this.applyPluginsWaterfall("render-with-entry", source, chunk, hash);
|
186
|
+
}
|
187
|
+
if(!source) throw new Error("Compiler error: MainTemplate plugin 'render' should return something");
|
188
|
+
chunk.rendered = true;
|
189
|
+
return new ConcatSource(source, ";");
|
185
190
|
}
|
186
|
-
if(!source) throw new Error("Compiler error: MainTemplate plugin 'render' should return something");
|
187
|
-
chunk.rendered = true;
|
188
|
-
return new ConcatSource(source, ";");
|
189
|
-
};
|
190
191
|
|
191
|
-
|
192
|
-
|
193
|
-
}
|
192
|
+
renderRequireFunctionForModule(hash, chunk, varModuleId) {
|
193
|
+
return this.applyPluginsWaterfall("module-require", this.requireFn, chunk, hash, varModuleId);
|
194
|
+
}
|
194
195
|
|
195
|
-
|
196
|
-
|
197
|
-
}
|
196
|
+
renderAddModule(hash, chunk, varModuleId, varModule) {
|
197
|
+
return this.applyPluginsWaterfall("add-module", "modules[" + varModuleId + "] = " + varModule + ";", chunk, hash, varModuleId, varModule);
|
198
|
+
}
|
198
199
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
}
|
200
|
+
renderCurrentHashCode(hash, length) {
|
201
|
+
length = length || Infinity;
|
202
|
+
return this.applyPluginsWaterfall("current-hash", JSON.stringify(hash.substr(0, length)), length);
|
203
|
+
}
|
203
204
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
205
|
+
entryPointInChildren(chunk) {
|
206
|
+
let checkChildren = (chunk, alreadyCheckedChunks) => {
|
207
|
+
return chunk.chunks.some((child) => {
|
208
|
+
if(alreadyCheckedChunks.indexOf(child) >= 0) return;
|
209
|
+
alreadyCheckedChunks.push(child);
|
210
|
+
return child.hasEntryModule() || checkChildren(child, alreadyCheckedChunks);
|
211
|
+
});
|
212
|
+
};
|
213
|
+
return checkChildren(chunk, []);
|
211
214
|
}
|
212
|
-
return checkChildren(chunk, []);
|
213
|
-
};
|
214
215
|
|
215
|
-
|
216
|
-
|
217
|
-
}
|
216
|
+
getPublicPath(options) {
|
217
|
+
return this.applyPluginsWaterfall("asset-path", this.outputOptions.publicPath || "", options);
|
218
|
+
}
|
218
219
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
}
|
220
|
+
updateHash(hash) {
|
221
|
+
hash.update("maintemplate");
|
222
|
+
hash.update("3");
|
223
|
+
hash.update(this.outputOptions.publicPath + "");
|
224
|
+
this.applyPlugins("hash", hash);
|
225
|
+
}
|
225
226
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
}
|
227
|
+
updateHashForChunk(hash, chunk) {
|
228
|
+
this.updateHash(hash);
|
229
|
+
this.applyPlugins("hash-for-chunk", hash, chunk);
|
230
|
+
}
|
230
231
|
|
231
|
-
|
232
|
-
|
233
|
-
|
232
|
+
useChunkHash(chunk) {
|
233
|
+
let paths = this.applyPluginsWaterfall("global-hash-paths", []);
|
234
|
+
return !this.applyPluginsBailResult("global-hash", chunk, paths);
|
235
|
+
}
|
234
236
|
};
|
package/lib/MultiWatching.js
CHANGED
@@ -2,22 +2,24 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
5
|
+
"use strict";
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
const async = require("async");
|
8
|
+
|
9
|
+
class MultiWatching {
|
10
|
+
constructor(watchings) {
|
11
|
+
this.watchings = watchings;
|
12
|
+
}
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
});
|
15
|
-
};
|
14
|
+
invalidate() {
|
15
|
+
this.watchings.forEach((watching) => watching.invalidate());
|
16
|
+
}
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
18
|
+
close(callback) {
|
19
|
+
async.forEach(this.watchings, (watching, finishedCallback) => {
|
20
|
+
watching.close(finishedCallback);
|
21
|
+
}, callback);
|
22
|
+
}
|
23
|
+
}
|
22
24
|
|
23
25
|
module.exports = MultiWatching;
|
@@ -2,18 +2,21 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
5
|
+
"use strict";
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if(compilation.errors.length > 0)
|
11
|
-
return false;
|
12
|
-
});
|
13
|
-
compiler.plugin("compilation", function(compilation) {
|
14
|
-
compilation.plugin("should-record", function() {
|
7
|
+
class NoEmitOnErrorsPlugin {
|
8
|
+
apply(compiler) {
|
9
|
+
compiler.plugin("should-emit", (compilation) => {
|
15
10
|
if(compilation.errors.length > 0)
|
16
11
|
return false;
|
17
12
|
});
|
18
|
-
|
19
|
-
|
13
|
+
compiler.plugin("compilation", (compilation) => {
|
14
|
+
compilation.plugin("should-record", () => {
|
15
|
+
if(compilation.errors.length > 0)
|
16
|
+
return false;
|
17
|
+
});
|
18
|
+
});
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
module.exports = NoEmitOnErrorsPlugin;
|
package/lib/NodeStuffPlugin.js
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
var path = require("path");
|
6
6
|
var ParserHelpers = require("./ParserHelpers");
|
7
7
|
var ConstDependency = require("./dependencies/ConstDependency");
|
8
|
-
var BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
9
8
|
|
10
9
|
var NullFactory = require("./NullFactory");
|
11
10
|
|
@@ -51,12 +50,9 @@ NodeStuffPlugin.prototype.apply = function(compiler) {
|
|
51
50
|
}
|
52
51
|
parser.plugin("evaluate Identifier __filename", function(expr) {
|
53
52
|
if(!this.state.module) return;
|
54
|
-
var res = new BasicEvaluatedExpression();
|
55
53
|
var resource = this.state.module.resource;
|
56
54
|
var i = resource.indexOf("?");
|
57
|
-
|
58
|
-
res.setRange(expr.range);
|
59
|
-
return res;
|
55
|
+
return ParserHelpers.evaluateToString(i < 0 ? resource : resource.substr(0, i))(expr);
|
60
56
|
});
|
61
57
|
if(localOptions.__dirname === "mock") {
|
62
58
|
setConstant("__dirname", "/");
|
@@ -67,42 +63,22 @@ NodeStuffPlugin.prototype.apply = function(compiler) {
|
|
67
63
|
}
|
68
64
|
parser.plugin("evaluate Identifier __dirname", function(expr) {
|
69
65
|
if(!this.state.module) return;
|
70
|
-
|
71
|
-
res.setString(this.state.module.context);
|
72
|
-
res.setRange(expr.range);
|
73
|
-
return res;
|
74
|
-
});
|
75
|
-
parser.plugin("expression require.main", function(expr) {
|
76
|
-
var dep = new ConstDependency("__webpack_require__.c[__webpack_require__.s]", expr.range);
|
77
|
-
dep.loc = expr.loc;
|
78
|
-
this.state.current.addDependency(dep);
|
79
|
-
return true;
|
66
|
+
return ParserHelpers.evaluateToString(this.state.module.context)(expr);
|
80
67
|
});
|
68
|
+
parser.plugin("expression require.main", ParserHelpers.toConstantDependency("__webpack_require__.c[__webpack_require__.s]"));
|
81
69
|
parser.plugin(
|
82
70
|
"expression require.extensions",
|
83
71
|
ParserHelpers.expressionIsUnsupported("require.extensions is not supported by webpack. Use a loader instead.")
|
84
72
|
);
|
85
|
-
parser.plugin("expression module.loaded",
|
86
|
-
|
87
|
-
dep.loc = expr.loc;
|
88
|
-
this.state.current.addDependency(dep);
|
89
|
-
return true;
|
90
|
-
});
|
91
|
-
parser.plugin("expression module.id", function(expr) {
|
92
|
-
var dep = new ConstDependency("module.i", expr.range);
|
93
|
-
dep.loc = expr.loc;
|
94
|
-
this.state.current.addDependency(dep);
|
95
|
-
return true;
|
96
|
-
});
|
73
|
+
parser.plugin("expression module.loaded", ParserHelpers.toConstantDependency("module.l"));
|
74
|
+
parser.plugin("expression module.id", ParserHelpers.toConstantDependency("module.i"));
|
97
75
|
parser.plugin("expression module.exports", function() {
|
98
76
|
var module = this.state.module;
|
99
77
|
var isHarmony = module.meta && module.meta.harmonyModule;
|
100
78
|
if(!isHarmony)
|
101
79
|
return true;
|
102
80
|
});
|
103
|
-
parser.plugin("evaluate Identifier module.hot",
|
104
|
-
return new BasicEvaluatedExpression().setBoolean(false).setRange(expr.range);
|
105
|
-
});
|
81
|
+
parser.plugin("evaluate Identifier module.hot", ParserHelpers.evaluateToBoolean(false));
|
106
82
|
parser.plugin("expression module", function() {
|
107
83
|
var module = this.state.module;
|
108
84
|
var isHarmony = module.meta && module.meta.harmonyModule;
|
@@ -16,8 +16,8 @@ function loaderToIdent(data) {
|
|
16
16
|
return data.loader + "?" + data.options;
|
17
17
|
if(typeof data.options !== "object")
|
18
18
|
throw new Error("loader options must be string or object");
|
19
|
-
if(data.
|
20
|
-
return data.loader + "??" + data.
|
19
|
+
if(data.ident)
|
20
|
+
return data.loader + "??" + data.ident;
|
21
21
|
return data.loader + "?" + JSON.stringify(data.options);
|
22
22
|
}
|
23
23
|
|