webpack 2.2.0 → 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/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/ConstPlugin.js +2 -6
- package/lib/DefinePlugin.js +9 -27
- package/lib/EnvironmentPlugin.js +25 -9
- package/lib/EvalDevToolModulePlugin.js +15 -10
- 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/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 +8 -7
- 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/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 +12 -6
package/README.md
CHANGED
@@ -119,121 +119,96 @@ or are automatically applied via regex from your webpack configuration.
|
|
119
119
|
|
120
120
|
|Name|Status|Description|
|
121
121
|
|:--:|:----:|:----------|
|
122
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/json.svg">|![json-npm]|Loads a JSON file (included by default)|
|
123
|
-
|<img width="48" height="48" src="https://cdn.rawgit.com/json5/json5-logo/master/json5-logo.svg">|![json5-npm]|Loads and transpiles a JSON 5 file|
|
124
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg">|![cson-npm]|Loads and transpiles a CSON file|
|
122
|
+
|<a href="https://github.com/webpack/json-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/json.svg"></a>|![json-npm]|Loads a JSON file (included by default)|
|
123
|
+
|<a href="https://github.com/webpack/json5-loader"><img width="48" height="48" src="https://cdn.rawgit.com/json5/json5-logo/master/json5-logo.svg"></a>|![json5-npm]|Loads and transpiles a JSON 5 file|
|
124
|
+
|<a href="https://github.com/awnist/cson-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a>|![cson-npm]|Loads and transpiles a CSON file|
|
125
125
|
|
126
126
|
|
127
|
-
[json]: https://github.com/webpack/json-loader
|
128
127
|
[json-npm]: https://img.shields.io/npm/v/json-loader.svg
|
129
|
-
[json5]: https://github.com/webpack/json5-loader
|
130
128
|
[json5-npm]: https://img.shields.io/npm/v/json5-loader.svg
|
131
|
-
[cson]: https://github.com/awnist/cson-loader
|
132
129
|
[cson-npm]: https://img.shields.io/npm/v/cson-loader.svg
|
133
130
|
|
134
131
|
#### Transpiling
|
135
132
|
|
136
133
|
|Name|Status|Description|
|
137
134
|
|:--:|:----:|:----------|
|
138
|
-
|
139
|
-
|<img width="48" height="48" title="babel-loader" src="https://worldvectorlogo.com/logos/babel-10.svg"
|
140
|
-
|<img width="48" height="48" src="https://google.github.com/traceur-compiler/logo/tc.svg">|![traceur-npm]|Loads ES2015+ code and transpiles to ES5 using [Traceur](https://github.com/google/traceur)|
|
141
|
-
|<img width="48" height="48" src="https://cdn.rawgit.com/Microsoft/TypeScript/master/doc/logo.svg">|![type-npm]|Loads TypeScript like JavaScript|
|
142
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg">|![coffee-npm]|Loads CoffeeScript like JavaScript|
|
135
|
+
|<a href="https://github.com/webpack/script-loader">`<script>`</a>|![script-npm]|Executes a JavaScript file once in global context (like in script tag), requires are not parsed|
|
136
|
+
|<a href="https://github.com/babel/babel-loader"><img width="48" height="48" title="babel-loader" src="https://worldvectorlogo.com/logos/babel-10.svg"></a>|![babel-npm]|Loads ES2015+ code and transpiles to ES5 using <a href="https://github.com/babel/babel">Babel</a>|
|
137
|
+
|<a href="https://github.com/jupl/traceur-loader"><img width="48" height="48" src="https://google.github.com/traceur-compiler/logo/tc.svg"></a>|![traceur-npm]|Loads ES2015+ code and transpiles to ES5 using [Traceur](https://github.com/google/traceur)|
|
138
|
+
|<a href="https://github.com/andreypopp/typescript-loader"><img width="48" height="48" src="https://cdn.rawgit.com/Microsoft/TypeScript/master/doc/logo.svg"></a>|![type-npm]|Loads TypeScript like JavaScript|
|
139
|
+
|<a href="https://github.com/webpack/coffee-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a>|![coffee-npm]|Loads CoffeeScript like JavaScript|
|
143
140
|
|
144
141
|
|
145
|
-
[script]: https://github.com/webpack/script-loader
|
146
142
|
[script-npm]: https://img.shields.io/npm/v/script-loader.svg
|
147
|
-
[babel]: https://github.com/babel/babel-loader
|
148
143
|
[babel-npm]: https://img.shields.io/npm/v/babel-loader.svg
|
149
|
-
[traceur]: https://github.com/jupl/traceur-loader
|
150
144
|
[traceur-npm]: https://img.shields.io/npm/v/traceur-loader.svg
|
151
|
-
[coffee]: https://github.com/webpack/coffee-loader
|
152
145
|
[coffee-npm]: https://img.shields.io/npm/v/coffee-loader.svg
|
153
|
-
[type]: https://github.com/andreypopp/typescript-loader
|
154
146
|
[type-npm]: https://img.shields.io/npm/v/typescript-loader.svg
|
155
147
|
|
156
148
|
#### Templating
|
157
149
|
|
158
150
|
|Name|Status|Description|
|
159
151
|
|:--:|:----:|:----------|
|
160
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/html5.svg">|![html-npm]|Exports HTML as string, require references to static resources|
|
161
|
-
|<img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg">|![pug-npm]|Loads Pug templates and returns a function|
|
162
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/jade-3.svg">|![jade-npm]|Loads Jade templates and returns a function|
|
163
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/markdown.svg">|![md-npm]|Compiles Markdown to HTML|
|
164
|
-
|<img width="48" height="48" src="http://posthtml.github.io/posthtml/logo.svg">|![posthtml-npm]|Loads and transforms a HTML file using [PostHTML](https://github.com/posthtml/posthtml)|
|
165
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/handlebars-1.svg">|![hbs-npm]| Compiles Handlebars to HTML|
|
152
|
+
|<a href="https://github.com/webpack/html-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/html5.svg"></a>|![html-npm]|Exports HTML as string, require references to static resources|
|
153
|
+
|<a href="https://github.com/pugjs/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a>|![pug-npm]|Loads Pug templates and returns a function|
|
154
|
+
|<a href="https://github.com/webpack/jade-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/jade-3.svg"></a>|![jade-npm]|Loads Jade templates and returns a function|
|
155
|
+
|<a href="https://github.com/peerigon/markdown-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/markdown.svg"></a>|![md-npm]|Compiles Markdown to HTML|
|
156
|
+
|<a href="https://github.com/posthtml/posthtml-loader"><img width="48" height="48" src="http://posthtml.github.io/posthtml/logo.svg"></a>|![posthtml-npm]|Loads and transforms a HTML file using [PostHTML](https://github.com/posthtml/posthtml)|
|
157
|
+
|<a href="https://github.com/altano/handlebars-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/handlebars-1.svg"></a>|![hbs-npm]| Compiles Handlebars to HTML|
|
166
158
|
|
167
159
|
|
168
|
-
[html]: https://github.com/webpack/html-loader
|
169
160
|
[html-npm]: https://img.shields.io/npm/v/html-loader.svg
|
170
|
-
[pug]: https://github.com/pugjs/pug-loader
|
171
161
|
[pug-npm]: https://img.shields.io/npm/v/pug-loader.svg
|
172
|
-
[jade]: https://github.com/webpack/jade-loader
|
173
162
|
[jade-npm]: https://img.shields.io/npm/v/jade-loader.svg
|
174
|
-
[md]: https://github.com/peerigon/markdown-loader
|
175
163
|
[md-npm]: https://img.shields.io/npm/v/markdown-loader.svg
|
176
|
-
[posthtml]: https://github.com/posthtml/posthtml-loader
|
177
164
|
[posthtml-npm]: https://img.shields.io/npm/v/posthtml-loader.svg
|
178
|
-
[hbs]: https://github.com/altano/handlebars-loader
|
179
165
|
[hbs-npm]: https://img.shields.io/npm/v/handlebars-loader.svg
|
180
166
|
|
181
167
|
#### Styling
|
182
168
|
|
183
169
|
|Name|Status|Description|
|
184
170
|
|:--:|:----:|:----------|
|
185
|
-
|
186
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/css-3.svg">|![css-npm]|Loads CSS file with resolved imports and returns CSS code|
|
187
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/less-63.svg">|![less-npm]|Loads and compiles a LESS file|
|
188
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/sass-1.svg">|![sass-npm]|Loads and compiles a SASS/SCSS file|
|
189
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/stylus.svg">|![stylus-npm]|Loads and compiles a Stylus file|
|
190
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/postcss.svg">|![postcss-npm]|Loads and transforms a CSS/SSS file using [PostCSS](http://postcss.org)|
|
191
|
-
|
192
|
-
|
171
|
+
|<a href="https://github.com/webpack/style-loader">`<style>`|![style-npm]|Add exports of a module as style to DOM|
|
172
|
+
|<a href="https://github.com/webpack/css-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/css-3.svg"></a>|![css-npm]|Loads CSS file with resolved imports and returns CSS code|
|
173
|
+
|<a href="https://github.com/webpack/less-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/less-63.svg"></a>|![less-npm]|Loads and compiles a LESS file|
|
174
|
+
|<a href="https://github.com/jtangelder/sass-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/sass-1.svg"></a>|![sass-npm]|Loads and compiles a SASS/SCSS file|
|
175
|
+
|<a href="https://github.com/shama/stylus-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/stylus.svg"></a>|![stylus-npm]|Loads and compiles a Stylus file|
|
176
|
+
|<a href="https://github.com/postcss/postcss-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/postcss.svg"></a>|![postcss-npm]|Loads and transforms a CSS/SSS file using [PostCSS](http://postcss.org)|
|
177
|
+
|
178
|
+
|
193
179
|
[style-npm]: https://img.shields.io/npm/v/style-loader.svg
|
194
|
-
[css]: https://github.com/webpack/css-loader
|
195
180
|
[css-npm]: https://img.shields.io/npm/v/css-loader.svg
|
196
|
-
[less]: https://github.com/webpack/less-loader
|
197
181
|
[less-npm]: https://img.shields.io/npm/v/less-loader.svg
|
198
|
-
[sass]: https://github.com/jtangelder/sass-loader
|
199
182
|
[sass-npm]: https://img.shields.io/npm/v/sass-loader.svg
|
200
|
-
[stylus]: https://github.com/shama/stylus-loader
|
201
183
|
[stylus-npm]: https://img.shields.io/npm/v/stylus-loader.svg
|
202
|
-
[postcss]: https://github.com/postcss/postcss-loader
|
203
184
|
[postcss-npm]: https://img.shields.io/npm/v/postcss-loader.svg
|
204
185
|
|
205
186
|
#### Linting && Testing
|
206
187
|
|
207
188
|
|Name|Status|Description|
|
208
189
|
|:--:|:----:|:----------|
|
209
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/mocha.svg">|![mocha-npm]|Tests with mocha (Browser/NodeJS)|
|
210
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/eslint.svg">|![eslint-npm]|PreLoader for linting code using ESLint|
|
211
|
-
|<img width="48" height="48" src="http://jshint.com/res/jshint-dark.png">|![jshint-npm]|PreLoader for linting code using JSHint|
|
212
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/jscs.svg">|![jscs-npm]|PreLoader for code style checking using JSCS|
|
190
|
+
|<a href="https://github.com/webpack/mocha-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/mocha.svg"></a>|![mocha-npm]|Tests with mocha (Browser/NodeJS)|
|
191
|
+
|<a href="https://github.com/MoOx/eslint-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/eslint.svg"></a>|![eslint-npm]|PreLoader for linting code using ESLint|
|
192
|
+
|<a href="https://github.com/webpack/jslint-loader"><img width="48" height="48" src="http://jshint.com/res/jshint-dark.png"></a>|![jshint-npm]|PreLoader for linting code using JSHint|
|
193
|
+
|<a href="https://github.com/unindented/jscs-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/jscs.svg"></a>|![jscs-npm]|PreLoader for code style checking using JSCS|
|
213
194
|
|
214
195
|
|
215
|
-
[mocha]: https://github.com/webpack/mocha-loader
|
216
196
|
[mocha-npm]: https://img.shields.io/npm/v/mocha-loader.svg
|
217
|
-
[eslint]: https://github.com/MoOx/eslint-loader
|
218
197
|
[eslint-npm]: https://img.shields.io/npm/v/eslint-loader.svg
|
219
|
-
[jshint]: https://github.com/webpack/jslint-loader
|
220
198
|
[jshint-npm]: https://img.shields.io/npm/v/jslint-loader.svg
|
221
|
-
[jscs]: https://github.com/unindented/jscs-loader
|
222
199
|
[jscs-npm]: https://img.shields.io/npm/v/jscs-loader.svg
|
223
200
|
|
224
201
|
#### Frameworks
|
225
202
|
|
226
203
|
|Name|Status|Description|
|
227
204
|
|:--:|:----:|:----------|
|
228
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/vue-9.svg">|![vue-npm]|Loads and compiles Vue Components|
|
229
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/polymer.svg">|![polymer-npm]|Process HTML & CSS with preprocessor of choice and `require()` Web Components like first-class modules|
|
230
|
-
|<img width="48" height="48" src="https://worldvectorlogo.com/logos/angular-icon-1.svg">|![angular-npm]| Loads and compiles Angular 2 Components|
|
205
|
+
|<a href="https://github.com/vuejs/vue-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/vue-9.svg"></a>|![vue-npm]|Loads and compiles Vue Components|
|
206
|
+
|<a href="https://github.com/JonDum/polymer-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/polymer.svg"></a>|![polymer-npm]|Process HTML & CSS with preprocessor of choice and `require()` Web Components like first-class modules|
|
207
|
+
|<a href="https://github.com/TheLarkInn/angular2-template-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/angular-icon-1.svg"></a>|![angular-npm]| Loads and compiles Angular 2 Components|
|
208
|
+
|
231
209
|
|
232
|
-
[vue]: https://github.com/vue/vue-loader
|
233
210
|
[vue-npm]: https://img.shields.io/npm/v/vue-loader.svg
|
234
|
-
[polymer]: https://github.com/JonDum/polymer-loader
|
235
211
|
[polymer-npm]: https://img.shields.io/npm/v/polymer-loader.svg
|
236
|
-
[angular]: https://github.com/TheLarkInn/angular2-template-loader
|
237
212
|
[angular-npm]: https://img.shields.io/npm/v/angular2-template-loader.svg
|
238
213
|
|
239
214
|
### Performance
|
@@ -282,7 +257,7 @@ If you want to discuss something or just need help, [here is our Gitter room](ht
|
|
282
257
|
<table>
|
283
258
|
<tbody>
|
284
259
|
<tr>
|
285
|
-
<td align="center">
|
260
|
+
<td align="center" valign="top">
|
286
261
|
<img width="150" height="150" src="https://github.com/sokra.png?s=150">
|
287
262
|
<br>
|
288
263
|
<a href="https://github.com/sokra">Tobias Koppers</a>
|
@@ -290,7 +265,7 @@ If you want to discuss something or just need help, [here is our Gitter room](ht
|
|
290
265
|
<br>
|
291
266
|
<p>Founder of webpack</p>
|
292
267
|
</td>
|
293
|
-
<td align="center">
|
268
|
+
<td align="center" valign="top">
|
294
269
|
<img width="150" height="150" src="https://github.com/jhnns.png?s=150">
|
295
270
|
<br>
|
296
271
|
<a href="https://github.com/jhnns">Johannes Ewald</a>
|
@@ -298,7 +273,7 @@ If you want to discuss something or just need help, [here is our Gitter room](ht
|
|
298
273
|
<br>
|
299
274
|
<p>Early adopter of webpack</p>
|
300
275
|
</td>
|
301
|
-
<td align="center" width="20%">
|
276
|
+
<td align="center" width="20%" valign="top">
|
302
277
|
<img width="150" height="150" src="https://github.com/TheLarkInn.png?s=150">
|
303
278
|
<br>
|
304
279
|
<a href="https://github.com/TheLarkInn">Sean T. Larkin</a>
|
@@ -306,7 +281,7 @@ If you want to discuss something or just need help, [here is our Gitter room](ht
|
|
306
281
|
<br>
|
307
282
|
<p>Founder of the core team</p>
|
308
283
|
</td>
|
309
|
-
<td align="center">
|
284
|
+
<td align="center" valign="top">
|
310
285
|
<img width="150" height="150" src="https://github.com/bebraw.png?s=150">
|
311
286
|
<br>
|
312
287
|
<a href="https://github.com/bebraw">Juho Vepsäläinen</a>
|
@@ -314,20 +289,21 @@ If you want to discuss something or just need help, [here is our Gitter room](ht
|
|
314
289
|
<br>
|
315
290
|
<p>Author</p>
|
316
291
|
<a href="https://leanpub.com/survivejs-webpack">
|
317
|
-
<img height="15" src="https://cloud.githubusercontent.com/assets/1365881/20286923/93e325c0-aac9-11e6-964d-cabe218c584c.png">
|
292
|
+
<img height="15" src="https://cloud.githubusercontent.com/assets/1365881/20286923/93e325c0-aac9-11e6-964d-cabe218c584c.png">
|
318
293
|
</a>
|
294
|
+
<br>
|
319
295
|
</td>
|
320
|
-
<td align="center">
|
296
|
+
<td align="center" valign="top">
|
321
297
|
<img width="150" height="150" src="https://github.com/spacek33z.png?s=150">
|
322
298
|
<br>
|
323
299
|
<a href="https://github.com/spacek33z">Kees Kluskens</a>
|
324
300
|
<p>Development</p>
|
325
301
|
<br>
|
326
|
-
<br>
|
327
302
|
<p>Sponsor<p>
|
328
303
|
<a href="https://codeyellow.nl/">
|
329
|
-
<img height="
|
304
|
+
<img height="15px" src="https://cloud.githubusercontent.com/assets/1365881/20286583/ad62eb04-aac7-11e6-9c14-a0fef35b9b56.png">
|
330
305
|
</a>
|
306
|
+
<br>
|
331
307
|
</td>
|
332
308
|
</tr>
|
333
309
|
</tbody>
|
package/lib/APIPlugin.js
CHANGED
@@ -37,17 +37,11 @@ class APIPlugin {
|
|
37
37
|
|
38
38
|
params.normalModuleFactory.plugin("parser", parser => {
|
39
39
|
Object.keys(REPLACEMENTS).forEach(key => {
|
40
|
-
parser.plugin(`expression ${key}`,
|
41
|
-
const dep = new ConstDependency(REPLACEMENTS[key], expr.range);
|
42
|
-
dep.loc = expr.loc;
|
43
|
-
parser.state.current.addDependency(dep);
|
44
|
-
return true;
|
45
|
-
});
|
46
|
-
|
40
|
+
parser.plugin(`expression ${key}`, ParserHelpers.toConstantDependency(REPLACEMENTS[key]));
|
47
41
|
parser.plugin(`evaluate typeof ${key}`, ParserHelpers.evaluateToString(REPLACEMENT_TYPES[key]));
|
48
42
|
});
|
49
43
|
IGNORES.forEach(key => {
|
50
|
-
parser.plugin(key,
|
44
|
+
parser.plugin(key, ParserHelpers.skipTraversal);
|
51
45
|
});
|
52
46
|
});
|
53
47
|
});
|
@@ -2,61 +2,52 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
5
|
+
"use strict";
|
6
|
+
const DependenciesBlock = require("./DependenciesBlock");
|
7
|
+
|
8
|
+
module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
|
9
|
+
constructor(name, module, loc) {
|
10
|
+
super();
|
11
|
+
this.chunkName = name;
|
12
|
+
this.chunks = null;
|
13
|
+
this.module = module;
|
14
|
+
this.loc = loc;
|
15
|
+
}
|
16
|
+
get chunk() {
|
17
|
+
throw new Error("`chunk` was been renamed to `chunks` and is now an array");
|
18
|
+
}
|
19
|
+
set chunk(chunk) {
|
20
|
+
throw new Error("`chunk` was been renamed to `chunks` and is now an array");
|
21
|
+
}
|
22
|
+
updateHash(hash) {
|
23
|
+
hash.update(this.chunkName || "");
|
24
|
+
hash.update(this.chunks && this.chunks.map((chunk) => {
|
25
|
+
return typeof chunk.id === "number" ? chunk.id : "";
|
26
|
+
}).join(",") || "");
|
27
|
+
super.updateHash(hash);
|
28
|
+
}
|
29
|
+
disconnect() {
|
30
|
+
this.chunks = null;
|
31
|
+
super.disconnect();
|
32
|
+
}
|
33
|
+
unseal() {
|
34
|
+
this.chunks = null;
|
35
|
+
super.unseal();
|
36
|
+
}
|
37
|
+
sortItems() {
|
38
|
+
super.sortItems();
|
39
|
+
if(this.chunks) {
|
40
|
+
this.chunks.sort((a, b) => {
|
41
|
+
let i = 0;
|
42
|
+
while(true) { // eslint-disable-line no-constant-condition
|
43
|
+
if(!a.modules[i] && !b.modules[i]) return 0;
|
44
|
+
if(!a.modules[i]) return -1;
|
45
|
+
if(!b.modules[i]) return 1;
|
46
|
+
if(a.modules[i].id > b.modules[i].id) return 1;
|
47
|
+
if(a.modules[i].id < b.modules[i].id) return -1;
|
48
|
+
i++;
|
49
|
+
}
|
50
|
+
});
|
20
51
|
}
|
21
|
-
});
|
22
|
-
|
23
|
-
}
|
24
|
-
module.exports = AsyncDependenciesBlock;
|
25
|
-
|
26
|
-
AsyncDependenciesBlock.prototype = Object.create(DependenciesBlock.prototype);
|
27
|
-
AsyncDependenciesBlock.prototype.constructor = AsyncDependenciesBlock;
|
28
|
-
|
29
|
-
AsyncDependenciesBlock.prototype.updateHash = function updateHash(hash) {
|
30
|
-
hash.update(this.chunkName || "");
|
31
|
-
hash.update(this.chunks && this.chunks.map(function(chunk) {
|
32
|
-
return typeof chunk.id === "number" ? chunk.id : "";
|
33
|
-
}).join(",") || "");
|
34
|
-
DependenciesBlock.prototype.updateHash.call(this, hash);
|
35
|
-
};
|
36
|
-
|
37
|
-
AsyncDependenciesBlock.prototype.disconnect = function() {
|
38
|
-
this.chunks = null;
|
39
|
-
DependenciesBlock.prototype.disconnect.call(this);
|
40
|
-
};
|
41
|
-
|
42
|
-
AsyncDependenciesBlock.prototype.unseal = function() {
|
43
|
-
this.chunks = null;
|
44
|
-
DependenciesBlock.prototype.unseal.call(this);
|
45
|
-
};
|
46
|
-
|
47
|
-
AsyncDependenciesBlock.prototype.sortItems = function() {
|
48
|
-
DependenciesBlock.prototype.sortItems.call(this);
|
49
|
-
if(this.chunks) {
|
50
|
-
this.chunks.sort(function(a, b) {
|
51
|
-
var i = 0;
|
52
|
-
while(true) { // eslint-disable-line no-constant-condition
|
53
|
-
if(!a.modules[i] && !b.modules[i]) return 0;
|
54
|
-
if(!a.modules[i]) return -1;
|
55
|
-
if(!b.modules[i]) return 1;
|
56
|
-
if(a.modules[i].id > b.modules[i].id) return 1;
|
57
|
-
if(a.modules[i].id < b.modules[i].id) return -1;
|
58
|
-
i++;
|
59
|
-
}
|
60
|
-
});
|
61
52
|
}
|
62
53
|
};
|
package/lib/ChunkTemplate.js
CHANGED
@@ -2,36 +2,35 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
6
|
-
var Template = require("./Template");
|
5
|
+
"use strict";
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
}
|
7
|
+
const ConcatSource = require("webpack-sources").ConcatSource;
|
8
|
+
const Template = require("./Template");
|
11
9
|
|
12
|
-
module.exports = ChunkTemplate
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
module.exports = class ChunkTemplate extends Template {
|
11
|
+
constructor(outputOptions) {
|
12
|
+
super(outputOptions);
|
13
|
+
}
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
render(chunk, moduleTemplate, dependencyTemplates) {
|
16
|
+
let modules = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates);
|
17
|
+
let core = this.applyPluginsWaterfall("modules", modules, chunk, moduleTemplate, dependencyTemplates);
|
18
|
+
let source = this.applyPluginsWaterfall("render", core, chunk, moduleTemplate, dependencyTemplates);
|
19
|
+
if(chunk.hasEntryModule()) {
|
20
|
+
source = this.applyPluginsWaterfall("render-with-entry", source, chunk);
|
21
|
+
}
|
22
|
+
chunk.rendered = true;
|
23
|
+
return new ConcatSource(source, ";");
|
23
24
|
}
|
24
|
-
chunk.rendered = true;
|
25
|
-
return new ConcatSource(source, ";");
|
26
|
-
};
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
}
|
26
|
+
updateHash(hash) {
|
27
|
+
hash.update("ChunkTemplate");
|
28
|
+
hash.update("2");
|
29
|
+
this.applyPlugins("hash", hash);
|
30
|
+
}
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
updateHashForChunk(hash, chunk) {
|
33
|
+
this.updateHash(hash);
|
34
|
+
this.applyPlugins("hash-for-chunk", hash, chunk);
|
35
|
+
}
|
37
36
|
};
|
@@ -2,53 +2,56 @@
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
3
|
Author Tobias Koppers @sokra
|
4
4
|
*/
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const ConstDependency = require("./dependencies/ConstDependency");
|
8
|
+
|
9
|
+
const NullFactory = require("./NullFactory");
|
10
|
+
|
11
|
+
const jsonLoaderPath = require.resolve("json-loader");
|
12
|
+
const matchJson = /\.json$/i;
|
13
|
+
|
14
|
+
class CompatibilityPlugin {
|
15
|
+
|
16
|
+
apply(compiler) {
|
17
|
+
compiler.plugin("compilation", (compilation, params) => {
|
18
|
+
compilation.dependencyFactories.set(ConstDependency, new NullFactory());
|
19
|
+
compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
|
20
|
+
|
21
|
+
params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
|
22
|
+
|
23
|
+
if(typeof parserOptions.browserify !== "undefined" && !parserOptions.browserify)
|
24
|
+
return;
|
25
|
+
|
26
|
+
parser.plugin("call require", (expr) => {
|
27
|
+
// support for browserify style require delegator: "require(o, !0)"
|
28
|
+
if(expr.arguments.length !== 2) return;
|
29
|
+
const second = parser.evaluateExpression(expr.arguments[1]);
|
30
|
+
if(!second.isBoolean()) return;
|
31
|
+
if(second.asBool() !== true) return;
|
32
|
+
const dep = new ConstDependency("require", expr.callee.range);
|
33
|
+
dep.loc = expr.loc;
|
34
|
+
if(parser.state.current.dependencies.length > 1) {
|
35
|
+
const last = parser.state.current.dependencies[parser.state.current.dependencies.length - 1];
|
36
|
+
if(last.critical && last.request === "." && last.userRequest === "." && last.recursive)
|
37
|
+
parser.state.current.dependencies.pop();
|
38
|
+
}
|
39
|
+
parser.state.current.addDependency(dep);
|
40
|
+
return true;
|
41
|
+
});
|
42
|
+
});
|
14
43
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
if(typeof parserOptions.browserify !== "undefined" && !parserOptions.browserify)
|
23
|
-
return;
|
24
|
-
|
25
|
-
parser.plugin("call require", function(expr) {
|
26
|
-
// support for browserify style require delegator: "require(o, !0)"
|
27
|
-
if(expr.arguments.length !== 2) return;
|
28
|
-
var second = this.evaluateExpression(expr.arguments[1]);
|
29
|
-
if(!second.isBoolean()) return;
|
30
|
-
if(second.asBool() !== true) return;
|
31
|
-
var dep = new ConstDependency("require", expr.callee.range);
|
32
|
-
dep.loc = expr.loc;
|
33
|
-
if(this.state.current.dependencies.length > 1) {
|
34
|
-
var last = this.state.current.dependencies[this.state.current.dependencies.length - 1];
|
35
|
-
if(last.critical && last.request === "." && last.userRequest === "." && last.recursive)
|
36
|
-
this.state.current.dependencies.pop();
|
44
|
+
params.normalModuleFactory.plugin("after-resolve", (data, done) => {
|
45
|
+
// if this is a json file and there are no loaders active, we use the json-loader in order to avoid parse errors
|
46
|
+
// @see https://github.com/webpack/webpack/issues/3363
|
47
|
+
if(matchJson.test(data.request) && data.loaders.length === 0) {
|
48
|
+
data.loaders.push({
|
49
|
+
loader: jsonLoaderPath
|
50
|
+
});
|
37
51
|
}
|
38
|
-
|
39
|
-
return true;
|
52
|
+
done(null, data);
|
40
53
|
});
|
41
54
|
});
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
// @see https://github.com/webpack/webpack/issues/3363
|
46
|
-
if(matchJson.test(data.request) && data.loaders.length === 0) {
|
47
|
-
data.loaders.push({
|
48
|
-
loader: jsonLoaderPath
|
49
|
-
});
|
50
|
-
}
|
51
|
-
done(null, data);
|
52
|
-
});
|
53
|
-
});
|
54
|
-
};
|
55
|
+
}
|
56
|
+
}
|
57
|
+
module.exports = CompatibilityPlugin;
|