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/README.md
CHANGED
@@ -18,6 +18,9 @@
|
|
18
18
|
<a href="https://npmcharts.com/compare/webpack?minimal=true">
|
19
19
|
<img src="https://img.shields.io/npm/dm/webpack.svg">
|
20
20
|
</a>
|
21
|
+
<a href="https://packagephobia.now.sh/result?p=webpack">
|
22
|
+
<img src="https://packagephobia.now.sh/badge?p=webpack" alt="install size">
|
23
|
+
</a>
|
21
24
|
<a href="https://opencollective.com/webpack#backer">
|
22
25
|
<img src="https://opencollective.com/webpack/backers/badge.svg">
|
23
26
|
</a>
|
@@ -84,25 +87,30 @@ interface](https://webpack.js.org/plugins/). Most of the features
|
|
84
87
|
within webpack itself use this plugin interface. This makes webpack very
|
85
88
|
**flexible**.
|
86
89
|
|
87
|
-
|Name|Status|Description|
|
88
|
-
|
89
|
-
|[extract-text-webpack-plugin][extract]|![extract-npm]|Extracts Text (CSS) from your bundles into a separate file (app.bundle.css)|
|
90
|
-
|[compression-webpack-plugin][compression]|![compression-npm]|Prepares compressed versions of assets to serve them with Content-Encoding|
|
91
|
-
|[i18n-webpack-plugin][i18n]|![i18n-npm]|Adds i18n support to your bundles|
|
92
|
-
|[html-webpack-plugin][html-plugin]|![html-plugin-npm]| Simplifies creation of HTML files (`index.html`) to serve your bundles|
|
90
|
+
|Name|Status|Install Size|Description|
|
91
|
+
|:--:|:----:|:----------:|:----------|
|
92
|
+
|[extract-text-webpack-plugin][extract]|![extract-npm]|![extract-size]|Extracts Text (CSS) from your bundles into a separate file (app.bundle.css)|
|
93
|
+
|[compression-webpack-plugin][compression]|![compression-npm]|![compression-size]|Prepares compressed versions of assets to serve them with Content-Encoding|
|
94
|
+
|[i18n-webpack-plugin][i18n]|![i18n-npm]|![i18n-size]|Adds i18n support to your bundles|
|
95
|
+
|[html-webpack-plugin][html-plugin]|![html-plugin-npm]|![html-plugin-size]| Simplifies creation of HTML files (`index.html`) to serve your bundles|
|
93
96
|
|
94
97
|
|
95
98
|
[common-npm]: https://img.shields.io/npm/v/webpack.svg
|
96
99
|
[extract]: https://github.com/webpack/extract-text-webpack-plugin
|
97
100
|
[extract-npm]: https://img.shields.io/npm/v/extract-text-webpack-plugin.svg
|
101
|
+
[extract-size]: https://packagephobia.now.sh/badge?p=extract-text-webpack-plugin
|
98
102
|
[component]: https://github.com/webpack/component-webpack-plugin
|
99
103
|
[component-npm]: https://img.shields.io/npm/v/component-webpack-plugin.svg
|
104
|
+
[component-size]: https://packagephobia.now.sh/badge?p=component-webpack-plugin
|
100
105
|
[compression]: https://github.com/webpack/compression-webpack-plugin
|
101
106
|
[compression-npm]: https://img.shields.io/npm/v/compression-webpack-plugin.svg
|
107
|
+
[compression-size]: https://packagephobia.now.sh/badge?p=compression-webpack-plugin
|
102
108
|
[i18n]: https://github.com/webpack/i18n-webpack-plugin
|
103
109
|
[i18n-npm]: https://img.shields.io/npm/v/i18n-webpack-plugin.svg
|
110
|
+
[i18n-size]: https://packagephobia.now.sh/badge?p=i18n-webpack-plugin
|
104
111
|
[html-plugin]: https://github.com/ampedandwired/html-webpack-plugin
|
105
112
|
[html-plugin-npm]: https://img.shields.io/npm/v/html-webpack-plugin.svg
|
113
|
+
[html-plugin-size]: https://packagephobia.now.sh/badge?p=html-webpack-plugin
|
106
114
|
|
107
115
|
### [Loaders](https://webpack.js.org/loaders/)
|
108
116
|
|
@@ -115,121 +123,154 @@ or are automatically applied via regex from your webpack configuration.
|
|
115
123
|
|
116
124
|
#### Files
|
117
125
|
|
118
|
-
|Name|Status|Description|
|
119
|
-
|
120
|
-
|[raw-loader][raw]|![raw-npm]|Loads raw content of a file (utf-8)|
|
121
|
-
|[val-loader][val]|![val-npm]|Executes code as module and considers exports as JS code|
|
122
|
-
|[url-loader][url]|![url-npm]|Works like the file loader, but can return a Data Url if the file is smaller than a limit|
|
123
|
-
|[file-loader][file]|![file-npm]|Emits the file into the output folder and returns the (relative) url|
|
126
|
+
|Name|Status|Install Size|Description|
|
127
|
+
|:--:|:----:|:----------:|:----------|
|
128
|
+
|[raw-loader][raw]|![raw-npm]|![raw-size]|Loads raw content of a file (utf-8)|
|
129
|
+
|[val-loader][val]|![val-npm]|![val-size]|Executes code as module and considers exports as JS code|
|
130
|
+
|[url-loader][url]|![url-npm]|![url-size]|Works like the file loader, but can return a Data Url if the file is smaller than a limit|
|
131
|
+
|[file-loader][file]|![file-npm]|![file-size]|Emits the file into the output folder and returns the (relative) url|
|
124
132
|
|
125
133
|
|
126
134
|
[raw]: https://github.com/webpack/raw-loader
|
127
135
|
[raw-npm]: https://img.shields.io/npm/v/raw-loader.svg
|
136
|
+
[raw-size]: https://packagephobia.now.sh/badge?p=raw-loader
|
128
137
|
[val]: https://github.com/webpack/val-loader
|
129
138
|
[val-npm]: https://img.shields.io/npm/v/val-loader.svg
|
139
|
+
[val-size]: https://packagephobia.now.sh/badge?p=val-loader
|
130
140
|
[url]: https://github.com/webpack/url-loader
|
131
141
|
[url-npm]: https://img.shields.io/npm/v/url-loader.svg
|
142
|
+
[url-size]: https://packagephobia.now.sh/badge?p=url-loader
|
132
143
|
[file]: https://github.com/webpack/file-loader
|
133
144
|
[file-npm]: https://img.shields.io/npm/v/file-loader.svg
|
145
|
+
[file-size]: https://packagephobia.now.sh/badge?p=file-loader
|
134
146
|
|
135
147
|
#### JSON
|
136
148
|
|
137
|
-
|Name|Status|Description|
|
138
|
-
|
139
|
-
|<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)|
|
140
|
-
|<a href="https://github.com/webpack/json5-loader"><img width="48" height="10.656" src="https://cdn.rawgit.com/json5/json5-logo/master/json5-logo.svg"></a>|![json5-npm]|Loads and transpiles a JSON 5 file|
|
141
|
-
|<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|
|
149
|
+
|Name|Status|Install Size|Description|
|
150
|
+
|:--:|:----:|:----------:|:----------|
|
151
|
+
|<a href="https://github.com/webpack/json-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/json.svg"></a>|![json-npm]|![json-size]|Loads a JSON file (included by default)|
|
152
|
+
|<a href="https://github.com/webpack/json5-loader"><img width="48" height="10.656" src="https://cdn.rawgit.com/json5/json5-logo/master/json5-logo.svg"></a>|![json5-npm]|![json5-size]|Loads and transpiles a JSON 5 file|
|
153
|
+
|<a href="https://github.com/awnist/cson-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a>|![cson-npm]|![cson-size]|Loads and transpiles a CSON file|
|
142
154
|
|
143
155
|
|
144
156
|
[json-npm]: https://img.shields.io/npm/v/json-loader.svg
|
157
|
+
[json-size]: https://packagephobia.now.sh/badge?p=json-loader
|
145
158
|
[json5-npm]: https://img.shields.io/npm/v/json5-loader.svg
|
159
|
+
[json5-size]: https://packagephobia.now.sh/badge?p=json5-loader
|
146
160
|
[cson-npm]: https://img.shields.io/npm/v/cson-loader.svg
|
161
|
+
[cson-size]: https://packagephobia.now.sh/badge?p=cson-loader
|
147
162
|
|
148
163
|
#### Transpiling
|
149
164
|
|
150
|
-
|Name|Status|Description|
|
151
|
-
|
152
|
-
|<a href="https://github.com/webpack/script-loader">`<script>`</a>|![script-npm]|Executes a JavaScript file once in global context (like in script tag), `require()`s are not parsed|
|
153
|
-
|<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>|
|
154
|
-
|<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-compiler)|
|
155
|
-
|<a href="https://github.com/TypeStrong/ts-loader"><img width="48" height="48" src="https://cdn.rawgit.com/Microsoft/TypeScript/master/doc/logo.svg"></a>|![type-npm]|Loads TypeScript like JavaScript|
|
156
|
-
|[`awesome-typescript-loader`](https://github.com/s-panferov/awesome-typescript-loader)|![awesome-typescript-npm]|Awesome TypeScript loader for webpack|
|
157
|
-
|<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|
|
165
|
+
|Name|Status|Install Size|Description|
|
166
|
+
|:--:|:----:|:----------:|:----------|
|
167
|
+
|<a href="https://github.com/webpack/script-loader">`<script>`</a>|![script-npm]|![script-size]|Executes a JavaScript file once in global context (like in script tag), `require()`s are not parsed|
|
168
|
+
|<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]|![babel-size]|Loads ES2015+ code and transpiles to ES5 using <a href="https://github.com/babel/babel">Babel</a>|
|
169
|
+
|<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]|![traceur-size]|Loads ES2015+ code and transpiles to ES5 using [Traceur](https://github.com/google/traceur-compiler)|
|
170
|
+
|<a href="https://github.com/TypeStrong/ts-loader"><img width="48" height="48" src="https://cdn.rawgit.com/Microsoft/TypeScript/master/doc/logo.svg"></a>|![type-npm]|![type-size]|Loads TypeScript like JavaScript|
|
171
|
+
|[`awesome-typescript-loader`](https://github.com/s-panferov/awesome-typescript-loader)|![awesome-typescript-npm]|![awesome-typescript-size]|Awesome TypeScript loader for webpack|
|
172
|
+
|<a href="https://github.com/webpack/coffee-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a>|![coffee-npm]|![coffee-size]|Loads CoffeeScript like JavaScript|
|
158
173
|
|
159
174
|
|
160
175
|
[script-npm]: https://img.shields.io/npm/v/script-loader.svg
|
176
|
+
[script-size]: https://packagephobia.now.sh/badge?p=script-loader
|
161
177
|
[babel-npm]: https://img.shields.io/npm/v/babel-loader.svg
|
178
|
+
[babel-size]: https://packagephobia.now.sh/badge?p=babel-loader
|
162
179
|
[traceur-npm]: https://img.shields.io/npm/v/traceur-loader.svg
|
180
|
+
[traceur-size]: https://packagephobia.now.sh/badge?p=traceur-loader
|
163
181
|
[coffee-npm]: https://img.shields.io/npm/v/coffee-loader.svg
|
182
|
+
[coffee-size]: https://packagephobia.now.sh/badge?p=coffee-loader
|
164
183
|
[type-npm]: https://img.shields.io/npm/v/ts-loader.svg
|
184
|
+
[type-size]: https://packagephobia.now.sh/badge?p=ts-loader
|
165
185
|
[awesome-typescript-npm]: https://img.shields.io/npm/v/awesome-typescript-loader.svg
|
186
|
+
[awesome-typescript-size]: https://packagephobia.now.sh/badge?p=awesome-typescript-loader
|
166
187
|
|
167
188
|
#### Templating
|
168
189
|
|
169
|
-
|Name|Status|Description|
|
170
|
-
|
171
|
-
|<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, requires references to static resources|
|
172
|
-
|<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|
|
173
|
-
|<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|
|
174
|
-
|<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|
|
175
|
-
|<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)|
|
176
|
-
|<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|
|
190
|
+
|Name|Status|Install Size|Description|
|
191
|
+
|:--:|:----:|:----------:|:----------|
|
192
|
+
|<a href="https://github.com/webpack/html-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/html5.svg"></a>|![html-npm]|![html-size]|Exports HTML as string, requires references to static resources|
|
193
|
+
|<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]|![pug-size]|Loads Pug templates and returns a function|
|
194
|
+
|<a href="https://github.com/webpack/jade-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/jade-3.svg"></a>|![jade-npm]|![jade-size]|Loads Jade templates and returns a function|
|
195
|
+
|<a href="https://github.com/peerigon/markdown-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/markdown.svg"></a>|![md-npm]|![md-size]|Compiles Markdown to HTML|
|
196
|
+
|<a href="https://github.com/posthtml/posthtml-loader"><img width="48" height="48" src="http://posthtml.github.io/posthtml/logo.svg"></a>|![posthtml-npm]|![posthtml-size]|Loads and transforms a HTML file using [PostHTML](https://github.com/posthtml/posthtml)|
|
197
|
+
|<a href="https://github.com/altano/handlebars-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/handlebars-1.svg"></a>|![hbs-npm]|![hbs-size]| Compiles Handlebars to HTML|
|
177
198
|
|
178
199
|
|
179
200
|
[html-npm]: https://img.shields.io/npm/v/html-loader.svg
|
201
|
+
[html-size]: https://packagephobia.now.sh/badge?p=html-loader
|
180
202
|
[pug-npm]: https://img.shields.io/npm/v/pug-loader.svg
|
203
|
+
[pug-size]: https://packagephobia.now.sh/badge?p=pug-loader
|
181
204
|
[jade-npm]: https://img.shields.io/npm/v/jade-loader.svg
|
205
|
+
[jade-size]: https://packagephobia.now.sh/badge?p=jade-loader
|
182
206
|
[md-npm]: https://img.shields.io/npm/v/markdown-loader.svg
|
207
|
+
[md-size]: https://packagephobia.now.sh/badge?p=markdown-loader
|
183
208
|
[posthtml-npm]: https://img.shields.io/npm/v/posthtml-loader.svg
|
209
|
+
[posthtml-size]: https://packagephobia.now.sh/badge?p=posthtml-loader
|
184
210
|
[hbs-npm]: https://img.shields.io/npm/v/handlebars-loader.svg
|
211
|
+
[hbs-size]: https://packagephobia.now.sh/badge?p=handlebars-loader
|
185
212
|
|
186
213
|
#### Styling
|
187
214
|
|
188
|
-
|Name|Status|Description|
|
189
|
-
|
190
|
-
|<a href="https://github.com/webpack/style-loader">`<style>`</a>|![style-npm]|Add exports of a module as style to DOM|
|
191
|
-
|<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|
|
192
|
-
|<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|
|
193
|
-
|<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|
|
194
|
-
|<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|
|
195
|
-
|<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)|
|
215
|
+
|Name|Status|Install Size|Description|
|
216
|
+
|:--:|:----:|:----------:|:----------|
|
217
|
+
|<a href="https://github.com/webpack/style-loader">`<style>`</a>|![style-npm]|![style-size]|Add exports of a module as style to DOM|
|
218
|
+
|<a href="https://github.com/webpack/css-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/css-3.svg"></a>|![css-npm]|![css-size]|Loads CSS file with resolved imports and returns CSS code|
|
219
|
+
|<a href="https://github.com/webpack/less-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/less-63.svg"></a>|![less-npm]|![less-size]|Loads and compiles a LESS file|
|
220
|
+
|<a href="https://github.com/jtangelder/sass-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/sass-1.svg"></a>|![sass-npm]|![sass-size]|Loads and compiles a SASS/SCSS file|
|
221
|
+
|<a href="https://github.com/shama/stylus-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/stylus.svg"></a>|![stylus-npm]|![stylus-size]|Loads and compiles a Stylus file|
|
222
|
+
|<a href="https://github.com/postcss/postcss-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/postcss.svg"></a>|![postcss-npm]|![postcss-size]|Loads and transforms a CSS/SSS file using [PostCSS](http://postcss.org)|
|
196
223
|
|
197
224
|
|
198
225
|
[style-npm]: https://img.shields.io/npm/v/style-loader.svg
|
226
|
+
[style-size]: https://packagephobia.now.sh/badge?p=style-loader
|
199
227
|
[css-npm]: https://img.shields.io/npm/v/css-loader.svg
|
228
|
+
[css-size]: https://packagephobia.now.sh/badge?p=css-loader
|
200
229
|
[less-npm]: https://img.shields.io/npm/v/less-loader.svg
|
230
|
+
[less-size]: https://packagephobia.now.sh/badge?p=less-loader
|
201
231
|
[sass-npm]: https://img.shields.io/npm/v/sass-loader.svg
|
232
|
+
[sass-size]: https://packagephobia.now.sh/badge?p=sass-loader
|
202
233
|
[stylus-npm]: https://img.shields.io/npm/v/stylus-loader.svg
|
234
|
+
[stylus-size]: https://packagephobia.now.sh/badge?p=stylus-loader
|
203
235
|
[postcss-npm]: https://img.shields.io/npm/v/postcss-loader.svg
|
236
|
+
[postcss-size]: https://packagephobia.now.sh/badge?p=postcss-loader
|
204
237
|
|
205
238
|
#### Linting & Testing
|
206
239
|
|
207
|
-
|Name|Status|Description|
|
208
|
-
|
209
|
-
|<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)|
|
210
|
-
|<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|
|
211
|
-
|<a href="https://github.com/webpack-contrib/jshint-loader"><img width="48" height="20.64" src="http://jshint.com/res/jshint-dark.png"></a>|![jshint-npm]|PreLoader for linting code using JSHint|
|
240
|
+
|Name|Status|Install Size|Description|
|
241
|
+
|:--:|:----:|:----------:|:----------|
|
242
|
+
|<a href="https://github.com/webpack/mocha-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/mocha.svg"></a>|![mocha-npm]|![mocha-size]|Tests with mocha (Browser/NodeJS)|
|
243
|
+
|<a href="https://github.com/MoOx/eslint-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/eslint.svg"></a>|![eslint-npm]|![eslint-size]|PreLoader for linting code using ESLint|
|
244
|
+
|<a href="https://github.com/webpack-contrib/jshint-loader"><img width="48" height="20.64" src="http://jshint.com/res/jshint-dark.png"></a>|![jshint-npm]|![jshint-size]|PreLoader for linting code using JSHint|
|
212
245
|
|
213
246
|
[mocha-npm]: https://img.shields.io/npm/v/mocha-loader.svg
|
247
|
+
[mocha-size]: https://packagephobia.now.sh/badge?p=mocha-loader
|
214
248
|
[eslint-npm]: https://img.shields.io/npm/v/eslint-loader.svg
|
249
|
+
[eslint-size]: https://packagephobia.now.sh/badge?p=eslint-loader
|
215
250
|
[jshint-npm]: https://img.shields.io/npm/v/jshint-loader.svg
|
251
|
+
[jshint-size]: https://packagephobia.now.sh/badge?p=jshint-loader
|
216
252
|
[jscs-npm]: https://img.shields.io/npm/v/jscs-loader.svg
|
253
|
+
[jscs-size]: https://packagephobia.now.sh/badge?p=jscs-loader
|
217
254
|
|
218
255
|
#### Frameworks
|
219
256
|
|
220
|
-
|Name|Status|Description|
|
221
|
-
|
222
|
-
|<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|
|
223
|
-
|<a href="https://github.com/webpack-contrib/polymer-webpack-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|
|
224
|
-
|<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|
|
225
|
-
|<a href="https://github.com/riot/tag-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/riot.svg"></a>|![riot-npm]| Riot official webpack loader|
|
257
|
+
|Name|Status|Install Size|Description|
|
258
|
+
|:--:|:----:|:----------:|:----------|
|
259
|
+
|<a href="https://github.com/vuejs/vue-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/vue-9.svg"></a>|![vue-npm]|![vue-size]|Loads and compiles Vue Components|
|
260
|
+
|<a href="https://github.com/webpack-contrib/polymer-webpack-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/polymer.svg"></a>|![polymer-npm]|![polymer-size]|Process HTML & CSS with preprocessor of choice and `require()` Web Components like first-class modules|
|
261
|
+
|<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]|![angular-size]| Loads and compiles Angular 2 Components|
|
262
|
+
|<a href="https://github.com/riot/tag-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/riot.svg"></a>|![riot-npm]|![riot-size]| Riot official webpack loader|
|
226
263
|
|
227
264
|
|
228
265
|
|
229
266
|
[vue-npm]: https://img.shields.io/npm/v/vue-loader.svg
|
267
|
+
[vue-size]: https://packagephobia.now.sh/badge?p=vue-loader
|
230
268
|
[polymer-npm]: https://img.shields.io/npm/v/polymer-webpack-loader.svg
|
269
|
+
[polymer-size]: https://packagephobia.now.sh/badge?p=polymer-webpack-loader
|
231
270
|
[angular-npm]: https://img.shields.io/npm/v/angular2-template-loader.svg
|
271
|
+
[angular-size]: https://packagephobia.now.sh/badge?p=angular2-template-loader
|
232
272
|
[riot-npm]: https://img.shields.io/npm/v/riot-tag-loader.svg
|
273
|
+
[riot-size]: https://packagephobia.now.sh/badge?p=riot-tag-loader
|
233
274
|
|
234
275
|
### Performance
|
235
276
|
|
@@ -287,6 +328,8 @@ We consider webpack to be a low-level tool used not only individually but also l
|
|
287
328
|
|
288
329
|
If you're just getting started, take a look at [our new docs and concepts page](https://webpack.js.org/concepts/). This has a high level overview that is great for beginners!!
|
289
330
|
|
331
|
+
Looking for webpack 1 docs? Please check out the old [wiki](https://github.com/webpack/docs/wiki/contents), but note that this deprecated version is no longer supported.
|
332
|
+
|
290
333
|
If you want to discuss something or just need help, [here is our Gitter room](https://gitter.im/webpack/webpack) where there are always individuals looking to help out!
|
291
334
|
|
292
335
|
If you are still having difficulty, we would love for you to post
|
package/bin/webpack.js
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
2
|
+
|
3
|
+
process.exitCode = 0;
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @param {string} command process to run
|
7
|
+
* @param {string[]} args commandline arguments
|
8
|
+
* @returns {Promise<void>} promise
|
9
|
+
*/
|
10
|
+
const runCommand = (command, args) => {
|
3
11
|
const cp = require("child_process");
|
4
12
|
return new Promise((resolve, reject) => {
|
5
|
-
const executedCommand = cp.spawn(command,
|
13
|
+
const executedCommand = cp.spawn(command, args, {
|
6
14
|
stdio: "inherit",
|
7
15
|
shell: true
|
8
16
|
});
|
@@ -13,69 +21,146 @@ function runCommand(command, options) {
|
|
13
21
|
|
14
22
|
executedCommand.on("exit", code => {
|
15
23
|
if (code === 0) {
|
16
|
-
resolve(
|
24
|
+
resolve();
|
17
25
|
} else {
|
18
26
|
reject();
|
19
27
|
}
|
20
28
|
});
|
21
29
|
});
|
22
|
-
}
|
30
|
+
};
|
23
31
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
/**
|
33
|
+
* @param {string} packageName name of the package
|
34
|
+
* @returns {boolean} is the package installed?
|
35
|
+
*/
|
36
|
+
const isInstalled = packageName => {
|
37
|
+
try {
|
38
|
+
require.resolve(packageName);
|
31
39
|
|
32
|
-
|
40
|
+
return true;
|
41
|
+
} catch (err) {
|
42
|
+
return false;
|
43
|
+
}
|
44
|
+
};
|
45
|
+
|
46
|
+
/**
|
47
|
+
* @typedef {Object} CliOption
|
48
|
+
* @property {string} name display name
|
49
|
+
* @property {string} package npm package name
|
50
|
+
* @property {string} alias shortcut for choice
|
51
|
+
* @property {boolean} installed currently installed?
|
52
|
+
* @property {string} url homepage
|
53
|
+
* @property {string} description description
|
54
|
+
*/
|
55
|
+
|
56
|
+
/** @type {CliOption[]} */
|
57
|
+
const CLIs = [
|
58
|
+
{
|
59
|
+
name: "webpack-cli",
|
60
|
+
package: "webpack-cli",
|
61
|
+
alias: "cli",
|
62
|
+
installed: isInstalled("webpack-cli"),
|
63
|
+
url: "https://github.com/webpack/webpack-cli",
|
64
|
+
description: "The original webpack full-featured CLI."
|
65
|
+
},
|
66
|
+
{
|
67
|
+
name: "webpack-command",
|
68
|
+
package: "webpack-command",
|
69
|
+
alias: "command",
|
70
|
+
installed: isInstalled("webpack-command"),
|
71
|
+
url: "https://github.com/webpack-contrib/webpack-command",
|
72
|
+
description: "A lightweight, opinionated webpack CLI."
|
73
|
+
}
|
74
|
+
];
|
75
|
+
|
76
|
+
const installedClis = CLIs.filter(cli => cli.installed);
|
77
|
+
|
78
|
+
if (installedClis.length === 0) {
|
33
79
|
const path = require("path");
|
34
80
|
const fs = require("fs");
|
35
81
|
const readLine = require("readline");
|
36
|
-
const isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));
|
37
82
|
|
38
|
-
|
39
|
-
|
83
|
+
let notify =
|
84
|
+
"One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:";
|
40
85
|
|
41
|
-
|
42
|
-
|
86
|
+
for (const item of CLIs) {
|
87
|
+
notify += `\n - ${item.name} (${item.url})\n ${item.description}`;
|
43
88
|
}
|
44
89
|
|
45
|
-
|
90
|
+
console.error(notify);
|
46
91
|
|
47
|
-
const
|
92
|
+
const isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));
|
93
|
+
|
94
|
+
const packageManager = isYarn ? "yarn" : "npm";
|
95
|
+
const installOptions = [isYarn ? "add" : "install", "-D"];
|
96
|
+
|
97
|
+
console.error(
|
98
|
+
`We will use "${packageManager}" to install the CLI via "${packageManager} ${installOptions.join(
|
99
|
+
" "
|
100
|
+
)}".`
|
101
|
+
);
|
102
|
+
|
103
|
+
let question = `Which one do you like to install (${CLIs.map(
|
104
|
+
item => item.name
|
105
|
+
).join("/")}):\n`;
|
48
106
|
|
49
|
-
console.error("The CLI moved into a separate package: webpack-cli");
|
50
107
|
const questionInterface = readLine.createInterface({
|
51
108
|
input: process.stdin,
|
52
|
-
output: process.
|
109
|
+
output: process.stderr
|
53
110
|
});
|
54
111
|
questionInterface.question(question, answer => {
|
55
112
|
questionInterface.close();
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
"
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
113
|
+
|
114
|
+
const normalizedAnswer = answer.toLowerCase();
|
115
|
+
const selectedPackage = CLIs.find(item => {
|
116
|
+
return item.name === normalizedAnswer || item.alias === normalizedAnswer;
|
117
|
+
});
|
118
|
+
|
119
|
+
if (!normalizedAnswer) {
|
120
|
+
console.error(
|
121
|
+
"One CLI needs to be installed alongside webpack to use the CLI."
|
122
|
+
);
|
123
|
+
process.exitCode = 1;
|
124
|
+
|
125
|
+
return;
|
126
|
+
} else if (!selectedPackage) {
|
127
|
+
console.error(
|
128
|
+
"No matching choice.\n" +
|
129
|
+
"One CLI needs to be installed alongside webpack to use the CLI.\n" +
|
130
|
+
"Try to installing your CLI of choice manually."
|
131
|
+
);
|
132
|
+
process.exitCode = 1;
|
133
|
+
|
134
|
+
return;
|
77
135
|
}
|
136
|
+
|
137
|
+
const packageName = selectedPackage.package;
|
138
|
+
|
139
|
+
console.log(
|
140
|
+
`Installing '${
|
141
|
+
selectedPackage.name
|
142
|
+
}' (running '${packageManager} ${installOptions.join(
|
143
|
+
" "
|
144
|
+
)} ${packageName}')...`
|
145
|
+
);
|
146
|
+
|
147
|
+
runCommand(packageManager, installOptions.concat(packageName))
|
148
|
+
.then(() => {
|
149
|
+
require(packageName); //eslint-disable-line
|
150
|
+
})
|
151
|
+
.catch(error => {
|
152
|
+
console.error(error);
|
153
|
+
process.exitCode = 1;
|
154
|
+
});
|
78
155
|
});
|
156
|
+
} else if (installedClis.length === 1) {
|
157
|
+
require(installedClis[0].package); // eslint-disable-line
|
79
158
|
} else {
|
80
|
-
|
159
|
+
console.warn(
|
160
|
+
`You have installed ${installedClis
|
161
|
+
.map(item => item.name)
|
162
|
+
.join(
|
163
|
+
" and "
|
164
|
+
)} together. To work with the "webpack" command you need only one CLI package, please remove one of them or use them directly via their binary.`
|
165
|
+
);
|
81
166
|
}
|
@@ -8,11 +8,21 @@
|
|
8
8
|
const { ConcatSource } = require("webpack-sources");
|
9
9
|
const Template = require("./Template");
|
10
10
|
|
11
|
+
/** @typedef {import("./Compilation")} Compilation */
|
12
|
+
|
11
13
|
class AmdMainTemplatePlugin {
|
14
|
+
/**
|
15
|
+
* @param {string} name the library name
|
16
|
+
*/
|
12
17
|
constructor(name) {
|
18
|
+
/** @type {string} */
|
13
19
|
this.name = name;
|
14
20
|
}
|
15
21
|
|
22
|
+
/**
|
23
|
+
* @param {Compilation} compilation the compilation instance
|
24
|
+
* @returns {void}
|
25
|
+
*/
|
16
26
|
apply(compilation) {
|
17
27
|
const { mainTemplate, chunkTemplate } = compilation;
|
18
28
|
|
@@ -6,7 +6,15 @@
|
|
6
6
|
|
7
7
|
const WebpackError = require("./WebpackError");
|
8
8
|
|
9
|
-
|
9
|
+
/** @typedef {import("./Module")} Module */
|
10
|
+
|
11
|
+
class AsyncDependencyToInitialChunkError extends WebpackError {
|
12
|
+
/**
|
13
|
+
* Creates an instance of AsyncDependencyToInitialChunkError.
|
14
|
+
* @param {string} chunkName Name of Chunk
|
15
|
+
* @param {Module} module module tied to dependency
|
16
|
+
* @param {TODO} loc location of dependency
|
17
|
+
*/
|
10
18
|
constructor(chunkName, module, loc) {
|
11
19
|
super();
|
12
20
|
|
@@ -18,4 +26,6 @@ module.exports = class AsyncDependencyToInitialChunkError extends WebpackError {
|
|
18
26
|
|
19
27
|
Error.captureStackTrace(this, this.constructor);
|
20
28
|
}
|
21
|
-
}
|
29
|
+
}
|
30
|
+
|
31
|
+
module.exports = AsyncDependencyToInitialChunkError;
|