aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpack
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/webpack')
-rw-r--r--node_modules/webpack/README.md88
-rw-r--r--node_modules/webpack/bin/config-optimist.js1
-rw-r--r--node_modules/webpack/bin/config-yargs.js16
-rw-r--r--node_modules/webpack/bin/convert-argv.js45
-rwxr-xr-xnode_modules/webpack/bin/webpack.js408
-rw-r--r--node_modules/webpack/hot/dev-server.js17
-rw-r--r--node_modules/webpack/hot/log-apply-result.js20
-rw-r--r--node_modules/webpack/hot/log.js44
-rw-r--r--node_modules/webpack/hot/only-dev-server.js26
-rw-r--r--node_modules/webpack/hot/poll.js11
-rw-r--r--node_modules/webpack/hot/signal.js19
-rw-r--r--node_modules/webpack/lib/AmdMainTemplatePlugin.js2
-rw-r--r--node_modules/webpack/lib/AsyncDependenciesBlock.js12
-rw-r--r--node_modules/webpack/lib/BasicEvaluatedExpression.js24
-rw-r--r--node_modules/webpack/lib/Chunk.js120
-rw-r--r--node_modules/webpack/lib/Compilation.js427
-rw-r--r--node_modules/webpack/lib/Compiler.js875
-rw-r--r--node_modules/webpack/lib/ContextModule.js100
-rw-r--r--node_modules/webpack/lib/ContextModuleFactory.js261
-rw-r--r--node_modules/webpack/lib/DefinePlugin.js4
-rw-r--r--node_modules/webpack/lib/DelegatedModule.js14
-rw-r--r--node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js9
-rw-r--r--node_modules/webpack/lib/DelegatedPlugin.js3
-rw-r--r--node_modules/webpack/lib/DllReferencePlugin.js3
-rw-r--r--node_modules/webpack/lib/EntryOptionPlugin.js20
-rw-r--r--node_modules/webpack/lib/EvalSourceMapDevToolModuleTemplatePlugin.js7
-rw-r--r--node_modules/webpack/lib/ExportPropertyMainTemplatePlugin.js31
-rw-r--r--node_modules/webpack/lib/ExternalModule.js7
-rw-r--r--node_modules/webpack/lib/ExternalModuleFactoryPlugin.js2
-rw-r--r--node_modules/webpack/lib/FlagDependencyExportsPlugin.js2
-rw-r--r--node_modules/webpack/lib/FlagInitialModulesAsUsedPlugin.js2
-rw-r--r--node_modules/webpack/lib/FunctionModuleTemplatePlugin.js20
-rw-r--r--node_modules/webpack/lib/HotModuleReplacement.runtime.js76
-rw-r--r--node_modules/webpack/lib/HotModuleReplacementPlugin.js442
-rw-r--r--node_modules/webpack/lib/HotUpdateChunkTemplate.js11
-rw-r--r--node_modules/webpack/lib/JsonpMainTemplate.runtime.js5
-rw-r--r--node_modules/webpack/lib/JsonpMainTemplatePlugin.js17
-rw-r--r--node_modules/webpack/lib/LibManifestPlugin.js17
-rw-r--r--node_modules/webpack/lib/LibraryTemplatePlugin.js7
-rw-r--r--node_modules/webpack/lib/MainTemplate.js4
-rw-r--r--node_modules/webpack/lib/Module.js140
-rw-r--r--node_modules/webpack/lib/ModuleFilenameHelpers.js2
-rw-r--r--node_modules/webpack/lib/ModuleReason.js42
-rw-r--r--node_modules/webpack/lib/MultiCompiler.js284
-rw-r--r--node_modules/webpack/lib/NodeStuffPlugin.js2
-rw-r--r--node_modules/webpack/lib/NormalModule.js53
-rw-r--r--node_modules/webpack/lib/NormalModuleFactory.js278
-rw-r--r--node_modules/webpack/lib/Parser.js181
-rw-r--r--node_modules/webpack/lib/ParserHelpers.js9
-rw-r--r--node_modules/webpack/lib/ProgressPlugin.js24
-rw-r--r--node_modules/webpack/lib/RawModule.js4
-rw-r--r--node_modules/webpack/lib/RecordIdsPlugin.js6
-rw-r--r--node_modules/webpack/lib/RequestShortener.js41
-rw-r--r--node_modules/webpack/lib/RequireJsStuffPlugin.js2
-rw-r--r--node_modules/webpack/lib/RuleSet.js6
-rw-r--r--node_modules/webpack/lib/SourceMapDevToolPlugin.js165
-rw-r--r--node_modules/webpack/lib/Stats.js333
-rw-r--r--node_modules/webpack/lib/Template.js8
-rw-r--r--node_modules/webpack/lib/UmdMainTemplatePlugin.js49
-rw-r--r--node_modules/webpack/lib/WebpackOptionsApply.js10
-rw-r--r--node_modules/webpack/lib/WebpackOptionsDefaulter.js9
-rw-r--r--node_modules/webpack/lib/dependencies/AMDPlugin.js4
-rw-r--r--node_modules/webpack/lib/dependencies/CommonJsPlugin.js3
-rw-r--r--node_modules/webpack/lib/dependencies/DelegatedExportsDependency.js33
-rw-r--r--node_modules/webpack/lib/dependencies/DepBlockHelpers.js35
-rw-r--r--node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js2
-rw-r--r--node_modules/webpack/lib/dependencies/HarmonyImportDependencyParserPlugin.js19
-rw-r--r--node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js8
-rw-r--r--node_modules/webpack/lib/dependencies/HarmonyModulesHelpers.js20
-rw-r--r--node_modules/webpack/lib/dependencies/ImportParserPlugin.js15
-rw-r--r--node_modules/webpack/lib/dependencies/ImportPlugin.js10
-rw-r--r--node_modules/webpack/lib/dependencies/ImportWeakContextDependency.js22
-rw-r--r--node_modules/webpack/lib/dependencies/ImportWeakDependency.js47
-rw-r--r--node_modules/webpack/lib/dependencies/RequireContextDependency.js6
-rw-r--r--node_modules/webpack/lib/dependencies/RequireContextDependencyParserPlugin.js10
-rw-r--r--node_modules/webpack/lib/dependencies/RequireContextPlugin.js31
-rw-r--r--node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlock.js8
-rw-r--r--node_modules/webpack/lib/dependencies/RequireResolveDependencyParserPlugin.js2
-rw-r--r--node_modules/webpack/lib/node/NodeMainTemplatePlugin.js332
-rw-r--r--node_modules/webpack/lib/node/NodeSourcePlugin.js2
-rw-r--r--node_modules/webpack/lib/node/NodeWatchFileSystem.js2
-rw-r--r--node_modules/webpack/lib/optimize/AggressiveMergingPlugin.js62
-rw-r--r--node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js101
-rw-r--r--node_modules/webpack/lib/optimize/ChunkModuleIdRangePlugin.js4
-rw-r--r--node_modules/webpack/lib/optimize/CommonsChunkPlugin.js51
-rw-r--r--node_modules/webpack/lib/optimize/ConcatenatedModule.js816
-rw-r--r--node_modules/webpack/lib/optimize/EnsureChunkConditionsPlugin.js9
-rw-r--r--node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js8
-rw-r--r--node_modules/webpack/lib/optimize/MergeDuplicateChunksPlugin.js15
-rw-r--r--node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js307
-rw-r--r--node_modules/webpack/lib/optimize/OccurrenceOrderPlugin.js120
-rw-r--r--node_modules/webpack/lib/optimize/RemoveParentModulesPlugin.js50
-rw-r--r--node_modules/webpack/lib/optimize/UglifyJsPlugin.js229
-rw-r--r--node_modules/webpack/lib/prepareOptions.js29
-rw-r--r--node_modules/webpack/lib/util/Semaphore.js32
-rw-r--r--node_modules/webpack/lib/util/SortableSet.js45
-rw-r--r--node_modules/webpack/lib/util/identifier.js24
-rw-r--r--node_modules/webpack/lib/webpack.js106
-rw-r--r--node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js4
-rw-r--r--node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js5
-rw-r--r--node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js57
l---------node_modules/webpack/node_modules/.bin/uglifyjs1
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/README.md118
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js51
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/AliasPlugin.js57
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/AppendPlugin.js22
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js271
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js24
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordExtensionsPlugin.js37
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordMainPlugin.js30
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordModulesPlugin.js44
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js51
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js93
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js30
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/FileExistsPlugin.js30
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/FileKindPlugin.js19
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js21
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/LogInfoPlugin.js25
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/MainFieldPlugin.js48
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/ModuleAppendPlugin.js35
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js26
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js46
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js22
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/NextPlugin.js16
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/NodeJsInputFileSystem.js29
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/ParsePlugin.js27
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js227
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/ResolverFactory.js273
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/ResultPlugin.js18
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/SymlinkPlugin.js47
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js58
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/TryNextPlugin.js18
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js43
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/UseFilePlugin.js23
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/concord.js189
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js41
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/forEachBail.js65
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/getInnerRequest.js22
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/getPaths.js33
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/globToRegExp.js188
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/lib/node.js144
-rw-r--r--node_modules/webpack/node_modules/enhanced-resolve/package.json52
-rw-r--r--node_modules/webpack/package.json58
-rw-r--r--node_modules/webpack/schemas/webpackOptionsSchema.json183
144 files changed, 7521 insertions, 2886 deletions
diff --git a/node_modules/webpack/README.md b/node_modules/webpack/README.md
index f8189de95..a8f844748 100644
--- a/node_modules/webpack/README.md
+++ b/node_modules/webpack/README.md
@@ -1,4 +1,12 @@
+<div align="center">
+ <a href="https://github.com/webpack/webpack">
+ <img width="200" heigth="200" src="https://webpack.js.org/assets/icon-square-big.svg">
+ </a>
+ <br>
+ <br>
+
[![npm][npm]][npm-url]
+
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
@@ -6,11 +14,6 @@
[![coverage][cover]][cover-url]
[![licenses][licenses]][licenses-url]
-<div align="center">
- <a href="https://github.com/webpack/webpack">
- <img width="200" heigth="200" src="https://webpack.js.org/assets/icon-square-big.svg">
- </a>
- <br>
<br>
<a href="https://npmjs.com/package/webpack">
<img src="https://img.shields.io/npm/dm/webpack.svg">
@@ -32,10 +35,18 @@
<h2 align="center">Install</h2>
+Install with npm:
+
```bash
npm install --save-dev webpack
```
+Install with yarn:
+
+```bash
+yarn add webpack --dev
+```
+
<h2 align="center">Introduction</h2>
> The README reflects webpack v2.x, webpack v1.x [documentation can be found here](https://webpack.github.io/docs/?utm_source=github&utm_medium=readme&utm_campaign=top).
@@ -69,7 +80,6 @@ within webpack itself use this plugin interface. This makes webpack very
|:--:|:----:|:----------|
|[common-chunks-webpack-plugin][common]|![common-npm]|Generates chunks of common modules shared between entry points and splits them into separate bundles (e.g vendor.bundle.js && app.bundle.js)|
|[extract-text-webpack-plugin][extract]|![extract-npm]|Extracts Text (CSS) from your bundles into a separate file (app.bundle.css)|
-|[component-webpack-plugin][component]|![component-npm]|Use components with webpack|
|[compression-webpack-plugin][compression]|![compression-npm]|Prepare compressed versions of assets to serve them with Content-Encoding|
|[i18n-webpack-plugin][i18n]|![i18n-npm]|Adds i18n support to your bundles|
|[html-webpack-plugin][html-plugin]|![html-plugin-npm]| Simplifies creation of HTML files (`index.html`) to serve your bundles|
@@ -121,7 +131,7 @@ or are automatically applied via regex from your webpack configuration.
|Name|Status|Description|
|:--:|:----:|:----------|
|<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)|
-|<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|
+|<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|
|<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|
@@ -184,19 +194,17 @@ or are automatically applied via regex from your webpack configuration.
[stylus-npm]: https://img.shields.io/npm/v/stylus-loader.svg
[postcss-npm]: https://img.shields.io/npm/v/postcss-loader.svg
-#### Linting && Testing
+#### Linting & Testing
|Name|Status|Description|
|:--:|:----:|:----------|
|<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)|
|<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|
-|<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|
-|<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|
-
+|<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|
[mocha-npm]: https://img.shields.io/npm/v/mocha-loader.svg
[eslint-npm]: https://img.shields.io/npm/v/eslint-loader.svg
-[jshint-npm]: https://img.shields.io/npm/v/jslint-loader.svg
+[jshint-npm]: https://img.shields.io/npm/v/jshint-loader.svg
[jscs-npm]: https://img.shields.io/npm/v/jscs-loader.svg
#### Frameworks
@@ -241,20 +249,44 @@ friendly** by using hashes.
<h2 align="center">Contributing</h2>
-Most of the time, if webpack is not working correctly for you it is a simple configuration issue.
+**We want contributing to webpack to be fun, enjoyable, and educational for anyone, and everyone.** We have a [vibrant ecosystem](https://medium.com/webpack/contributors-guide/home) that spans beyond this single repo. We welcome you to check out any of the repositories in [our organization](http://github.com/webpack) or [webpack-contrib organization](http://github.com/webpack-contrib) which houses all of our loaders and plugins.
-If you are still having difficulty after looking over your configuration carefully, please post
-a question to [StackOverflow with the webpack tag](https://stackoverflow.com/tags/webpack). Questions
-that include your webpack.config.js and relevant files are more likely to receive responses.
+Contributions go far beyond pull requests and commits. Although we love giving you the opportunity to put your stamp on webpack, we also are thrilled to receive a variety of other contributions including:
-If you have discovered a bug or have a feature suggestion, feel free to create an issue on Github.
+* [Documentation](https://github.com/webpack/webpack.js.org) updates, enhancements, designs, or bugfixes
+* Spelling or grammar fixes
+* README.md corrections or redesigns
+* Adding unit, or functional tests
+* Triaging GitHub issues -- especially determining whether an issue still persists or is reproducible.
+* [Searching #webpack on twitter](https://twitter.com/search?q=webpack) and helping someone else who needs help
+* Teaching others how to contribute to one of the many webpack repo's!
+* [Blogging, speaking about, or creating tutorials](https://github.com/webpack-contrib/awesome-webpack) about one of webpack's many features.
+* Helping others in our webpack [gitter channel](https://gitter.im/webpack/webpack).
-If you create a loader or plugin, please consider open sourcing it, putting it
-on npm and following the `x-loader`, `x-webpack-plugin` convention.
+If you are worried or don't know where to start, you can **always** reach out to [Sean Larkin (@TheLarkInn) on Twitter](https://twitter.com/thelarkinn) or simply submit an issue and a maintainer can help give you guidance!
-You are also welcome to correct any spelling mistakes or any language issues.
+We have also started a series on our [Medium Publication](https://medium.com/webpack) called [The Contributor's Guide to webpack](https://medium.com/webpack/contributors-guide/home). We welcome you to read it and post any questions or responses if you still need help.
-If you want to discuss something or just need help, [here is our Gitter room](https://gitter.im/webpack/webpack).
+_Looking to speak about webpack?_ We'd **love** to review your talk abstract/CFP! You can email it to webpack [at] opencollective [dot] com and we can give pointers or tips!!!
+
+<h3 align="center">Creating your own plugins and loaders</h3>
+
+If you create a loader or plugin, we would <3 for you to open source it, and put it on npm. We follow the `x-loader`, `x-webpack-plugin` naming convention.
+
+<h2 align="center">Support</h2>
+
+We consider webpack to be a low-level tool used not only individually but also layered beneath other awesome tools. Because of it's flexibility, webpack isn't always the _easiest_ entry-level solution, however we do believe it is the most powerful. That said, we're always looking for ways improve and simplify the tool without compromising functionality. If you have any ideas on ways to accomplish this, we're all ears!
+
+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!!
+
+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!
+
+If you are still having difficulty, we would love for you to post
+a question to [StackOverflow with the webpack tag](https://stackoverflow.com/tags/webpack). It is much easier to answer questions that include your webpack.config.js and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)
+
+If you are twitter savvy you can tweet #webpack with your question and someone should be able to reach out and help also.
+
+If you have discovered a 🐜 or have a feature suggestion, feel free to create an issue on Github.
### License
@@ -293,7 +325,7 @@ If you want to discuss something or just need help, [here is our Gitter room](ht
<img width="150" height="150" src="https://github.com/bebraw.png?s=150">
<br>
<a href="https://github.com/bebraw">Juho Vepsäläinen</a>
- <p>Documentation<p>
+ <p>Documentation</p>
<br>
<p>Author</p>
<a href="https://leanpub.com/survivejs-webpack">
@@ -333,23 +365,33 @@ This is how we use the donations:
<h2 align="center">Premium Partners</h2>
+<div align="center">
+
<a href="https://www.ag-grid.com/?utm_source=webpack&utm_medium=banner&utm_campaign=sponsorship" target="_blank"><img align="center" src="https://raw.githubusercontent.com/webpack/media/2b399d58/horiz-banner-ad-ag-grid.png">
</a>
+</div>
+
<h2 align="center">Other Backers and Sponsors</h2>
Before we started using OpenCollective, donations were made anonymously. Now that we have made the switch, we would like to acknowledge these sponsors (and the ones who continue to donate using OpenCollective). If we've missed someone, please send us a PR, and we'll add you to this list.
+<div align="center">
+
[Google Angular Team](https://angular.io/), [Architects.io](http://architects.io/),
<a href="https://moonmail.io" target="_blank" title="Email Marketing Software"><img
src="https://static.moonmail.io/moonmail-logo.svg" height="30" alt="MoonMail"></a>
<a href="https://monei.net" target="_blank" title="Best payment gateway rates"><img
src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
+</div>
+
<h2 align="center">Sponsors</h2>
[Become a sponsor](https://opencollective.com/webpack#sponsor) and get your logo on our README on Github with a link to your site.
+<div align="center">
+
<a href="https://opencollective.com/webpack/sponsor/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/0/avatar.svg?requireActive=false"></a>
<a href="https://opencollective.com/webpack/sponsor/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/1/avatar.svg?requireActive=false"></a>
<a href="https://opencollective.com/webpack/sponsor/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/2/avatar.svg?requireActive=false"></a>
@@ -381,6 +423,8 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
<a href="https://opencollective.com/webpack/sponsor/28/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/28/avatar.svg?requireActive=false"></a>
<a href="https://opencollective.com/webpack/sponsor/29/website?requireActive=false" target="_blank"><img src="https://opencollective.com/webpack/sponsor/29/avatar.svg?requireActive=false"></a>
+</div>
+
<h2 align="center">Backers</h2>
[Become a backer](https://opencollective.com/webpack#backer) and get your image on our README on Github with a link to your site.
diff --git a/node_modules/webpack/bin/config-optimist.js b/node_modules/webpack/bin/config-optimist.js
index 5ea07ee14..6ec4d62c8 100644
--- a/node_modules/webpack/bin/config-optimist.js
+++ b/node_modules/webpack/bin/config-optimist.js
@@ -2,6 +2,7 @@ module.exports = function(optimist) {
optimist
.boolean("help").alias("help", "h").alias("help", "?").describe("help")
.string("config").describe("config", "Path to the config file")
+ .string("config-name").describe("config-name", "Name of the config to use")
.string("env").describe("env", "Environment passed to the config, when it is a function")
.string("context").describe("context", "The root directory for resolving entry point and stats")
.string("entry").describe("entry", "The entry point")
diff --git a/node_modules/webpack/bin/config-yargs.js b/node_modules/webpack/bin/config-yargs.js
index a3f7e0c3e..e7c166671 100644
--- a/node_modules/webpack/bin/config-yargs.js
+++ b/node_modules/webpack/bin/config-yargs.js
@@ -9,7 +9,7 @@ var OPTIMIZE_GROUP = "Optimizing options:";
module.exports = function(yargs) {
yargs
.help("help")
- .alias("help", "h", "?")
+ .alias("help", "h")
.version()
.alias("version", "v")
.options({
@@ -20,6 +20,12 @@ module.exports = function(yargs) {
defaultDescription: "webpack.config.js or webpackfile.js",
requiresArg: true
},
+ "config-name": {
+ type: "string",
+ describe: "Name of the config to use",
+ group: CONFIG_GROUP,
+ requiresArg: true
+ },
"env": {
describe: "Environment passed to the config, when it is a function",
group: CONFIG_GROUP
@@ -194,7 +200,7 @@ module.exports = function(yargs) {
},
"resolve-extensions": {
"type": "array",
- describe: "Setup extensions that should be used to resolve modules (Example: --resolve-extensions .es6 .js)",
+ describe: "Setup extensions that should be used to resolve modules (Example: --resolve-extensions .es6,.js)",
group: RESOLVE_GROUP,
requiresArg: true
},
@@ -245,12 +251,14 @@ module.exports = function(yargs) {
"bail": {
type: "boolean",
describe: "Abort the compilation on first error",
- group: ADVANCED_GROUP
+ group: ADVANCED_GROUP,
+ default: null
},
"profile": {
type: "boolean",
describe: "Profile the compilation and include information in stats",
- group: ADVANCED_GROUP
+ group: ADVANCED_GROUP,
+ default: null
},
"d": {
type: "boolean",
diff --git a/node_modules/webpack/bin/convert-argv.js b/node_modules/webpack/bin/convert-argv.js
index ab0ba3343..043ea2abb 100644
--- a/node_modules/webpack/bin/convert-argv.js
+++ b/node_modules/webpack/bin/convert-argv.js
@@ -2,6 +2,7 @@ var path = require("path");
var fs = require("fs");
fs.existsSync = fs.existsSync || path.existsSync;
var interpret = require("interpret");
+var prepareOptions = require("../lib/prepareOptions");
module.exports = function(yargs, argv, convertOptions) {
@@ -94,13 +95,7 @@ module.exports = function(yargs, argv, convertOptions) {
var requireConfig = function requireConfig(configPath) {
var options = require(configPath);
- var isES6DefaultExportedFunc = (
- typeof options === "object" && options !== null && typeof options.default === "function"
- );
- if(typeof options === "function" || isES6DefaultExportedFunc) {
- options = isES6DefaultExportedFunc ? options.default : options;
- options = options(argv.env, argv);
- }
+ options = prepareOptions(options, argv);
return options;
};
@@ -135,6 +130,20 @@ module.exports = function(yargs, argv, convertOptions) {
return processConfiguredOptions(options.default);
}
+ // filter multi-config by name
+ if(Array.isArray(options) && argv["config-name"]) {
+ var namedOptions = options.filter(function(opt) {
+ return opt.name === argv["config-name"];
+ });
+ if(namedOptions.length === 0) {
+ console.error("Configuration with name '" + argv["config-name"] + "' was not found.");
+ process.exit(-1); // eslint-disable-line
+ } else if(namedOptions.length === 1) {
+ return processConfiguredOptions(namedOptions[0]);
+ }
+ options = namedOptions;
+ }
+
if(Array.isArray(options)) {
options.forEach(processOptions);
} else {
@@ -284,24 +293,30 @@ module.exports = function(yargs, argv, convertOptions) {
ensureObject(options, "entry");
});
- function bindLoaders(arg, collection) {
+ function bindRules(arg) {
ifArgPair(arg, function(name, binding) {
if(name === null) {
name = binding;
binding += "-loader";
}
- options.module[collection].push({
- test: new RegExp("\\." + name.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "$"),
+ var rule = {
+ test: new RegExp("\\." + name.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "$"), // eslint-disable-line no-useless-escape
loader: binding
- });
+ };
+ if(arg === "module-bind-pre") {
+ rule.enforce = "pre";
+ } else if(arg === "module-bind-post") {
+ rule.enforce = "post";
+ }
+ options.module.rules.push(rule);
}, function() {
ensureObject(options, "module");
- ensureArray(options.module, collection);
+ ensureArray(options.module, "rules");
});
}
- bindLoaders("module-bind", "loaders");
- bindLoaders("module-bind-pre", "preLoaders");
- bindLoaders("module-bind-post", "postLoaders");
+ bindRules("module-bind");
+ bindRules("module-bind-pre");
+ bindRules("module-bind-post");
var defineObject;
ifArgPair("define", function(name, value) {
diff --git a/node_modules/webpack/bin/webpack.js b/node_modules/webpack/bin/webpack.js
index 37125533c..d61288841 100755
--- a/node_modules/webpack/bin/webpack.js
+++ b/node_modules/webpack/bin/webpack.js
@@ -124,11 +124,21 @@ yargs.options({
group: DISPLAY_GROUP,
describe: "Display information about exports provided from modules"
},
+ "display-optimization-bailout": {
+ type: "boolean",
+ group: DISPLAY_GROUP,
+ describe: "Display information about why optimization bailed out for modules"
+ },
"display-error-details": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display details about errors"
},
+ "display": {
+ type: "string",
+ group: DISPLAY_GROUP,
+ describe: "Select display preset (verbose, detailed, normal, minimal, errors-only, none)"
+ },
"verbose": {
type: "boolean",
group: DISPLAY_GROUP,
@@ -136,228 +146,244 @@ yargs.options({
}
});
-var argv = yargs.argv;
-
-if(argv.verbose) {
- argv["display-reasons"] = true;
- argv["display-depth"] = true;
- argv["display-entrypoints"] = true;
- argv["display-used-exports"] = true;
- argv["display-provided-exports"] = true;
- argv["display-error-details"] = true;
- argv["display-modules"] = true;
- argv["display-cached"] = true;
- argv["display-cached-assets"] = true;
-}
-
-var options = require("./convert-argv")(yargs, argv);
-
-function ifArg(name, fn, init) {
- if(Array.isArray(argv[name])) {
- if(init) init();
- argv[name].forEach(fn);
- } else if(typeof argv[name] !== "undefined") {
- if(init) init();
- fn(argv[name], -1);
- }
-}
-
-function processOptions(options) {
- // process Promise
- if(typeof options.then === "function") {
- options.then(processOptions).catch(function(err) {
- console.error(err.stack || err);
- process.exit(1); // eslint-disable-line
- });
+// yargs will terminate the process early when the user uses help or version.
+// This causes large help outputs to be cut short (https://github.com/nodejs/node/wiki/API-changes-between-v0.10-and-v4#process).
+// To prevent this we use the yargs.parse API and exit the process normally
+yargs.parse(process.argv.slice(2), (err, argv, output) => {
+
+ // arguments validation failed
+ if(err && output) {
+ console.error(output);
+ process.exitCode = 1;
return;
}
- var firstOptions = [].concat(options)[0];
- var statsPresetToOptions = require("../lib/Stats.js").presetToOptions;
+ // help or version info
+ if(output) {
+ console.log(output);
+ return;
+ }
- var outputOptions = options.stats;
- if(typeof outputOptions === "boolean" || typeof outputOptions === "string") {
- outputOptions = statsPresetToOptions(outputOptions);
- } else if(!outputOptions) {
- outputOptions = {};
+ if(argv.verbose) {
+ argv["display"] = "verbose";
}
- outputOptions = Object.create(outputOptions);
- if(Array.isArray(options) && !outputOptions.children) {
- outputOptions.children = options.map(o => o.stats);
+
+ var options = require("./convert-argv")(yargs, argv);
+
+ function ifArg(name, fn, init) {
+ if(Array.isArray(argv[name])) {
+ if(init) init();
+ argv[name].forEach(fn);
+ } else if(typeof argv[name] !== "undefined") {
+ if(init) init();
+ fn(argv[name], -1);
+ }
}
- if(typeof outputOptions.context === "undefined")
- outputOptions.context = firstOptions.context;
-
- ifArg("json", function(bool) {
- if(bool)
- outputOptions.json = bool;
- });
-
- if(typeof outputOptions.colors === "undefined")
- outputOptions.colors = require("supports-color");
-
- ifArg("sort-modules-by", function(value) {
- outputOptions.modulesSort = value;
- });
-
- ifArg("sort-chunks-by", function(value) {
- outputOptions.chunksSort = value;
- });
-
- ifArg("sort-assets-by", function(value) {
- outputOptions.assetsSort = value;
- });
-
- ifArg("display-exclude", function(value) {
- outputOptions.exclude = value;
- });
-
- if(!outputOptions.json) {
- if(typeof outputOptions.cached === "undefined")
- outputOptions.cached = false;
- if(typeof outputOptions.cachedAssets === "undefined")
- outputOptions.cachedAssets = false;
-
- ifArg("display-chunks", function(bool) {
- outputOptions.modules = !bool;
- outputOptions.chunks = bool;
- });
- ifArg("display-entrypoints", function(bool) {
- outputOptions.entrypoints = bool;
- });
+ function processOptions(options) {
+ // process Promise
+ if(typeof options.then === "function") {
+ options.then(processOptions).catch(function(err) {
+ console.error(err.stack || err);
+ process.exit(1); // eslint-disable-line
+ });
+ return;
+ }
- ifArg("display-reasons", function(bool) {
- outputOptions.reasons = bool;
- });
+ var firstOptions = [].concat(options)[0];
+ var statsPresetToOptions = require("../lib/Stats.js").presetToOptions;
- ifArg("display-depth", function(bool) {
- outputOptions.depth = bool;
- });
+ var outputOptions = options.stats;
+ if(typeof outputOptions === "boolean" || typeof outputOptions === "string") {
+ outputOptions = statsPresetToOptions(outputOptions);
+ } else if(!outputOptions) {
+ outputOptions = {};
+ }
- ifArg("display-used-exports", function(bool) {
- outputOptions.usedExports = bool;
+ ifArg("display", function(preset) {
+ outputOptions = statsPresetToOptions(preset);
});
- ifArg("display-provided-exports", function(bool) {
- outputOptions.providedExports = bool;
- });
+ outputOptions = Object.create(outputOptions);
+ if(Array.isArray(options) && !outputOptions.children) {
+ outputOptions.children = options.map(o => o.stats);
+ }
+ if(typeof outputOptions.context === "undefined")
+ outputOptions.context = firstOptions.context;
- ifArg("display-error-details", function(bool) {
- outputOptions.errorDetails = bool;
+ ifArg("json", function(bool) {
+ if(bool)
+ outputOptions.json = bool;
});
- ifArg("display-origins", function(bool) {
- outputOptions.chunkOrigins = bool;
+ if(typeof outputOptions.colors === "undefined")
+ outputOptions.colors = require("supports-color");
+
+ ifArg("sort-modules-by", function(value) {
+ outputOptions.modulesSort = value;
});
- ifArg("display-max-modules", function(value) {
- outputOptions.maxModules = value;
+ ifArg("sort-chunks-by", function(value) {
+ outputOptions.chunksSort = value;
});
- ifArg("display-cached", function(bool) {
- if(bool)
- outputOptions.cached = true;
+ ifArg("sort-assets-by", function(value) {
+ outputOptions.assetsSort = value;
});
- ifArg("display-cached-assets", function(bool) {
- if(bool)
- outputOptions.cachedAssets = true;
+ ifArg("display-exclude", function(value) {
+ outputOptions.exclude = value;
});
- if(!outputOptions.exclude)
- outputOptions.exclude = ["node_modules", "bower_components", "components"];
+ if(!outputOptions.json) {
+ if(typeof outputOptions.cached === "undefined")
+ outputOptions.cached = false;
+ if(typeof outputOptions.cachedAssets === "undefined")
+ outputOptions.cachedAssets = false;
+
+ ifArg("display-chunks", function(bool) {
+ if(bool) {
+ outputOptions.modules = false;
+ outputOptions.chunks = true;
+ outputOptions.chunkModules = true;
+ }
+ });
- if(argv["display-modules"]) {
- outputOptions.maxModules = Infinity;
- outputOptions.exclude = undefined;
- }
- } else {
- if(typeof outputOptions.chunks === "undefined")
- outputOptions.chunks = true;
- if(typeof outputOptions.entrypoints === "undefined")
- outputOptions.entrypoints = true;
- if(typeof outputOptions.modules === "undefined")
- outputOptions.modules = true;
- if(typeof outputOptions.chunkModules === "undefined")
- outputOptions.chunkModules = true;
- if(typeof outputOptions.reasons === "undefined")
- outputOptions.reasons = true;
- if(typeof outputOptions.cached === "undefined")
- outputOptions.cached = true;
- if(typeof outputOptions.cachedAssets === "undefined")
- outputOptions.cachedAssets = true;
- }
+ ifArg("display-entrypoints", function(bool) {
+ if(bool)
+ outputOptions.entrypoints = true;
+ });
- ifArg("hide-modules", function(bool) {
- if(bool) {
- outputOptions.modules = false;
- outputOptions.chunkModules = false;
- }
- });
-
- var webpack = require("../lib/webpack.js");
-
- Error.stackTraceLimit = 30;
- var lastHash = null;
- var compiler;
- try {
- compiler = webpack(options);
- } catch(e) {
- var WebpackOptionsValidationError = require("../lib/WebpackOptionsValidationError");
- if(e instanceof WebpackOptionsValidationError) {
- if(argv.color)
- console.error("\u001b[1m\u001b[31m" + e.message + "\u001b[39m\u001b[22m");
- else
- console.error(e.message);
- process.exit(1); // eslint-disable-line no-process-exit
- }
- throw e;
- }
+ ifArg("display-reasons", function(bool) {
+ if(bool)
+ outputOptions.reasons = true;
+ });
- if(argv.progress) {
- var ProgressPlugin = require("../lib/ProgressPlugin");
- compiler.apply(new ProgressPlugin({
- profile: argv.profile
- }));
- }
+ ifArg("display-depth", function(bool) {
+ if(bool)
+ outputOptions.depth = true;
+ });
+
+ ifArg("display-used-exports", function(bool) {
+ if(bool)
+ outputOptions.usedExports = true;
+ });
+
+ ifArg("display-provided-exports", function(bool) {
+ if(bool)
+ outputOptions.providedExports = true;
+ });
+
+ ifArg("display-optimization-bailout", function(bool) {
+ if(bool)
+ outputOptions.optimizationBailout = bool;
+ });
+
+ ifArg("display-error-details", function(bool) {
+ if(bool)
+ outputOptions.errorDetails = true;
+ });
+
+ ifArg("display-origins", function(bool) {
+ if(bool)
+ outputOptions.chunkOrigins = true;
+ });
+
+ ifArg("display-max-modules", function(value) {
+ outputOptions.maxModules = +value;
+ });
+
+ ifArg("display-cached", function(bool) {
+ if(bool)
+ outputOptions.cached = true;
+ });
+
+ ifArg("display-cached-assets", function(bool) {
+ if(bool)
+ outputOptions.cachedAssets = true;
+ });
+
+ if(!outputOptions.exclude)
+ outputOptions.exclude = ["node_modules", "bower_components", "components"];
- function compilerCallback(err, stats) {
- if(!options.watch || err) {
- // Do not keep cache anymore
- compiler.purgeInputFileSystem();
+ if(argv["display-modules"]) {
+ outputOptions.maxModules = Infinity;
+ outputOptions.exclude = undefined;
+ outputOptions.modules = true;
+ }
}
- if(err) {
- lastHash = null;
- console.error(err.stack || err);
- if(err.details) console.error(err.details);
- process.exit(1); // eslint-disable-line
+
+ ifArg("hide-modules", function(bool) {
+ if(bool) {
+ outputOptions.modules = false;
+ outputOptions.chunkModules = false;
+ }
+ });
+
+ var webpack = require("../lib/webpack.js");
+
+ Error.stackTraceLimit = 30;
+ var lastHash = null;
+ var compiler;
+ try {
+ compiler = webpack(options);
+ } catch(e) {
+ var WebpackOptionsValidationError = require("../lib/WebpackOptionsValidationError");
+ if(e instanceof WebpackOptionsValidationError) {
+ if(argv.color)
+ console.error("\u001b[1m\u001b[31m" + e.message + "\u001b[39m\u001b[22m");
+ else
+ console.error(e.message);
+ process.exit(1); // eslint-disable-line no-process-exit
+ }
+ throw e;
}
- if(outputOptions.json) {
- process.stdout.write(JSON.stringify(stats.toJson(outputOptions), null, 2) + "\n");
- } else if(stats.hash !== lastHash) {
- lastHash = stats.hash;
- process.stdout.write(stats.toString(outputOptions) + "\n");
+
+ if(argv.progress) {
+ var ProgressPlugin = require("../lib/ProgressPlugin");
+ compiler.apply(new ProgressPlugin({
+ profile: argv.profile
+ }));
}
- if(!options.watch && stats.hasErrors()) {
- process.on("exit", function() {
- process.exit(2); // eslint-disable-line
- });
+
+ function compilerCallback(err, stats) {
+ if(!options.watch || err) {
+ // Do not keep cache anymore
+ compiler.purgeInputFileSystem();
+ }
+ if(err) {
+ lastHash = null;
+ console.error(err.stack || err);
+ if(err.details) console.error(err.details);
+ process.exit(1); // eslint-disable-line
+ }
+ if(outputOptions.json) {
+ process.stdout.write(JSON.stringify(stats.toJson(outputOptions), null, 2) + "\n");
+ } else if(stats.hash !== lastHash) {
+ lastHash = stats.hash;
+ var statsString = stats.toString(outputOptions);
+ if(statsString)
+ process.stdout.write(statsString + "\n");
+ }
+ if(!options.watch && stats.hasErrors()) {
+ process.exitCode = 2;
+ }
}
+ if(firstOptions.watch || options.watch) {
+ var watchOptions = firstOptions.watchOptions || firstOptions.watch || options.watch || {};
+ if(watchOptions.stdin) {
+ process.stdin.on("end", function() {
+ process.exit(); // eslint-disable-line
+ });
+ process.stdin.resume();
+ }
+ compiler.watch(watchOptions, compilerCallback);
+ console.log("\nWebpack is watching the files…\n");
+ } else
+ compiler.run(compilerCallback);
+
}
- if(firstOptions.watch || options.watch) {
- var watchOptions = firstOptions.watchOptions || firstOptions.watch || options.watch || {};
- if(watchOptions.stdin) {
- process.stdin.on("end", function() {
- process.exit(0); // eslint-disable-line
- });
- process.stdin.resume();
- }
- compiler.watch(watchOptions, compilerCallback);
- console.log("\nWebpack is watching the files…\n");
- } else
- compiler.run(compilerCallback);
-}
+ processOptions(options);
-processOptions(options);
+});
diff --git a/node_modules/webpack/hot/dev-server.js b/node_modules/webpack/hot/dev-server.js
index da39afedd..95894674d 100644
--- a/node_modules/webpack/hot/dev-server.js
+++ b/node_modules/webpack/hot/dev-server.js
@@ -8,11 +8,12 @@ if(module.hot) {
var upToDate = function upToDate() {
return lastHash.indexOf(__webpack_hash__) >= 0;
};
+ var log = require("./log");
var check = function check() {
module.hot.check(true).then(function(updatedModules) {
if(!updatedModules) {
- console.warn("[HMR] Cannot find update. Need to do a full reload!");
- console.warn("[HMR] (Probably because of restarting the webpack-dev-server)");
+ log("warning", "[HMR] Cannot find update. Need to do a full reload!");
+ log("warning", "[HMR] (Probably because of restarting the webpack-dev-server)");
window.location.reload();
return;
}
@@ -24,17 +25,17 @@ if(module.hot) {
require("./log-apply-result")(updatedModules, updatedModules);
if(upToDate()) {
- console.log("[HMR] App is up to date.");
+ log("info", "[HMR] App is up to date.");
}
}).catch(function(err) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
- console.warn("[HMR] Cannot apply update. Need to do a full reload!");
- console.warn("[HMR] " + err.stack || err.message);
+ log("warning", "[HMR] Cannot apply update. Need to do a full reload!");
+ log("warning", "[HMR] " + err.stack || err.message);
window.location.reload();
} else {
- console.warn("[HMR] Update failed: " + err.stack || err.message);
+ log("warning", "[HMR] Update failed: " + err.stack || err.message);
}
});
};
@@ -42,11 +43,11 @@ if(module.hot) {
hotEmitter.on("webpackHotUpdate", function(currentHash) {
lastHash = currentHash;
if(!upToDate() && module.hot.status() === "idle") {
- console.log("[HMR] Checking for updates on the server...");
+ log("info", "[HMR] Checking for updates on the server...");
check();
}
});
- console.log("[HMR] Waiting for update signal from WDS...");
+ log("info", "[HMR] Waiting for update signal from WDS...");
} else {
throw new Error("[HMR] Hot Module Replacement is disabled.");
}
diff --git a/node_modules/webpack/hot/log-apply-result.js b/node_modules/webpack/hot/log-apply-result.js
index 96c900b9f..8a312b3c6 100644
--- a/node_modules/webpack/hot/log-apply-result.js
+++ b/node_modules/webpack/hot/log-apply-result.js
@@ -6,25 +6,33 @@ module.exports = function(updatedModules, renewedModules) {
var unacceptedModules = updatedModules.filter(function(moduleId) {
return renewedModules && renewedModules.indexOf(moduleId) < 0;
});
+ var log = require("./log");
if(unacceptedModules.length > 0) {
- console.warn("[HMR] The following modules couldn't be hot updated: (They would need a full reload!)");
+ log("warning", "[HMR] The following modules couldn't be hot updated: (They would need a full reload!)");
unacceptedModules.forEach(function(moduleId) {
- console.warn("[HMR] - " + moduleId);
+ log("warning", "[HMR] - " + moduleId);
});
}
if(!renewedModules || renewedModules.length === 0) {
- console.log("[HMR] Nothing hot updated.");
+ log("info", "[HMR] Nothing hot updated.");
} else {
- console.log("[HMR] Updated modules:");
+ log("info", "[HMR] Updated modules:");
renewedModules.forEach(function(moduleId) {
- console.log("[HMR] - " + moduleId);
+ if(typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
+ var parts = moduleId.split("!");
+ log.groupCollapsed("info", "[HMR] - " + parts.pop());
+ log("info", "[HMR] - " + moduleId);
+ log.groupEnd("info");
+ } else {
+ log("info", "[HMR] - " + moduleId);
+ }
});
var numberIds = renewedModules.every(function(moduleId) {
return typeof moduleId === "number";
});
if(numberIds)
- console.log("[HMR] Consider using the NamedModulesPlugin for module names.");
+ log("info", "[HMR] Consider using the NamedModulesPlugin for module names.");
}
};
diff --git a/node_modules/webpack/hot/log.js b/node_modules/webpack/hot/log.js
new file mode 100644
index 000000000..2ade0511d
--- /dev/null
+++ b/node_modules/webpack/hot/log.js
@@ -0,0 +1,44 @@
+var logLevel = "info";
+
+function dummy() {}
+
+function shouldLog(level) {
+ var shouldLog = (logLevel === "info" && level === "info") ||
+ (["info", "warning"].indexOf(logLevel) >= 0 && level === "warning") ||
+ (["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error");
+ return shouldLog;
+}
+
+function logGroup(logFn) {
+ return function(level, msg) {
+ if(shouldLog(level)) {
+ logFn(msg);
+ }
+ };
+}
+
+module.exports = function(level, msg) {
+ if(shouldLog(level)) {
+ if(level === "info") {
+ console.log(msg);
+ } else if(level === "warning") {
+ console.warn(msg);
+ } else if(level === "error") {
+ console.error(msg);
+ }
+ }
+};
+
+var group = console.group || dummy;
+var groupCollapsed = console.groupCollapsed || dummy;
+var groupEnd = console.groupEnd || dummy;
+
+module.exports.group = logGroup(group);
+
+module.exports.groupCollapsed = logGroup(groupCollapsed);
+
+module.exports.groupEnd = logGroup(groupEnd);
+
+module.exports.setLogLevel = function(level) {
+ logLevel = level;
+};
diff --git a/node_modules/webpack/hot/only-dev-server.js b/node_modules/webpack/hot/only-dev-server.js
index 214f757f6..252df58fd 100644
--- a/node_modules/webpack/hot/only-dev-server.js
+++ b/node_modules/webpack/hot/only-dev-server.js
@@ -8,11 +8,12 @@ if(module.hot) {
var upToDate = function upToDate() {
return lastHash.indexOf(__webpack_hash__) >= 0;
};
+ var log = require("./log");
var check = function check() {
module.hot.check().then(function(updatedModules) {
if(!updatedModules) {
- console.warn("[HMR] Cannot find update. Need to do a full reload!");
- console.warn("[HMR] (Probably because of restarting the webpack-dev-server)");
+ log("warning", "[HMR] Cannot find update. Need to do a full reload!");
+ log("warning", "[HMR] (Probably because of restarting the webpack-dev-server)");
return;
}
@@ -21,13 +22,14 @@ if(module.hot) {
ignoreDeclined: true,
ignoreErrored: true,
onUnaccepted: function(data) {
- console.warn("Ignored an update to unaccepted module " + data.chain.join(" -> "));
+ log("warning", "Ignored an update to unaccepted module " + data.chain.join(" -> "));
},
onDeclined: function(data) {
- console.warn("Ignored an update to declined module " + data.chain.join(" -> "));
+ log("warning", "Ignored an update to declined module " + data.chain.join(" -> "));
},
onErrored: function(data) {
- console.warn("Ignored an error while updating module " + data.moduleId + " (" + data.type + ")");
+ log("error", data.error);
+ log("warning", "Ignored an error while updating module " + data.moduleId + " (" + data.type + ")");
}
}).then(function(renewedModules) {
if(!upToDate()) {
@@ -37,16 +39,16 @@ if(module.hot) {
require("./log-apply-result")(updatedModules, renewedModules);
if(upToDate()) {
- console.log("[HMR] App is up to date.");
+ log("info", "[HMR] App is up to date.");
}
});
}).catch(function(err) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
- console.warn("[HMR] Cannot check for update. Need to do a full reload!");
- console.warn("[HMR] " + err.stack || err.message);
+ log("warning", "[HMR] Cannot check for update. Need to do a full reload!");
+ log("warning", "[HMR] " + err.stack || err.message);
} else {
- console.warn("[HMR] Update check failed: " + err.stack || err.message);
+ log("warning", "[HMR] Update check failed: " + err.stack || err.message);
}
});
};
@@ -56,14 +58,14 @@ if(module.hot) {
if(!upToDate()) {
var status = module.hot.status();
if(status === "idle") {
- console.log("[HMR] Checking for updates on the server...");
+ log("info", "[HMR] Checking for updates on the server...");
check();
} else if(["abort", "fail"].indexOf(status) >= 0) {
- console.warn("[HMR] Cannot apply update as a previous update " + status + "ed. Need to do a full reload!");
+ log("warning", "[HMR] Cannot apply update as a previous update " + status + "ed. Need to do a full reload!");
}
}
});
- console.log("[HMR] Waiting for update signal from WDS...");
+ log("info", "[HMR] Waiting for update signal from WDS...");
} else {
throw new Error("[HMR] Hot Module Replacement is disabled.");
}
diff --git a/node_modules/webpack/hot/poll.js b/node_modules/webpack/hot/poll.js
index a4bc7ccab..75e3a2b67 100644
--- a/node_modules/webpack/hot/poll.js
+++ b/node_modules/webpack/hot/poll.js
@@ -5,12 +5,13 @@
/*globals __resourceQuery */
if(module.hot) {
var hotPollInterval = +(__resourceQuery.substr(1)) || (10 * 60 * 1000);
+ var log = require("./log");
var checkForUpdate = function checkForUpdate(fromUpdate) {
if(module.hot.status() === "idle") {
module.hot.check(true).then(function(updatedModules) {
if(!updatedModules) {
- if(fromUpdate) console.log("[HMR] Update applied.");
+ if(fromUpdate) log("info", "[HMR] Update applied.");
return;
}
require("./log-apply-result")(updatedModules, updatedModules);
@@ -18,11 +19,11 @@ if(module.hot) {
}).catch(function(err) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
- console.warn("[HMR] Cannot apply update.");
- console.warn("[HMR] " + err.stack || err.message);
- console.warn("[HMR] You need to restart the application!");
+ log("warning", "[HMR] Cannot apply update.");
+ log("warning", "[HMR] " + err.stack || err.message);
+ log("warning", "[HMR] You need to restart the application!");
} else {
- console.warn("[HMR] Update failed: " + err.stack || err.message);
+ log("warning", "[HMR] Update failed: " + err.stack || err.message);
}
});
}
diff --git a/node_modules/webpack/hot/signal.js b/node_modules/webpack/hot/signal.js
index fffd35075..77ec94d4a 100644
--- a/node_modules/webpack/hot/signal.js
+++ b/node_modules/webpack/hot/signal.js
@@ -4,20 +4,21 @@
*/
/*globals __resourceQuery */
if(module.hot) {
+ var log = require("./log");
var checkForUpdate = function checkForUpdate(fromUpdate) {
module.hot.check().then(function(updatedModules) {
if(!updatedModules) {
if(fromUpdate)
- console.log("[HMR] Update applied.");
+ log("info", "[HMR] Update applied.");
else
- console.warn("[HMR] Cannot find update.");
+ log("warning", "[HMR] Cannot find update.");
return;
}
return module.hot.apply({
ignoreUnaccepted: true,
onUnaccepted: function(data) {
- console.warn("Ignored an update to unaccepted module " + data.chain.join(" -> "));
+ log("warning", "Ignored an update to unaccepted module " + data.chain.join(" -> "));
},
}).then(function(renewedModules) {
require("./log-apply-result")(updatedModules, renewedModules);
@@ -27,19 +28,19 @@ if(module.hot) {
}).catch(function(err) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
- console.warn("[HMR] Cannot apply update.");
- console.warn("[HMR] " + err.stack || err.message);
- console.warn("[HMR] You need to restart the application!");
+ log("warning", "[HMR] Cannot apply update.");
+ log("warning", "[HMR] " + err.stack || err.message);
+ log("warning", "[HMR] You need to restart the application!");
} else {
- console.warn("[HMR] Update failed: " + err.stack || err.message);
+ log("warning", "[HMR] Update failed: " + err.stack || err.message);
}
});
};
process.on(__resourceQuery.substr(1) || "SIGUSR2", function() {
if(module.hot.status() !== "idle") {
- console.warn("[HMR] Got signal but currently in " + module.hot.status() + " state.");
- console.warn("[HMR] Need to be in idle state to start hot update.");
+ log("warning", "[HMR] Got signal but currently in " + module.hot.status() + " state.");
+ log("warning", "[HMR] Need to be in idle state to start hot update.");
return;
}
diff --git a/node_modules/webpack/lib/AmdMainTemplatePlugin.js b/node_modules/webpack/lib/AmdMainTemplatePlugin.js
index 0ff688167..727f49ba3 100644
--- a/node_modules/webpack/lib/AmdMainTemplatePlugin.js
+++ b/node_modules/webpack/lib/AmdMainTemplatePlugin.js
@@ -17,7 +17,7 @@ class AmdMainTemplatePlugin {
const mainTemplate = compilation.mainTemplate;
compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
- const externals = chunk.modules.filter((m) => m.external);
+ const externals = chunk.getModules().filter((m) => m.external);
const externalsDepsArray = JSON.stringify(externals.map((m) =>
typeof m.request === "object" ? m.request.amd : m.request
));
diff --git a/node_modules/webpack/lib/AsyncDependenciesBlock.js b/node_modules/webpack/lib/AsyncDependenciesBlock.js
index 0f5603324..27d5988b6 100644
--- a/node_modules/webpack/lib/AsyncDependenciesBlock.js
+++ b/node_modules/webpack/lib/AsyncDependenciesBlock.js
@@ -37,17 +37,7 @@ module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
sortItems() {
super.sortItems();
if(this.chunks) {
- this.chunks.sort((a, b) => {
- let i = 0;
- while(true) { // eslint-disable-line no-constant-condition
- if(!a.modules[i] && !b.modules[i]) return 0;
- if(!a.modules[i]) return -1;
- if(!b.modules[i]) return 1;
- if(a.modules[i].id > b.modules[i].id) return 1;
- if(a.modules[i].id < b.modules[i].id) return -1;
- i++;
- }
- });
+ this.chunks.sort((a, b) => a.compareTo(b));
}
}
};
diff --git a/node_modules/webpack/lib/BasicEvaluatedExpression.js b/node_modules/webpack/lib/BasicEvaluatedExpression.js
index d811cbebe..eab51de83 100644
--- a/node_modules/webpack/lib/BasicEvaluatedExpression.js
+++ b/node_modules/webpack/lib/BasicEvaluatedExpression.js
@@ -55,8 +55,18 @@ class BasicEvaluatedExpression {
return Object.prototype.hasOwnProperty.call(this, "quasis");
}
+ isTruthy() {
+ return this.truthy;
+ }
+
+ isFalsy() {
+ return this.falsy;
+ }
+
asBool() {
- if(this.isBoolean()) return this.bool;
+ if(this.truthy) return true;
+ else if(this.falsy) return false;
+ else if(this.isBoolean()) return this.bool;
else if(this.isNull()) return false;
else if(this.isString()) return !!this.string;
else if(this.isNumber()) return !!this.number;
@@ -163,6 +173,18 @@ class BasicEvaluatedExpression {
return this;
}
+ setTruthy() {
+ this.falsy = false;
+ this.truthy = true;
+ return this;
+ }
+
+ setFalsy() {
+ this.falsy = true;
+ this.truthy = false;
+ return this;
+ }
+
addOptions(options) {
if(!this.options) this.options = [];
options.forEach(item => {
diff --git a/node_modules/webpack/lib/Chunk.js b/node_modules/webpack/lib/Chunk.js
index 6962fd6c7..8e7cef13c 100644
--- a/node_modules/webpack/lib/Chunk.js
+++ b/node_modules/webpack/lib/Chunk.js
@@ -4,15 +4,23 @@
*/
"use strict";
+const util = require("util");
const compareLocations = require("./compareLocations");
+const SortableSet = require("./util/SortableSet");
let debugId = 1000;
-const byId = (a, b) => {
+const sortById = (a, b) => {
if(a.id < b.id) return -1;
if(b.id < a.id) return 1;
return 0;
};
+const sortByIdentifier = (a, b) => {
+ if(a.identifier() > b.identifier()) return 1;
+ if(a.identifier() < b.identifier()) return -1;
+ return 0;
+};
+
class Chunk {
constructor(name, module, loc) {
@@ -20,7 +28,7 @@ class Chunk {
this.ids = null;
this.debugId = debugId++;
this.name = name;
- this.modules = [];
+ this._modules = new SortableSet(undefined, sortByIdentifier);
this.entrypoints = [];
this.chunks = [];
this.parents = [];
@@ -88,7 +96,11 @@ class Chunk {
}
addModule(module) {
- return this.addToCollection(this.modules, module);
+ if(!this._modules.has(module)) {
+ this._modules.add(module);
+ return true;
+ }
+ return false;
}
addBlock(block) {
@@ -96,9 +108,7 @@ class Chunk {
}
removeModule(module) {
- const idx = this.modules.indexOf(module);
- if(idx >= 0) {
- this.modules.splice(idx, 1);
+ if(this._modules.delete(module)) {
module.removeChunk(this);
return true;
}
@@ -133,9 +143,65 @@ class Chunk {
});
}
+ setModules(modules) {
+ this._modules = new SortableSet(modules, sortByIdentifier);
+ }
+
+ getNumberOfModules() {
+ return this._modules.size;
+ }
+
+ get modulesIterable() {
+ return this._modules;
+ }
+
+ forEachModule(fn) {
+ this._modules.forEach(fn);
+ }
+
+ mapModules(fn) {
+ return Array.from(this._modules, fn);
+ }
+
+ compareTo(otherChunk) {
+ this._modules.sort();
+ otherChunk._modules.sort();
+ if(this._modules.size > otherChunk._modules.size) return -1;
+ if(this._modules.size < otherChunk._modules.size) return 1;
+ const a = this._modules[Symbol.iterator]();
+ const b = otherChunk._modules[Symbol.iterator]();
+ while(true) { // eslint-disable-line
+ const aItem = a.next();
+ const bItem = b.next();
+ if(aItem.done) return 0;
+ const aModuleIdentifier = aItem.value.identifier();
+ const bModuleIdentifier = bItem.value.identifier();
+ if(aModuleIdentifier > bModuleIdentifier) return -1;
+ if(aModuleIdentifier < bModuleIdentifier) return 1;
+ }
+ }
+
+ containsModule(module) {
+ return this._modules.has(module);
+ }
+
+ getModules() {
+ return Array.from(this._modules);
+ }
+
+ getModulesIdent() {
+ this._modules.sort();
+ let str = "";
+ this._modules.forEach(m => {
+ str += m.identifier() + "#";
+ });
+ return str;
+ }
+
remove(reason) {
// cleanup modules
- this.modules.slice().forEach(module => {
+ // Array.from is used here to create a clone, because removeChunk modifies this._modules
+ Array.from(this._modules).forEach(module => {
module.removeChunk(this);
});
@@ -219,9 +285,10 @@ class Chunk {
return false;
}
- const otherChunkModules = otherChunk.modules.slice();
+ // Array.from is used here to create a clone, because moveModule modifies otherChunk._modules
+ const otherChunkModules = Array.from(otherChunk._modules);
otherChunkModules.forEach(module => otherChunk.moveModule(module, this));
- otherChunk.modules.length = 0;
+ otherChunk._modules.clear();
otherChunk.parents.forEach(parentChunk => parentChunk.replaceChunk(otherChunk, this));
otherChunk.parents.length = 0;
@@ -276,14 +343,14 @@ class Chunk {
}
isEmpty() {
- return this.modules.length === 0;
+ return this._modules.size === 0;
}
updateHash(hash) {
hash.update(`${this.id} `);
hash.update(this.ids ? this.ids.join(",") : "");
hash.update(`${this.name || ""} `);
- this.modules.forEach(m => m.updateHash(hash));
+ this._modules.forEach(m => m.updateHash(hash));
}
canBeIntegrated(otherChunk) {
@@ -307,8 +374,8 @@ class Chunk {
modulesSize() {
let count = 0;
- for(let i = 0; i < this.modules.length; i++) {
- count += this.modules[i].size();
+ for(const module of this._modules) {
+ count += module.size();
}
return count;
}
@@ -325,9 +392,8 @@ class Chunk {
let integratedModulesSize = this.modulesSize();
// only count modules that do not exist in this chunk!
- for(let i = 0; i < otherChunk.modules.length; i++) {
- const otherModule = otherChunk.modules[i];
- if(this.modules.indexOf(otherModule) === -1) {
+ for(const otherModule of otherChunk._modules) {
+ if(!this._modules.has(otherModule)) {
integratedModulesSize += otherModule.size();
}
}
@@ -355,8 +421,12 @@ class Chunk {
};
}
+ sortModules(sortByFn) {
+ this._modules.sortWith(sortByFn || sortById);
+ }
+
sortItems() {
- this.modules.sort(byId);
+ this.sortModules();
this.origins.sort((a, b) => {
const aIdent = a.module.identifier();
const bIdent = b.module.identifier();
@@ -368,12 +438,12 @@ class Chunk {
if(origin.reasons)
origin.reasons.sort();
});
- this.parents.sort(byId);
- this.chunks.sort(byId);
+ this.parents.sort(sortById);
+ this.chunks.sort(sortById);
}
toString() {
- return `Chunk[${this.modules.join()}]`;
+ return `Chunk[${Array.from(this._modules).join()}]`;
}
checkConstraints() {
@@ -393,4 +463,14 @@ class Chunk {
}
}
+Object.defineProperty(Chunk.prototype, "modules", {
+ configurable: false,
+ get: util.deprecate(function() {
+ return Array.from(this._modules);
+ }, "Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsModule instead."),
+ set: util.deprecate(function(value) {
+ this.setModules(value);
+ }, "Chunk.modules is deprecated. Use Chunk.addModule/removeModule instead.")
+});
+
module.exports = Chunk;
diff --git a/node_modules/webpack/lib/Compilation.js b/node_modules/webpack/lib/Compilation.js
index 4ac48da50..b59c0eb53 100644
--- a/node_modules/webpack/lib/Compilation.js
+++ b/node_modules/webpack/lib/Compilation.js
@@ -22,6 +22,7 @@ const Dependency = require("./Dependency");
const ChunkRenderError = require("./ChunkRenderError");
const CachedSource = require("webpack-sources").CachedSource;
const Stats = require("./Stats");
+const Semaphore = require("./util/Semaphore");
function byId(a, b) {
if(a.id < b.id) return -1;
@@ -62,6 +63,8 @@ class Compilation extends Tapable {
this.hotUpdateChunkTemplate = new HotUpdateChunkTemplate(this.outputOptions);
this.moduleTemplate = new ModuleTemplate(this.outputOptions);
+ this.semaphore = new Semaphore(options.parallelism || 100);
+
this.entries = [];
this.preparedChunks = [];
this.entrypoints = {};
@@ -80,6 +83,8 @@ class Compilation extends Tapable {
this.children = [];
this.dependencyFactories = new Map();
this.dependencyTemplates = new Map();
+ this.dependencyTemplates.set("hash", "");
+ this.childrenCounters = {};
}
getStats() {
@@ -112,8 +117,6 @@ class Compilation extends Tapable {
cacheModule.errors.forEach(err => this.errors.push(err), this);
cacheModule.warnings.forEach(err => this.warnings.push(err), this);
return cacheModule;
- } else {
- module.lastId = cacheModule.id;
}
}
module.unbuild();
@@ -229,120 +232,128 @@ class Compilation extends Tapable {
callback();
};
- const factory = item[0];
- factory.create({
- contextInfo: {
- issuer: module.nameForCondition && module.nameForCondition(),
- compiler: _this.compiler.name
- },
- context: module.context,
- dependencies: dependencies
- }, function factoryCallback(err, dependentModule) {
- let afterFactory;
-
- function isOptional() {
- return dependencies.filter(d => !d.optional).length === 0;
- }
+ _this.semaphore.acquire(() => {
+ const factory = item[0];
+ factory.create({
+ contextInfo: {
+ issuer: module.nameForCondition && module.nameForCondition(),
+ compiler: _this.compiler.name
+ },
+ context: module.context,
+ dependencies: dependencies
+ }, function factoryCallback(err, dependentModule) {
+ let afterFactory;
+
+ function isOptional() {
+ return dependencies.filter(d => !d.optional).length === 0;
+ }
- function errorOrWarningAndCallback(err) {
- if(isOptional()) {
- return warningAndCallback(err);
- } else {
- return errorAndCallback(err);
+ function errorOrWarningAndCallback(err) {
+ if(isOptional()) {
+ return warningAndCallback(err);
+ } else {
+ return errorAndCallback(err);
+ }
}
- }
- function iterationDependencies(depend) {
- for(let index = 0; index < depend.length; index++) {
- const dep = depend[index];
- dep.module = dependentModule;
- dependentModule.addReason(module, dep);
+ function iterationDependencies(depend) {
+ for(let index = 0; index < depend.length; index++) {
+ const dep = depend[index];
+ dep.module = dependentModule;
+ dependentModule.addReason(module, dep);
+ }
}
- }
- if(err) {
- return errorOrWarningAndCallback(new ModuleNotFoundError(module, err, dependencies));
- }
- if(!dependentModule) {
- return process.nextTick(callback);
- }
- if(_this.profile) {
- if(!dependentModule.profile) {
- dependentModule.profile = {};
+ if(err) {
+ _this.semaphore.release();
+ return errorOrWarningAndCallback(new ModuleNotFoundError(module, err, dependencies));
+ }
+ if(!dependentModule) {
+ _this.semaphore.release();
+ return process.nextTick(callback);
+ }
+ if(_this.profile) {
+ if(!dependentModule.profile) {
+ dependentModule.profile = {};
+ }
+ afterFactory = Date.now();
+ dependentModule.profile.factory = afterFactory - start;
}
- afterFactory = Date.now();
- dependentModule.profile.factory = afterFactory - start;
- }
- dependentModule.issuer = module;
- const newModule = _this.addModule(dependentModule, cacheGroup);
+ dependentModule.issuer = module;
+ const newModule = _this.addModule(dependentModule, cacheGroup);
- if(!newModule) { // from cache
- dependentModule = _this.getModule(dependentModule);
+ if(!newModule) { // from cache
+ dependentModule = _this.getModule(dependentModule);
- if(dependentModule.optional) {
- dependentModule.optional = isOptional();
- }
+ if(dependentModule.optional) {
+ dependentModule.optional = isOptional();
+ }
- iterationDependencies(dependencies);
+ iterationDependencies(dependencies);
- if(_this.profile) {
- if(!module.profile) {
- module.profile = {};
- }
- const time = Date.now() - start;
- if(!module.profile.dependencies || time > module.profile.dependencies) {
- module.profile.dependencies = time;
+ if(_this.profile) {
+ if(!module.profile) {
+ module.profile = {};
+ }
+ const time = Date.now() - start;
+ if(!module.profile.dependencies || time > module.profile.dependencies) {
+ module.profile.dependencies = time;
+ }
}
+
+ _this.semaphore.release();
+ return process.nextTick(callback);
}
- return process.nextTick(callback);
- }
+ if(newModule instanceof Module) {
+ if(_this.profile) {
+ newModule.profile = dependentModule.profile;
+ }
- if(newModule instanceof Module) {
- if(_this.profile) {
- newModule.profile = dependentModule.profile;
- }
+ newModule.optional = isOptional();
+ newModule.issuer = dependentModule.issuer;
+ dependentModule = newModule;
- newModule.optional = isOptional();
- newModule.issuer = dependentModule.issuer;
- dependentModule = newModule;
+ iterationDependencies(dependencies);
- iterationDependencies(dependencies);
+ if(_this.profile) {
+ const afterBuilding = Date.now();
+ module.profile.building = afterBuilding - afterFactory;
+ }
- if(_this.profile) {
- const afterBuilding = Date.now();
- module.profile.building = afterBuilding - afterFactory;
+ _this.semaphore.release();
+ if(recursive) {
+ return process.nextTick(_this.processModuleDependencies.bind(_this, dependentModule, callback));
+ } else {
+ return process.nextTick(callback);
+ }
}
- if(recursive) {
- return process.nextTick(_this.processModuleDependencies.bind(_this, dependentModule, callback));
- } else {
- return process.nextTick(callback);
- }
- }
+ dependentModule.optional = isOptional();
- dependentModule.optional = isOptional();
+ iterationDependencies(dependencies);
- iterationDependencies(dependencies);
+ _this.buildModule(dependentModule, isOptional(), module, dependencies, err => {
+ if(err) {
+ _this.semaphore.release();
+ return errorOrWarningAndCallback(err);
+ }
- _this.buildModule(dependentModule, isOptional(), module, dependencies, err => {
- if(err) {
- return errorOrWarningAndCallback(err);
- }
+ if(_this.profile) {
+ const afterBuilding = Date.now();
+ dependentModule.profile.building = afterBuilding - afterFactory;
+ }
- if(_this.profile) {
- const afterBuilding = Date.now();
- dependentModule.profile.building = afterBuilding - afterFactory;
- }
+ _this.semaphore.release();
+ if(recursive) {
+ _this.processModuleDependencies(dependentModule, callback);
+ } else {
+ return callback();
+ }
+ });
- if(recursive) {
- _this.processModuleDependencies(dependentModule, callback);
- } else {
- return callback();
- }
});
-
});
}, function finalCallbackAddModuleDependencies(err) {
// In V8, the Error objects keep a reference to the functions on the stack. These warnings &
@@ -362,13 +373,13 @@ class Compilation extends Tapable {
_addModuleChain(context, dependency, onModule, callback) {
const start = this.profile && Date.now();
- const errorAndCallback = this.bail ? function errorAndCallback(err) {
+ const errorAndCallback = this.bail ? (err) => {
callback(err);
- } : function errorAndCallback(err) {
+ } : (err) => {
err.dependencies = [dependency];
this.errors.push(err);
callback();
- }.bind(this);
+ };
if(typeof dependency !== "object" || dependency === null || !dependency.constructor) {
throw new Error("Parameter 'dependency' must be a Dependency");
@@ -379,79 +390,85 @@ class Compilation extends Tapable {
throw new Error(`No dependency factory available for this dependency type: ${dependency.constructor.name}`);
}
- moduleFactory.create({
- contextInfo: {
- issuer: "",
- compiler: this.compiler.name
- },
- context: context,
- dependencies: [dependency]
- }, (err, module) => {
- if(err) {
- return errorAndCallback(new EntryModuleNotFoundError(err));
- }
-
- let afterFactory;
-
- if(this.profile) {
- if(!module.profile) {
- module.profile = {};
+ this.semaphore.acquire(() => {
+ moduleFactory.create({
+ contextInfo: {
+ issuer: "",
+ compiler: this.compiler.name
+ },
+ context: context,
+ dependencies: [dependency]
+ }, (err, module) => {
+ if(err) {
+ this.semaphore.release();
+ return errorAndCallback(new EntryModuleNotFoundError(err));
}
- afterFactory = Date.now();
- module.profile.factory = afterFactory - start;
- }
-
- const result = this.addModule(module);
- if(!result) {
- module = this.getModule(module);
- onModule(module);
+ let afterFactory;
if(this.profile) {
- const afterBuilding = Date.now();
- module.profile.building = afterBuilding - afterFactory;
+ if(!module.profile) {
+ module.profile = {};
+ }
+ afterFactory = Date.now();
+ module.profile.factory = afterFactory - start;
}
- return callback(null, module);
- }
+ const result = this.addModule(module);
+ if(!result) {
+ module = this.getModule(module);
- if(result instanceof Module) {
- if(this.profile) {
- result.profile = module.profile;
- }
+ onModule(module);
- module = result;
+ if(this.profile) {
+ const afterBuilding = Date.now();
+ module.profile.building = afterBuilding - afterFactory;
+ }
- onModule(module);
+ this.semaphore.release();
+ return callback(null, module);
+ }
- moduleReady.call(this);
- return;
- }
+ if(result instanceof Module) {
+ if(this.profile) {
+ result.profile = module.profile;
+ }
- onModule(module);
+ module = result;
- this.buildModule(module, false, null, null, (err) => {
- if(err) {
- return errorAndCallback(err);
- }
+ onModule(module);
- if(this.profile) {
- const afterBuilding = Date.now();
- module.profile.building = afterBuilding - afterFactory;
+ moduleReady.call(this);
+ return;
}
- moduleReady.call(this);
- });
+ onModule(module);
- function moduleReady() {
- this.processModuleDependencies(module, err => {
+ this.buildModule(module, false, null, null, (err) => {
if(err) {
- return callback(err);
+ this.semaphore.release();
+ return errorAndCallback(err);
}
- return callback(null, module);
+ if(this.profile) {
+ const afterBuilding = Date.now();
+ module.profile.building = afterBuilding - afterFactory;
+ }
+
+ moduleReady.call(this);
});
- }
+
+ function moduleReady() {
+ this.semaphore.release();
+ this.processModuleDependencies(module, err => {
+ if(err) {
+ return callback(err);
+ }
+
+ return callback(null, module);
+ });
+ }
+ });
});
}
@@ -511,7 +528,7 @@ class Compilation extends Tapable {
if(err) return callback(err);
deps.forEach(d => {
if(d.module && d.module.removeReason(module, d)) {
- module.chunks.forEach(chunk => {
+ module.forEachChunk(chunk => {
if(!d.module.hasReasonForChunk(chunk)) {
if(d.module.removeChunk(chunk)) {
this.removeChunkFromDependencies(d.module, chunk);
@@ -568,12 +585,12 @@ class Compilation extends Tapable {
while(self.applyPluginsBailResult1("optimize-modules-basic", self.modules) ||
self.applyPluginsBailResult1("optimize-modules", self.modules) ||
- self.applyPluginsBailResult1("optimize-modules-advanced", self.modules)); // eslint-disable-line no-extra-semi
+ self.applyPluginsBailResult1("optimize-modules-advanced", self.modules)) { /* empty */ }
self.applyPlugins1("after-optimize-modules", self.modules);
while(self.applyPluginsBailResult1("optimize-chunks-basic", self.chunks) ||
self.applyPluginsBailResult1("optimize-chunks", self.chunks) ||
- self.applyPluginsBailResult1("optimize-chunks-advanced", self.chunks)); // eslint-disable-line no-extra-semi
+ self.applyPluginsBailResult1("optimize-chunks-advanced", self.chunks)) { /* empty */ }
self.applyPlugins1("after-optimize-chunks", self.chunks);
self.applyPluginsAsyncSeries("optimize-tree", self.chunks, self.modules, function sealPart2(err) {
@@ -583,6 +600,11 @@ class Compilation extends Tapable {
self.applyPlugins2("after-optimize-tree", self.chunks, self.modules);
+ while(self.applyPluginsBailResult("optimize-chunk-modules-basic", self.chunks, self.modules) ||
+ self.applyPluginsBailResult("optimize-chunk-modules", self.chunks, self.modules) ||
+ self.applyPluginsBailResult("optimize-chunk-modules-advanced", self.chunks, self.modules)) { /* empty */ }
+ self.applyPlugins2("after-optimize-chunk-modules", self.chunks, self.modules);
+
const shouldRecord = self.applyPluginsBailResult("should-record") !== false;
self.applyPlugins2("revive-modules", self.modules, self.records);
@@ -824,7 +846,11 @@ class Compilation extends Tapable {
}
}
- processDependenciesBlockForChunk(block, chunk) {
+ processDependenciesBlockForChunk(module, chunk) {
+ let block = module;
+ const initialChunk = chunk;
+ const chunkDependencies = new Map(); // Map<Chunk, Array<{Module, Chunk}>>
+
const iteratorBlock = b => {
let c;
if(!b.chunks) {
@@ -834,9 +860,17 @@ class Compilation extends Tapable {
} else {
c = b.chunks[0];
}
- chunk.addChunk(c);
- c.addParent(chunk);
- queue.push([b, c]);
+ let deps = chunkDependencies.get(chunk);
+ if(!deps) chunkDependencies.set(chunk, deps = []);
+ deps.push({
+ chunk: c,
+ module
+ });
+ queue.push({
+ block: b,
+ module: null,
+ chunk: c
+ });
};
const iteratorDependency = d => {
@@ -848,18 +882,25 @@ class Compilation extends Tapable {
}
if(chunk.addModule(d.module)) {
d.module.addChunk(chunk);
- queue.push([d.module, chunk]);
+ queue.push({
+ block: d.module,
+ module: d.module,
+ chunk
+ });
}
};
- const queue = [
- [block, chunk]
- ];
+ const queue = [{
+ block,
+ module,
+ chunk
+ }];
while(queue.length) {
const queueItem = queue.pop();
- block = queueItem[0];
- chunk = queueItem[1];
+ block = queueItem.block;
+ module = queueItem.module;
+ chunk = queueItem.chunk;
if(block.variables) {
iterationBlockVariable(block.variables, iteratorDependency);
@@ -873,6 +914,47 @@ class Compilation extends Tapable {
iterationOfArrayCallback(block.blocks, iteratorBlock);
}
}
+
+ chunk = initialChunk;
+ let chunks = new Set();
+ const queue2 = [{
+ chunk,
+ chunks
+ }];
+
+ const filterFn = dep => {
+ if(chunks.has(dep.chunk)) return false;
+ for(const chunk of chunks) {
+ if(chunk.containsModule(dep.module))
+ return false;
+ }
+ return true;
+ };
+
+ while(queue2.length) {
+ const queueItem = queue2.pop();
+ chunk = queueItem.chunk;
+ chunks = queueItem.chunks;
+
+ const deps = chunkDependencies.get(chunk);
+ if(!deps) continue;
+
+ const depsFiltered = deps.filter(filterFn);
+
+ for(let i = 0; i < depsFiltered.length; i++) {
+ const dep = depsFiltered[i];
+ const depChunk = dep.chunk;
+ chunk.addChunk(depChunk);
+ depChunk.addParent(chunk);
+
+ const newChunks = depsFiltered.length > 1 ? new Set(chunks) : chunks;
+ newChunks.add(chunk);
+ queue2.push({
+ chunk: depChunk,
+ chunks: newChunks
+ });
+ }
+ }
}
removeChunkFromDependencies(block, chunk) {
@@ -1017,7 +1099,7 @@ class Compilation extends Tapable {
const modules = this.modules;
for(let indexModule = 0; indexModule < modules.length; indexModule++) {
- modules[indexModule].sortItems();
+ modules[indexModule].sortItems(false);
}
const chunks = this.chunks;
@@ -1031,13 +1113,24 @@ class Compilation extends Tapable {
const modules = this.modules;
for(let indexModule = 0; indexModule < modules.length; indexModule++) {
- modules[indexModule].sortItems();
+ modules[indexModule].sortItems(true);
}
const chunks = this.chunks;
for(let indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
chunks[indexChunk].sortItems();
}
+
+ const byMessage = (a, b) => {
+ const ma = `${a.message}`;
+ const mb = `${b.message}`;
+ if(ma < mb) return -1;
+ if(mb < ma) return 1;
+ return 0;
+ };
+
+ this.errors.sort(byMessage);
+ this.warnings.sort(byMessage);
}
summarizeDependencies() {
@@ -1106,6 +1199,12 @@ class Compilation extends Tapable {
this.children.forEach(function(child) {
hash.update(child.hash);
});
+ this.warnings.forEach(function(warning) {
+ hash.update(`${warning.message}`);
+ });
+ this.errors.forEach(function(error) {
+ hash.update(`${error.message}`);
+ });
// clone needed as sort below is inplace mutation
const chunks = this.chunks.slice();
/**
@@ -1218,8 +1317,10 @@ class Compilation extends Tapable {
return this.mainTemplate.applyPluginsWaterfall("asset-path", filename, data);
}
- createChildCompiler(name, outputOptions) {
- return this.compiler.createChildCompiler(this, name, outputOptions);
+ createChildCompiler(name, outputOptions, plugins) {
+ var idx = (this.childrenCounters[name] || 0);
+ this.childrenCounters[name] = idx + 1;
+ return this.compiler.createChildCompiler(this, name, idx, outputOptions, plugins);
}
checkConstraints() {
diff --git a/node_modules/webpack/lib/Compiler.js b/node_modules/webpack/lib/Compiler.js
index dc17a89f3..8e3118a8c 100644
--- a/node_modules/webpack/lib/Compiler.js
+++ b/node_modules/webpack/lib/Compiler.js
@@ -2,503 +2,528 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var path = require("path");
-var Tapable = require("tapable");
-
-var Compilation = require("./Compilation");
-var Stats = require("./Stats");
-var NormalModuleFactory = require("./NormalModuleFactory");
-var ContextModuleFactory = require("./ContextModuleFactory");
-
-function Watching(compiler, watchOptions, handler) {
- this.startTime = null;
- this.invalid = false;
- this.handler = handler;
- this.closed = false;
- if(typeof watchOptions === "number") {
- this.watchOptions = {
- aggregateTimeout: watchOptions
- };
- } else if(watchOptions && typeof watchOptions === "object") {
- this.watchOptions = Object.assign({}, watchOptions);
- } else {
- this.watchOptions = {};
+"use strict";
+
+const path = require("path");
+const Tapable = require("tapable");
+
+const Compilation = require("./Compilation");
+const Stats = require("./Stats");
+const NormalModuleFactory = require("./NormalModuleFactory");
+const ContextModuleFactory = require("./ContextModuleFactory");
+
+const makePathsRelative = require("./util/identifier").makePathsRelative;
+
+class Watching {
+ constructor(compiler, watchOptions, handler) {
+ this.startTime = null;
+ this.invalid = false;
+ this.handler = handler;
+ this.callbacks = [];
+ this.closed = false;
+ if(typeof watchOptions === "number") {
+ this.watchOptions = {
+ aggregateTimeout: watchOptions
+ };
+ } else if(watchOptions && typeof watchOptions === "object") {
+ this.watchOptions = Object.assign({}, watchOptions);
+ } else {
+ this.watchOptions = {};
+ }
+ this.watchOptions.aggregateTimeout = this.watchOptions.aggregateTimeout || 200;
+ this.compiler = compiler;
+ this.running = true;
+ this.compiler.readRecords(err => {
+ if(err) return this._done(err);
+
+ this._go();
+ });
}
- this.watchOptions.aggregateTimeout = this.watchOptions.aggregateTimeout || 200;
- this.compiler = compiler;
- this.running = true;
- this.compiler.readRecords(function(err) {
- if(err) return this._done(err);
-
- this._go();
- }.bind(this));
-}
-Watching.prototype._go = function() {
- var self = this;
- self.startTime = Date.now();
- self.running = true;
- self.invalid = false;
- self.compiler.applyPluginsAsync("watch-run", self, function(err) {
- if(err) return self._done(err);
- self.compiler.compile(function onCompiled(err, compilation) {
- if(err) return self._done(err);
- if(self.invalid) return self._done();
-
- if(self.compiler.applyPluginsBailResult("should-emit", compilation) === false) {
- return self._done(null, compilation);
- }
+ _go() {
+ this.startTime = Date.now();
+ this.running = true;
+ this.invalid = false;
+ this.compiler.applyPluginsAsync("watch-run", this, err => {
+ if(err) return this._done(err);
+ const onCompiled = (err, compilation) => {
+ if(err) return this._done(err);
+ if(this.invalid) return this._done();
+
+ if(this.compiler.applyPluginsBailResult("should-emit", compilation) === false) {
+ return this._done(null, compilation);
+ }
- self.compiler.emitAssets(compilation, function(err) {
- if(err) return self._done(err);
- if(self.invalid) return self._done();
+ this.compiler.emitAssets(compilation, err => {
+ if(err) return this._done(err);
+ if(this.invalid) return this._done();
- self.compiler.emitRecords(function(err) {
- if(err) return self._done(err);
+ this.compiler.emitRecords(err => {
+ if(err) return this._done(err);
- if(compilation.applyPluginsBailResult("need-additional-pass")) {
- compilation.needAdditionalPass = true;
+ if(compilation.applyPluginsBailResult("need-additional-pass")) {
+ compilation.needAdditionalPass = true;
- var stats = new Stats(compilation);
- stats.startTime = self.startTime;
- stats.endTime = Date.now();
- self.compiler.applyPlugins("done", stats);
+ const stats = new Stats(compilation);
+ stats.startTime = this.startTime;
+ stats.endTime = Date.now();
+ this.compiler.applyPlugins("done", stats);
- self.compiler.applyPluginsAsync("additional-pass", function(err) {
- if(err) return self._done(err);
- self.compiler.compile(onCompiled);
- });
- return;
- }
- return self._done(null, compilation);
+ this.compiler.applyPluginsAsync("additional-pass", err => {
+ if(err) return this._done(err);
+ this.compiler.compile(onCompiled);
+ });
+ return;
+ }
+ return this._done(null, compilation);
+ });
});
- });
+ };
+ this.compiler.compile(onCompiled);
});
- });
-};
-
-Watching.prototype._getStats = function(compilation) {
- var stats = new Stats(compilation);
- stats.startTime = this.startTime;
- stats.endTime = Date.now();
- return stats;
-};
-
-Watching.prototype._done = function(err, compilation) {
- this.running = false;
- if(this.invalid) return this._go();
-
- var stats = compilation ? this._getStats(compilation) : null;
- if(err) {
- this.compiler.applyPlugins("failed", err);
- this.handler(err, stats);
- return;
}
- this.compiler.applyPlugins("done", stats);
- this.handler(null, stats);
- if(!this.closed) {
- this.watch(compilation.fileDependencies, compilation.contextDependencies, compilation.missingDependencies);
- }
-};
-
-Watching.prototype.watch = function(files, dirs, missing) {
- this.pausedWatcher = null;
- this.watcher = this.compiler.watchFileSystem.watch(files, dirs, missing, this.startTime, this.watchOptions, function(err, filesModified, contextModified, missingModified, fileTimestamps, contextTimestamps) {
- this.pausedWatcher = this.watcher;
- this.watcher = null;
- if(err) return this.handler(err);
-
- this.compiler.fileTimestamps = fileTimestamps;
- this.compiler.contextTimestamps = contextTimestamps;
- this.invalidate();
- }.bind(this), function(fileName, changeTime) {
- this.compiler.applyPlugins("invalid", fileName, changeTime);
- }.bind(this));
-};
-
-Watching.prototype.invalidate = function() {
- if(this.watcher) {
- this.pausedWatcher = this.watcher;
- this.watcher.pause();
- this.watcher = null;
+ _getStats(compilation) {
+ const stats = new Stats(compilation);
+ stats.startTime = this.startTime;
+ stats.endTime = Date.now();
+ return stats;
}
- if(this.running) {
- this.invalid = true;
- return false;
- } else {
- this._go();
- }
-};
-
-Watching.prototype.close = function(callback) {
- if(callback === undefined) callback = function() {};
- this.closed = true;
- if(this.watcher) {
- this.watcher.close();
- this.watcher = null;
+ _done(err, compilation) {
+ this.running = false;
+ if(this.invalid) return this._go();
+
+ const stats = compilation ? this._getStats(compilation) : null;
+ if(err) {
+ this.compiler.applyPlugins("failed", err);
+ this.handler(err, stats);
+ return;
+ }
+
+ this.compiler.applyPlugins("done", stats);
+ this.handler(null, stats);
+ if(!this.closed) {
+ this.watch(compilation.fileDependencies, compilation.contextDependencies, compilation.missingDependencies);
+ }
+ this.callbacks.forEach(cb => cb());
+ this.callbacks.length = 0;
}
- if(this.pausedWatcher) {
- this.pausedWatcher.close();
+
+ watch(files, dirs, missing) {
this.pausedWatcher = null;
+ this.watcher = this.compiler.watchFileSystem.watch(files, dirs, missing, this.startTime, this.watchOptions, (err, filesModified, contextModified, missingModified, fileTimestamps, contextTimestamps) => {
+ this.pausedWatcher = this.watcher;
+ this.watcher = null;
+ if(err) return this.handler(err);
+
+ this.compiler.fileTimestamps = fileTimestamps;
+ this.compiler.contextTimestamps = contextTimestamps;
+ this.invalidate();
+ }, (fileName, changeTime) => {
+ this.compiler.applyPlugins("invalid", fileName, changeTime);
+ });
+ }
+
+ invalidate(callback) {
+ if(callback) {
+ this.callbacks.push(callback);
+ }
+ if(this.watcher) {
+ this.pausedWatcher = this.watcher;
+ this.watcher.pause();
+ this.watcher = null;
+ }
+ if(this.running) {
+ this.invalid = true;
+ return false;
+ } else {
+ this._go();
+ }
}
- if(this.running) {
- this.invalid = true;
- this._done = () => {
+
+ close(callback) {
+ if(callback === undefined) callback = function() {};
+
+ this.closed = true;
+ if(this.watcher) {
+ this.watcher.close();
+ this.watcher = null;
+ }
+ if(this.pausedWatcher) {
+ this.pausedWatcher.close();
+ this.pausedWatcher = null;
+ }
+ if(this.running) {
+ this.invalid = true;
+ this._done = () => {
+ this.compiler.applyPlugins("watch-close");
+ callback();
+ };
+ } else {
this.compiler.applyPlugins("watch-close");
callback();
- };
- } else {
- this.compiler.applyPlugins("watch-close");
- callback();
+ }
}
-};
-
-function Compiler() {
- Tapable.call(this);
-
- this.outputPath = "";
- this.outputFileSystem = null;
- this.inputFileSystem = null;
-
- this.recordsInputPath = null;
- this.recordsOutputPath = null;
- this.records = {};
-
- this.fileTimestamps = {};
- this.contextTimestamps = {};
-
- this.resolvers = {
- normal: null,
- loader: null,
- context: null
- };
- var deprecationReported = false;
- this.parser = {
- plugin: function(hook, fn) {
- if(!deprecationReported) {
- console.warn("webpack: Using compiler.parser is deprecated.\n" +
- "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.plugin(/* ... */); });\n}); instead. " +
- "It was called " + new Error().stack.split("\n")[2].trim() + ".");
- deprecationReported = true;
- }
- this.plugin("compilation", function(compilation, data) {
- data.normalModuleFactory.plugin("parser", function(parser) {
- parser.plugin(hook, fn);
- });
- });
- }.bind(this),
- apply: function() {
- var args = arguments;
- if(!deprecationReported) {
- console.warn("webpack: Using compiler.parser is deprecated.\n" +
- "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.apply(/* ... */); });\n}); instead. " +
- "It was called " + new Error().stack.split("\n")[2].trim() + ".");
- deprecationReported = true;
- }
- this.plugin("compilation", function(compilation, data) {
- data.normalModuleFactory.plugin("parser", function(parser) {
- parser.apply.apply(parser, args);
- });
- });
- }.bind(this)
- };
-
- this.options = {};
}
-module.exports = Compiler;
-Compiler.prototype = Object.create(Tapable.prototype);
-Compiler.prototype.constructor = Compiler;
+class Compiler extends Tapable {
+ constructor() {
+ super();
+ this.outputPath = "";
+ this.outputFileSystem = null;
+ this.inputFileSystem = null;
-Compiler.Watching = Watching;
-Compiler.prototype.watch = function(watchOptions, handler) {
- this.fileTimestamps = {};
- this.contextTimestamps = {};
- var watching = new Watching(this, watchOptions, handler);
- return watching;
-};
+ this.recordsInputPath = null;
+ this.recordsOutputPath = null;
+ this.records = {};
+
+ this.fileTimestamps = {};
+ this.contextTimestamps = {};
-Compiler.prototype.run = function(callback) {
- var self = this;
- var startTime = Date.now();
+ this.resolvers = {
+ normal: null,
+ loader: null,
+ context: null
+ };
+ let deprecationReported = false;
+ this.parser = {
+ plugin: (hook, fn) => {
+ if(!deprecationReported) {
+ console.warn("webpack: Using compiler.parser is deprecated.\n" +
+ "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.plugin(/* ... */); });\n}); instead. " +
+ "It was called " + new Error().stack.split("\n")[2].trim() + ".");
+ deprecationReported = true;
+ }
+ this.plugin("compilation", (compilation, data) => {
+ data.normalModuleFactory.plugin("parser", parser => {
+ parser.plugin(hook, fn);
+ });
+ });
+ },
+ apply: () => {
+ const args = arguments;
+ if(!deprecationReported) {
+ console.warn("webpack: Using compiler.parser is deprecated.\n" +
+ "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.apply(/* ... */); });\n}); instead. " +
+ "It was called " + new Error().stack.split("\n")[2].trim() + ".");
+ deprecationReported = true;
+ }
+ this.plugin("compilation", (compilation, data) => {
+ data.normalModuleFactory.plugin("parser", parser => {
+ parser.apply.apply(parser, args);
+ });
+ });
+ }
+ };
- self.applyPluginsAsync("before-run", self, function(err) {
- if(err) return callback(err);
+ this.options = {};
+ }
+
+ watch(watchOptions, handler) {
+ this.fileTimestamps = {};
+ this.contextTimestamps = {};
+ const watching = new Watching(this, watchOptions, handler);
+ return watching;
+ }
+
+ run(callback) {
+ const startTime = Date.now();
- self.applyPluginsAsync("run", self, function(err) {
+ const onCompiled = (err, compilation) => {
if(err) return callback(err);
- self.readRecords(function(err) {
+ if(this.applyPluginsBailResult("should-emit", compilation) === false) {
+ const stats = new Stats(compilation);
+ stats.startTime = startTime;
+ stats.endTime = Date.now();
+ this.applyPlugins("done", stats);
+ return callback(null, stats);
+ }
+
+ this.emitAssets(compilation, err => {
if(err) return callback(err);
- self.compile(function onCompiled(err, compilation) {
- if(err) return callback(err);
+ if(compilation.applyPluginsBailResult("need-additional-pass")) {
+ compilation.needAdditionalPass = true;
- if(self.applyPluginsBailResult("should-emit", compilation) === false) {
- var stats = new Stats(compilation);
- stats.startTime = startTime;
- stats.endTime = Date.now();
- self.applyPlugins("done", stats);
- return callback(null, stats);
- }
+ const stats = new Stats(compilation);
+ stats.startTime = startTime;
+ stats.endTime = Date.now();
+ this.applyPlugins("done", stats);
- self.emitAssets(compilation, function(err) {
+ this.applyPluginsAsync("additional-pass", err => {
if(err) return callback(err);
+ this.compile(onCompiled);
+ });
+ return;
+ }
- if(compilation.applyPluginsBailResult("need-additional-pass")) {
- compilation.needAdditionalPass = true;
+ this.emitRecords(err => {
+ if(err) return callback(err);
- var stats = new Stats(compilation);
- stats.startTime = startTime;
- stats.endTime = Date.now();
- self.applyPlugins("done", stats);
+ const stats = new Stats(compilation);
+ stats.startTime = startTime;
+ stats.endTime = Date.now();
+ this.applyPlugins("done", stats);
+ return callback(null, stats);
+ });
+ });
+ };
- self.applyPluginsAsync("additional-pass", function(err) {
- if(err) return callback(err);
- self.compile(onCompiled);
- });
- return;
- }
+ this.applyPluginsAsync("before-run", this, err => {
+ if(err) return callback(err);
- self.emitRecords(function(err) {
- if(err) return callback(err);
+ this.applyPluginsAsync("run", this, err => {
+ if(err) return callback(err);
- var stats = new Stats(compilation);
- stats.startTime = startTime;
- stats.endTime = Date.now();
- self.applyPlugins("done", stats);
- return callback(null, stats);
- });
- });
+ this.readRecords(err => {
+ if(err) return callback(err);
+
+ this.compile(onCompiled);
});
});
});
- });
-};
-
-Compiler.prototype.runAsChild = function(callback) {
- this.compile(function(err, compilation) {
- if(err) return callback(err);
-
- this.parentCompilation.children.push(compilation);
- Object.keys(compilation.assets).forEach(function(name) {
- this.parentCompilation.assets[name] = compilation.assets[name];
- }.bind(this));
-
- var entries = Object.keys(compilation.entrypoints).map(function(name) {
- return compilation.entrypoints[name].chunks;
- }).reduce(function(array, chunks) {
- return array.concat(chunks);
- }, []);
-
- return callback(null, entries, compilation);
- }.bind(this));
-};
-
-Compiler.prototype.purgeInputFileSystem = function() {
- if(this.inputFileSystem && this.inputFileSystem.purge)
- this.inputFileSystem.purge();
-};
-
-Compiler.prototype.emitAssets = function(compilation, callback) {
- var outputPath;
-
- this.applyPluginsAsync("emit", compilation, function(err) {
- if(err) return callback(err);
- outputPath = compilation.getPath(this.outputPath);
- this.outputFileSystem.mkdirp(outputPath, emitFiles.bind(this));
- }.bind(this));
-
- function emitFiles(err) {
- if(err) return callback(err);
-
- require("async").forEach(Object.keys(compilation.assets), function(file, callback) {
-
- var targetFile = file;
- var queryStringIdx = targetFile.indexOf("?");
- if(queryStringIdx >= 0) {
- targetFile = targetFile.substr(0, queryStringIdx);
- }
+ }
- if(targetFile.match(/\/|\\/)) {
- var dir = path.dirname(targetFile);
- this.outputFileSystem.mkdirp(this.outputFileSystem.join(outputPath, dir), writeOut.bind(this));
- } else writeOut.call(this);
+ runAsChild(callback) {
+ this.compile((err, compilation) => {
+ if(err) return callback(err);
- function writeOut(err) {
- if(err) return callback(err);
- var targetPath = this.outputFileSystem.join(outputPath, targetFile);
- var source = compilation.assets[file];
- if(source.existsAt === targetPath) {
- source.emitted = false;
- return callback();
- }
- var content = source.source();
+ this.parentCompilation.children.push(compilation);
+ Object.keys(compilation.assets).forEach(name => {
+ this.parentCompilation.assets[name] = compilation.assets[name];
+ });
+
+ const entries = Object.keys(compilation.entrypoints).map(name => {
+ return compilation.entrypoints[name].chunks;
+ }).reduce((array, chunks) => {
+ return array.concat(chunks);
+ }, []);
+
+ return callback(null, entries, compilation);
+ });
+ }
+
+ purgeInputFileSystem() {
+ if(this.inputFileSystem && this.inputFileSystem.purge)
+ this.inputFileSystem.purge();
+ }
+
+ emitAssets(compilation, callback) {
+ let outputPath;
+
+ const emitFiles = (err) => {
+ if(err) return callback(err);
- if(!Buffer.isBuffer(content)) {
- content = new Buffer(content, "utf8"); //eslint-disable-line
+ require("async").forEach(Object.keys(compilation.assets), (file, callback) => {
+
+ let targetFile = file;
+ const queryStringIdx = targetFile.indexOf("?");
+ if(queryStringIdx >= 0) {
+ targetFile = targetFile.substr(0, queryStringIdx);
}
- source.existsAt = targetPath;
- source.emitted = true;
- this.outputFileSystem.writeFile(targetPath, content, callback);
- }
+ const writeOut = (err) => {
+ if(err) return callback(err);
+ const targetPath = this.outputFileSystem.join(outputPath, targetFile);
+ const source = compilation.assets[file];
+ if(source.existsAt === targetPath) {
+ source.emitted = false;
+ return callback();
+ }
+ let content = source.source();
+
+ if(!Buffer.isBuffer(content)) {
+ content = new Buffer(content, "utf8"); // eslint-disable-line
+ }
+
+ source.existsAt = targetPath;
+ source.emitted = true;
+ this.outputFileSystem.writeFile(targetPath, content, callback);
+ };
+
+ if(targetFile.match(/\/|\\/)) {
+ const dir = path.dirname(targetFile);
+ this.outputFileSystem.mkdirp(this.outputFileSystem.join(outputPath, dir), writeOut);
+ } else writeOut();
- }.bind(this), function(err) {
+ }, err => {
+ if(err) return callback(err);
+
+ afterEmit.call(this);
+ });
+ };
+
+ this.applyPluginsAsync("emit", compilation, err => {
if(err) return callback(err);
+ outputPath = compilation.getPath(this.outputPath);
+ this.outputFileSystem.mkdirp(outputPath, emitFiles);
+ });
+
+ function afterEmit() {
+ this.applyPluginsAsyncSeries1("after-emit", compilation, err => {
+ if(err) return callback(err);
+
+ return callback();
+ });
+ }
- afterEmit.call(this);
- }.bind(this));
}
- function afterEmit() {
- this.applyPluginsAsyncSeries1("after-emit", compilation, function(err) {
+ emitRecords(callback) {
+ if(!this.recordsOutputPath) return callback();
+ const idx1 = this.recordsOutputPath.lastIndexOf("/");
+ const idx2 = this.recordsOutputPath.lastIndexOf("\\");
+ let recordsOutputPathDirectory = null;
+ if(idx1 > idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx1);
+ if(idx1 < idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx2);
+ if(!recordsOutputPathDirectory) return writeFile.call(this);
+ this.outputFileSystem.mkdirp(recordsOutputPathDirectory, err => {
if(err) return callback(err);
+ writeFile.call(this);
+ });
+
+ function writeFile() {
+ this.outputFileSystem.writeFile(this.recordsOutputPath, JSON.stringify(this.records, undefined, 2), callback);
+ }
+ }
+ readRecords(callback) {
+ if(!this.recordsInputPath) {
+ this.records = {};
return callback();
+ }
+ this.inputFileSystem.stat(this.recordsInputPath, err => {
+ // It doesn't exist
+ // We can ignore this.
+ if(err) return callback();
+
+ this.inputFileSystem.readFile(this.recordsInputPath, (err, content) => {
+ if(err) return callback(err);
+
+ try {
+ this.records = JSON.parse(content.toString("utf-8"));
+ } catch(e) {
+ e.message = "Cannot parse records: " + e.message;
+ return callback(e);
+ }
+
+ return callback();
+ });
});
}
-};
-
-Compiler.prototype.emitRecords = function emitRecords(callback) {
- if(!this.recordsOutputPath) return callback();
- var idx1 = this.recordsOutputPath.lastIndexOf("/");
- var idx2 = this.recordsOutputPath.lastIndexOf("\\");
- var recordsOutputPathDirectory = null;
- if(idx1 > idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx1);
- if(idx1 < idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx2);
- if(!recordsOutputPathDirectory) return writeFile.call(this);
- this.outputFileSystem.mkdirp(recordsOutputPathDirectory, function(err) {
- if(err) return callback(err);
- writeFile.call(this);
- }.bind(this));
-
- function writeFile() {
- this.outputFileSystem.writeFile(this.recordsOutputPath, JSON.stringify(this.records, undefined, 2), callback);
+ createChildCompiler(compilation, compilerName, compilerIndex, outputOptions, plugins) {
+ const childCompiler = new Compiler();
+ if(Array.isArray(plugins)) {
+ plugins.forEach(plugin => childCompiler.apply(plugin));
+ }
+ for(const name in this._plugins) {
+ if(["make", "compile", "emit", "after-emit", "invalid", "done", "this-compilation"].indexOf(name) < 0)
+ childCompiler._plugins[name] = this._plugins[name].slice();
+ }
+ childCompiler.name = compilerName;
+ childCompiler.outputPath = this.outputPath;
+ childCompiler.inputFileSystem = this.inputFileSystem;
+ childCompiler.outputFileSystem = null;
+ childCompiler.resolvers = this.resolvers;
+ childCompiler.fileTimestamps = this.fileTimestamps;
+ childCompiler.contextTimestamps = this.contextTimestamps;
+
+ const relativeCompilerName = makePathsRelative(this.context, compilerName);
+ if(!this.records[relativeCompilerName]) this.records[relativeCompilerName] = [];
+ if(this.records[relativeCompilerName][compilerIndex])
+ childCompiler.records = this.records[relativeCompilerName][compilerIndex];
+ else
+ this.records[relativeCompilerName].push(childCompiler.records = {});
+
+ if(this.cache) {
+ if(!this.cache.children) this.cache.children = {};
+ if(!this.cache.children[compilerName]) this.cache.children[compilerName] = [];
+ if(this.cache.children[compilerName][compilerIndex])
+ childCompiler.cache = this.cache.children[compilerName][compilerIndex];
+ else
+ this.cache.children[compilerName].push(childCompiler.cache = {});
+ }
+
+ childCompiler.options = Object.create(this.options);
+ childCompiler.options.output = Object.create(childCompiler.options.output);
+ for(const name in outputOptions) {
+ childCompiler.options.output[name] = outputOptions[name];
+ }
+ childCompiler.parentCompilation = compilation;
+ return childCompiler;
}
-};
-Compiler.prototype.readRecords = function readRecords(callback) {
- var self = this;
- if(!self.recordsInputPath) {
- self.records = {};
- return callback();
+ isChild() {
+ return !!this.parentCompilation;
}
- self.inputFileSystem.stat(self.recordsInputPath, function(err) {
- // It doesn't exist
- // We can ignore self.
- if(err) return callback();
-
- self.inputFileSystem.readFile(self.recordsInputPath, function(err, content) {
- if(err) return callback(err);
- try {
- self.records = JSON.parse(content.toString("utf-8"));
- } catch(e) {
- e.message = "Cannot parse records: " + e.message;
- return callback(e);
- }
+ createCompilation() {
+ return new Compilation(this);
+ }
- return callback();
- });
- });
-};
+ newCompilation(params) {
+ const compilation = this.createCompilation();
+ compilation.fileTimestamps = this.fileTimestamps;
+ compilation.contextTimestamps = this.contextTimestamps;
+ compilation.name = this.name;
+ compilation.records = this.records;
+ compilation.compilationDependencies = params.compilationDependencies;
+ this.applyPlugins("this-compilation", compilation, params);
+ this.applyPlugins("compilation", compilation, params);
+ return compilation;
+ }
-Compiler.prototype.createChildCompiler = function(compilation, compilerName, outputOptions, plugins) {
- var childCompiler = new Compiler();
- if(Array.isArray(plugins)) {
- plugins.forEach(plugin => childCompiler.apply(plugin));
+ createNormalModuleFactory() {
+ const normalModuleFactory = new NormalModuleFactory(this.options.context, this.resolvers, this.options.module || {});
+ this.applyPlugins("normal-module-factory", normalModuleFactory);
+ return normalModuleFactory;
}
- for(var name in this._plugins) {
- if(["make", "compile", "emit", "after-emit", "invalid", "done", "this-compilation"].indexOf(name) < 0)
- childCompiler._plugins[name] = this._plugins[name].slice();
+
+ createContextModuleFactory() {
+ const contextModuleFactory = new ContextModuleFactory(this.resolvers, this.inputFileSystem);
+ this.applyPlugins("context-module-factory", contextModuleFactory);
+ return contextModuleFactory;
}
- childCompiler.name = compilerName;
- childCompiler.outputPath = this.outputPath;
- childCompiler.inputFileSystem = this.inputFileSystem;
- childCompiler.outputFileSystem = null;
- childCompiler.resolvers = this.resolvers;
- childCompiler.fileTimestamps = this.fileTimestamps;
- childCompiler.contextTimestamps = this.contextTimestamps;
- if(!this.records[compilerName]) this.records[compilerName] = [];
- this.records[compilerName].push(childCompiler.records = {});
- childCompiler.options = Object.create(this.options);
- childCompiler.options.output = Object.create(childCompiler.options.output);
- for(name in outputOptions) {
- childCompiler.options.output[name] = outputOptions[name];
+
+ newCompilationParams() {
+ const params = {
+ normalModuleFactory: this.createNormalModuleFactory(),
+ contextModuleFactory: this.createContextModuleFactory(),
+ compilationDependencies: []
+ };
+ return params;
}
- childCompiler.parentCompilation = compilation;
- return childCompiler;
-};
-
-Compiler.prototype.isChild = function() {
- return !!this.parentCompilation;
-};
-
-Compiler.prototype.createCompilation = function() {
- return new Compilation(this);
-};
-
-Compiler.prototype.newCompilation = function(params) {
- var compilation = this.createCompilation();
- compilation.fileTimestamps = this.fileTimestamps;
- compilation.contextTimestamps = this.contextTimestamps;
- compilation.name = this.name;
- compilation.records = this.records;
- compilation.compilationDependencies = params.compilationDependencies;
- this.applyPlugins("this-compilation", compilation, params);
- this.applyPlugins("compilation", compilation, params);
- return compilation;
-};
-
-Compiler.prototype.createNormalModuleFactory = function() {
- var normalModuleFactory = new NormalModuleFactory(this.options.context, this.resolvers, this.options.module || {});
- this.applyPlugins("normal-module-factory", normalModuleFactory);
- return normalModuleFactory;
-};
-
-Compiler.prototype.createContextModuleFactory = function() {
- var contextModuleFactory = new ContextModuleFactory(this.resolvers, this.inputFileSystem);
- this.applyPlugins("context-module-factory", contextModuleFactory);
- return contextModuleFactory;
-};
-
-Compiler.prototype.newCompilationParams = function() {
- var params = {
- normalModuleFactory: this.createNormalModuleFactory(),
- contextModuleFactory: this.createContextModuleFactory(),
- compilationDependencies: []
- };
- return params;
-};
-
-Compiler.prototype.compile = function(callback) {
- var self = this;
- var params = self.newCompilationParams();
- self.applyPluginsAsync("before-compile", params, function(err) {
- if(err) return callback(err);
-
- self.applyPlugins("compile", params);
-
- var compilation = self.newCompilation(params);
-
- self.applyPluginsParallel("make", compilation, function(err) {
+
+ compile(callback) {
+ const params = this.newCompilationParams();
+ this.applyPluginsAsync("before-compile", params, err => {
if(err) return callback(err);
- compilation.finish();
+ this.applyPlugins("compile", params);
- compilation.seal(function(err) {
+ const compilation = this.newCompilation(params);
+
+ this.applyPluginsParallel("make", compilation, err => {
if(err) return callback(err);
- self.applyPluginsAsync("after-compile", compilation, function(err) {
+ compilation.finish();
+
+ compilation.seal(err => {
if(err) return callback(err);
- return callback(null, compilation);
+ this.applyPluginsAsync("after-compile", compilation, err => {
+ if(err) return callback(err);
+
+ return callback(null, compilation);
+ });
});
});
});
- });
-};
+ }
+}
+
+Compiler.Watching = Watching;
+module.exports = Compiler;
diff --git a/node_modules/webpack/lib/ContextModule.js b/node_modules/webpack/lib/ContextModule.js
index 9771fcd80..a894e6268 100644
--- a/node_modules/webpack/lib/ContextModule.js
+++ b/node_modules/webpack/lib/ContextModule.js
@@ -140,8 +140,13 @@ class ContextModule extends Module {
this.addBlock(block);
}
- } else {
+ } else if(this.async === "weak" || this.async === "async-weak") {
+
+ // we mark all dependencies as weak
+ dependencies.forEach(dep => dep.weak = true);
+ this.dependencies = dependencies;
+ } else {
// if we are lazy create a new async dependency block per dependency
// and add all blocks to this context
dependencies.forEach((dep, idx) => {
@@ -198,6 +203,58 @@ module.exports = webpackContext;
webpackContext.id = ${JSON.stringify(id)};`;
}
+ getWeakSyncSource(dependencies, id) {
+ const map = this.getUserRequestMap(dependencies);
+ return `var map = ${JSON.stringify(map, null, "\t")};
+function webpackContext(req) {
+ var id = webpackContextResolve(req);
+ if(!__webpack_require__.m[id])
+ throw new Error("Module '" + req + "' ('" + id + "') is not available (weak dependency)");
+ return __webpack_require__(id);
+};
+function webpackContextResolve(req) {
+ var id = map[req];
+ if(!(id + 1)) // check for number or string
+ throw new Error("Cannot find module '" + req + "'.");
+ return id;
+};
+webpackContext.keys = function webpackContextKeys() {
+ return Object.keys(map);
+};
+webpackContext.resolve = webpackContextResolve;
+webpackContext.id = ${JSON.stringify(id)};
+module.exports = webpackContext;`;
+ }
+
+ getAsyncWeakSource(dependencies, id) {
+ const map = this.getUserRequestMap(dependencies);
+
+ return `var map = ${JSON.stringify(map, null, "\t")};
+function webpackAsyncContext(req) {
+ return webpackAsyncContextResolve(req).then(function(id) {
+ if(!__webpack_require__.m[id])
+ throw new Error("Module '" + req + "' ('" + id + "') is not available (weak dependency)");
+ return __webpack_require__(id);
+ });
+};
+function webpackAsyncContextResolve(req) {
+ // Here Promise.resolve().then() is used instead of new Promise() to prevent
+ // uncatched exception popping up in devtools
+ return Promise.resolve().then(function() {
+ var id = map[req];
+ if(!(id + 1)) // check for number or string
+ throw new Error("Cannot find module '" + req + "'.");
+ return id;
+ });
+};
+webpackAsyncContext.keys = function webpackAsyncContextKeys() {
+ return Object.keys(map);
+};
+webpackAsyncContext.resolve = webpackAsyncContextResolve;
+webpackAsyncContext.id = ${JSON.stringify(id)};
+module.exports = webpackAsyncContext;`;
+ }
+
getEagerSource(dependencies, id) {
const map = this.getUserRequestMap(dependencies);
return `var map = ${JSON.stringify(map, null, "\t")};
@@ -205,20 +262,21 @@ function webpackAsyncContext(req) {
return webpackAsyncContextResolve(req).then(__webpack_require__);
};
function webpackAsyncContextResolve(req) {
- return new Promise(function(resolve, reject) {
+ // Here Promise.resolve().then() is used instead of new Promise() to prevent
+ // uncatched exception popping up in devtools
+ return Promise.resolve().then(function() {
var id = map[req];
if(!(id + 1)) // check for number or string
- reject(new Error("Cannot find module '" + req + "'."));
- else
- resolve(id);
+ throw new Error("Cannot find module '" + req + "'.");
+ return id;
});
};
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
return Object.keys(map);
};
webpackAsyncContext.resolve = webpackAsyncContextResolve;
-module.exports = webpackAsyncContext;
-webpackAsyncContext.id = ${JSON.stringify(id)};`;
+webpackAsyncContext.id = ${JSON.stringify(id)};
+module.exports = webpackAsyncContext;`;
}
getLazyOnceSource(block, dependencies, id, outputOptions, requestShortener) {
@@ -240,8 +298,8 @@ webpackAsyncContext.keys = function webpackAsyncContextKeys() {
return Object.keys(map);
};
webpackAsyncContext.resolve = webpackAsyncContextResolve;
-module.exports = webpackAsyncContext;
-webpackAsyncContext.id = ${JSON.stringify(id)};`;
+webpackAsyncContext.id = ${JSON.stringify(id)};
+module.exports = webpackAsyncContext;`;
}
getLazySource(blocks, id) {
@@ -282,8 +340,8 @@ function webpackAsyncContext(req) {
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
return Object.keys(map);
};
-module.exports = webpackAsyncContext;
-webpackAsyncContext.id = ${JSON.stringify(id)};`;
+webpackAsyncContext.id = ${JSON.stringify(id)};
+module.exports = webpackAsyncContext;`;
}
getSourceForEmptyContext(id) {
@@ -298,7 +356,11 @@ webpackEmptyContext.id = ${JSON.stringify(id)};`;
getSourceForEmptyAsyncContext(id) {
return `function webpackEmptyAsyncContext(req) {
- return new Promise(function(resolve, reject) { reject(new Error("Cannot find module '" + req + "'.")); });
+ // Here Promise.resolve().then() is used instead of new Promise() to prevent
+ // uncatched exception popping up in devtools
+ return Promise.resolve().then(function() {
+ throw new Error("Cannot find module '" + req + "'.");
+ });
}
webpackEmptyAsyncContext.keys = function() { return []; };
webpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;
@@ -318,13 +380,25 @@ webpackEmptyAsyncContext.id = ${JSON.stringify(id)};`;
return this.getEagerSource(this.dependencies, this.id);
}
return this.getSourceForEmptyAsyncContext(this.id);
- } else if(asyncMode === "lazy-once") {
+ }
+ if(asyncMode === "lazy-once") {
const block = this.blocks[0];
if(block) {
return this.getLazyOnceSource(block, block.dependencies, this.id, outputOptions, requestShortener);
}
return this.getSourceForEmptyAsyncContext(this.id);
}
+ if(asyncMode === "async-weak") {
+ if(this.dependencies && this.dependencies.length > 0) {
+ return this.getAsyncWeakSource(this.dependencies, this.id);
+ }
+ return this.getSourceForEmptyAsyncContext(this.id);
+ }
+ if(asyncMode === "weak") {
+ if(this.dependencies && this.dependencies.length > 0) {
+ return this.getWeakSyncSource(this.dependencies, this.id);
+ }
+ }
if(this.dependencies && this.dependencies.length > 0) {
return this.getSyncSource(this.dependencies, this.id);
}
diff --git a/node_modules/webpack/lib/ContextModuleFactory.js b/node_modules/webpack/lib/ContextModuleFactory.js
index a2b666fad..a5947064b 100644
--- a/node_modules/webpack/lib/ContextModuleFactory.js
+++ b/node_modules/webpack/lib/ContextModuleFactory.js
@@ -2,158 +2,159 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var asyncLib = require("async");
-var path = require("path");
-
-var Tapable = require("tapable");
-var ContextModule = require("./ContextModule");
-var ContextElementDependency = require("./dependencies/ContextElementDependency");
-
-function ContextModuleFactory(resolvers) {
- Tapable.call(this);
- this.resolvers = resolvers;
-}
-module.exports = ContextModuleFactory;
-
-ContextModuleFactory.prototype = Object.create(Tapable.prototype);
-ContextModuleFactory.prototype.constructor = ContextModuleFactory;
-
-ContextModuleFactory.prototype.create = function(data, callback) {
- var module = this;
- var context = data.context;
- var dependencies = data.dependencies;
- var dependency = dependencies[0];
- this.applyPluginsAsyncWaterfall("before-resolve", {
- context: context,
- request: dependency.request,
- recursive: dependency.recursive,
- regExp: dependency.regExp,
- async: dependency.async,
- dependencies: dependencies
- }, function(err, result) {
- if(err) return callback(err);
-
- // Ignored
- if(!result) return callback();
-
- var context = result.context;
- var request = result.request;
- var recursive = result.recursive;
- var regExp = result.regExp;
- var asyncContext = result.async;
- var dependencies = result.dependencies;
-
- var loaders, resource, loadersPrefix = "";
- var idx = request.lastIndexOf("!");
- if(idx >= 0) {
- loaders = request.substr(0, idx + 1);
- for(var i = 0; i < loaders.length && loaders[i] === "!"; i++) {
- loadersPrefix += "!";
+"use strict";
+
+const asyncLib = require("async");
+const path = require("path");
+
+const Tapable = require("tapable");
+const ContextModule = require("./ContextModule");
+const ContextElementDependency = require("./dependencies/ContextElementDependency");
+
+module.exports = class ContextModuleFactory extends Tapable {
+ constructor(resolvers) {
+ super();
+ this.resolvers = resolvers;
+ }
+
+ create(data, callback) {
+ const module = this;
+ const context = data.context;
+ const dependencies = data.dependencies;
+ const dependency = dependencies[0];
+ this.applyPluginsAsyncWaterfall("before-resolve", {
+ context: context,
+ request: dependency.request,
+ recursive: dependency.recursive,
+ regExp: dependency.regExp,
+ async: dependency.async,
+ dependencies: dependencies
+ }, (err, result) => {
+ if(err) return callback(err);
+
+ // Ignored
+ if(!result) return callback();
+
+ const context = result.context;
+ const request = result.request;
+ const recursive = result.recursive;
+ const regExp = result.regExp;
+ const asyncContext = result.async;
+ const dependencies = result.dependencies;
+
+ let loaders, resource, loadersPrefix = "";
+ const idx = request.lastIndexOf("!");
+ if(idx >= 0) {
+ loaders = request.substr(0, idx + 1);
+ let i;
+ for(i = 0; i < loaders.length && loaders[i] === "!"; i++) {
+ loadersPrefix += "!";
+ }
+ loaders = loaders.substr(i).replace(/!+$/, "").replace(/!!+/g, "!");
+ if(loaders === "") loaders = [];
+ else loaders = loaders.split("!");
+ resource = request.substr(idx + 1);
+ } else {
+ loaders = [];
+ resource = request;
}
- loaders = loaders.substr(i).replace(/!+$/, "").replace(/!!+/g, "!");
- if(loaders === "") loaders = [];
- else loaders = loaders.split("!");
- resource = request.substr(idx + 1);
- } else {
- loaders = [];
- resource = request;
- }
-
- var resolvers = module.resolvers;
-
- asyncLib.parallel([
- function(callback) {
- resolvers.context.resolve({}, context, resource, function(err, result) {
- if(err) return callback(err);
- callback(null, result);
- });
- },
- function(callback) {
- asyncLib.map(loaders, function(loader, callback) {
- resolvers.loader.resolve({}, context, loader, function(err, result) {
+
+ const resolvers = module.resolvers;
+
+ asyncLib.parallel([
+ function(callback) {
+ resolvers.context.resolve({}, context, resource, function(err, result) {
if(err) return callback(err);
callback(null, result);
});
- }, callback);
- }
- ], function(err, result) {
- if(err) return callback(err);
-
- module.applyPluginsAsyncWaterfall("after-resolve", {
- loaders: loadersPrefix + result[1].join("!") + (result[1].length > 0 ? "!" : ""),
- resource: result[0],
- recursive: recursive,
- regExp: regExp,
- async: asyncContext,
- dependencies: dependencies,
- resolveDependencies: module.resolveDependencies.bind(module)
- }, function(err, result) {
+ },
+ function(callback) {
+ asyncLib.map(loaders, function(loader, callback) {
+ resolvers.loader.resolve({}, context, loader, function(err, result) {
+ if(err) return callback(err);
+ callback(null, result);
+ });
+ }, callback);
+ }
+ ], (err, result) => {
if(err) return callback(err);
- // Ignored
- if(!result) return callback();
+ module.applyPluginsAsyncWaterfall("after-resolve", {
+ loaders: loadersPrefix + result[1].join("!") + (result[1].length > 0 ? "!" : ""),
+ resource: result[0],
+ recursive: recursive,
+ regExp: regExp,
+ async: asyncContext,
+ dependencies: dependencies,
+ resolveDependencies: module.resolveDependencies.bind(module)
+ }, function(err, result) {
+ if(err) return callback(err);
+
+ // Ignored
+ if(!result) return callback();
- return callback(null, new ContextModule(result.resolveDependencies, result.resource, result.recursive, result.regExp, result.loaders, result.async, dependency.chunkName));
+ return callback(null, new ContextModule(result.resolveDependencies, result.resource, result.recursive, result.regExp, result.loaders, result.async, dependency.chunkName));
+ });
});
});
- });
-};
+ }
-ContextModuleFactory.prototype.resolveDependencies = function resolveDependencies(fs, resource, recursive, regExp, callback) {
- if(!regExp || !resource)
- return callback(null, []);
- (function addDirectory(directory, callback) {
- fs.readdir(directory, function(err, files) {
- if(err) return callback(err);
- if(!files || files.length === 0) return callback(null, []);
- asyncLib.map(files.filter(function(p) {
- return p.indexOf(".") !== 0;
- }), function(seqment, callback) {
+ resolveDependencies(fs, resource, recursive, regExp, callback) {
+ if(!regExp || !resource)
+ return callback(null, []);
+ (function addDirectory(directory, callback) {
+ fs.readdir(directory, (err, files) => {
+ if(err) return callback(err);
+ if(!files || files.length === 0) return callback(null, []);
+ asyncLib.map(files.filter(function(p) {
+ return p.indexOf(".") !== 0;
+ }), (seqment, callback) => {
- var subResource = path.join(directory, seqment);
+ const subResource = path.join(directory, seqment);
- fs.stat(subResource, function(err, stat) {
- if(err) return callback(err);
+ fs.stat(subResource, (err, stat) => {
+ if(err) return callback(err);
- if(stat.isDirectory()) {
+ if(stat.isDirectory()) {
- if(!recursive) return callback();
- addDirectory.call(this, subResource, callback);
+ if(!recursive) return callback();
+ addDirectory.call(this, subResource, callback);
- } else if(stat.isFile()) {
+ } else if(stat.isFile()) {
- var obj = {
- context: resource,
- request: "." + subResource.substr(resource.length).replace(/\\/g, "/")
- };
+ const obj = {
+ context: resource,
+ request: "." + subResource.substr(resource.length).replace(/\\/g, "/")
+ };
- this.applyPluginsAsyncWaterfall("alternatives", [obj], function(err, alternatives) {
- if(err) return callback(err);
- alternatives = alternatives.filter(function(obj) {
- return regExp.test(obj.request);
- }).map(function(obj) {
- var dep = new ContextElementDependency(obj.request);
- dep.optional = true;
- return dep;
+ this.applyPluginsAsyncWaterfall("alternatives", [obj], (err, alternatives) => {
+ if(err) return callback(err);
+ alternatives = alternatives.filter(function(obj) {
+ return regExp.test(obj.request);
+ }).map(function(obj) {
+ const dep = new ContextElementDependency(obj.request);
+ dep.optional = true;
+ return dep;
+ });
+ callback(null, alternatives);
});
- callback(null, alternatives);
- });
- } else callback();
+ } else callback();
- }.bind(this));
+ });
- }.bind(this), function(err, result) {
- if(err) return callback(err);
+ }, (err, result) => {
+ if(err) return callback(err);
- if(!result) return callback(null, []);
+ if(!result) return callback(null, []);
- callback(null, result.filter(function(i) {
- return !!i;
- }).reduce(function(a, i) {
- return a.concat(i);
- }, []));
+ callback(null, result.filter(function(i) {
+ return !!i;
+ }).reduce(function(a, i) {
+ return a.concat(i);
+ }, []));
+ });
});
- }.bind(this));
- }.call(this, resource, callback));
+ }.call(this, resource, callback));
+ }
};
diff --git a/node_modules/webpack/lib/DefinePlugin.js b/node_modules/webpack/lib/DefinePlugin.js
index 52bbdfe31..6318124f5 100644
--- a/node_modules/webpack/lib/DefinePlugin.js
+++ b/node_modules/webpack/lib/DefinePlugin.js
@@ -35,7 +35,7 @@ class DefinePlugin {
}(definitions, ""));
function stringifyObj(obj) {
- return "__webpack_require__.i({" + Object.keys(obj).map((key) => {
+ return "Object({" + Object.keys(obj).map((key) => {
const code = obj[key];
return JSON.stringify(key) + ":" + toCode(code);
}).join(",") + "})";
@@ -111,7 +111,7 @@ class DefinePlugin {
function applyObjectDefine(key, obj) {
const code = stringifyObj(obj);
parser.plugin("can-rename " + key, ParserHelpers.approve);
- parser.plugin("evaluate Identifier " + key, (expr) => new BasicEvaluatedExpression().setRange(expr.range));
+ parser.plugin("evaluate Identifier " + key, (expr) => new BasicEvaluatedExpression().setTruthy().setRange(expr.range));
parser.plugin("evaluate typeof " + key, ParserHelpers.evaluateToString("object"));
parser.plugin("expression " + key, ParserHelpers.toConstantDependency(code));
parser.plugin("typeof " + key, ParserHelpers.toConstantDependency(JSON.stringify("object")));
diff --git a/node_modules/webpack/lib/DelegatedModule.js b/node_modules/webpack/lib/DelegatedModule.js
index d06e82214..cd80a21ff 100644
--- a/node_modules/webpack/lib/DelegatedModule.js
+++ b/node_modules/webpack/lib/DelegatedModule.js
@@ -9,20 +9,26 @@ const OriginalSource = require("webpack-sources").OriginalSource;
const RawSource = require("webpack-sources").RawSource;
const WebpackMissingModule = require("./dependencies/WebpackMissingModule");
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
+const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDependency");
class DelegatedModule extends Module {
- constructor(sourceRequest, data, type, userRequest) {
+ constructor(sourceRequest, data, type, userRequest, originalRequest) {
super();
this.sourceRequest = sourceRequest;
this.request = data.id;
this.meta = data.meta;
this.type = type;
+ this.originalRequest = originalRequest;
this.userRequest = userRequest;
this.built = false;
this.delegated = true;
this.delegateData = data;
}
+ libIdent(options) {
+ return typeof this.originalRequest === "string" ? this.originalRequest : this.originalRequest.libIdent(options);
+ }
+
identifier() {
return `delegated ${JSON.stringify(this.request)} from ${this.sourceRequest}`;
}
@@ -38,10 +44,10 @@ class DelegatedModule extends Module {
build(options, compilation, resolver, fs, callback) {
this.built = true;
this.builtTime = Date.now();
- this.usedExports = true;
- this.providedExports = this.delegateData.exports || true;
+ this.cacheable = true;
this.dependencies.length = 0;
this.addDependency(new DelegatedSourceDependency(this.sourceRequest));
+ this.addDependency(new DelegatedExportsDependency(this, this.delegateData.exports || true));
callback();
}
@@ -57,7 +63,7 @@ class DelegatedModule extends Module {
if(!sourceModule) {
str = WebpackMissingModule.moduleCode(this.sourceRequest);
} else {
- str = `module.exports = (__webpack_require__(${sourceModule.id}))`;
+ str = `module.exports = (__webpack_require__(${JSON.stringify(sourceModule.id)}))`;
switch(this.type) {
case "require":
diff --git a/node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js b/node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js
index 501125bd0..f26dfca94 100644
--- a/node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js
+++ b/node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js
@@ -29,13 +29,14 @@ class DelegatedModuleFactoryPlugin {
let resolved;
if(innerRequest in this.options.content) {
resolved = this.options.content[innerRequest];
- return callback(null, new DelegatedModule(this.options.source, resolved, this.options.type, innerRequest));
+ return callback(null, new DelegatedModule(this.options.source, resolved, this.options.type, innerRequest, request));
}
for(let i = 0; i < this.options.extensions.length; i++) {
- const requestPlusExt = innerRequest + this.options.extensions[i];
+ const extension = this.options.extensions[i];
+ const requestPlusExt = innerRequest + extension;
if(requestPlusExt in this.options.content) {
resolved = this.options.content[requestPlusExt];
- return callback(null, new DelegatedModule(this.options.source, resolved, this.options.type, requestPlusExt));
+ return callback(null, new DelegatedModule(this.options.source, resolved, this.options.type, requestPlusExt, request + extension));
}
}
}
@@ -47,7 +48,7 @@ class DelegatedModuleFactoryPlugin {
const request = module.libIdent(this.options);
if(request && request in this.options.content) {
const resolved = this.options.content[request];
- return new DelegatedModule(this.options.source, resolved, this.options.type, request);
+ return new DelegatedModule(this.options.source, resolved, this.options.type, request, module);
}
}
return module;
diff --git a/node_modules/webpack/lib/DelegatedPlugin.js b/node_modules/webpack/lib/DelegatedPlugin.js
index 709ede204..67894d9bd 100644
--- a/node_modules/webpack/lib/DelegatedPlugin.js
+++ b/node_modules/webpack/lib/DelegatedPlugin.js
@@ -7,6 +7,8 @@
const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
+const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDependency");
+const NullFactory = require("./NullFactory");
class DelegatedPlugin {
constructor(options) {
@@ -16,6 +18,7 @@ class DelegatedPlugin {
apply(compiler) {
compiler.plugin("compilation", (compilation, params) => {
compilation.dependencyFactories.set(DelegatedSourceDependency, params.normalModuleFactory);
+ compilation.dependencyFactories.set(DelegatedExportsDependency, new NullFactory());
});
compiler.plugin("compile", (params) => {
diff --git a/node_modules/webpack/lib/DllReferencePlugin.js b/node_modules/webpack/lib/DllReferencePlugin.js
index 39289db61..cd2ef28a6 100644
--- a/node_modules/webpack/lib/DllReferencePlugin.js
+++ b/node_modules/webpack/lib/DllReferencePlugin.js
@@ -7,6 +7,8 @@
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
+const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDependency");
+const NullFactory = require("./NullFactory");
class DllReferencePlugin {
constructor(options) {
@@ -17,6 +19,7 @@ class DllReferencePlugin {
compiler.plugin("compilation", (compilation, params) => {
const normalModuleFactory = params.normalModuleFactory;
compilation.dependencyFactories.set(DelegatedSourceDependency, normalModuleFactory);
+ compilation.dependencyFactories.set(DelegatedExportsDependency, new NullFactory());
});
compiler.plugin("before-compile", (params, callback) => {
diff --git a/node_modules/webpack/lib/EntryOptionPlugin.js b/node_modules/webpack/lib/EntryOptionPlugin.js
index 49b1c798a..03692edd4 100644
--- a/node_modules/webpack/lib/EntryOptionPlugin.js
+++ b/node_modules/webpack/lib/EntryOptionPlugin.js
@@ -1,27 +1,27 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
- */
+*/
"use strict";
const SingleEntryPlugin = require("./SingleEntryPlugin");
const MultiEntryPlugin = require("./MultiEntryPlugin");
const DynamicEntryPlugin = require("./DynamicEntryPlugin");
+function itemToPlugin(context, item, name) {
+ if(Array.isArray(item)) {
+ return new MultiEntryPlugin(context, item, name);
+ }
+ return new SingleEntryPlugin(context, item, name);
+}
+
module.exports = class EntryOptionPlugin {
apply(compiler) {
compiler.plugin("entry-option", (context, entry) => {
- function itemToPlugin(item, name) {
- if(Array.isArray(item)) {
- return new MultiEntryPlugin(context, item, name);
- } else {
- return new SingleEntryPlugin(context, item, name);
- }
- }
if(typeof entry === "string" || Array.isArray(entry)) {
- compiler.apply(itemToPlugin(entry, "main"));
+ compiler.apply(itemToPlugin(context, entry, "main"));
} else if(typeof entry === "object") {
- Object.keys(entry).forEach(name => compiler.apply(itemToPlugin(entry[name], name)));
+ Object.keys(entry).forEach(name => compiler.apply(itemToPlugin(context, entry[name], name)));
} else if(typeof entry === "function") {
compiler.apply(new DynamicEntryPlugin(context, entry));
}
diff --git a/node_modules/webpack/lib/EvalSourceMapDevToolModuleTemplatePlugin.js b/node_modules/webpack/lib/EvalSourceMapDevToolModuleTemplatePlugin.js
index 31c44492a..85aece2f7 100644
--- a/node_modules/webpack/lib/EvalSourceMapDevToolModuleTemplatePlugin.js
+++ b/node_modules/webpack/lib/EvalSourceMapDevToolModuleTemplatePlugin.js
@@ -10,7 +10,7 @@ const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
class EvalSourceMapDevToolModuleTemplatePlugin {
constructor(compilation, options) {
this.compilation = compilation;
- this.sourceMapComment = options.append || "//# sourceMappingURL=[url]";
+ this.sourceMapComment = options.append || "//# sourceURL=[module]\n//# sourceMappingURL=[url]";
this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack:///[resource-path]?[hash]";
this.options = options;
}
@@ -61,13 +61,14 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
sourceMap.sourceRoot = options.sourceRoot || "";
sourceMap.file = `${module.id}.js`;
- const footer = self.sourceMapComment.replace(/\[url\]/g, `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf8").toString("base64")}`); //eslint-disable-line
+ const footer = self.sourceMapComment.replace(/\[url\]/g, `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf8").toString("base64")}`) + //eslint-disable-line
+ `\n//# sourceURL=webpack-internal:///${module.id}\n`; // workaround for chrome bug
source.__EvalSourceMapDevToolData = new RawSource(`eval(${JSON.stringify(content + footer)});`);
return source.__EvalSourceMapDevToolData;
});
moduleTemplate.plugin("hash", function(hash) {
hash.update("eval-source-map");
- hash.update("1");
+ hash.update("2");
});
}
}
diff --git a/node_modules/webpack/lib/ExportPropertyMainTemplatePlugin.js b/node_modules/webpack/lib/ExportPropertyMainTemplatePlugin.js
new file mode 100644
index 000000000..8dd80901e
--- /dev/null
+++ b/node_modules/webpack/lib/ExportPropertyMainTemplatePlugin.js
@@ -0,0 +1,31 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const ConcatSource = require("webpack-sources").ConcatSource;
+
+function accessorToObjectAccess(accessor) {
+ return accessor.map(a => `[${JSON.stringify(a)}]`).join("");
+}
+
+class ExportPropertyMainTemplatePlugin {
+ constructor(property) {
+ this.property = property;
+ }
+
+ apply(compilation) {
+ const mainTemplate = compilation.mainTemplate;
+ compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
+ const postfix = `${accessorToObjectAccess([].concat(this.property))}`;
+ return new ConcatSource(source, postfix);
+ });
+ mainTemplate.plugin("hash", hash => {
+ hash.update("export property");
+ hash.update(`${this.property}`);
+ });
+ }
+}
+
+module.exports = ExportPropertyMainTemplatePlugin;
diff --git a/node_modules/webpack/lib/ExternalModule.js b/node_modules/webpack/lib/ExternalModule.js
index 340d6b61e..2a8137ebc 100644
--- a/node_modules/webpack/lib/ExternalModule.js
+++ b/node_modules/webpack/lib/ExternalModule.js
@@ -10,14 +10,19 @@ const WebpackMissingModule = require("./dependencies/WebpackMissingModule");
const Template = require("./Template");
class ExternalModule extends Module {
- constructor(request, type) {
+ constructor(request, type, userRequest) {
super();
this.request = request;
+ this.userRequest = userRequest;
this.type = type;
this.built = false;
this.external = true;
}
+ libIdent() {
+ return this.userRequest;
+ }
+
chunkCondition(chunk) {
return chunk.hasEntryModule();
}
diff --git a/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js b/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js
index 54cf0a28b..7066aae42 100644
--- a/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js
+++ b/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js
@@ -30,7 +30,7 @@ class ExternalModuleFactoryPlugin {
type = value.substr(0, idx);
value = value.substr(idx + 1);
}
- callback(null, new ExternalModule(value, type || globalType));
+ callback(null, new ExternalModule(value, type || globalType, dependency.request));
return true;
}
(function handleExternals(externals, callback) {
diff --git a/node_modules/webpack/lib/FlagDependencyExportsPlugin.js b/node_modules/webpack/lib/FlagDependencyExportsPlugin.js
index 581c30fa0..ff5e11255 100644
--- a/node_modules/webpack/lib/FlagDependencyExportsPlugin.js
+++ b/node_modules/webpack/lib/FlagDependencyExportsPlugin.js
@@ -19,7 +19,7 @@ class FlagDependencyExportsPlugin {
module = queue[i];
if(module.providedExports !== true) {
- moduleWithExports = false;
+ moduleWithExports = module.meta && module.meta.harmonyModule;
moduleProvidedExports = Array.isArray(module.providedExports) ? new Set(module.providedExports) : new Set();
processDependenciesBlock(module);
if(!moduleWithExports) {
diff --git a/node_modules/webpack/lib/FlagInitialModulesAsUsedPlugin.js b/node_modules/webpack/lib/FlagInitialModulesAsUsedPlugin.js
index 8f68805ed..0356006ab 100644
--- a/node_modules/webpack/lib/FlagInitialModulesAsUsedPlugin.js
+++ b/node_modules/webpack/lib/FlagInitialModulesAsUsedPlugin.js
@@ -12,7 +12,7 @@ class FlagInitialModulesAsUsedPlugin {
if(!chunk.isInitial()) {
return;
}
- chunk.modules.forEach((module) => {
+ chunk.forEachModule((module) => {
module.usedExports = true;
});
});
diff --git a/node_modules/webpack/lib/FunctionModuleTemplatePlugin.js b/node_modules/webpack/lib/FunctionModuleTemplatePlugin.js
index dd20b7867..72e214808 100644
--- a/node_modules/webpack/lib/FunctionModuleTemplatePlugin.js
+++ b/node_modules/webpack/lib/FunctionModuleTemplatePlugin.js
@@ -25,17 +25,23 @@ class FunctionModuleTemplatePlugin {
if(this.outputOptions.pathinfo) {
const source = new ConcatSource();
const req = module.readableIdentifier(this.requestShortener);
+ source.add("/*!****" + req.replace(/./g, "*") + "****!*\\\n");
+ source.add(" !*** " + req.replace(/\*\//g, "*_/") + " ***!\n");
+ source.add(" \\****" + req.replace(/./g, "*") + "****/\n");
if(Array.isArray(module.providedExports))
- source.add("/* exports provided: " + module.providedExports.join(", ") + " */\n");
+ source.add("/*! exports provided: " + module.providedExports.join(", ") + " */\n");
else if(module.providedExports)
- source.add("/* unknown exports provided */\n");
+ source.add("/*! no static exports found */\n");
if(Array.isArray(module.usedExports))
- source.add("/* exports used: " + module.usedExports.join(", ") + " */\n");
+ source.add("/*! exports used: " + module.usedExports.join(", ") + " */\n");
else if(module.usedExports)
- source.add("/* all exports used */\n");
- source.add("/*!****" + req.replace(/./g, "*") + "****!*\\\n");
- source.add(" !*** " + req.replace(/\*\//g, "*_/") + " ***!\n");
- source.add(" \\****" + req.replace(/./g, "*") + "****/\n");
+ source.add("/*! all exports used */\n");
+ if(module.optimizationBailout) {
+ module.optimizationBailout.forEach(text => {
+ if(typeof text === "function") text = text(this.requestShortener);
+ source.add(`/*! ${text} */\n`);
+ });
+ }
source.add(moduleSource);
return source;
}
diff --git a/node_modules/webpack/lib/HotModuleReplacement.runtime.js b/node_modules/webpack/lib/HotModuleReplacement.runtime.js
index 7df072ea8..f537bfdd7 100644
--- a/node_modules/webpack/lib/HotModuleReplacement.runtime.js
+++ b/node_modules/webpack/lib/HotModuleReplacement.runtime.js
@@ -2,11 +2,12 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-/*global $hash$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */
+/*global $hash$ $requestTimeout$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */
module.exports = function() {
var hotApplyOnUpdate = true;
var hotCurrentHash = $hash$; // eslint-disable-line no-unused-vars
+ var hotRequestTimeout = $requestTimeout$;
var hotCurrentModuleData = {};
var hotCurrentChildModule; // eslint-disable-line no-unused-vars
var hotCurrentParents = []; // eslint-disable-line no-unused-vars
@@ -167,7 +168,7 @@ module.exports = function() {
if(hotStatus !== "idle") throw new Error("check() is only allowed in idle status");
hotApplyOnUpdate = apply;
hotSetStatus("check");
- return hotDownloadManifest().then(function(update) {
+ return hotDownloadManifest(hotRequestTimeout).then(function(update) {
if(!update) {
hotSetStatus("idle");
return null;
@@ -227,11 +228,19 @@ module.exports = function() {
hotDeferred = null;
if(!deferred) return;
if(hotApplyOnUpdate) {
- hotApply(hotApplyOnUpdate).then(function(result) {
- deferred.resolve(result);
- }, function(err) {
- deferred.reject(err);
- });
+ // Wrap deferred object in Promise to mark it as a well-handled Promise to
+ // avoid triggering uncaught exception warning in Chrome.
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=465666
+ Promise.resolve().then(function() {
+ return hotApply(hotApplyOnUpdate);
+ }).then(
+ function(result) {
+ deferred.resolve(result);
+ },
+ function(err) {
+ deferred.reject(err);
+ }
+ );
} else {
var outdatedModules = [];
for(var id in hotUpdate) {
@@ -453,6 +462,9 @@ module.exports = function() {
// remove module from cache
delete installedModules[moduleId];
+ // when disposing there is no need to call dispose handler
+ delete outdatedDependencies[moduleId];
+
// remove "parents" references from all children
for(j = 0; j < module.children.length; j++) {
var child = installedModules[module.children[j]];
@@ -498,30 +510,34 @@ module.exports = function() {
for(moduleId in outdatedDependencies) {
if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) {
module = installedModules[moduleId];
- moduleOutdatedDependencies = outdatedDependencies[moduleId];
- var callbacks = [];
- for(i = 0; i < moduleOutdatedDependencies.length; i++) {
- dependency = moduleOutdatedDependencies[i];
- cb = module.hot._acceptedDependencies[dependency];
- if(callbacks.indexOf(cb) >= 0) continue;
- callbacks.push(cb);
- }
- for(i = 0; i < callbacks.length; i++) {
- cb = callbacks[i];
- try {
- cb(moduleOutdatedDependencies);
- } catch(err) {
- if(options.onErrored) {
- options.onErrored({
- type: "accept-errored",
- moduleId: moduleId,
- dependencyId: moduleOutdatedDependencies[i],
- error: err
- });
+ if(module) {
+ moduleOutdatedDependencies = outdatedDependencies[moduleId];
+ var callbacks = [];
+ for(i = 0; i < moduleOutdatedDependencies.length; i++) {
+ dependency = moduleOutdatedDependencies[i];
+ cb = module.hot._acceptedDependencies[dependency];
+ if(cb) {
+ if(callbacks.indexOf(cb) >= 0) continue;
+ callbacks.push(cb);
}
- if(!options.ignoreErrored) {
- if(!error)
- error = err;
+ }
+ for(i = 0; i < callbacks.length; i++) {
+ cb = callbacks[i];
+ try {
+ cb(moduleOutdatedDependencies);
+ } catch(err) {
+ if(options.onErrored) {
+ options.onErrored({
+ type: "accept-errored",
+ moduleId: moduleId,
+ dependencyId: moduleOutdatedDependencies[i],
+ error: err
+ });
+ }
+ if(!options.ignoreErrored) {
+ if(!error)
+ error = err;
+ }
}
}
}
diff --git a/node_modules/webpack/lib/HotModuleReplacementPlugin.js b/node_modules/webpack/lib/HotModuleReplacementPlugin.js
index 640e05e9d..b6dbdd7f7 100644
--- a/node_modules/webpack/lib/HotModuleReplacementPlugin.js
+++ b/node_modules/webpack/lib/HotModuleReplacementPlugin.js
@@ -3,257 +3,249 @@
Author Tobias Koppers @sokra
*/
"use strict";
-var Template = require("./Template");
-var ModuleHotAcceptDependency = require("./dependencies/ModuleHotAcceptDependency");
-var ModuleHotDeclineDependency = require("./dependencies/ModuleHotDeclineDependency");
-var RawSource = require("webpack-sources").RawSource;
-var ConstDependency = require("./dependencies/ConstDependency");
-var NullFactory = require("./NullFactory");
+const Template = require("./Template");
+const ModuleHotAcceptDependency = require("./dependencies/ModuleHotAcceptDependency");
+const ModuleHotDeclineDependency = require("./dependencies/ModuleHotDeclineDependency");
+const RawSource = require("webpack-sources").RawSource;
+const ConstDependency = require("./dependencies/ConstDependency");
+const NullFactory = require("./NullFactory");
const ParserHelpers = require("./ParserHelpers");
-function HotModuleReplacementPlugin(options) {
- options = options || {};
- this.multiStep = options.multiStep;
- this.fullBuildTimeout = options.fullBuildTimeout || 200;
-}
-module.exports = HotModuleReplacementPlugin;
-
-HotModuleReplacementPlugin.prototype.apply = function(compiler) {
- var multiStep = this.multiStep;
- var fullBuildTimeout = this.fullBuildTimeout;
- var hotUpdateChunkFilename = compiler.options.output.hotUpdateChunkFilename;
- var hotUpdateMainFilename = compiler.options.output.hotUpdateMainFilename;
- compiler.plugin("compilation", function(compilation, params) {
- var hotUpdateChunkTemplate = compilation.hotUpdateChunkTemplate;
- if(!hotUpdateChunkTemplate) return;
-
- var normalModuleFactory = params.normalModuleFactory;
-
- compilation.dependencyFactories.set(ConstDependency, new NullFactory());
- compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
-
- compilation.dependencyFactories.set(ModuleHotAcceptDependency, normalModuleFactory);
- compilation.dependencyTemplates.set(ModuleHotAcceptDependency, new ModuleHotAcceptDependency.Template());
-
- compilation.dependencyFactories.set(ModuleHotDeclineDependency, normalModuleFactory);
- compilation.dependencyTemplates.set(ModuleHotDeclineDependency, new ModuleHotDeclineDependency.Template());
-
- compilation.plugin("record", function(compilation, records) {
- if(records.hash === this.hash) return;
- records.hash = compilation.hash;
- records.moduleHashs = {};
- this.modules.forEach(function(module) {
- var identifier = module.identifier();
- var hash = require("crypto").createHash("md5");
- module.updateHash(hash);
- records.moduleHashs[identifier] = hash.digest("hex");
+module.exports = class HotModuleReplacementPlugin {
+ constructor(options) {
+ this.options = options || {};
+ this.multiStep = this.options.multiStep;
+ this.fullBuildTimeout = this.options.fullBuildTimeout || 200;
+ this.requestTimeout = this.options.requestTimeout || 10000;
+ }
+
+ apply(compiler) {
+ const multiStep = this.multiStep;
+ const fullBuildTimeout = this.fullBuildTimeout;
+ const requestTimeout = this.requestTimeout;
+ const hotUpdateChunkFilename = compiler.options.output.hotUpdateChunkFilename;
+ const hotUpdateMainFilename = compiler.options.output.hotUpdateMainFilename;
+ compiler.plugin("compilation", (compilation, params) => {
+ const hotUpdateChunkTemplate = compilation.hotUpdateChunkTemplate;
+ if(!hotUpdateChunkTemplate) return;
+
+ const normalModuleFactory = params.normalModuleFactory;
+
+ compilation.dependencyFactories.set(ConstDependency, new NullFactory());
+ compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
+
+ compilation.dependencyFactories.set(ModuleHotAcceptDependency, normalModuleFactory);
+ compilation.dependencyTemplates.set(ModuleHotAcceptDependency, new ModuleHotAcceptDependency.Template());
+
+ compilation.dependencyFactories.set(ModuleHotDeclineDependency, normalModuleFactory);
+ compilation.dependencyTemplates.set(ModuleHotDeclineDependency, new ModuleHotDeclineDependency.Template());
+
+ compilation.plugin("record", function(compilation, records) {
+ if(records.hash === this.hash) return;
+ records.hash = compilation.hash;
+ records.moduleHashs = {};
+ this.modules.forEach(module => {
+ const identifier = module.identifier();
+ const hash = require("crypto").createHash("md5");
+ module.updateHash(hash);
+ records.moduleHashs[identifier] = hash.digest("hex");
+ });
+ records.chunkHashs = {};
+ this.chunks.forEach(chunk => {
+ records.chunkHashs[chunk.id] = chunk.hash;
+ });
+ records.chunkModuleIds = {};
+ this.chunks.forEach(chunk => {
+ records.chunkModuleIds[chunk.id] = chunk.mapModules(m => m.id);
+ });
+ });
+ let initialPass = false;
+ let recompilation = false;
+ compilation.plugin("after-hash", function() {
+ let records = this.records;
+ if(!records) {
+ initialPass = true;
+ return;
+ }
+ if(!records.hash)
+ initialPass = true;
+ const preHash = records.preHash || "x";
+ const prepreHash = records.prepreHash || "x";
+ if(preHash === this.hash) {
+ recompilation = true;
+ this.modifyHash(prepreHash);
+ return;
+ }
+ records.prepreHash = records.hash || "x";
+ records.preHash = this.hash;
+ this.modifyHash(records.prepreHash);
});
- records.chunkHashs = {};
- this.chunks.forEach(function(chunk) {
- records.chunkHashs[chunk.id] = chunk.hash;
+ compilation.plugin("should-generate-chunk-assets", () => {
+ if(multiStep && !recompilation && !initialPass)
+ return false;
});
- records.chunkModuleIds = {};
- this.chunks.forEach(function(chunk) {
- records.chunkModuleIds[chunk.id] = chunk.modules.map(function(m) {
- return m.id;
- });
+ compilation.plugin("need-additional-pass", () => {
+ if(multiStep && !recompilation && !initialPass)
+ return true;
});
- });
- var initialPass = false;
- var recompilation = false;
- compilation.plugin("after-hash", function() {
- var records = this.records;
- if(!records) {
- initialPass = true;
- return;
- }
- if(!records.hash)
- initialPass = true;
- var preHash = records.preHash || "x";
- var prepreHash = records.prepreHash || "x";
- if(preHash === this.hash) {
- recompilation = true;
- this.modifyHash(prepreHash);
- return;
- }
- records.prepreHash = records.hash || "x";
- records.preHash = this.hash;
- this.modifyHash(records.prepreHash);
- });
- compilation.plugin("should-generate-chunk-assets", function() {
- if(multiStep && !recompilation && !initialPass)
- return false;
- });
- compilation.plugin("need-additional-pass", function() {
- if(multiStep && !recompilation && !initialPass)
- return true;
- });
- compiler.plugin("additional-pass", function(callback) {
- if(multiStep)
- return setTimeout(callback, fullBuildTimeout);
- return callback();
- });
- compilation.plugin("additional-chunk-assets", function() {
- var records = this.records;
- if(records.hash === this.hash) return;
- if(!records.moduleHashs || !records.chunkHashs || !records.chunkModuleIds) return;
- this.modules.forEach(function(module) {
- var identifier = module.identifier();
- var hash = require("crypto").createHash("md5");
- module.updateHash(hash);
- hash = hash.digest("hex");
- module.hotUpdate = records.moduleHashs[identifier] !== hash;
+ compiler.plugin("additional-pass", callback => {
+ if(multiStep)
+ return setTimeout(callback, fullBuildTimeout);
+ return callback();
});
- var hotUpdateMainContent = {
- h: this.hash,
- c: {}
- };
- Object.keys(records.chunkHashs).forEach(function(chunkId) {
- chunkId = isNaN(+chunkId) ? chunkId : +chunkId;
- var currentChunk = this.chunks.find(chunk => chunk.id === chunkId);
- if(currentChunk) {
- var newModules = currentChunk.modules.filter(function(module) {
- return module.hotUpdate;
- });
- var allModules = {};
- currentChunk.modules.forEach(function(module) {
- allModules[module.id] = true;
- });
- var removedModules = records.chunkModuleIds[chunkId].filter(function(id) {
- return !allModules[id];
- });
- if(newModules.length > 0 || removedModules.length > 0) {
- var source = hotUpdateChunkTemplate.render(chunkId, newModules, removedModules, this.hash, this.moduleTemplate, this.dependencyTemplates);
- var filename = this.getPath(hotUpdateChunkFilename, {
- hash: records.hash,
- chunk: currentChunk
+ compilation.plugin("additional-chunk-assets", function() {
+ const records = this.records;
+ if(records.hash === this.hash) return;
+ if(!records.moduleHashs || !records.chunkHashs || !records.chunkModuleIds) return;
+ this.modules.forEach(module => {
+ const identifier = module.identifier();
+ let hash = require("crypto").createHash("md5");
+ module.updateHash(hash);
+ hash = hash.digest("hex");
+ module.hotUpdate = records.moduleHashs[identifier] !== hash;
+ });
+ const hotUpdateMainContent = {
+ h: this.hash,
+ c: {},
+ };
+ Object.keys(records.chunkHashs).forEach(function(chunkId) {
+ chunkId = isNaN(+chunkId) ? chunkId : +chunkId;
+ const currentChunk = this.chunks.find(chunk => chunk.id === chunkId);
+ if(currentChunk) {
+ const newModules = currentChunk.getModules().filter(module => module.hotUpdate);
+ const allModules = {};
+ currentChunk.forEachModule(module => {
+ allModules[module.id] = true;
});
- this.additionalChunkAssets.push(filename);
- this.assets[filename] = source;
- hotUpdateMainContent.c[chunkId] = true;
- currentChunk.files.push(filename);
- this.applyPlugins("chunk-asset", currentChunk, filename);
+ const removedModules = records.chunkModuleIds[chunkId].filter(id => !allModules[id]);
+ if(newModules.length > 0 || removedModules.length > 0) {
+ const source = hotUpdateChunkTemplate.render(chunkId, newModules, removedModules, this.hash, this.moduleTemplate, this.dependencyTemplates);
+ const filename = this.getPath(hotUpdateChunkFilename, {
+ hash: records.hash,
+ chunk: currentChunk
+ });
+ this.additionalChunkAssets.push(filename);
+ this.assets[filename] = source;
+ hotUpdateMainContent.c[chunkId] = true;
+ currentChunk.files.push(filename);
+ this.applyPlugins("chunk-asset", currentChunk, filename);
+ }
+ } else {
+ hotUpdateMainContent.c[chunkId] = false;
}
- } else {
- hotUpdateMainContent.c[chunkId] = false;
- }
- }, this);
- var source = new RawSource(JSON.stringify(hotUpdateMainContent));
- var filename = this.getPath(hotUpdateMainFilename, {
- hash: records.hash
+ }, this);
+ const source = new RawSource(JSON.stringify(hotUpdateMainContent));
+ const filename = this.getPath(hotUpdateMainFilename, {
+ hash: records.hash
+ });
+ this.assets[filename] = source;
});
- this.assets[filename] = source;
- });
- compilation.mainTemplate.plugin("hash", function(hash) {
- hash.update("HotMainTemplateDecorator");
- });
-
- compilation.mainTemplate.plugin("module-require", function(_, chunk, hash, varModuleId) {
- return "hotCreateRequire(" + varModuleId + ")";
- });
+ compilation.mainTemplate.plugin("hash", hash => {
+ hash.update("HotMainTemplateDecorator");
+ });
- compilation.mainTemplate.plugin("require-extensions", function(source) {
- var buf = [source];
- buf.push("");
- buf.push("// __webpack_hash__");
- buf.push(this.requireFn + ".h = function() { return hotCurrentHash; };");
- return this.asString(buf);
- });
+ compilation.mainTemplate.plugin("module-require", (_, chunk, hash, varModuleId) => {
+ return `hotCreateRequire(${varModuleId})`;
+ });
- compilation.mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
- source = this.applyPluginsWaterfall("hot-bootstrap", source, chunk, hash);
- return this.asString([
- source,
- "",
- hotInitCode
- .replace(/\$require\$/g, this.requireFn)
- .replace(/\$hash\$/g, JSON.stringify(hash))
- .replace(/\/\*foreachInstalledChunks\*\//g, chunk.chunks.length > 0 ? "for(var chunkId in installedChunks)" : "var chunkId = " + JSON.stringify(chunk.id) + ";")
- ]);
- });
+ compilation.mainTemplate.plugin("require-extensions", function(source) {
+ const buf = [source];
+ buf.push("");
+ buf.push("// __webpack_hash__");
+ buf.push(this.requireFn + ".h = function() { return hotCurrentHash; };");
+ return this.asString(buf);
+ });
- compilation.mainTemplate.plugin("global-hash", function() {
- return true;
- });
+ compilation.mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
+ source = this.applyPluginsWaterfall("hot-bootstrap", source, chunk, hash);
+ return this.asString([
+ source,
+ "",
+ hotInitCode
+ .replace(/\$require\$/g, this.requireFn)
+ .replace(/\$hash\$/g, JSON.stringify(hash))
+ .replace(/\$requestTimeout\$/g, requestTimeout)
+ .replace(/\/\*foreachInstalledChunks\*\//g, chunk.chunks.length > 0 ? "for(var chunkId in installedChunks)" : `var chunkId = ${JSON.stringify(chunk.id)};`)
+ ]);
+ });
- compilation.mainTemplate.plugin("current-hash", function(_, length) {
- if(isFinite(length))
- return "hotCurrentHash.substr(0, " + length + ")";
- else
- return "hotCurrentHash";
- });
+ compilation.mainTemplate.plugin("global-hash", () => true);
- compilation.mainTemplate.plugin("module-obj", function(source, chunk, hash, varModuleId) {
- return this.asString([
- source + ",",
- "hot: hotCreateModule(" + varModuleId + "),",
- "parents: (hotCurrentParentsTemp = hotCurrentParents, hotCurrentParents = [], hotCurrentParentsTemp),",
- "children: []"
- ]);
- });
+ compilation.mainTemplate.plugin("current-hash", (_, length) => {
+ if(isFinite(length))
+ return `hotCurrentHash.substr(0, ${length})`;
+ else
+ return "hotCurrentHash";
+ });
- params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
- parser.plugin("expression __webpack_hash__", ParserHelpers.toConstantDependency("__webpack_require__.h()"));
- parser.plugin("evaluate typeof __webpack_hash__", ParserHelpers.evaluateToString("string"));
- parser.plugin("evaluate Identifier module.hot", function(expr) {
- return ParserHelpers.evaluateToBoolean(!!this.state.compilation.hotUpdateChunkTemplate)(expr);
+ compilation.mainTemplate.plugin("module-obj", function(source, chunk, hash, varModuleId) {
+ return this.asString([
+ `${source},`,
+ `hot: hotCreateModule(${varModuleId}),`,
+ "parents: (hotCurrentParentsTemp = hotCurrentParents, hotCurrentParents = [], hotCurrentParentsTemp),",
+ "children: []"
+ ]);
});
- parser.plugin("call module.hot.accept", function(expr) {
- if(!this.state.compilation.hotUpdateChunkTemplate) return false;
- if(expr.arguments.length >= 1) {
- var arg = this.evaluateExpression(expr.arguments[0]);
- var params = [],
- requests = [];
- if(arg.isString()) {
- params = [arg];
- } else if(arg.isArray()) {
- params = arg.items.filter(function(param) {
- return param.isString();
- });
+
+ params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
+ parser.plugin("expression __webpack_hash__", ParserHelpers.toConstantDependency("__webpack_require__.h()"));
+ parser.plugin("evaluate typeof __webpack_hash__", ParserHelpers.evaluateToString("string"));
+ parser.plugin("evaluate Identifier module.hot", function(expr) {
+ return ParserHelpers.evaluateToIdentifier("module.hot", !!this.state.compilation.hotUpdateChunkTemplate)(expr);
+ });
+ parser.plugin("call module.hot.accept", function(expr) {
+ if(!this.state.compilation.hotUpdateChunkTemplate) return false;
+ if(expr.arguments.length >= 1) {
+ const arg = this.evaluateExpression(expr.arguments[0]);
+ let params = [];
+ let requests = [];
+ if(arg.isString()) {
+ params = [arg];
+ } else if(arg.isArray()) {
+ params = arg.items.filter(param => param.isString());
+ }
+ if(params.length > 0) {
+ params.forEach((param, idx) => {
+ const request = param.string;
+ const dep = new ModuleHotAcceptDependency(request, param.range);
+ dep.optional = true;
+ dep.loc = Object.create(expr.loc);
+ dep.loc.index = idx;
+ this.state.module.addDependency(dep);
+ requests.push(request);
+ });
+ if(expr.arguments.length > 1)
+ this.applyPluginsBailResult("hot accept callback", expr.arguments[1], requests);
+ else
+ this.applyPluginsBailResult("hot accept without callback", expr, requests);
+ }
}
- if(params.length > 0) {
- params.forEach(function(param, idx) {
- var request = param.string;
- var dep = new ModuleHotAcceptDependency(request, param.range);
+ });
+ parser.plugin("call module.hot.decline", function(expr) {
+ if(!this.state.compilation.hotUpdateChunkTemplate) return false;
+ if(expr.arguments.length === 1) {
+ const arg = this.evaluateExpression(expr.arguments[0]);
+ let params = [];
+ if(arg.isString()) {
+ params = [arg];
+ } else if(arg.isArray()) {
+ params = arg.items.filter(param => param.isString());
+ }
+ params.forEach((param, idx) => {
+ const dep = new ModuleHotDeclineDependency(param.string, param.range);
dep.optional = true;
dep.loc = Object.create(expr.loc);
dep.loc.index = idx;
this.state.module.addDependency(dep);
- requests.push(request);
- }.bind(this));
- if(expr.arguments.length > 1)
- this.applyPluginsBailResult("hot accept callback", expr.arguments[1], requests);
- else
- this.applyPluginsBailResult("hot accept without callback", expr, requests);
- }
- }
- });
- parser.plugin("call module.hot.decline", function(expr) {
- if(!this.state.compilation.hotUpdateChunkTemplate) return false;
- if(expr.arguments.length === 1) {
- var arg = this.evaluateExpression(expr.arguments[0]);
- var params = [];
- if(arg.isString()) {
- params = [arg];
- } else if(arg.isArray()) {
- params = arg.items.filter(function(param) {
- return param.isString();
});
}
- params.forEach(function(param, idx) {
- var dep = new ModuleHotDeclineDependency(param.string, param.range);
- dep.optional = true;
- dep.loc = Object.create(expr.loc);
- dep.loc.index = idx;
- this.state.module.addDependency(dep);
- }.bind(this));
- }
+ });
+ parser.plugin("expression module.hot", ParserHelpers.skipTraversal);
});
- parser.plugin("expression module.hot", ParserHelpers.skipTraversal);
});
- });
+ }
};
-var hotInitCode = Template.getFunctionContent(require("./HotModuleReplacement.runtime.js"));
+const hotInitCode = Template.getFunctionContent(require("./HotModuleReplacement.runtime.js"));
diff --git a/node_modules/webpack/lib/HotUpdateChunkTemplate.js b/node_modules/webpack/lib/HotUpdateChunkTemplate.js
index 89cda0b69..0a83c9a85 100644
--- a/node_modules/webpack/lib/HotUpdateChunkTemplate.js
+++ b/node_modules/webpack/lib/HotUpdateChunkTemplate.js
@@ -5,6 +5,7 @@
"use strict";
const Template = require("./Template");
+const Chunk = require("./Chunk");
module.exports = class HotUpdateChunkTemplate extends Template {
constructor(outputOptions) {
@@ -12,11 +13,11 @@ module.exports = class HotUpdateChunkTemplate extends Template {
}
render(id, modules, removedModules, hash, moduleTemplate, dependencyTemplates) {
- const modulesSource = this.renderChunkModules({
- id: id,
- modules: modules,
- removedModules: removedModules
- }, moduleTemplate, dependencyTemplates);
+ const hotUpdateChunk = new Chunk();
+ hotUpdateChunk.id = id;
+ hotUpdateChunk.setModules(modules);
+ hotUpdateChunk.removedModules = removedModules;
+ const modulesSource = this.renderChunkModules(hotUpdateChunk, moduleTemplate, dependencyTemplates);
const core = this.applyPluginsWaterfall("modules", modulesSource, modules, removedModules, moduleTemplate, dependencyTemplates);
const source = this.applyPluginsWaterfall("render", core, modules, removedModules, hash, id, moduleTemplate, dependencyTemplates);
return source;
diff --git a/node_modules/webpack/lib/JsonpMainTemplate.runtime.js b/node_modules/webpack/lib/JsonpMainTemplate.runtime.js
index dc177376e..bd0e7ba3b 100644
--- a/node_modules/webpack/lib/JsonpMainTemplate.runtime.js
+++ b/node_modules/webpack/lib/JsonpMainTemplate.runtime.js
@@ -18,7 +18,8 @@ module.exports = function() {
head.appendChild(script);
}
- function hotDownloadManifest() { // eslint-disable-line no-unused-vars
+ function hotDownloadManifest(requestTimeout) { // eslint-disable-line no-unused-vars
+ requestTimeout = requestTimeout || 10000;
return new Promise(function(resolve, reject) {
if(typeof XMLHttpRequest === "undefined")
return reject(new Error("No browser support"));
@@ -26,7 +27,7 @@ module.exports = function() {
var request = new XMLHttpRequest();
var requestPath = $require$.p + $hotMainFilename$;
request.open("GET", requestPath, true);
- request.timeout = 10000;
+ request.timeout = requestTimeout;
request.send(null);
} catch(err) {
return reject(err);
diff --git a/node_modules/webpack/lib/JsonpMainTemplatePlugin.js b/node_modules/webpack/lib/JsonpMainTemplatePlugin.js
index daba5b3e3..9a80e099d 100644
--- a/node_modules/webpack/lib/JsonpMainTemplatePlugin.js
+++ b/node_modules/webpack/lib/JsonpMainTemplatePlugin.js
@@ -19,9 +19,7 @@ class JsonpMainTemplatePlugin {
this.indent(
chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(",\n")
),
- "};",
- "",
- "var resolvedPromise = new Promise(function(resolve) { resolve(); });"
+ "};"
]);
}
return source;
@@ -81,26 +79,27 @@ class JsonpMainTemplatePlugin {
});
mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
return this.asString([
- "if(installedChunks[chunkId] === 0) {",
+ "var installedChunkData = installedChunks[chunkId];",
+ "if(installedChunkData === 0) {",
this.indent([
- "return resolvedPromise;"
+ "return new Promise(function(resolve) { resolve(); });"
]),
"}",
"",
"// a Promise means \"currently loading\".",
- "if(installedChunks[chunkId]) {",
+ "if(installedChunkData) {",
this.indent([
- "return installedChunks[chunkId][2];"
+ "return installedChunkData[2];"
]),
"}",
"",
"// setup Promise in chunk cache",
"var promise = new Promise(function(resolve, reject) {",
this.indent([
- "installedChunks[chunkId] = [resolve, reject];"
+ "installedChunkData = installedChunks[chunkId] = [resolve, reject];"
]),
"});",
- "installedChunks[chunkId][2] = promise;",
+ "installedChunkData[2] = promise;",
"",
"// start chunk loading",
"var head = document.getElementsByTagName('head')[0];",
diff --git a/node_modules/webpack/lib/LibManifestPlugin.js b/node_modules/webpack/lib/LibManifestPlugin.js
index 59558f406..dc2f0ae14 100644
--- a/node_modules/webpack/lib/LibManifestPlugin.js
+++ b/node_modules/webpack/lib/LibManifestPlugin.js
@@ -30,21 +30,26 @@ class LibManifestPlugin {
const manifest = {
name,
type: this.options.type,
- content: chunk.modules.reduce((obj, module) => {
+ content: chunk.mapModules(module => {
if(module.libIdent) {
const ident = module.libIdent({
context: this.options.context || compiler.options.context
});
if(ident) {
- obj[ident] = {
- id: module.id,
- meta: module.meta,
- exports: Array.isArray(module.providedExports) ? module.providedExports : undefined
+ return {
+ ident,
+ data: {
+ id: module.id,
+ meta: module.meta,
+ exports: Array.isArray(module.providedExports) ? module.providedExports : undefined
+ }
};
}
}
+ }).filter(Boolean).reduce((obj, item) => {
+ obj[item.ident] = item.data;
return obj;
- }, {})
+ }, Object.create(null))
};
const content = new Buffer(JSON.stringify(manifest), "utf8"); //eslint-disable-line
compiler.outputFileSystem.mkdirp(path.dirname(targetPath), err => {
diff --git a/node_modules/webpack/lib/LibraryTemplatePlugin.js b/node_modules/webpack/lib/LibraryTemplatePlugin.js
index 6e389053d..11ab06074 100644
--- a/node_modules/webpack/lib/LibraryTemplatePlugin.js
+++ b/node_modules/webpack/lib/LibraryTemplatePlugin.js
@@ -26,15 +26,20 @@ function accessorAccess(base, accessor, joinWith) {
class LibraryTemplatePlugin {
- constructor(name, target, umdNamedDefine, auxiliaryComment) {
+ constructor(name, target, umdNamedDefine, auxiliaryComment, exportProperty) {
this.name = name;
this.target = target;
this.umdNamedDefine = umdNamedDefine;
this.auxiliaryComment = auxiliaryComment;
+ this.exportProperty = exportProperty;
}
apply(compiler) {
compiler.plugin("this-compilation", (compilation) => {
+ if(this.exportProperty) {
+ var ExportPropertyMainTemplatePlugin = require("./ExportPropertyMainTemplatePlugin");
+ compilation.apply(new ExportPropertyMainTemplatePlugin(this.exportProperty));
+ }
switch(this.target) {
case "var":
compilation.apply(new SetVarMainTemplatePlugin(`var ${accessorAccess(false, this.name)}`));
diff --git a/node_modules/webpack/lib/MainTemplate.js b/node_modules/webpack/lib/MainTemplate.js
index d14883d15..58a3409d5 100644
--- a/node_modules/webpack/lib/MainTemplate.js
+++ b/node_modules/webpack/lib/MainTemplate.js
@@ -115,10 +115,6 @@ module.exports = class MainTemplate extends Template {
buf.push(`${this.requireFn}.c = installedModules;`);
buf.push("");
- buf.push("// identity function for calling harmony imports with the correct context");
- buf.push(`${this.requireFn}.i = function(value) { return value; };`);
-
- buf.push("");
buf.push("// define getter function for harmony exports");
buf.push(`${this.requireFn}.d = function(exports, name, getter) {`);
buf.push(this.indent([
diff --git a/node_modules/webpack/lib/Module.js b/node_modules/webpack/lib/Module.js
index 8ce9c85ad..26977e63f 100644
--- a/node_modules/webpack/lib/Module.js
+++ b/node_modules/webpack/lib/Module.js
@@ -4,30 +4,30 @@
*/
"use strict";
+const util = require("util");
+
const DependenciesBlock = require("./DependenciesBlock");
const ModuleReason = require("./ModuleReason");
+const SortableSet = require("./util/SortableSet");
const Template = require("./Template");
-function addToSet(set, items) {
- for(let item of items) {
- if(set.indexOf(item) < 0)
- set.push(item);
- }
-}
+let debugId = 1000;
-function byId(a, b) {
+const sortById = (a, b) => {
return a.id - b.id;
-}
+};
-let debugId = 1000;
+const sortByDebugId = (a, b) => {
+ return a.debugId - b.debugId;
+};
class Module extends DependenciesBlock {
+
constructor() {
super();
this.context = null;
this.reasons = [];
this.debugId = debugId++;
- this.lastId = -1;
this.id = null;
this.portableId = null;
this.index = null;
@@ -36,18 +36,19 @@ class Module extends DependenciesBlock {
this.used = null;
this.usedExports = null;
this.providedExports = null;
- this.chunks = [];
+ this._chunks = new SortableSet(undefined, sortById);
+ this._chunksDebugIdent = undefined;
this.warnings = [];
this.dependenciesWarnings = [];
this.errors = [];
this.dependenciesErrors = [];
this.strict = false;
this.meta = {};
+ this.optimizationBailout = [];
}
disconnect() {
this.reasons.length = 0;
- this.lastId = this.id;
this.id = null;
this.index = null;
this.index2 = null;
@@ -55,36 +56,91 @@ class Module extends DependenciesBlock {
this.used = null;
this.usedExports = null;
this.providedExports = null;
- this.chunks.length = 0;
+ this._chunks.clear();
+ this._chunksDebugIdent = undefined;
super.disconnect();
}
unseal() {
- this.lastId = this.id;
this.id = null;
this.index = null;
this.index2 = null;
this.depth = null;
- this.chunks.length = 0;
+ this._chunks.clear();
+ this._chunksDebugIdent = undefined;
super.unseal();
}
+ setChunks(chunks) {
+ this._chunks = new SortableSet(chunks, sortById);
+ }
+
addChunk(chunk) {
- let idx = this.chunks.indexOf(chunk);
- if(idx < 0)
- this.chunks.push(chunk);
+ this._chunks.add(chunk);
+ this._chunksDebugIdent = undefined;
}
removeChunk(chunk) {
- let idx = this.chunks.indexOf(chunk);
- if(idx >= 0) {
- this.chunks.splice(idx, 1);
+ if(this._chunks.delete(chunk)) {
+ this._chunksDebugIdent = undefined;
chunk.removeModule(this);
return true;
}
return false;
}
+ isInChunk(chunk) {
+ return this._chunks.has(chunk);
+ }
+
+ getChunkIdsIdent() {
+ if(this._chunksDebugIdent !== undefined) return this._chunksDebugIdent;
+ this._chunks.sortWith(sortByDebugId);
+ const chunks = this._chunks;
+ const list = [];
+ for(const chunk of chunks) {
+ const debugId = chunk.debugId;
+
+ if(typeof debugId !== "number") {
+ return this._chunksDebugIdent = null;
+ }
+
+ list.push(debugId);
+ }
+
+ return this._chunksDebugIdent = list.join(",");
+ }
+
+ forEachChunk(fn) {
+ this._chunks.forEach(fn);
+ }
+
+ mapChunks(fn) {
+ return Array.from(this._chunks, fn);
+ }
+
+ getChunks() {
+ return Array.from(this._chunks);
+ }
+
+ getNumberOfChunks() {
+ return this._chunks.size;
+ }
+
+ hasEqualsChunks(otherModule) {
+ if(this._chunks.size !== otherModule._chunks.size) return false;
+ this._chunks.sortWith(sortByDebugId);
+ otherModule._chunks.sortWith(sortByDebugId);
+ const a = this._chunks[Symbol.iterator]();
+ const b = otherModule._chunks[Symbol.iterator]();
+ while(true) { // eslint-disable-line
+ const aItem = a.next();
+ const bItem = b.next();
+ if(aItem.done) return true;
+ if(aItem.value !== bItem.value) return false;
+ }
+ }
+
addReason(module, dependency) {
this.reasons.push(new ModuleReason(module, dependency));
}
@@ -101,28 +157,17 @@ class Module extends DependenciesBlock {
}
hasReasonForChunk(chunk) {
- for(let r of this.reasons) {
- if(r.chunks) {
- if(r.chunks.indexOf(chunk) >= 0)
- return true;
- } else if(r.module.chunks.indexOf(chunk) >= 0)
+ for(let i = 0; i < this.reasons.length; i++) {
+ if(this.reasons[i].hasChunk(chunk))
return true;
}
return false;
}
rewriteChunkInReasons(oldChunk, newChunks) {
- this.reasons.forEach(r => {
- if(!r.chunks) {
- if(r.module.chunks.indexOf(oldChunk) < 0)
- return;
- r.chunks = r.module.chunks;
- }
- r.chunks = r.chunks.reduce((arr, c) => {
- addToSet(arr, c !== oldChunk ? [c] : newChunks);
- return arr;
- }, []);
- });
+ for(let i = 0; i < this.reasons.length; i++) {
+ this.reasons[i].rewriteChunks(oldChunk, newChunks);
+ }
}
isUsed(exportName) {
@@ -158,10 +203,14 @@ class Module extends DependenciesBlock {
super.updateHash(hash);
}
- sortItems() {
+ sortItems(sortChunks) {
super.sortItems();
- this.chunks.sort(byId);
- this.reasons.sort((a, b) => byId(a.module, b.module));
+ if(sortChunks)
+ this._chunks.sort();
+ this.reasons.sort((a, b) => sortById(a.module, b.module));
+ if(Array.isArray(this.usedExports)) {
+ this.usedExports.sort();
+ }
}
unbuild() {
@@ -178,6 +227,17 @@ Object.defineProperty(Module.prototype, "entry", {
throw new Error("Module.entry was removed. Use Chunk.entryModule");
}
});
+
+Object.defineProperty(Module.prototype, "chunks", {
+ configurable: false,
+ get: util.deprecate(function() {
+ return Array.from(this._chunks);
+ }, "Module.chunks: Use Module.forEachChunk/mapChunks/getNumberOfChunks/isInChunk/addChunk/removeChunk instead"),
+ set() {
+ throw new Error("Readonly. Use Module.addChunk/removeChunk to modify chunks.");
+ }
+});
+
Module.prototype.identifier = null;
Module.prototype.readableIdentifier = null;
Module.prototype.build = null;
diff --git a/node_modules/webpack/lib/ModuleFilenameHelpers.js b/node_modules/webpack/lib/ModuleFilenameHelpers.js
index 5deda6e17..f61358b07 100644
--- a/node_modules/webpack/lib/ModuleFilenameHelpers.js
+++ b/node_modules/webpack/lib/ModuleFilenameHelpers.js
@@ -112,7 +112,7 @@ ModuleFilenameHelpers.createFooter = function createFooter(module, requestShorte
"// WEBPACK FOOTER",
`// ${module.readableIdentifier(requestShortener)}`,
`// module id = ${module.id}`,
- `// module chunks = ${module.chunks.map(c => c.id).join(" ")}`
+ `// module chunks = ${module.mapChunks(c => c.id).join(" ")}`
].join("\n");
}
};
diff --git a/node_modules/webpack/lib/ModuleReason.js b/node_modules/webpack/lib/ModuleReason.js
index 999952069..52f539d01 100644
--- a/node_modules/webpack/lib/ModuleReason.js
+++ b/node_modules/webpack/lib/ModuleReason.js
@@ -4,9 +4,47 @@
*/
"use strict";
-module.exports = class ModuleReason {
+const util = require("util");
+
+class ModuleReason {
constructor(module, dependency) {
this.module = module;
this.dependency = dependency;
+ this._chunks = null;
+ }
+
+ hasChunk(chunk) {
+ if(this._chunks) {
+ if(this._chunks.has(chunk))
+ return true;
+ } else if(this.module._chunks.has(chunk))
+ return true;
+ return false;
+ }
+
+ rewriteChunks(oldChunk, newChunks) {
+ if(!this._chunks) {
+ if(!this.module._chunks.has(oldChunk))
+ return;
+ this._chunks = new Set(this.module._chunks);
+ }
+ if(this._chunks.has(oldChunk)) {
+ this._chunks.delete(oldChunk);
+ for(let i = 0; i < newChunks.length; i++) {
+ this._chunks.add(newChunks[i]);
+ }
+ }
+ }
+}
+
+Object.defineProperty(ModuleReason.prototype, "chunks", {
+ configurable: false,
+ get: util.deprecate(function() {
+ return this._chunks ? Array.from(this._chunks) : null;
+ }, "ModuleReason.chunks: Use ModuleReason.hasChunk/rewriteChunks instead"),
+ set() {
+ throw new Error("Readonly. Use ModuleReason.rewriteChunks to modify chunks.");
}
-};
+});
+
+module.exports = ModuleReason;
diff --git a/node_modules/webpack/lib/MultiCompiler.js b/node_modules/webpack/lib/MultiCompiler.js
index d04ef778f..8c9b8c183 100644
--- a/node_modules/webpack/lib/MultiCompiler.js
+++ b/node_modules/webpack/lib/MultiCompiler.js
@@ -2,175 +2,163 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var Tapable = require("tapable");
-var asyncLib = require("async");
-var MultiWatching = require("./MultiWatching");
-var MultiStats = require("./MultiStats");
+"use strict";
-function MultiCompiler(compilers) {
- Tapable.call(this);
- if(!Array.isArray(compilers)) {
- compilers = Object.keys(compilers).map(function(name) {
- compilers[name].name = name;
- return compilers[name];
- });
- }
- this.compilers = compilers;
+const Tapable = require("tapable");
+const asyncLib = require("async");
+const MultiWatching = require("./MultiWatching");
+const MultiStats = require("./MultiStats");
- function delegateProperty(name) {
- Object.defineProperty(this, name, {
- configurable: false,
- get: function() {
- throw new Error("Cannot read " + name + " of a MultiCompiler");
- },
- set: function(value) {
- this.compilers.forEach(function(compiler) {
- compiler[name] = value;
- });
- }.bind(this)
- });
+module.exports = class MultiCompiler extends Tapable {
+ constructor(compilers) {
+ super();
+ if(!Array.isArray(compilers)) {
+ compilers = Object.keys(compilers).map((name) => {
+ compilers[name].name = name;
+ return compilers[name];
+ });
+ }
+ this.compilers = compilers;
+ let doneCompilers = 0;
+ let compilerStats = [];
+ this.compilers.forEach((compiler, idx) => {
+ let compilerDone = false;
+ compiler.plugin("done", stats => {
+ if(!compilerDone) {
+ compilerDone = true;
+ doneCompilers++;
+ }
+ compilerStats[idx] = stats;
+ if(doneCompilers === this.compilers.length) {
+ this.applyPlugins("done", new MultiStats(compilerStats));
+ }
+ });
+ compiler.plugin("invalid", () => {
+ if(compilerDone) {
+ compilerDone = false;
+ doneCompilers--;
+ }
+ this.applyPlugins("invalid");
+ });
+ }, this);
}
- delegateProperty.call(this, "outputFileSystem");
- delegateProperty.call(this, "inputFileSystem");
- Object.defineProperty(this, "outputPath", {
- configurable: false,
- get: function() {
- var commonPath = compilers[0].outputPath;
- for(var i = 1; i < compilers.length; i++) {
- while(compilers[i].outputPath.indexOf(commonPath) !== 0 && /[\/\\]/.test(commonPath)) {
- commonPath = commonPath.replace(/[\/\\][^\/\\]*$/, "");
- }
+ get outputPath() {
+ let commonPath = this.compilers[0].outputPath;
+ for(const compiler of this.compilers) {
+ while(compiler.outputPath.indexOf(commonPath) !== 0 && /[/\\]/.test(commonPath)) {
+ commonPath = commonPath.replace(/[/\\][^/\\]*$/, "");
}
- if(!commonPath && compilers[0].outputPath[0] === "/") return "/";
- return commonPath;
}
- });
- var doneCompilers = 0;
- var compilerStats = [];
- this.compilers.forEach(function(compiler, idx) {
- var compilerDone = false;
- compiler.plugin("done", function(stats) {
- if(!compilerDone) {
- compilerDone = true;
- doneCompilers++;
- }
- compilerStats[idx] = stats;
- if(doneCompilers === this.compilers.length) {
- this.applyPlugins("done", new MultiStats(compilerStats));
- }
- }.bind(this));
- compiler.plugin("invalid", function() {
- if(compilerDone) {
- compilerDone = false;
- doneCompilers--;
- }
- this.applyPlugins("invalid");
- }.bind(this));
- }, this);
-}
-module.exports = MultiCompiler;
+ if(!commonPath && this.compilers[0].outputPath[0] === "/") return "/";
+ return commonPath;
+ }
-MultiCompiler.prototype = Object.create(Tapable.prototype);
-MultiCompiler.prototype.constructor = MultiCompiler;
+ get inputFileSystem() {
+ throw new Error("Cannot read inputFileSystem of a MultiCompiler");
+ }
-function runWithDependencies(compilers, fn, callback) {
- var fulfilledNames = {};
- var remainingCompilers = compilers;
+ get outputFileSystem() {
+ throw new Error("Cannot read outputFileSystem of a MultiCompiler");
+ }
- function isDependencyFulfilled(d) {
- return fulfilledNames[d];
+ set inputFileSystem(value) {
+ this.compilers.forEach(compiler => {
+ compiler.inputFileSystem = value;
+ });
}
- function getReadyCompilers() {
- var readyCompilers = [];
- var list = remainingCompilers;
- remainingCompilers = [];
- for(var i = 0; i < list.length; i++) {
- var c = list[i];
- var ready = !c.dependencies || c.dependencies.every(isDependencyFulfilled);
- if(ready)
- readyCompilers.push(c);
- else
- remainingCompilers.push(c);
- }
- return readyCompilers;
+ set outputFileSystem(value) {
+ this.compilers.forEach(compiler => {
+ compiler.outputFileSystem = value;
+ });
}
- function runCompilers(callback) {
- if(remainingCompilers.length === 0) return callback();
- asyncLib.map(getReadyCompilers(), function(compiler, callback) {
- fn(compiler, function(err) {
- if(err) return callback(err);
- fulfilledNames[compiler.name] = true;
- runCompilers(callback);
- });
- }, callback);
+ runWithDependencies(compilers, fn, callback) {
+ let fulfilledNames = {};
+ let remainingCompilers = compilers;
+ const isDependencyFulfilled = (d) => fulfilledNames[d];
+ const getReadyCompilers = () => {
+ let readyCompilers = [];
+ let list = remainingCompilers;
+ remainingCompilers = [];
+ for(const c of list) {
+ const ready = !c.dependencies || c.dependencies.every(isDependencyFulfilled);
+ if(ready)
+ readyCompilers.push(c);
+ else
+ remainingCompilers.push(c);
+ }
+ return readyCompilers;
+ };
+ const runCompilers = (callback) => {
+ if(remainingCompilers.length === 0) return callback();
+ asyncLib.map(getReadyCompilers(), (compiler, callback) => {
+ fn(compiler, (err) => {
+ if(err) return callback(err);
+ fulfilledNames[compiler.name] = true;
+ runCompilers(callback);
+ });
+ }, callback);
+ };
+ runCompilers(callback);
}
- runCompilers(callback);
-}
-MultiCompiler.prototype.watch = function(watchOptions, handler) {
- var watchings = [];
- var allStats = this.compilers.map(function() {
- return null;
- });
- var compilerStatus = this.compilers.map(function() {
- return false;
- });
- runWithDependencies(this.compilers, function(compiler, callback) {
- var compilerIdx = this.compilers.indexOf(compiler);
- var firstRun = true;
- var watching = compiler.watch(Array.isArray(watchOptions) ? watchOptions[compilerIdx] : watchOptions, function(err, stats) {
- if(err)
- handler(err);
- if(stats) {
- allStats[compilerIdx] = stats;
- compilerStatus[compilerIdx] = "new";
- if(compilerStatus.every(Boolean)) {
- var freshStats = allStats.filter(function(s, idx) {
- return compilerStatus[idx] === "new";
- });
- compilerStatus.fill(true);
- var multiStats = new MultiStats(freshStats);
- handler(null, multiStats);
+ watch(watchOptions, handler) {
+ let watchings = [];
+ let allStats = this.compilers.map(() => null);
+ let compilerStatus = this.compilers.map(() => false);
+ this.runWithDependencies(this.compilers, (compiler, callback) => {
+ const compilerIdx = this.compilers.indexOf(compiler);
+ let firstRun = true;
+ let watching = compiler.watch(Array.isArray(watchOptions) ? watchOptions[compilerIdx] : watchOptions, (err, stats) => {
+ if(err)
+ handler(err);
+ if(stats) {
+ allStats[compilerIdx] = stats;
+ compilerStatus[compilerIdx] = "new";
+ if(compilerStatus.every(Boolean)) {
+ const freshStats = allStats.filter((s, idx) => {
+ return compilerStatus[idx] === "new";
+ });
+ compilerStatus.fill(true);
+ const multiStats = new MultiStats(freshStats);
+ handler(null, multiStats);
+ }
}
- }
- if(firstRun && !err) {
- firstRun = false;
- callback();
- }
+ if(firstRun && !err) {
+ firstRun = false;
+ callback();
+ }
+ });
+ watchings.push(watching);
+ }, () => {
+ // ignore
});
- watchings.push(watching);
- }.bind(this), function() {
- // ignore
- });
- return new MultiWatching(watchings, this);
-};
-
-MultiCompiler.prototype.run = function(callback) {
- var allStats = this.compilers.map(function() {
- return null;
- });
+ return new MultiWatching(watchings, this);
+ }
- runWithDependencies(this.compilers, function(compiler, callback) {
- var compilerIdx = this.compilers.indexOf(compiler);
- compiler.run(function(err, stats) {
+ run(callback) {
+ const allStats = this.compilers.map(() => null);
+ this.runWithDependencies(this.compilers, ((compiler, callback) => {
+ const compilerIdx = this.compilers.indexOf(compiler);
+ compiler.run((err, stats) => {
+ if(err) return callback(err);
+ allStats[compilerIdx] = stats;
+ callback();
+ });
+ }), (err) => {
if(err) return callback(err);
- allStats[compilerIdx] = stats;
- callback();
+ callback(null, new MultiStats(allStats));
});
- }.bind(this), function(err) {
- if(err) return callback(err);
- callback(null, new MultiStats(allStats));
- });
-};
+ }
-MultiCompiler.prototype.purgeInputFileSystem = function() {
- this.compilers.forEach(function(compiler) {
- if(compiler.inputFileSystem && compiler.inputFileSystem.purge)
- compiler.inputFileSystem.purge();
- });
+ purgeInputFileSystem() {
+ this.compilers.forEach((compiler) => {
+ if(compiler.inputFileSystem && compiler.inputFileSystem.purge)
+ compiler.inputFileSystem.purge();
+ });
+ }
};
diff --git a/node_modules/webpack/lib/NodeStuffPlugin.js b/node_modules/webpack/lib/NodeStuffPlugin.js
index 07a63d1cc..b18ed173c 100644
--- a/node_modules/webpack/lib/NodeStuffPlugin.js
+++ b/node_modules/webpack/lib/NodeStuffPlugin.js
@@ -77,7 +77,7 @@ class NodeStuffPlugin {
if(!isHarmony)
return true;
});
- parser.plugin("evaluate Identifier module.hot", ParserHelpers.evaluateToBoolean(false));
+ parser.plugin("evaluate Identifier module.hot", ParserHelpers.evaluateToIdentifier("module.hot", false));
parser.plugin("expression module", function() {
const module = this.state.module;
const isHarmony = module.meta && module.meta.harmonyModule;
diff --git a/node_modules/webpack/lib/NormalModule.js b/node_modules/webpack/lib/NormalModule.js
index b3dda7e5a..d150fc767 100644
--- a/node_modules/webpack/lib/NormalModule.js
+++ b/node_modules/webpack/lib/NormalModule.js
@@ -54,6 +54,8 @@ class NonErrorEmittedError extends WebpackError {
}
}
+const dependencyTemplatesHashMap = new WeakMap();
+
class NormalModule extends Module {
constructor(request, userRequest, rawRequest, loaders, resource, parser) {
@@ -224,6 +226,10 @@ class NormalModule extends Module {
if(typeof rule === "string") {
return content.indexOf(rule) === 0;
}
+
+ if(typeof rule === "function") {
+ return rule(content);
+ }
// we assume rule is a regexp
return rule.test(content);
}
@@ -301,9 +307,11 @@ class NormalModule extends Module {
});
}
- getHashDigest() {
+ getHashDigest(dependencyTemplates) {
+ let dtHash = dependencyTemplatesHashMap.get("hash");
const hash = crypto.createHash("md5");
this.updateHash(hash);
+ hash.update(`${dtHash}`);
return hash.digest("hex");
}
@@ -384,9 +392,16 @@ class NormalModule extends Module {
* These will contain the variable name and its expression.
* The name will be added as a paramter in a IIFE the expression as its value.
*/
- const vars = block.variables.map((variable) => this.sourceVariables(
- variable, availableVars, dependencyTemplates, outputOptions, requestShortener))
- .filter(Boolean);
+ const vars = block.variables.reduce((result, value) => {
+ const variable = this.sourceVariables(
+ value, availableVars, dependencyTemplates, outputOptions, requestShortener);
+
+ if(variable) {
+ result.push(variable);
+ }
+
+ return result;
+ }, []);
/**
* if we actually have variables
@@ -412,15 +427,22 @@ class NormalModule extends Module {
const injectionVariableChunks = this.splitVariablesInUniqueNamedChunks(vars);
// create all the beginnings of IIFEs
- const functionWrapperStarts = injectionVariableChunks.map((variableChunk) => variableChunk.map(variable => variable.name))
- .map(names => this.variableInjectionFunctionWrapperStartCode(names));
+ const functionWrapperStarts = injectionVariableChunks.map((variableChunk) => {
+ return this.variableInjectionFunctionWrapperStartCode(
+ variableChunk.map(variable => variable.name)
+ );
+ });
// and all the ends
- const functionWrapperEnds = injectionVariableChunks.map((variableChunk) => variableChunk.map(variable => variable.expression))
- .map(expressions => this.variableInjectionFunctionWrapperEndCode(expressions, block));
+ const functionWrapperEnds = injectionVariableChunks.map((variableChunk) => {
+ return this.variableInjectionFunctionWrapperEndCode(
+ variableChunk.map(variable => variable.expression), block
+ );
+ });
// join them to one big string
const varStartCode = functionWrapperStarts.join("");
+
// reverse the ends first before joining them, as the last added must be the inner most
const varEndCode = functionWrapperEnds.reverse().join("");
@@ -432,12 +454,21 @@ class NormalModule extends Module {
source.insert(end + 0.5, "\n/* WEBPACK VAR INJECTION */" + varEndCode);
}
}
- block.blocks.forEach((block) => this.sourceBlock(
- block, availableVars.concat(vars), dependencyTemplates, source, outputOptions, requestShortener));
+
+ block.blocks.forEach((block) =>
+ this.sourceBlock(
+ block,
+ availableVars.concat(vars),
+ dependencyTemplates,
+ source,
+ outputOptions,
+ requestShortener
+ )
+ );
}
source(dependencyTemplates, outputOptions, requestShortener) {
- const hashDigest = this.getHashDigest();
+ const hashDigest = this.getHashDigest(dependencyTemplates);
if(this._cachedSource && this._cachedSource.hash === hashDigest) {
return this._cachedSource.source;
}
diff --git a/node_modules/webpack/lib/NormalModuleFactory.js b/node_modules/webpack/lib/NormalModuleFactory.js
index 170afb1c3..138b87d18 100644
--- a/node_modules/webpack/lib/NormalModuleFactory.js
+++ b/node_modules/webpack/lib/NormalModuleFactory.js
@@ -50,173 +50,161 @@ class NormalModuleFactory extends Tapable {
this.cachePredicate = typeof options.unsafeCache === "function" ? options.unsafeCache : Boolean.bind(null, options.unsafeCache);
this.context = context || "";
this.parserCache = {};
- this.plugin("factory", function() {
- /* beautify preserve:start */
- // js-beautify consider to concat "return" and "("
- // but it сontradicts eslint rule (keyword-spacing)
- return (result, callback) => {
- /* beautify preserve:end */
- let resolver = this.applyPluginsWaterfall0("resolver", null);
+ this.plugin("factory", () => (result, callback) => {
+ let resolver = this.applyPluginsWaterfall0("resolver", null);
- // Ignored
- if(!resolver) return callback();
-
- resolver(result, (err, data) => {
- if(err) return callback(err);
+ // Ignored
+ if(!resolver) return callback();
- // Ignored
- if(!data) return callback();
+ resolver(result, (err, data) => {
+ if(err) return callback(err);
- // direct module
- if(typeof data.source === "function")
- return callback(null, data);
+ // Ignored
+ if(!data) return callback();
- this.applyPluginsAsyncWaterfall("after-resolve", data, (err, result) => {
- if(err) return callback(err);
+ // direct module
+ if(typeof data.source === "function")
+ return callback(null, data);
- // Ignored
- if(!result) return callback();
+ this.applyPluginsAsyncWaterfall("after-resolve", data, (err, result) => {
+ if(err) return callback(err);
- let createdModule = this.applyPluginsBailResult("create-module", result);
- if(!createdModule) {
+ // Ignored
+ if(!result) return callback();
- if(!result.request) {
- return callback(new Error("Empty dependency (no request)"));
- }
+ let createdModule = this.applyPluginsBailResult("create-module", result);
+ if(!createdModule) {
- createdModule = new NormalModule(
- result.request,
- result.userRequest,
- result.rawRequest,
- result.loaders,
- result.resource,
- result.parser
- );
+ if(!result.request) {
+ return callback(new Error("Empty dependency (no request)"));
}
- createdModule = this.applyPluginsWaterfall0("module", createdModule);
+ createdModule = new NormalModule(
+ result.request,
+ result.userRequest,
+ result.rawRequest,
+ result.loaders,
+ result.resource,
+ result.parser
+ );
+ }
- return callback(null, createdModule);
- });
+ createdModule = this.applyPluginsWaterfall0("module", createdModule);
+
+ return callback(null, createdModule);
});
- };
+ });
});
- this.plugin("resolver", function() {
- /* beautify preserve:start */
- // js-beautify consider to concat "return" and "("
- // but it сontradicts eslint rule (keyword-spacing)
- return (data, callback) => {
- /* beautify preserve:end */
- const contextInfo = data.contextInfo;
- const context = data.context;
- const request = data.request;
-
- const noAutoLoaders = /^-?!/.test(request);
- const noPrePostAutoLoaders = /^!!/.test(request);
- const noPostAutoLoaders = /^-!/.test(request);
- let elements = request.replace(/^-?!+/, "").replace(/!!+/g, "!").split("!");
- let resource = elements.pop();
- elements = elements.map(identToLoaderRequest);
-
- asyncLib.parallel([
- callback => this.resolveRequestArray(contextInfo, context, elements, this.resolvers.loader, callback),
- callback => {
- if(resource === "" || resource[0] === "?")
- return callback(null, {
- resource
- });
-
- this.resolvers.normal.resolve(contextInfo, context, resource, (err, resource, resourceResolveData) => {
- if(err) return callback(err);
- callback(null, {
- resourceResolveData,
- resource
- });
+ this.plugin("resolver", () => (data, callback) => {
+ const contextInfo = data.contextInfo;
+ const context = data.context;
+ const request = data.request;
+
+ const noAutoLoaders = /^-?!/.test(request);
+ const noPrePostAutoLoaders = /^!!/.test(request);
+ const noPostAutoLoaders = /^-!/.test(request);
+ let elements = request.replace(/^-?!+/, "").replace(/!!+/g, "!").split("!");
+ let resource = elements.pop();
+ elements = elements.map(identToLoaderRequest);
+
+ asyncLib.parallel([
+ callback => this.resolveRequestArray(contextInfo, context, elements, this.resolvers.loader, callback),
+ callback => {
+ if(resource === "" || resource[0] === "?")
+ return callback(null, {
+ resource
});
- }
- ], (err, results) => {
- if(err) return callback(err);
- let loaders = results[0];
- const resourceResolveData = results[1].resourceResolveData;
- resource = results[1].resource;
-
- // translate option idents
- try {
- loaders.forEach(item => {
- if(typeof item.options === "string" && /^\?/.test(item.options)) {
- item.options = this.ruleSet.findOptionsByIdent(item.options.substr(1));
- }
+
+ this.resolvers.normal.resolve(contextInfo, context, resource, (err, resource, resourceResolveData) => {
+ if(err) return callback(err);
+ callback(null, {
+ resourceResolveData,
+ resource
});
- } catch(e) {
- return callback(e);
- }
+ });
+ }
+ ], (err, results) => {
+ if(err) return callback(err);
+ let loaders = results[0];
+ const resourceResolveData = results[1].resourceResolveData;
+ resource = results[1].resource;
+
+ // translate option idents
+ try {
+ loaders.forEach(item => {
+ if(typeof item.options === "string" && /^\?/.test(item.options)) {
+ item.options = this.ruleSet.findOptionsByIdent(item.options.substr(1));
+ }
+ });
+ } catch(e) {
+ return callback(e);
+ }
- if(resource === false) {
- // ignored
- return callback(null,
- new RawModule(
- "/* (ignored) */",
- `ignored ${context} ${request}`,
- `${request} (ignored)`
- )
- );
- }
+ if(resource === false) {
+ // ignored
+ return callback(null,
+ new RawModule(
+ "/* (ignored) */",
+ `ignored ${context} ${request}`,
+ `${request} (ignored)`
+ )
+ );
+ }
- const userRequest = loaders.map(loaderToIdent).concat([resource]).join("!");
+ const userRequest = loaders.map(loaderToIdent).concat([resource]).join("!");
- let resourcePath = resource;
- let resourceQuery = "";
- const queryIndex = resourcePath.indexOf("?");
- if(queryIndex >= 0) {
- resourceQuery = resourcePath.substr(queryIndex);
- resourcePath = resourcePath.substr(0, queryIndex);
- }
+ let resourcePath = resource;
+ let resourceQuery = "";
+ const queryIndex = resourcePath.indexOf("?");
+ if(queryIndex >= 0) {
+ resourceQuery = resourcePath.substr(queryIndex);
+ resourcePath = resourcePath.substr(0, queryIndex);
+ }
- const result = this.ruleSet.exec({
- resource: resourcePath,
- resourceQuery,
- issuer: contextInfo.issuer,
- compiler: contextInfo.compiler
- });
- const settings = {};
- const useLoadersPost = [];
- const useLoaders = [];
- const useLoadersPre = [];
- result.forEach(r => {
- if(r.type === "use") {
- if(r.enforce === "post" && !noPostAutoLoaders && !noPrePostAutoLoaders)
- useLoadersPost.push(r.value);
- else if(r.enforce === "pre" && !noPrePostAutoLoaders)
- useLoadersPre.push(r.value);
- else if(!r.enforce && !noAutoLoaders && !noPrePostAutoLoaders)
- useLoaders.push(r.value);
- } else {
- settings[r.type] = r.value;
- }
- });
- asyncLib.parallel([
- this.resolveRequestArray.bind(this, contextInfo, this.context, useLoadersPost, this.resolvers.loader),
- this.resolveRequestArray.bind(this, contextInfo, this.context, useLoaders, this.resolvers.loader),
- this.resolveRequestArray.bind(this, contextInfo, this.context, useLoadersPre, this.resolvers.loader)
- ], (err, results) => {
- if(err) return callback(err);
- loaders = results[0].concat(loaders, results[1], results[2]);
- process.nextTick(() => {
- callback(null, {
- context: context,
- request: loaders.map(loaderToIdent).concat([resource]).join("!"),
- dependencies: data.dependencies,
- userRequest,
- rawRequest: request,
- loaders,
- resource,
- resourceResolveData,
- parser: this.getParser(settings.parser)
- });
+ const result = this.ruleSet.exec({
+ resource: resourcePath,
+ resourceQuery,
+ issuer: contextInfo.issuer,
+ compiler: contextInfo.compiler
+ });
+ const settings = {};
+ const useLoadersPost = [];
+ const useLoaders = [];
+ const useLoadersPre = [];
+ result.forEach(r => {
+ if(r.type === "use") {
+ if(r.enforce === "post" && !noPostAutoLoaders && !noPrePostAutoLoaders)
+ useLoadersPost.push(r.value);
+ else if(r.enforce === "pre" && !noPrePostAutoLoaders)
+ useLoadersPre.push(r.value);
+ else if(!r.enforce && !noAutoLoaders && !noPrePostAutoLoaders)
+ useLoaders.push(r.value);
+ } else {
+ settings[r.type] = r.value;
+ }
+ });
+ asyncLib.parallel([
+ this.resolveRequestArray.bind(this, contextInfo, this.context, useLoadersPost, this.resolvers.loader),
+ this.resolveRequestArray.bind(this, contextInfo, this.context, useLoaders, this.resolvers.loader),
+ this.resolveRequestArray.bind(this, contextInfo, this.context, useLoadersPre, this.resolvers.loader)
+ ], (err, results) => {
+ if(err) return callback(err);
+ loaders = results[0].concat(loaders, results[1], results[2]);
+ process.nextTick(() => {
+ callback(null, {
+ context: context,
+ request: loaders.map(loaderToIdent).concat([resource]).join("!"),
+ dependencies: data.dependencies,
+ userRequest,
+ rawRequest: request,
+ loaders,
+ resource,
+ resourceResolveData,
+ parser: this.getParser(settings.parser)
});
});
});
- };
+ });
});
}
diff --git a/node_modules/webpack/lib/Parser.js b/node_modules/webpack/lib/Parser.js
index bd81b55ab..88f9b65db 100644
--- a/node_modules/webpack/lib/Parser.js
+++ b/node_modules/webpack/lib/Parser.js
@@ -17,10 +17,12 @@ function joinRanges(startRange, endRange) {
return [startRange[0], endRange[1]];
}
+const ECMA_VERSION = 2017;
+
const POSSIBLE_AST_OPTIONS = [{
ranges: true,
locations: true,
- ecmaVersion: 2017,
+ ecmaVersion: ECMA_VERSION,
sourceType: "module",
plugins: {
dynamicImport: true
@@ -28,7 +30,7 @@ const POSSIBLE_AST_OPTIONS = [{
}, {
ranges: true,
locations: true,
- ecmaVersion: 2017,
+ ecmaVersion: ECMA_VERSION,
sourceType: "script",
plugins: {
dynamicImport: true
@@ -212,19 +214,10 @@ class Parser extends Tapable {
}
}
if(expr.argument.type === "MemberExpression") {
- let expression = expr.argument;
- let exprName = [];
- while(expression.type === "MemberExpression" && !expression.computed) {
- exprName.unshift(this.scope.renames["$" + expression.property.name] || expression.property.name);
- expression = expression.object;
- }
- if(expression.type === "Identifier") {
- exprName.unshift(this.scope.renames["$" + expression.name] || expression.name);
- if(this.scope.definitions.indexOf(name) === -1) {
- exprName = exprName.join(".");
- res = this.applyPluginsBailResult1("evaluate typeof " + exprName, expr);
- if(res !== undefined) return res;
- }
+ const exprName = this.getNameForExpression(expr.argument);
+ if(exprName && exprName.free) {
+ res = this.applyPluginsBailResult1("evaluate typeof " + exprName.name, expr);
+ if(res !== undefined) return res;
}
}
if(expr.argument.type === "FunctionExpression") {
@@ -240,6 +233,10 @@ class Parser extends Tapable {
if(!argument) return;
if(argument.isBoolean()) {
return new BasicEvaluatedExpression().setBoolean(!argument.bool).setRange(expr.range);
+ } else if(argument.isTruthy()) {
+ return new BasicEvaluatedExpression().setBoolean(false).setRange(expr.range);
+ } else if(argument.isFalsy()) {
+ return new BasicEvaluatedExpression().setBoolean(true).setRange(expr.range);
} else if(argument.isString()) {
return new BasicEvaluatedExpression().setBoolean(!argument.string).setRange(expr.range);
} else if(argument.isNumber()) {
@@ -260,25 +257,23 @@ class Parser extends Tapable {
return this.applyPluginsBailResult1("evaluate defined Identifier " + name, expr);
}
});
- this.plugin("evaluate MemberExpression", function(expression) {
- let expr = expression;
- let exprName = [];
- while(expr.type === "MemberExpression" && expr.property.type === (expr.computed ? "Literal" : "Identifier")) {
- exprName.unshift(expr.property.name || expr.property.value);
- expr = expr.object;
+ this.plugin("evaluate ThisExpression", function(expr) {
+ const name = this.scope.renames.$this;
+ if(name) {
+ const result = this.applyPluginsBailResult1("evaluate Identifier " + name, expr);
+ if(result) return result;
+ return new BasicEvaluatedExpression().setIdentifier(name).setRange(expr.range);
}
- if(expr.type === "Identifier") {
- const name = this.scope.renames["$" + expr.name] || expr.name;
- if(this.scope.definitions.indexOf(name) === -1) {
- exprName.unshift(name);
- exprName = exprName.join(".");
- if(this.scope.definitions.indexOf(expr.name) === -1) {
- const result = this.applyPluginsBailResult1("evaluate Identifier " + exprName, expression);
- if(result) return result;
- return new BasicEvaluatedExpression().setIdentifier(exprName).setRange(expression.range);
- } else {
- return this.applyPluginsBailResult1("evaluate defined Identifier " + exprName, expression);
- }
+ });
+ this.plugin("evaluate MemberExpression", function(expression) {
+ let exprName = this.getNameForExpression(expression);
+ if(exprName) {
+ if(exprName.free) {
+ const result = this.applyPluginsBailResult1("evaluate Identifier " + exprName.name, expression);
+ if(result) return result;
+ return new BasicEvaluatedExpression().setIdentifier(exprName.name).setRange(expression.range);
+ } else {
+ return this.applyPluginsBailResult1("evaluate defined Identifier " + exprName.name, expression);
}
}
});
@@ -639,14 +634,14 @@ class Parser extends Tapable {
statement.params.forEach(param => {
this.walkPattern(param);
});
- this.inScope(statement.params, function() {
+ this.inScope(statement.params, () => {
if(statement.body.type === "BlockStatement") {
this.prewalkStatement(statement.body);
this.walkStatement(statement.body);
} else {
this.walkExpression(statement.body);
}
- }.bind(this));
+ });
}
prewalkImportDeclaration(statement) {
@@ -789,10 +784,10 @@ class Parser extends Tapable {
}
walkCatchClause(catchClause) {
- this.inScope([catchClause.param], function() {
+ this.inScope([catchClause.param], () => {
this.prewalkStatement(catchClause.body);
this.walkStatement(catchClause.body);
- }.bind(this));
+ });
}
prewalkVariableDeclarators(declarators) {
@@ -921,28 +916,28 @@ class Parser extends Tapable {
expression.params.forEach(param => {
this.walkPattern(param);
});
- this.inScope(expression.params, function() {
+ this.inScope(expression.params, () => {
if(expression.body.type === "BlockStatement") {
this.prewalkStatement(expression.body);
this.walkStatement(expression.body);
} else {
this.walkExpression(expression.body);
}
- }.bind(this));
+ });
}
walkArrowFunctionExpression(expression) {
expression.params.forEach(param => {
this.walkPattern(param);
});
- this.inScope(expression.params, function() {
+ this.inScope(expression.params, () => {
if(expression.body.type === "BlockStatement") {
this.prewalkStatement(expression.body);
this.walkStatement(expression.body);
} else {
this.walkExpression(expression.body);
}
- }.bind(this));
+ });
}
walkSequenceExpression(expression) {
@@ -956,16 +951,9 @@ class Parser extends Tapable {
walkUnaryExpression(expression) {
if(expression.operator === "typeof") {
- let expr = expression.argument;
- let exprName = [];
- while(expr.type === "MemberExpression" && expr.property.type === (expr.computed ? "Literal" : "Identifier")) {
- exprName.unshift(expr.property.name || expr.property.value);
- expr = expr.object;
- }
- if(expr.type === "Identifier" && this.scope.definitions.indexOf(expr.name) === -1) {
- exprName.unshift(this.scope.renames["$" + expr.name] || expr.name);
- exprName = exprName.join(".");
- const result = this.applyPluginsBailResult1("typeof " + exprName, expression);
+ const exprName = this.getNameForExpression(expression.argument);
+ if(exprName && exprName.free) {
+ const result = this.applyPluginsBailResult1("typeof " + exprName.name, expression);
if(result === true)
return;
}
@@ -1057,19 +1045,24 @@ class Parser extends Tapable {
walkCallExpression(expression) {
let result;
- function walkIIFE(functionExpression, options) {
- const params = functionExpression.params;
- const args = options.map(function(arg) {
- const renameIdentifier = this.getRenameIdentifier(arg);
- if(renameIdentifier && this.applyPluginsBailResult1("can-rename " + renameIdentifier, arg)) {
- if(!this.applyPluginsBailResult1("rename " + renameIdentifier, arg))
+ function walkIIFE(functionExpression, options, currentThis) {
+ function renameArgOrThis(argOrThis) {
+ const renameIdentifier = this.getRenameIdentifier(argOrThis);
+ if(renameIdentifier && this.applyPluginsBailResult1("can-rename " + renameIdentifier, argOrThis)) {
+ if(!this.applyPluginsBailResult1("rename " + renameIdentifier, argOrThis))
return renameIdentifier;
}
- this.walkExpression(arg);
- }, this);
+ this.walkExpression(argOrThis);
+ }
+ const params = functionExpression.params;
+ const renameThis = currentThis ? renameArgOrThis.call(this, currentThis) : null;
+ const args = options.map(renameArgOrThis, this);
this.inScope(params.filter(function(identifier, idx) {
return !args[idx];
- }), function() {
+ }), () => {
+ if(renameThis) {
+ this.scope.renames.$this = renameThis;
+ }
for(let i = 0; i < args.length; i++) {
const param = args[i];
if(!param) continue;
@@ -1081,18 +1074,17 @@ class Parser extends Tapable {
this.walkStatement(functionExpression.body);
} else
this.walkExpression(functionExpression.body);
- }.bind(this));
+ });
}
if(expression.callee.type === "MemberExpression" &&
expression.callee.object.type === "FunctionExpression" &&
!expression.callee.computed &&
(["call", "bind"]).indexOf(expression.callee.property.name) >= 0 &&
expression.arguments &&
- expression.arguments.length > 1
+ expression.arguments.length > 0
) {
// (function(...) { }.call/bind(?, ...))
- walkIIFE.call(this, expression.callee.object, expression.arguments.slice(1));
- this.walkExpression(expression.arguments[0]);
+ walkIIFE.call(this, expression.callee.object, expression.arguments.slice(1), expression.arguments[0]);
} else if(expression.callee.type === "FunctionExpression" && expression.arguments) {
// (function(...) { }(...))
walkIIFE.call(this, expression.callee, expression.arguments);
@@ -1110,6 +1102,12 @@ class Parser extends Tapable {
result = this.applyPluginsBailResult1("call " + callee.identifier, expression);
if(result === true)
return;
+ let identifier = callee.identifier.replace(/\.[^.]+$/, ".*");
+ if(identifier !== callee.identifier) {
+ result = this.applyPluginsBailResult1("call " + identifier, expression);
+ if(result === true)
+ return;
+ }
}
if(expression.callee)
@@ -1120,19 +1118,12 @@ class Parser extends Tapable {
}
walkMemberExpression(expression) {
- let expr = expression;
- let exprName = [];
- while(expr.type === "MemberExpression" && expr.property.type === (expr.computed ? "Literal" : "Identifier")) {
- exprName.unshift(expr.property.name || expr.property.value);
- expr = expr.object;
- }
- if(expr.type === "Identifier" && this.scope.definitions.indexOf(expr.name) === -1) {
- exprName.unshift(this.scope.renames["$" + expr.name] || expr.name);
- let result = this.applyPluginsBailResult1("expression " + exprName.join("."), expression);
+ const exprName = this.getNameForExpression(expression);
+ if(exprName && exprName.free) {
+ let result = this.applyPluginsBailResult1("expression " + exprName.name, expression);
if(result === true)
return;
- exprName[exprName.length - 1] = "*";
- result = this.applyPluginsBailResult1("expression " + exprName.join("."), expression);
+ result = this.applyPluginsBailResult1("expression " + exprName.nameGeneral, expression);
if(result === true)
return;
}
@@ -1158,6 +1149,8 @@ class Parser extends Tapable {
renames: Object.create(oldScope.renames)
};
+ this.scope.renames.$this = undefined;
+
for(let paramIndex = 0, len = params.length; paramIndex < len; paramIndex++) {
const param = params[paramIndex];
@@ -1335,7 +1328,7 @@ class Parser extends Tapable {
ast = acorn.parse(source, {
ranges: true,
locations: true,
- ecmaVersion: 2017,
+ ecmaVersion: ECMA_VERSION,
sourceType: "module",
plugins: {
dynamicImport: true
@@ -1369,7 +1362,7 @@ class Parser extends Tapable {
const ast = acorn.parse("(" + source + ")", {
ranges: true,
locations: true,
- ecmaVersion: 2017,
+ ecmaVersion: ECMA_VERSION,
sourceType: "module",
plugins: {
dynamicImport: true
@@ -1399,6 +1392,40 @@ class Parser extends Tapable {
return options.reduce((o, i) => Object.assign(o, i), {});
}
+ getNameForExpression(expression) {
+ let expr = expression;
+ const exprName = [];
+ while(expr.type === "MemberExpression" && expr.property.type === (expr.computed ? "Literal" : "Identifier")) {
+ exprName.push(expr.computed ? expr.property.value : expr.property.name);
+ expr = expr.object;
+ }
+ let free;
+ if(expr.type === "Identifier") {
+ free = this.scope.definitions.indexOf(expr.name) === -1;
+ exprName.push(this.scope.renames["$" + expr.name] || expr.name);
+ } else if(expr.type === "ThisExpression" && this.scope.renames.$this) {
+ free = true;
+ exprName.push(this.scope.renames.$this);
+ } else if(expr.type === "ThisExpression") {
+ free = false;
+ exprName.push("this");
+ } else {
+ return null;
+ }
+ let prefix = "";
+ for(let i = exprName.length - 1; i >= 1; i--)
+ prefix += exprName[i] + ".";
+ const name = prefix + exprName[0];
+ const nameGeneral = prefix + "*";
+ return {
+ name,
+ nameGeneral,
+ free
+ };
+ }
+
}
+Parser.ECMA_VERSION = ECMA_VERSION;
+
module.exports = Parser;
diff --git a/node_modules/webpack/lib/ParserHelpers.js b/node_modules/webpack/lib/ParserHelpers.js
index 944c54820..64a0e9996 100644
--- a/node_modules/webpack/lib/ParserHelpers.js
+++ b/node_modules/webpack/lib/ParserHelpers.js
@@ -56,6 +56,15 @@ ParserHelpers.evaluateToBoolean = function(value) {
};
};
+ParserHelpers.evaluateToIdentifier = function(identifier, truthy) {
+ return function identifierExpression(expr) {
+ let evex = new BasicEvaluatedExpression().setIdentifier(identifier).setRange(expr.range);
+ if(truthy === true) evex = evex.setTruthy();
+ else if(truthy === false) evex = evex.setFalsy();
+ return evex;
+ };
+};
+
ParserHelpers.expressionIsUnsupported = function(message) {
return function unsupportedExpression(expr) {
var dep = new ConstDependency("(void 0)", expr.range);
diff --git a/node_modules/webpack/lib/ProgressPlugin.js b/node_modules/webpack/lib/ProgressPlugin.js
index 5bb256f4b..b0828d8a8 100644
--- a/node_modules/webpack/lib/ProgressPlugin.js
+++ b/node_modules/webpack/lib/ProgressPlugin.js
@@ -82,17 +82,19 @@ class ProgressPlugin {
"optimize-chunks": [0.77, "chunk optimization"],
"optimize-chunks-advanced": [0.78, "advanced chunk optimization"],
// optimize-tree
- "revive-modules": [0.80, "module reviving"],
- "optimize-module-order": [0.81, "module order optimization"],
- "optimize-module-ids": [0.82, "module id optimization"],
- "revive-chunks": [0.83, "chunk reviving"],
- "optimize-chunk-order": [0.84, "chunk order optimization"],
- "optimize-chunk-ids": [0.85, "chunk id optimization"],
- "before-hash": [0.86, "hashing"],
- "before-module-assets": [0.87, "module assets processing"],
- "before-chunk-assets": [0.88, "chunk assets processing"],
- "additional-chunk-assets": [0.89, "additional chunk assets processing"],
- "record": [0.90, "recording"]
+ "optimize-chunk-modules": [0.80, "chunk modules optimization"],
+ "optimize-chunk-modules-advanced": [0.81, "advanced chunk modules optimization"],
+ "revive-modules": [0.82, "module reviving"],
+ "optimize-module-order": [0.83, "module order optimization"],
+ "optimize-module-ids": [0.84, "module id optimization"],
+ "revive-chunks": [0.85, "chunk reviving"],
+ "optimize-chunk-order": [0.86, "chunk order optimization"],
+ "optimize-chunk-ids": [0.87, "chunk id optimization"],
+ "before-hash": [0.88, "hashing"],
+ "before-module-assets": [0.89, "module assets processing"],
+ "before-chunk-assets": [0.90, "chunk assets processing"],
+ "additional-chunk-assets": [0.91, "additional chunk assets processing"],
+ "record": [0.92, "recording"]
};
Object.keys(syncHooks).forEach(name => {
let pass = 0;
diff --git a/node_modules/webpack/lib/RawModule.js b/node_modules/webpack/lib/RawModule.js
index 3d29cdb98..d937cafc0 100644
--- a/node_modules/webpack/lib/RawModule.js
+++ b/node_modules/webpack/lib/RawModule.js
@@ -47,4 +47,8 @@ module.exports = class RawModule extends Module {
return new RawSource(this.sourceStr);
}
+ updateHash(hash) {
+ hash.update(this.sourceStr);
+ super.updateHash(hash);
+ }
};
diff --git a/node_modules/webpack/lib/RecordIdsPlugin.js b/node_modules/webpack/lib/RecordIdsPlugin.js
index 735288f40..a4d53085b 100644
--- a/node_modules/webpack/lib/RecordIdsPlugin.js
+++ b/node_modules/webpack/lib/RecordIdsPlugin.js
@@ -47,12 +47,12 @@ class RecordIdsPlugin {
const p = block.parent;
const idx = p.blocks.indexOf(block);
const l = p.blocks.length - 1;
- ident.unshift(`${idx}/${l}`);
+ ident.push(`${idx}/${l}`);
block = block.parent;
}
if(!block.identifier) return null;
- ident.unshift(identifierUtils.makePathsRelative(compiler.context, block.identifier()));
- return ident.join(":");
+ ident.push(identifierUtils.makePathsRelative(compiler.context, block.identifier()));
+ return ident.reverse().join(":");
}
compilation.plugin("record-chunks", (chunks, records) => {
records.nextFreeChunkId = compilation.nextFreeChunkId;
diff --git a/node_modules/webpack/lib/RequestShortener.js b/node_modules/webpack/lib/RequestShortener.js
index 369e44334..0dd27a7d2 100644
--- a/node_modules/webpack/lib/RequestShortener.js
+++ b/node_modules/webpack/lib/RequestShortener.js
@@ -5,40 +5,48 @@
"use strict";
const path = require("path");
+const NORMALIZE_SLASH_DIRECTION_REGEXP = /\\/g;
+const PATH_CHARS_REGEXP = /[-[\]{}()*+?.,\\^$|#\s]/g;
+const SEPARATOR_REGEXP = /[/\\]$/;
+const FRONT_OR_BACK_BANG_REGEXP = /^!|!$/g;
+const INDEX_JS_REGEXP = /\/index.js(!|\?|\(query\))/g;
+
+const normalizeBackSlashDirection = (request) => {
+ return request.replace(NORMALIZE_SLASH_DIRECTION_REGEXP, "/");
+};
+
+const createRegExpForPath = (path) => {
+ const regexpTypePartial = path.replace(PATH_CHARS_REGEXP, "\\$&");
+ return new RegExp(`(^|!)${regexpTypePartial}`, "g");
+};
class RequestShortener {
constructor(directory) {
- directory = directory.replace(/\\/g, "/");
- if(/[\/\\]$/.test(directory)) directory = directory.substr(0, directory.length - 1);
+ directory = normalizeBackSlashDirection(directory);
+ if(SEPARATOR_REGEXP.test(directory)) directory = directory.substr(0, directory.length - 1);
if(directory) {
- const currentDirectoryRegExpString = directory.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
- this.currentDirectoryRegExp = new RegExp("^" + currentDirectoryRegExpString + "|(!)" + currentDirectoryRegExpString, "g");
+ this.currentDirectoryRegExp = createRegExpForPath(directory);
}
const dirname = path.dirname(directory);
- const endsWithSeperator = /[\/\\]$/.test(dirname);
+ const endsWithSeperator = SEPARATOR_REGEXP.test(dirname);
const parentDirectory = endsWithSeperator ? dirname.substr(0, dirname.length - 1) : dirname;
if(parentDirectory && parentDirectory !== directory) {
- const parentDirectoryRegExpString = parentDirectory.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
- this.parentDirectoryRegExp = new RegExp("^" + parentDirectoryRegExpString + "|(!)" + parentDirectoryRegExpString, "g");
+ this.parentDirectoryRegExp = createRegExpForPath(parentDirectory);
}
if(__dirname.length >= 2) {
- const buildins = path.join(__dirname, "..").replace(/\\/g, "/");
+ const buildins = normalizeBackSlashDirection(path.join(__dirname, ".."));
const buildinsAsModule = this.currentDirectoryRegExp && this.currentDirectoryRegExp.test(buildins);
this.buildinsAsModule = buildinsAsModule;
- const buildinsRegExpString = buildins.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
- this.buildinsRegExp = new RegExp("^" + buildinsRegExpString + "|(!)" + buildinsRegExpString, "g");
+ this.buildinsRegExp = createRegExpForPath(buildins);
}
-
- this.nodeModulesRegExp = /\/node_modules\//g;
- this.indexJsRegExp = /\/index.js(!|\?|\(query\))/g;
}
shorten(request) {
if(!request) return request;
- request = request.replace(/\\/g, "/");
+ request = normalizeBackSlashDirection(request);
if(this.buildinsAsModule && this.buildinsRegExp)
request = request.replace(this.buildinsRegExp, "!(webpack)");
if(this.currentDirectoryRegExp)
@@ -47,9 +55,8 @@ class RequestShortener {
request = request.replace(this.parentDirectoryRegExp, "!..");
if(!this.buildinsAsModule && this.buildinsRegExp)
request = request.replace(this.buildinsRegExp, "!(webpack)");
- request = request.replace(this.nodeModulesRegExp, "/~/");
- request = request.replace(this.indexJsRegExp, "$1");
- return request.replace(/^!|!$/, "");
+ request = request.replace(INDEX_JS_REGEXP, "$1");
+ return request.replace(FRONT_OR_BACK_BANG_REGEXP, "");
}
}
diff --git a/node_modules/webpack/lib/RequireJsStuffPlugin.js b/node_modules/webpack/lib/RequireJsStuffPlugin.js
index 0bd6aa7d5..92bc3fc91 100644
--- a/node_modules/webpack/lib/RequireJsStuffPlugin.js
+++ b/node_modules/webpack/lib/RequireJsStuffPlugin.js
@@ -23,7 +23,7 @@ module.exports = class RequireJsStuffPlugin {
parser.plugin("call requirejs.config", ParserHelpers.toConstantDependency("undefined"));
parser.plugin("expression require.version", ParserHelpers.toConstantDependency(JSON.stringify("0.0.0")));
- parser.plugin("expression requirejs.onError", ParserHelpers.toConstantDependency(JSON.stringify("__webpack_require__.oe")));
+ parser.plugin("expression requirejs.onError", ParserHelpers.toConstantDependency("__webpack_require__.oe"));
});
});
}
diff --git a/node_modules/webpack/lib/RuleSet.js b/node_modules/webpack/lib/RuleSet.js
index c52226b84..cb679b5f6 100644
--- a/node_modules/webpack/lib/RuleSet.js
+++ b/node_modules/webpack/lib/RuleSet.js
@@ -104,7 +104,7 @@ module.exports = class RuleSet {
if(typeof rule !== "object")
throw new Error("Unexcepted " + typeof rule + " when object was expected as rule (" + rule + ")");
- let newRule = {};
+ const newRule = {};
let useSource;
let resourceSource;
let condition;
@@ -265,7 +265,7 @@ module.exports = class RuleSet {
return RuleSet.normalizeUseItemString(item);
}
- let newItem = {};
+ const newItem = {};
if(item.options && item.query)
throw new Error("Provided options and query in use");
@@ -312,7 +312,7 @@ module.exports = class RuleSet {
if(typeof condition !== "object")
throw Error("Unexcepted " + typeof condition + " when condition was expected (" + condition + ")");
- let matchers = [];
+ const matchers = [];
Object.keys(condition).forEach(key => {
const value = condition[key];
switch(key) {
diff --git a/node_modules/webpack/lib/SourceMapDevToolPlugin.js b/node_modules/webpack/lib/SourceMapDevToolPlugin.js
index 53645fb4e..abd8d5ee3 100644
--- a/node_modules/webpack/lib/SourceMapDevToolPlugin.js
+++ b/node_modules/webpack/lib/SourceMapDevToolPlugin.js
@@ -5,6 +5,7 @@
"use strict";
const path = require("path");
+const crypto = require("crypto");
const RequestShortener = require("./RequestShortener");
const ConcatSource = require("webpack-sources").ConcatSource;
const RawSource = require("webpack-sources").RawSource;
@@ -16,6 +17,38 @@ const basename = (name) => {
return name.substr(name.lastIndexOf("/") + 1);
};
+function getTaskForFile(file, chunk, options, compilation) {
+ const asset = compilation.assets[file];
+ if(asset.__SourceMapDevToolFile === file && asset.__SourceMapDevToolData) {
+ const data = asset.__SourceMapDevToolData;
+ for(const cachedFile in data) {
+ compilation.assets[cachedFile] = data[cachedFile];
+ if(cachedFile !== file)
+ chunk.files.push(cachedFile);
+ }
+ return;
+ }
+ let source, sourceMap;
+ if(asset.sourceAndMap) {
+ const sourceAndMap = asset.sourceAndMap(options);
+ sourceMap = sourceAndMap.map;
+ source = sourceAndMap.source;
+ } else {
+ sourceMap = asset.map(options);
+ source = asset.source();
+ }
+ if(sourceMap) {
+ return {
+ chunk,
+ file,
+ asset,
+ source,
+ sourceMap,
+ modules: undefined
+ };
+ }
+}
+
class SourceMapDevToolPlugin {
constructor(options) {
if(arguments.length > 1)
@@ -42,81 +75,85 @@ class SourceMapDevToolPlugin {
const requestShortener = new RequestShortener(compiler.context);
const options = this.options;
options.test = options.test || /\.(js|css)($|\?)/i;
+
+ const matchObject = ModuleFilenameHelpers.matchObject.bind(undefined, options);
+
compiler.plugin("compilation", compilation => {
new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
+
compilation.plugin("after-optimize-chunk-assets", function(chunks) {
- let allModules = [];
- let allModuleFilenames = [];
+ const moduleToSourceNameMapping = new Map();
const tasks = [];
+
chunks.forEach(function(chunk) {
- chunk.files.filter(ModuleFilenameHelpers.matchObject.bind(undefined, options)).map(function(file) {
- const asset = compilation.assets[file];
- if(asset.__SourceMapDevToolFile === file && asset.__SourceMapDevToolData) {
- const data = asset.__SourceMapDevToolData;
- for(const cachedFile in data) {
- compilation.assets[cachedFile] = data[cachedFile];
- if(cachedFile !== file)
- chunk.files.push(cachedFile);
+ chunk.files.forEach(file => {
+ if(matchObject(file)) {
+ const task = getTaskForFile(file, chunk, options, compilation);
+
+ if(task) {
+ const modules = task.sourceMap.sources.map(source => {
+ const module = compilation.findModule(source);
+ return module || source;
+ });
+
+ for(const module of modules) {
+ if(!moduleToSourceNameMapping.get(module)) {
+ moduleToSourceNameMapping.set(module, ModuleFilenameHelpers.createFilename(module, moduleFilenameTemplate, requestShortener));
+ }
+ }
+
+ task.modules = modules;
+
+ tasks.push(task);
}
- return;
}
- let source, sourceMap;
- if(asset.sourceAndMap) {
- const sourceAndMap = asset.sourceAndMap(options);
- sourceMap = sourceAndMap.map;
- source = sourceAndMap.source;
- } else {
- sourceMap = asset.map(options);
- source = asset.source();
- }
- if(sourceMap) {
- return {
- chunk,
- file,
- asset,
- source,
- sourceMap
- };
- }
- }).filter(Boolean).map(task => {
- const modules = task.sourceMap.sources.map(source => {
- const module = compilation.findModule(source);
- return module || source;
- });
- const moduleFilenames = modules.map(module => ModuleFilenameHelpers.createFilename(module, moduleFilenameTemplate, requestShortener));
- task.modules = modules;
- task.moduleFilenames = moduleFilenames;
- return task;
- }).forEach(task => {
- allModules = allModules.concat(task.modules);
- allModuleFilenames = allModuleFilenames.concat(task.moduleFilenames);
- tasks.push(task);
});
});
- allModuleFilenames = ModuleFilenameHelpers.replaceDuplicates(allModuleFilenames, (filename, i) => ModuleFilenameHelpers.createFilename(allModules[i], fallbackModuleFilenameTemplate, requestShortener), (ai, bi) => {
- let a = allModules[ai];
- let b = allModules[bi];
- a = !a ? "" : typeof a === "string" ? a : a.identifier();
- b = !b ? "" : typeof b === "string" ? b : b.identifier();
- return a.length - b.length;
- });
- allModuleFilenames = ModuleFilenameHelpers.replaceDuplicates(allModuleFilenames, (filename, i, n) => {
- for(let j = 0; j < n; j++)
- filename += "*";
- return filename;
- });
- tasks.forEach(task => {
- task.moduleFilenames = allModuleFilenames.slice(0, task.moduleFilenames.length);
- allModuleFilenames = allModuleFilenames.slice(task.moduleFilenames.length);
+
+ const usedNamesSet = new Set(moduleToSourceNameMapping.values());
+ const conflictDetectionSet = new Set();
+
+ // all modules in defined order (longest identifier first)
+ const allModules = Array.from(moduleToSourceNameMapping.keys()).sort((a, b) => {
+ const ai = typeof a === "string" ? a : a.identifier();
+ const bi = typeof b === "string" ? b : b.identifier();
+ return ai.length - bi.length;
});
+
+ // find modules with conflicting source names
+ for(const module of allModules) {
+ let sourceName = moduleToSourceNameMapping.get(module);
+ let hasName = conflictDetectionSet.has(sourceName);
+ if(!hasName) {
+ conflictDetectionSet.add(sourceName);
+ continue;
+ }
+
+ // try the fallback name first
+ sourceName = ModuleFilenameHelpers.createFilename(module, fallbackModuleFilenameTemplate, requestShortener);
+ hasName = usedNamesSet.has(sourceName);
+ if(!hasName) {
+ moduleToSourceNameMapping.set(module, sourceName);
+ usedNamesSet.add(sourceName);
+ continue;
+ }
+
+ // elsewise just append stars until we have a valid name
+ while(hasName) {
+ sourceName += "*";
+ hasName = usedNamesSet.has(sourceName);
+ }
+ moduleToSourceNameMapping.set(module, sourceName);
+ usedNamesSet.add(sourceName);
+ }
tasks.forEach(function(task) {
const chunk = task.chunk;
const file = task.file;
const asset = task.asset;
const sourceMap = task.sourceMap;
const source = task.source;
- const moduleFilenames = task.moduleFilenames;
const modules = task.modules;
+ const moduleFilenames = modules.map(m => moduleToSourceNameMapping.get(m));
sourceMap.sources = moduleFilenames;
if(sourceMap.sourcesContent && !options.noSources) {
sourceMap.sourcesContent = sourceMap.sourcesContent.map((content, i) => `${content}\n\n\n${ModuleFilenameHelpers.createFooter(modules[i], requestShortener)}`);
@@ -131,6 +168,7 @@ class SourceMapDevToolPlugin {
if(currentSourceMappingURLComment !== false && /\.css($|\?)/i.test(file)) {
currentSourceMappingURLComment = currentSourceMappingURLComment.replace(/^\n\/\/(.*)$/, "\n/*$1*/");
}
+ const sourceMapString = JSON.stringify(sourceMap);
if(sourceMapFilename) {
let filename = file;
let query = "";
@@ -139,22 +177,25 @@ class SourceMapDevToolPlugin {
query = filename.substr(idx);
filename = filename.substr(0, idx);
}
- const sourceMapFile = compilation.getPath(sourceMapFilename, {
+ let sourceMapFile = compilation.getPath(sourceMapFilename, {
chunk,
filename,
query,
basename: basename(filename)
});
+ if(sourceMapFile.indexOf("[contenthash]") !== -1) {
+ sourceMapFile = sourceMapFile.replace(/\[contenthash\]/g, crypto.createHash("md5").update(sourceMapString).digest("hex"));
+ }
const sourceMapUrl = path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/");
if(currentSourceMappingURLComment !== false) {
asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment.replace(/\[url\]/g, sourceMapUrl));
}
- asset.__SourceMapDevToolData[sourceMapFile] = compilation.assets[sourceMapFile] = new RawSource(JSON.stringify(sourceMap));
+ asset.__SourceMapDevToolData[sourceMapFile] = compilation.assets[sourceMapFile] = new RawSource(sourceMapString);
chunk.files.push(sourceMapFile);
} else {
asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment
- .replace(/\[map\]/g, () => JSON.stringify(sourceMap))
- .replace(/\[url\]/g, () => `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf-8").toString("base64")}`) // eslint-disable-line
+ .replace(/\[map\]/g, () => sourceMapString)
+ .replace(/\[url\]/g, () => `data:application/json;charset=utf-8;base64,${new Buffer(sourceMapString, "utf-8").toString("base64")}`) // eslint-disable-line
);
}
});
diff --git a/node_modules/webpack/lib/Stats.js b/node_modules/webpack/lib/Stats.js
index 0b88faa64..16c191714 100644
--- a/node_modules/webpack/lib/Stats.js
+++ b/node_modules/webpack/lib/Stats.js
@@ -7,8 +7,13 @@
const RequestShortener = require("./RequestShortener");
const SizeFormatHelpers = require("./SizeFormatHelpers");
const formatLocation = require("./formatLocation");
+const identifierUtils = require("./util/identifier");
-const optionOrFallback = (optionValue, fallbackValue) => optionValue !== undefined ? optionValue : fallbackValue;
+const optionsOrFallback = function() {
+ let optionValues = [];
+ optionValues.push.apply(optionValues, arguments);
+ return optionValues.find(optionValue => typeof optionValue !== "undefined");
+};
class Stats {
constructor(compilation) {
@@ -75,50 +80,66 @@ class Stats {
options = {};
}
+ const optionOrLocalFallback = (v, def) =>
+ typeof v !== "undefined" ? v :
+ typeof options.all !== "undefined" ? options.all : def;
+
+ const testAgainstGivenOption = (item) => {
+ if(typeof item === "string") {
+ const regExp = new RegExp(`[\\\\/]${item.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")}([\\\\/]|$|!|\\?)`); // eslint-disable-line no-useless-escape
+ return ident => regExp.test(ident);
+ }
+ if(item && typeof item === "object" && typeof item.test === "function")
+ return ident => item.test(ident);
+ if(typeof item === "function")
+ return item;
+ };
+
const compilation = this.compilation;
- const requestShortener = new RequestShortener(optionOrFallback(options.context, process.cwd()));
- const showPerformance = optionOrFallback(options.performance, true);
- const showHash = optionOrFallback(options.hash, true);
- const showVersion = optionOrFallback(options.version, true);
- const showTimings = optionOrFallback(options.timings, true);
- const showAssets = optionOrFallback(options.assets, true);
- const showEntrypoints = optionOrFallback(options.entrypoints, !forToString);
- const showChunks = optionOrFallback(options.chunks, true);
- const showChunkModules = optionOrFallback(options.chunkModules, !!forToString);
- const showChunkOrigins = optionOrFallback(options.chunkOrigins, !forToString);
- const showModules = optionOrFallback(options.modules, !forToString);
- const showDepth = optionOrFallback(options.depth, !forToString);
- const showCachedModules = optionOrFallback(options.cached, true);
- const showCachedAssets = optionOrFallback(options.cachedAssets, true);
- const showReasons = optionOrFallback(options.reasons, !forToString);
- const showUsedExports = optionOrFallback(options.usedExports, !forToString);
- const showProvidedExports = optionOrFallback(options.providedExports, !forToString);
- const showChildren = optionOrFallback(options.children, true);
- const showSource = optionOrFallback(options.source, !forToString);
- const showModuleTrace = optionOrFallback(options.moduleTrace, true);
- const showErrors = optionOrFallback(options.errors, true);
- const showErrorDetails = optionOrFallback(options.errorDetails, !forToString);
- const showWarnings = optionOrFallback(options.warnings, true);
- const warningsFilter = optionOrFallback(options.warningsFilter, null);
- const showPublicPath = optionOrFallback(options.publicPath, !forToString);
- const excludeModules = [].concat(optionOrFallback(options.exclude, [])).map(str => {
- if(typeof str !== "string") return str;
- return new RegExp(`[\\\\/]${str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")}([\\\\/]|$|!|\\?)`);
- });
- const maxModules = optionOrFallback(options.maxModules, forToString ? 15 : Infinity);
- const sortModules = optionOrFallback(options.modulesSort, "id");
- const sortChunks = optionOrFallback(options.chunksSort, "id");
- const sortAssets = optionOrFallback(options.assetsSort, "");
+ const context = optionsOrFallback(options.context, process.cwd());
+ const requestShortener = new RequestShortener(context);
+ const showPerformance = optionOrLocalFallback(options.performance, true);
+ const showHash = optionOrLocalFallback(options.hash, true);
+ const showVersion = optionOrLocalFallback(options.version, true);
+ const showTimings = optionOrLocalFallback(options.timings, true);
+ const showAssets = optionOrLocalFallback(options.assets, true);
+ const showEntrypoints = optionOrLocalFallback(options.entrypoints, !forToString);
+ const showChunks = optionOrLocalFallback(options.chunks, !forToString);
+ const showChunkModules = optionOrLocalFallback(options.chunkModules, true);
+ const showChunkOrigins = optionOrLocalFallback(options.chunkOrigins, !forToString);
+ const showModules = optionOrLocalFallback(options.modules, true);
+ const showDepth = optionOrLocalFallback(options.depth, !forToString);
+ const showCachedModules = optionOrLocalFallback(options.cached, true);
+ const showCachedAssets = optionOrLocalFallback(options.cachedAssets, true);
+ const showReasons = optionOrLocalFallback(options.reasons, !forToString);
+ const showUsedExports = optionOrLocalFallback(options.usedExports, !forToString);
+ const showProvidedExports = optionOrLocalFallback(options.providedExports, !forToString);
+ const showOptimizationBailout = optionOrLocalFallback(options.optimizationBailout, !forToString);
+ const showChildren = optionOrLocalFallback(options.children, true);
+ const showSource = optionOrLocalFallback(options.source, !forToString);
+ const showModuleTrace = optionOrLocalFallback(options.moduleTrace, true);
+ const showErrors = optionOrLocalFallback(options.errors, true);
+ const showErrorDetails = optionOrLocalFallback(options.errorDetails, !forToString);
+ const showWarnings = optionOrLocalFallback(options.warnings, true);
+ const warningsFilter = optionsOrFallback(options.warningsFilter, null);
+ const showPublicPath = optionOrLocalFallback(options.publicPath, !forToString);
+ const excludeModules = [].concat(optionsOrFallback(options.excludeModules, options.exclude, [])).map(testAgainstGivenOption);
+ const excludeAssets = [].concat(optionsOrFallback(options.excludeAssets, [])).map(testAgainstGivenOption);
+ const maxModules = optionsOrFallback(options.maxModules, forToString ? 15 : Infinity);
+ const sortModules = optionsOrFallback(options.modulesSort, "id");
+ const sortChunks = optionsOrFallback(options.chunksSort, "id");
+ const sortAssets = optionsOrFallback(options.assetsSort, "");
+
+ if(!showCachedModules) {
+ excludeModules.push((ident, module) => !module.built);
+ }
const createModuleFilter = () => {
let i = 0;
return module => {
- if(!showCachedModules && !module.built) {
- return false;
- }
if(excludeModules.length > 0) {
const ident = requestShortener.shorten(module.resource);
- const excluded = excludeModules.some(regExp => regExp.test(ident));
+ const excluded = excludeModules.some(fn => fn(ident, module));
if(excluded)
return false;
}
@@ -126,6 +147,18 @@ class Stats {
};
};
+ const createAssetFilter = () => {
+ return asset => {
+ if(excludeAssets.length > 0) {
+ const ident = asset.name;
+ const excluded = excludeAssets.some(fn => fn(ident, asset));
+ if(excluded)
+ return false;
+ }
+ return showCachedAssets || asset.emitted;
+ };
+ };
+
const sortByFieldAndOrder = (fieldKey, a, b) => {
if(a[fieldKey] === null && b[fieldKey] === null) return 0;
if(a[fieldKey] === null) return 1;
@@ -217,8 +250,9 @@ class Stats {
}
if(showAssets) {
const assetsByFile = {};
+ const compilationAssets = Object.keys(compilation.assets);
obj.assetsByChunkName = {};
- obj.assets = Object.keys(compilation.assets).map(asset => {
+ obj.assets = compilationAssets.map(asset => {
const obj = {
name: asset,
size: compilation.assets[asset].size(),
@@ -233,7 +267,8 @@ class Stats {
assetsByFile[asset] = obj;
return obj;
- }).filter(asset => showCachedAssets || asset.emitted);
+ }).filter(createAssetFilter());
+ obj.filteredAssets = compilationAssets.length - obj.assets.length;
compilation.chunks.forEach(chunk => {
chunk.files.forEach(asset => {
@@ -280,7 +315,7 @@ class Stats {
built: !!module.built,
optional: !!module.optional,
prefetched: !!module.prefetched,
- chunks: module.chunks.map(chunk => chunk.id),
+ chunks: module.mapChunks(chunk => chunk.id),
assets: Object.keys(module.assets || {}),
issuer: module.issuer && module.issuer.identifier(),
issuerId: module.issuer && module.issuer.id,
@@ -311,6 +346,12 @@ class Stats {
if(showProvidedExports) {
obj.providedExports = Array.isArray(module.providedExports) ? module.providedExports : null;
}
+ if(showOptimizationBailout) {
+ obj.optimizationBailout = module.optimizationBailout.map(item => {
+ if(typeof item === "function") return item(requestShortener);
+ return item;
+ });
+ }
if(showDepth) {
obj.depth = module.depth;
}
@@ -328,19 +369,19 @@ class Stats {
entry: chunk.hasRuntime(),
recorded: chunk.recorded,
extraAsync: !!chunk.extraAsync,
- size: chunk.modules.reduce((size, module) => size + module.size(), 0),
+ size: chunk.mapModules(m => m.size()).reduce((size, moduleSize) => size + moduleSize, 0),
names: chunk.name ? [chunk.name] : [],
files: chunk.files.slice(),
hash: chunk.renderedHash,
parents: chunk.parents.map(c => c.id)
};
if(showChunkModules) {
- obj.modules = chunk.modules
- .slice()
+ obj.modules = chunk
+ .getModules()
.sort(sortByField("depth"))
.filter(createModuleFilter())
.map(fnModule);
- obj.filteredModules = chunk.modules.length - obj.modules.length;
+ obj.filteredModules = chunk.getNumberOfModules() - obj.modules.length;
obj.modules.sort(sortByField(sortModules));
}
if(showChunkOrigins) {
@@ -373,7 +414,8 @@ class Stats {
const obj = new Stats(child).toJson(childOptions, forToString);
delete obj.hash;
delete obj.version;
- obj.name = child.name;
+ if(child.name)
+ obj.name = identifierUtils.makePathsRelative(context, child.name, compilation.cache);
return obj;
});
}
@@ -388,7 +430,7 @@ class Stats {
options = {};
}
- const useColors = optionOrFallback(options.colors, false);
+ const useColors = optionsOrFallback(options.colors, false);
const obj = this.toJson(options, true);
@@ -555,6 +597,16 @@ class Stats {
});
table(t, "rrrlll");
}
+ if(obj.filteredAssets > 0) {
+ colors.normal(" ");
+ if(obj.assets.length > 0)
+ colors.normal("+ ");
+ colors.normal(obj.filteredAssets);
+ if(obj.assets.length > 0)
+ colors.normal(" hidden");
+ colors.normal(obj.filteredAssets !== 1 ? " assets" : " asset");
+ newline();
+ }
if(obj.entrypoints) {
Object.keys(obj.entrypoints).forEach(name => {
const ep = obj.entrypoints[name];
@@ -623,19 +675,29 @@ class Stats {
const processModuleContent = (module, prefix) => {
if(Array.isArray(module.providedExports)) {
colors.normal(prefix);
- colors.cyan(`[exports: ${module.providedExports.join(", ")}]`);
+ if(module.providedExports.length === 0)
+ colors.cyan("[no exports]");
+ else
+ colors.cyan(`[exports: ${module.providedExports.join(", ")}]`);
newline();
}
if(module.usedExports !== undefined) {
if(module.usedExports !== true) {
colors.normal(prefix);
- if(module.usedExports === false)
+ if(module.usedExports === false || module.usedExports.length === 0)
colors.cyan("[no exports used]");
else
colors.cyan(`[only some exports used: ${module.usedExports.join(", ")}]`);
newline();
}
}
+ if(Array.isArray(module.optimizationBailout)) {
+ module.optimizationBailout.forEach(item => {
+ colors.normal(prefix);
+ colors.yellow(item);
+ newline();
+ });
+ }
if(module.reasons) {
module.reasons.forEach(reason => {
colors.normal(prefix);
@@ -659,9 +721,9 @@ class Stats {
const path = [];
let current = module;
while(current.issuer) {
- path.unshift(current = current.issuer);
+ path.push(current = current.issuer);
}
- path.forEach(module => {
+ path.reverse().forEach(module => {
colors.normal("[");
colors.normal(module.id);
colors.normal("] ");
@@ -685,6 +747,35 @@ class Stats {
}
};
+ const processModulesList = (obj, prefix) => {
+ if(obj.modules) {
+ obj.modules.forEach(module => {
+ colors.normal(prefix);
+ if(module.id < 1000) colors.normal(" ");
+ if(module.id < 100) colors.normal(" ");
+ if(module.id < 10) colors.normal(" ");
+ colors.normal("[");
+ colors.normal(module.id);
+ colors.normal("] ");
+ colors.bold(module.name || module.identifier);
+ processModuleAttributes(module);
+ newline();
+ processModuleContent(module, prefix + " ");
+ });
+ if(obj.filteredModules > 0) {
+ colors.normal(prefix);
+ colors.normal(" ");
+ if(obj.modules.length > 0)
+ colors.normal(" + ");
+ colors.normal(obj.filteredModules);
+ if(obj.modules.length > 0)
+ colors.normal(" hidden");
+ colors.normal(obj.filteredModules !== 1 ? " modules" : " module");
+ newline();
+ }
+ }
+ };
+
if(obj.chunks) {
obj.chunks.forEach(chunk => {
colors.normal("chunk ");
@@ -746,45 +837,11 @@ class Stats {
newline();
});
}
- if(chunk.modules) {
- chunk.modules.forEach(module => {
- colors.normal(" ");
- if(module.id < 1000) colors.normal(" ");
- if(module.id < 100) colors.normal(" ");
- if(module.id < 10) colors.normal(" ");
- colors.normal("[");
- colors.normal(module.id);
- colors.normal("] ");
- colors.bold(module.name);
- processModuleAttributes(module);
- newline();
- processModuleContent(module, " ");
- });
- if(chunk.filteredModules > 0) {
- colors.normal(` + ${chunk.filteredModules} hidden modules`);
- newline();
- }
- }
+ processModulesList(chunk, " ");
});
}
- if(obj.modules) {
- obj.modules.forEach(module => {
- if(module.id < 1000) colors.normal(" ");
- if(module.id < 100) colors.normal(" ");
- if(module.id < 10) colors.normal(" ");
- colors.normal("[");
- colors.normal(module.id);
- colors.normal("] ");
- colors.bold(module.name || module.identifier);
- processModuleAttributes(module);
- newline();
- processModuleContent(module, " ");
- });
- if(obj.filteredModules > 0) {
- colors.normal(` + ${obj.filteredModules} hidden modules`);
- newline();
- }
- }
+
+ processModulesList(obj, "");
if(obj._showWarnings && obj.warnings) {
obj.warnings.forEach(warning => {
@@ -827,51 +884,63 @@ class Stats {
}
static presetToOptions(name) {
- //Accepted values: none, errors-only, minimal, normal, verbose
- //Any other falsy value will behave as 'none', truthy values as 'normal'
- const pn = (typeof name === "string") && name.toLowerCase() || name;
- if(pn === "none" || !pn) {
- return {
- hash: false,
- version: false,
- timings: false,
- assets: false,
- entrypoints: false,
- chunks: false,
- chunkModules: false,
- modules: false,
- reasons: false,
- depth: false,
- usedExports: false,
- providedExports: false,
- children: false,
- source: false,
- errors: false,
- errorDetails: false,
- warnings: false,
- publicPath: false,
- performance: false
- };
- } else {
- return {
- hash: pn !== "errors-only" && pn !== "minimal",
- version: pn === "verbose",
- timings: pn !== "errors-only" && pn !== "minimal",
- assets: pn === "verbose",
- entrypoints: pn === "verbose",
- chunks: pn !== "errors-only",
- chunkModules: pn === "verbose",
- //warnings: pn !== "errors-only",
- errorDetails: pn !== "errors-only" && pn !== "minimal",
- reasons: pn === "verbose",
- depth: pn === "verbose",
- usedExports: pn === "verbose",
- providedExports: pn === "verbose",
- colors: true,
- performance: true
- };
+ // Accepted values: none, errors-only, minimal, normal, detailed, verbose
+ // Any other falsy value will behave as 'none', truthy values as 'normal'
+ const pn = (typeof name === "string") && name.toLowerCase() || name || "none";
+ switch(pn) {
+ case "none":
+ return {
+ all: false
+ };
+ case "verbose":
+ return {
+ entrypoints: true,
+ modules: false,
+ chunks: true,
+ chunkModules: true,
+ chunkOrigins: true,
+ depth: true,
+ reasons: true,
+ usedExports: true,
+ providedExports: true,
+ optimizationBailout: true,
+ errorDetails: true,
+ publicPath: true,
+ exclude: () => false,
+ maxModules: Infinity,
+ };
+ case "detailed":
+ return {
+ entrypoints: true,
+ chunks: true,
+ chunkModules: false,
+ chunkOrigins: true,
+ depth: true,
+ usedExports: true,
+ providedExports: true,
+ optimizationBailout: true,
+ errorDetails: true,
+ publicPath: true,
+ exclude: () => false,
+ maxModules: Infinity,
+ };
+ case "minimal":
+ return {
+ all: false,
+ modules: true,
+ maxModules: 0,
+ errors: true,
+ warnings: true,
+ };
+ case "errors-only":
+ return {
+ all: false,
+ errors: true,
+ moduleTrace: true,
+ };
+ default:
+ return {};
}
-
}
static getChildOptions(options, idx) {
diff --git a/node_modules/webpack/lib/Template.js b/node_modules/webpack/lib/Template.js
index 461a03679..b3e17a823 100644
--- a/node_modules/webpack/lib/Template.js
+++ b/node_modules/webpack/lib/Template.js
@@ -28,7 +28,7 @@ module.exports = class Template extends Tapable {
static toPath(str) {
if(typeof str !== "string") return "";
- return str.replace(/[^a-zA-Z0-9_!§$()=\-\^°]+/g, "-").replace(/^-|-$/, "");
+ return str.replace(/[^a-zA-Z0-9_!§$()=\-^°]+/g, "-").replace(/^-|-$/, "");
}
// map number to a single character a-z, A-Z or <_ + number> if number is too big
@@ -99,12 +99,12 @@ module.exports = class Template extends Tapable {
renderChunkModules(chunk, moduleTemplate, dependencyTemplates, prefix) {
if(!prefix) prefix = "";
var source = new ConcatSource();
- if(chunk.modules.length === 0) {
+ if(chunk.getNumberOfModules() === 0) {
source.add("[]");
return source;
}
var removedModules = chunk.removedModules;
- var allModules = chunk.modules.map(function(module) {
+ var allModules = chunk.mapModules(function(module) {
return {
id: module.id,
source: moduleTemplate.render(module, dependencyTemplates, chunk)
@@ -118,7 +118,7 @@ module.exports = class Template extends Tapable {
});
});
}
- var bounds = this.getModulesArrayBounds(chunk.modules);
+ var bounds = this.getModulesArrayBounds(allModules);
if(bounds) {
// Render a spare array
diff --git a/node_modules/webpack/lib/UmdMainTemplatePlugin.js b/node_modules/webpack/lib/UmdMainTemplatePlugin.js
index 81873305a..3ddb98d23 100644
--- a/node_modules/webpack/lib/UmdMainTemplatePlugin.js
+++ b/node_modules/webpack/lib/UmdMainTemplatePlugin.js
@@ -23,7 +23,17 @@ function accessorAccess(base, accessor) {
class UmdMainTemplatePlugin {
constructor(name, options) {
- this.name = name;
+ if(typeof name === "object" && !Array.isArray(name)) {
+ this.name = name.root || name.amd || name.commonjs;
+ this.names = name;
+ } else {
+ this.name = name;
+ this.names = {
+ commonjs: name,
+ root: name,
+ amd: name
+ };
+ }
this.optionalAmdExternalAsGlobal = options.optionalAmdExternalAsGlobal;
this.namedDefine = options.namedDefine;
this.auxiliaryComment = options.auxiliaryComment;
@@ -31,8 +41,8 @@ class UmdMainTemplatePlugin {
apply(compilation) {
const mainTemplate = compilation.mainTemplate;
- compilation.templatesPlugin("render-with-entry", function(source, chunk, hash) {
- let externals = chunk.modules.filter(m => m.external);
+ compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
+ let externals = chunk.getModules().filter(m => m.external);
const optionalExternals = [];
let requiredExternals = [];
if(this.optionalAmdExternalAsGlobal) {
@@ -72,6 +82,7 @@ class UmdMainTemplatePlugin {
let expr;
let request = m.request;
if(typeof request === "object") request = request[type];
+ if(typeof request === "undefined") throw new Error("Missing external configuration for type:" + type);
if(Array.isArray(request)) {
expr = `require(${JSON.stringify(request[0])})${accessorToObjectAccess(request.slice(1))}`;
} else
@@ -124,16 +135,16 @@ class UmdMainTemplatePlugin {
) +
" else if(typeof define === 'function' && define.amd)\n" +
(requiredExternals.length > 0 ?
- (this.name && this.namedDefine === true ?
- " define(" + libraryName(this.name) + ", " + externalsDepsArray(requiredExternals) + ", " + amdFactory + ");\n" :
+ (this.names.amd && this.namedDefine === true ?
+ " define(" + libraryName(this.names.amd) + ", " + externalsDepsArray(requiredExternals) + ", " + amdFactory + ");\n" :
" define(" + externalsDepsArray(requiredExternals) + ", " + amdFactory + ");\n"
) :
- (this.name && this.namedDefine === true ?
- " define(" + libraryName(this.name) + ", [], " + amdFactory + ");\n" :
+ (this.names.amd && this.namedDefine === true ?
+ " define(" + libraryName(this.names.amd) + ", [], " + amdFactory + ");\n" :
" define([], " + amdFactory + ");\n"
)
) +
- (this.name ?
+ (this.names.root || this.names.commonjs ?
(this.auxiliaryComment &&
typeof this.auxiliaryComment === "string" ?
" //" + this.auxiliaryComment + "\n" :
@@ -142,7 +153,7 @@ class UmdMainTemplatePlugin {
""
) +
" else if(typeof exports === 'object')\n" +
- " exports[" + libraryName(this.name) + "] = factory(" + externalsRequireArray("commonjs") + ");\n" +
+ " exports[" + libraryName(this.names.commonjs || this.names.root) + "] = factory(" + externalsRequireArray("commonjs") + ");\n" +
(this.auxiliaryComment &&
typeof this.auxiliaryComment === "string" ?
" //" + this.auxiliaryComment + "\n" :
@@ -151,7 +162,7 @@ class UmdMainTemplatePlugin {
""
) +
" else\n" +
- " " + replaceKeys(accessorAccess("root", this.name)) + " = factory(" + externalsRootArray(externals) + ");\n" :
+ " " + replaceKeys(accessorAccess("root", this.names.root || this.names.commonjs)) + " = factory(" + externalsRootArray(externals) + ");\n" :
" else {\n" +
(externals.length > 0 ?
" var a = typeof exports === 'object' ? factory(" + externalsRequireArray("commonjs") + ") : factory(" + externalsRootArray(externals) + ");\n" :
@@ -161,15 +172,19 @@ class UmdMainTemplatePlugin {
" }\n"
) +
"})(this, function(" + externalsArguments(externals) + ") {\nreturn ", "webpack/universalModuleDefinition"), source, ";\n})");
- }.bind(this));
- mainTemplate.plugin("global-hash-paths", function(paths) {
- if(this.name) paths = paths.concat(this.name);
+ });
+ mainTemplate.plugin("global-hash-paths", (paths) => {
+ if(this.names.root) paths = paths.concat(this.names.root);
+ if(this.names.amd) paths = paths.concat(this.names.amd);
+ if(this.names.commonjs) paths = paths.concat(this.names.commonjs);
return paths;
- }.bind(this));
- mainTemplate.plugin("hash", function(hash) {
+ });
+ mainTemplate.plugin("hash", (hash) => {
hash.update("umd");
- hash.update(`${this.name}`);
- }.bind(this));
+ hash.update(`${this.names.root}`);
+ hash.update(`${this.names.amd}`);
+ hash.update(`${this.names.commonjs}`);
+ });
}
}
diff --git a/node_modules/webpack/lib/WebpackOptionsApply.js b/node_modules/webpack/lib/WebpackOptionsApply.js
index e9231447c..ebddba717 100644
--- a/node_modules/webpack/lib/WebpackOptionsApply.js
+++ b/node_modules/webpack/lib/WebpackOptionsApply.js
@@ -73,7 +73,7 @@ class WebpackOptionsApply extends OptionsApply {
new JsonpTemplatePlugin(options.output),
new FunctionModulePlugin(options.output),
new NodeSourcePlugin(options.node),
- new LoaderTargetPlugin("web")
+ new LoaderTargetPlugin(options.target)
);
break;
case "webworker":
@@ -84,7 +84,7 @@ class WebpackOptionsApply extends OptionsApply {
new WebWorkerTemplatePlugin(),
new FunctionModulePlugin(options.output),
new NodeSourcePlugin(options.node),
- new LoaderTargetPlugin("webworker")
+ new LoaderTargetPlugin(options.target)
);
break;
}
@@ -110,7 +110,7 @@ class WebpackOptionsApply extends OptionsApply {
new FunctionModulePlugin(options.output),
new NodeTargetPlugin(),
new ExternalsPlugin("commonjs", "nw.gui"),
- new LoaderTargetPlugin("node-webkit")
+ new LoaderTargetPlugin(options.target)
);
break;
case "atom":
@@ -187,7 +187,7 @@ class WebpackOptionsApply extends OptionsApply {
if(options.output.library || options.output.libraryTarget !== "var") {
let LibraryTemplatePlugin = require("./LibraryTemplatePlugin");
- compiler.apply(new LibraryTemplatePlugin(options.output.library, options.output.libraryTarget, options.output.umdNamedDefine, options.output.auxiliaryComment || ""));
+ compiler.apply(new LibraryTemplatePlugin(options.output.library, options.output.libraryTarget, options.output.umdNamedDefine, options.output.auxiliaryComment || "", options.output.libraryExport));
}
if(options.externals) {
ExternalsPlugin = require("./ExternalsPlugin");
@@ -247,7 +247,7 @@ class WebpackOptionsApply extends OptionsApply {
new UseStrictPlugin(),
new RequireIncludePlugin(),
new RequireEnsurePlugin(),
- new RequireContextPlugin(options.resolve.modules, options.resolve.extensions),
+ new RequireContextPlugin(options.resolve.modules, options.resolve.extensions, options.resolve.mainFiles),
new ImportPlugin(options.module),
new SystemPlugin(options.module)
);
diff --git a/node_modules/webpack/lib/WebpackOptionsDefaulter.js b/node_modules/webpack/lib/WebpackOptionsDefaulter.js
index 48d8d472d..24bb42321 100644
--- a/node_modules/webpack/lib/WebpackOptionsDefaulter.js
+++ b/node_modules/webpack/lib/WebpackOptionsDefaulter.js
@@ -28,6 +28,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
this.set("module.wrappedContextRecursive", true);
this.set("module.wrappedContextCritical", false);
this.set("module.strictExportPresence", false);
+ this.set("module.strictThisContextOnImports", false);
this.set("module.unsafeCache", true);
@@ -84,6 +85,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
this.set("resolve.unsafeCache", true);
this.set("resolve.modules", ["node_modules"]);
this.set("resolve.extensions", [".js", ".json"]);
+ this.set("resolve.mainFiles", ["index"]);
this.set("resolve.aliasFields", "make", (options) => {
if(options.target === "web" || options.target === "webworker")
return ["browser"];
@@ -96,10 +98,17 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
else
return ["module", "main"];
});
+ this.set("resolve.cacheWithContext", "make", (options) => {
+ return Array.isArray(options.resolve.plugins) && options.resolve.plugins.length > 0;
+ });
this.set("resolveLoader", {});
this.set("resolveLoader.unsafeCache", true);
this.set("resolveLoader.mainFields", ["loader", "main"]);
this.set("resolveLoader.extensions", [".js", ".json"]);
+ this.set("resolveLoader.mainFiles", ["index"]);
+ this.set("resolveLoader.cacheWithContext", "make", (options) => {
+ return Array.isArray(options.resolveLoader.plugins) && options.resolveLoader.plugins.length > 0;
+ });
}
}
diff --git a/node_modules/webpack/lib/dependencies/AMDPlugin.js b/node_modules/webpack/lib/dependencies/AMDPlugin.js
index d1d5cf09e..944241c23 100644
--- a/node_modules/webpack/lib/dependencies/AMDPlugin.js
+++ b/node_modules/webpack/lib/dependencies/AMDPlugin.js
@@ -82,8 +82,8 @@ class AMDPlugin {
parser.state.current.addVariable("__webpack_amd_options__", JSON.stringify(amdOptions)));
parser.plugin("evaluate typeof define.amd", ParserHelpers.evaluateToString(typeof amdOptions));
parser.plugin("evaluate typeof require.amd", ParserHelpers.evaluateToString(typeof amdOptions));
- parser.plugin("evaluate Identifier define.amd", ParserHelpers.evaluateToBoolean(true));
- parser.plugin("evaluate Identifier require.amd", ParserHelpers.evaluateToBoolean(true));
+ parser.plugin("evaluate Identifier define.amd", ParserHelpers.evaluateToIdentifier("define.amd", true));
+ parser.plugin("evaluate Identifier require.amd", ParserHelpers.evaluateToIdentifier("require.amd", true));
parser.plugin("typeof define", ParserHelpers.toConstantDependency(JSON.stringify("function")));
parser.plugin("evaluate typeof define", ParserHelpers.evaluateToString("function"));
parser.plugin("can-rename define", ParserHelpers.approve);
diff --git a/node_modules/webpack/lib/dependencies/CommonJsPlugin.js b/node_modules/webpack/lib/dependencies/CommonJsPlugin.js
index e514fd99e..218cddb3d 100644
--- a/node_modules/webpack/lib/dependencies/CommonJsPlugin.js
+++ b/node_modules/webpack/lib/dependencies/CommonJsPlugin.js
@@ -54,8 +54,9 @@ class CommonJsPlugin {
const requireExpressions = ["require", "require.resolve", "require.resolveWeak"];
for(let expression of requireExpressions) {
- parser.plugin(`typeof ${expression}`, ParserHelpers.toConstantDependency("function"));
+ parser.plugin(`typeof ${expression}`, ParserHelpers.toConstantDependency(JSON.stringify("function")));
parser.plugin(`evaluate typeof ${expression}`, ParserHelpers.evaluateToString("function"));
+ parser.plugin(`evaluate Identifier ${expression}`, ParserHelpers.evaluateToIdentifier(expression, true));
}
parser.plugin("evaluate typeof module", ParserHelpers.evaluateToString("object"));
diff --git a/node_modules/webpack/lib/dependencies/DelegatedExportsDependency.js b/node_modules/webpack/lib/dependencies/DelegatedExportsDependency.js
new file mode 100644
index 000000000..ad36acbe4
--- /dev/null
+++ b/node_modules/webpack/lib/dependencies/DelegatedExportsDependency.js
@@ -0,0 +1,33 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+const NullDependency = require("./NullDependency");
+
+class DelegatedExportsDependency extends NullDependency {
+ constructor(originModule, exports) {
+ super();
+ this.originModule = originModule;
+ this.exports = exports;
+ }
+
+ get type() {
+ return "delegated exports";
+ }
+
+ getReference() {
+ return {
+ module: this.originModule,
+ importedNames: true
+ };
+ }
+
+ getExports() {
+ return {
+ exports: this.exports
+ };
+ }
+}
+
+module.exports = DelegatedExportsDependency;
diff --git a/node_modules/webpack/lib/dependencies/DepBlockHelpers.js b/node_modules/webpack/lib/dependencies/DepBlockHelpers.js
index d4a4014ec..c1e48a3a5 100644
--- a/node_modules/webpack/lib/dependencies/DepBlockHelpers.js
+++ b/node_modules/webpack/lib/dependencies/DepBlockHelpers.js
@@ -2,10 +2,12 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var DepBlockHelpers = exports;
+"use strict";
-DepBlockHelpers.getLoadDepBlockWrapper = function(depBlock, outputOptions, requestShortener, name) {
- var promiseCode = DepBlockHelpers.getDepBlockPromise(depBlock, outputOptions, requestShortener, name);
+const DepBlockHelpers = exports;
+
+DepBlockHelpers.getLoadDepBlockWrapper = (depBlock, outputOptions, requestShortener, name) => {
+ const promiseCode = DepBlockHelpers.getDepBlockPromise(depBlock, outputOptions, requestShortener, name);
return [
promiseCode + ".then(",
").catch(",
@@ -13,24 +15,19 @@ DepBlockHelpers.getLoadDepBlockWrapper = function(depBlock, outputOptions, reque
];
};
-DepBlockHelpers.getDepBlockPromise = function(depBlock, outputOptions, requestShortener, name) {
+DepBlockHelpers.getDepBlockPromise = (depBlock, outputOptions, requestShortener, name) => {
if(depBlock.chunks) {
- var chunks = depBlock.chunks.filter(function(chunk) {
- return !chunk.hasRuntime() && chunk.id !== null;
- });
+ const chunks = depBlock.chunks.filter(chunk => !chunk.hasRuntime() && chunk.id !== null);
+ const pathChunkCheck = outputOptions.pathinfo && depBlock.chunkName;
+ const shortChunkName = requestShortener.shorten(depBlock.chunkName);
+ const chunkReason = asComment(depBlock.chunkReason);
+ const requireChunkId = chunk => "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")";
+ name = asComment(name);
if(chunks.length === 1) {
- var chunk = chunks[0];
- return "__webpack_require__.e" + asComment(name) + "(" + JSON.stringify(chunk.id) + "" +
- (outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : "") +
- asComment(depBlock.chunkReason) + ")";
+ const chunkId = JSON.stringify(chunks[0].id);
+ return `__webpack_require__.e${name}(${chunkId}${pathChunkCheck ? "/*! " + shortChunkName + " */" : ""}${chunkReason})`;
} else if(chunks.length > 0) {
- return "Promise.all" + asComment(name) + "(" +
- (outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : "") +
- "[" +
- chunks.map(function(chunk) {
- return "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")";
- }).join(", ") +
- "])";
+ return `Promise.all${name}(${pathChunkCheck ? "/*! " + shortChunkName + " */" : ""}[${chunks.map(requireChunkId).join(", ")}])`;
}
}
return "new Promise(function(resolve) { resolve(); })";
@@ -38,5 +35,5 @@ DepBlockHelpers.getDepBlockPromise = function(depBlock, outputOptions, requestSh
function asComment(str) {
if(!str) return "";
- return "/* " + str + " */";
+ return `/* ${str} */`;
}
diff --git a/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js b/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js
index 9407499dc..8bd7bb708 100644
--- a/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js
+++ b/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js
@@ -21,7 +21,7 @@ HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate
const usedExports = dep.originModule.usedExports;
if(usedExports && !Array.isArray(usedExports)) {
const exportName = dep.originModule.exportsArgument || "exports";
- const content = `Object.defineProperty(${exportName}, \"__esModule\", { value: true });\n`;
+ const content = `Object.defineProperty(${exportName}, "__esModule", { value: true });\n`;
source.insert(-10, content);
}
}
diff --git a/node_modules/webpack/lib/dependencies/HarmonyImportDependencyParserPlugin.js b/node_modules/webpack/lib/dependencies/HarmonyImportDependencyParserPlugin.js
index 973383551..d756688d2 100644
--- a/node_modules/webpack/lib/dependencies/HarmonyImportDependencyParserPlugin.js
+++ b/node_modules/webpack/lib/dependencies/HarmonyImportDependencyParserPlugin.js
@@ -13,6 +13,7 @@ const HarmonyModulesHelpers = require("./HarmonyModulesHelpers");
module.exports = class HarmonyImportDependencyParserPlugin {
constructor(moduleOptions) {
this.strictExportPresence = moduleOptions.strictExportPresence;
+ this.strictThisContextOnImports = moduleOptions.strictThisContextOnImports;
}
apply(parser) {
@@ -52,6 +53,24 @@ module.exports = class HarmonyImportDependencyParserPlugin {
parser.state.current.addDependency(dep);
return true;
});
+ if(this.strictThisContextOnImports) {
+ // only in case when we strictly follow the spec we need a special case here
+ parser.plugin("call imported var.*", (expr) => {
+ const name = expr.callee.object.name;
+ const settings = parser.state.harmonySpecifier[`$${name}`];
+ if(settings[2] !== null)
+ return false;
+ const dep = new HarmonyImportSpecifierDependency(settings[0], settings[1], expr.callee.property.name || expr.callee.property.value, name, expr.callee.range, this.strictExportPresence);
+ dep.shorthand = parser.scope.inShorthand;
+ dep.directImport = false;
+ dep.namespaceObjectAsContext = true;
+ dep.loc = expr.callee.loc;
+ parser.state.current.addDependency(dep);
+ if(expr.arguments)
+ parser.walkExpressions(expr.arguments);
+ return true;
+ });
+ }
parser.plugin("call imported var", (expr) => {
const args = expr.arguments;
const fullExpr = expr;
diff --git a/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js b/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js
index 01290b962..083019291 100644
--- a/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js
+++ b/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js
@@ -14,6 +14,10 @@ class HarmonyImportSpecifierDependency extends NullDependency {
this.name = name;
this.range = range;
this.strictExportPresence = strictExportPresence;
+ this.namespaceObjectAsContext = false;
+ this.callArgs = undefined;
+ this.call = undefined;
+ this.directImport = undefined;
}
get type() {
@@ -24,7 +28,7 @@ class HarmonyImportSpecifierDependency extends NullDependency {
if(!this.importDependency.module) return null;
return {
module: this.importDependency.module,
- importedNames: this.id ? [this.id] : true
+ importedNames: this.id && !this.namespaceObjectAsContext ? [this.id] : true
};
}
@@ -93,7 +97,7 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
}
if(dep.call && dep.id) {
- return `${shortHandPrefix}__webpack_require__.i(${importedVar}${importedVarSuffix})`;
+ return `${shortHandPrefix}Object(${importedVar}${importedVarSuffix})`;
}
return `${shortHandPrefix}${importedVar}${importedVarSuffix}`;
diff --git a/node_modules/webpack/lib/dependencies/HarmonyModulesHelpers.js b/node_modules/webpack/lib/dependencies/HarmonyModulesHelpers.js
index cd3b63115..1f3387fe1 100644
--- a/node_modules/webpack/lib/dependencies/HarmonyModulesHelpers.js
+++ b/node_modules/webpack/lib/dependencies/HarmonyModulesHelpers.js
@@ -8,12 +8,12 @@ class HarmonyModulesHelpers {
static getModuleVar(state, request) {
if(!state.harmonyModules) state.harmonyModules = [];
- var idx = state.harmonyModules.indexOf(request);
+ let idx = state.harmonyModules.indexOf(request);
if(idx < 0) {
idx = state.harmonyModules.length;
state.harmonyModules.push(request);
}
- return "__WEBPACK_IMPORTED_MODULE_" + idx + "_" + request.replace(/[^A-Za-z0-9_]/g, "_").replace(/__+/g, "_") + "__";
+ return `__WEBPACK_IMPORTED_MODULE_${idx}_${request.replace(/[^A-Za-z0-9_]/g, "_").replace(/__+/g, "_")}__`;
}
static getNewModuleVar(state, request) {
@@ -31,17 +31,17 @@ class HarmonyModulesHelpers {
// checks if an harmony dependency is active in a module according to
// precedence rules.
static isActive(module, depInQuestion) {
- var desc = depInQuestion.describeHarmonyExport();
+ const desc = depInQuestion.describeHarmonyExport();
if(!desc.exportedName) return true;
- var before = true;
- for(var i = 0; i < module.dependencies.length; i++) {
- var dep = module.dependencies[i];
+ let before = true;
+ for(const moduleDependency of module.dependencies) {
+ const dep = moduleDependency;
if(dep === depInQuestion) {
before = false;
continue;
}
if(!dep.describeHarmonyExport) continue;
- var d = dep.describeHarmonyExport();
+ const d = dep.describeHarmonyExport();
if(!d || !d.exportedName) continue;
if(d.exportedName === desc.exportedName) {
if(d.precedence < desc.precedence) {
@@ -58,7 +58,7 @@ class HarmonyModulesHelpers {
// get a list of named exports defined in a module
// doesn't include * reexports.
static getActiveExports(module, currentDependency) {
- var desc = currentDependency && currentDependency.describeHarmonyExport();
+ const desc = currentDependency && currentDependency.describeHarmonyExport();
var currentIndex = currentDependency ? module.dependencies.indexOf(currentDependency) : -1;
return module.dependencies.map((dep, idx) => {
return {
@@ -66,9 +66,9 @@ class HarmonyModulesHelpers {
idx: idx
};
}).reduce((arr, data) => {
- var dep = data.dep;
+ const dep = data.dep;
if(!dep.describeHarmonyExport) return arr;
- var d = dep.describeHarmonyExport();
+ const d = dep.describeHarmonyExport();
if(!d) return arr;
if(!desc || (d.precedence < desc.precedence) || (d.precedence === desc.precedence && data.idx < currentIndex)) {
var names = [].concat(d.exportedName);
diff --git a/node_modules/webpack/lib/dependencies/ImportParserPlugin.js b/node_modules/webpack/lib/dependencies/ImportParserPlugin.js
index d97355dc7..a775571b2 100644
--- a/node_modules/webpack/lib/dependencies/ImportParserPlugin.js
+++ b/node_modules/webpack/lib/dependencies/ImportParserPlugin.js
@@ -5,6 +5,8 @@
"use strict";
const ImportEagerContextDependency = require("./ImportEagerContextDependency");
+const ImportWeakDependency = require("./ImportWeakDependency");
+const ImportWeakContextDependency = require("./ImportWeakContextDependency");
const ImportLazyOnceContextDependency = require("./ImportLazyOnceContextDependency");
const ImportLazyContextDependency = require("./ImportLazyContextDependency");
const ImportDependenciesBlock = require("./ImportDependenciesBlock");
@@ -46,26 +48,31 @@ class ImportParserPlugin {
}
if(param.isString()) {
- if(mode !== "lazy" && mode !== "eager") {
- parser.state.module.warnings.push(new UnsupportedFeatureWarning(parser.state.module, `\`webpackMode\` expected 'lazy' or 'eager', but received: ${mode}.`));
+ if(mode !== "lazy" && mode !== "eager" && mode !== "weak") {
+ parser.state.module.warnings.push(new UnsupportedFeatureWarning(parser.state.module, `\`webpackMode\` expected 'lazy', 'eager' or 'weak', but received: ${mode}.`));
}
if(mode === "eager") {
const dep = new ImportEagerDependency(param.string, expr.range);
parser.state.current.addDependency(dep);
+ } else if(mode === "weak") {
+ const dep = new ImportWeakDependency(param.string, expr.range);
+ parser.state.current.addDependency(dep);
} else {
const depBlock = new ImportDependenciesBlock(param.string, expr.range, chunkName, parser.state.module, expr.loc);
parser.state.current.addBlock(depBlock);
}
return true;
} else {
- if(mode !== "lazy" && mode !== "lazy-once" && mode !== "eager") {
- parser.state.module.warnings.push(new UnsupportedFeatureWarning(parser.state.module, `\`webpackMode\` expected 'lazy', 'lazy-once' or 'eager', but received: ${mode}.`));
+ if(mode !== "lazy" && mode !== "lazy-once" && mode !== "eager" && mode !== "weak") {
+ parser.state.module.warnings.push(new UnsupportedFeatureWarning(parser.state.module, `\`webpackMode\` expected 'lazy', 'lazy-once', 'eager' or 'weak', but received: ${mode}.`));
}
let Dep = ImportLazyContextDependency;
if(mode === "eager") {
Dep = ImportEagerContextDependency;
+ } else if(mode === "weak") {
+ Dep = ImportWeakContextDependency;
} else if(mode === "lazy-once") {
Dep = ImportLazyOnceContextDependency;
}
diff --git a/node_modules/webpack/lib/dependencies/ImportPlugin.js b/node_modules/webpack/lib/dependencies/ImportPlugin.js
index 4905df183..27118bbcf 100644
--- a/node_modules/webpack/lib/dependencies/ImportPlugin.js
+++ b/node_modules/webpack/lib/dependencies/ImportPlugin.js
@@ -6,7 +6,9 @@
const ImportDependency = require("./ImportDependency");
const ImportEagerDependency = require("./ImportEagerDependency");
+const ImportWeakDependency = require("./ImportWeakDependency");
const ImportEagerContextDependency = require("./ImportEagerContextDependency");
+const ImportWeakContextDependency = require("./ImportWeakContextDependency");
const ImportLazyOnceContextDependency = require("./ImportLazyOnceContextDependency");
const ImportLazyContextDependency = require("./ImportLazyContextDependency");
const ImportParserPlugin = require("./ImportParserPlugin");
@@ -28,16 +30,22 @@ class ImportPlugin {
compilation.dependencyFactories.set(ImportEagerDependency, normalModuleFactory);
compilation.dependencyTemplates.set(ImportEagerDependency, new ImportEagerDependency.Template());
+ compilation.dependencyFactories.set(ImportWeakDependency, normalModuleFactory);
+ compilation.dependencyTemplates.set(ImportWeakDependency, new ImportWeakDependency.Template());
+
compilation.dependencyFactories.set(ImportEagerContextDependency, contextModuleFactory);
compilation.dependencyTemplates.set(ImportEagerContextDependency, new ImportEagerContextDependency.Template());
+ compilation.dependencyFactories.set(ImportWeakContextDependency, contextModuleFactory);
+ compilation.dependencyTemplates.set(ImportWeakContextDependency, new ImportWeakContextDependency.Template());
+
compilation.dependencyFactories.set(ImportLazyOnceContextDependency, contextModuleFactory);
compilation.dependencyTemplates.set(ImportLazyOnceContextDependency, new ImportLazyOnceContextDependency.Template());
compilation.dependencyFactories.set(ImportLazyContextDependency, contextModuleFactory);
compilation.dependencyTemplates.set(ImportLazyContextDependency, new ImportLazyContextDependency.Template());
- params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
+ normalModuleFactory.plugin("parser", (parser, parserOptions) => {
if(typeof parserOptions.import !== "undefined" && !parserOptions.import)
return;
diff --git a/node_modules/webpack/lib/dependencies/ImportWeakContextDependency.js b/node_modules/webpack/lib/dependencies/ImportWeakContextDependency.js
new file mode 100644
index 000000000..f6c19613e
--- /dev/null
+++ b/node_modules/webpack/lib/dependencies/ImportWeakContextDependency.js
@@ -0,0 +1,22 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+const ImportContextDependency = require("./ImportContextDependency");
+const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
+
+class ImportWeakContextDependency extends ImportContextDependency {
+ constructor(request, recursive, regExp, range, valueRange, chunkName) {
+ super(request, recursive, regExp, range, valueRange, chunkName);
+ this.async = "async-weak";
+ }
+
+ get type() {
+ return "import() context weak";
+ }
+}
+
+ImportWeakContextDependency.Template = ContextDependencyTemplateAsRequireCall;
+
+module.exports = ImportWeakContextDependency;
diff --git a/node_modules/webpack/lib/dependencies/ImportWeakDependency.js b/node_modules/webpack/lib/dependencies/ImportWeakDependency.js
new file mode 100644
index 000000000..ccad2d92c
--- /dev/null
+++ b/node_modules/webpack/lib/dependencies/ImportWeakDependency.js
@@ -0,0 +1,47 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+const ModuleDependency = require("./ModuleDependency");
+const webpackMissingPromiseModule = require("./WebpackMissingModule").promise;
+
+class ImportWeakDependency extends ModuleDependency {
+ constructor(request, range) {
+ super(request);
+ this.range = range;
+ this.weak = true;
+ }
+
+ get type() {
+ return "import() weak";
+ }
+}
+
+ImportWeakDependency.Template = class ImportDependencyTemplate {
+ apply(dep, source, outputOptions, requestShortener) {
+ const comment = this.getOptionalComment(outputOptions.pathinfo, requestShortener.shorten(dep.request));
+
+ const content = this.getContent(dep, comment);
+ source.replace(dep.range[0], dep.range[1] - 1, content);
+ }
+
+ getOptionalComment(pathinfo, shortenedRequest) {
+ if(!pathinfo) {
+ return "";
+ }
+
+ return `/*! ${shortenedRequest} */ `;
+ }
+
+ getContent(dep, comment) {
+ if(dep.module) {
+ const stringifiedId = JSON.stringify(dep.module.id);
+ return `Promise.resolve(${comment}${stringifiedId}).then(function(id) { if(!__webpack_require__.m[id]) throw new Error("Module '" + id + "' is not available (weak dependency)"); return __webpack_require__(id); })`;
+ }
+
+ return webpackMissingPromiseModule(dep.request);
+ }
+};
+
+module.exports = ImportWeakDependency;
diff --git a/node_modules/webpack/lib/dependencies/RequireContextDependency.js b/node_modules/webpack/lib/dependencies/RequireContextDependency.js
index c0f6bdc75..e37b1b54c 100644
--- a/node_modules/webpack/lib/dependencies/RequireContextDependency.js
+++ b/node_modules/webpack/lib/dependencies/RequireContextDependency.js
@@ -7,9 +7,13 @@ const ContextDependency = require("./ContextDependency");
const ModuleDependencyTemplateAsRequireId = require("./ModuleDependencyTemplateAsRequireId");
class RequireContextDependency extends ContextDependency {
- constructor(request, recursive, regExp, range) {
+ constructor(request, recursive, regExp, asyncMode, range) {
super(request, recursive, regExp);
this.range = range;
+
+ if(asyncMode) {
+ this.async = asyncMode;
+ }
}
get type() {
diff --git a/node_modules/webpack/lib/dependencies/RequireContextDependencyParserPlugin.js b/node_modules/webpack/lib/dependencies/RequireContextDependencyParserPlugin.js
index 8587fba8d..04a8b25b9 100644
--- a/node_modules/webpack/lib/dependencies/RequireContextDependencyParserPlugin.js
+++ b/node_modules/webpack/lib/dependencies/RequireContextDependencyParserPlugin.js
@@ -11,7 +11,15 @@ module.exports = class RequireContextDependencyParserPlugin {
parser.plugin("call require.context", expr => {
let regExp = /^\.\/.*$/;
let recursive = true;
+ let asyncMode;
switch(expr.arguments.length) {
+ case 4:
+ {
+ const asyncModeExpr = parser.evaluateExpression(expr.arguments[3]);
+ if(!asyncModeExpr.isString()) return;
+ asyncMode = asyncModeExpr.string;
+ }
+ // falls through
case 3:
{
const regExpExpr = parser.evaluateExpression(expr.arguments[2]);
@@ -30,7 +38,7 @@ module.exports = class RequireContextDependencyParserPlugin {
{
const requestExpr = parser.evaluateExpression(expr.arguments[0]);
if(!requestExpr.isString()) return;
- const dep = new RequireContextDependency(requestExpr.string, recursive, regExp, expr.range);
+ const dep = new RequireContextDependency(requestExpr.string, recursive, regExp, asyncMode, expr.range);
dep.loc = expr.loc;
dep.optional = parser.scope.inTry;
parser.state.current.addDependency(dep);
diff --git a/node_modules/webpack/lib/dependencies/RequireContextPlugin.js b/node_modules/webpack/lib/dependencies/RequireContextPlugin.js
index 57acda586..3e08729d3 100644
--- a/node_modules/webpack/lib/dependencies/RequireContextPlugin.js
+++ b/node_modules/webpack/lib/dependencies/RequireContextPlugin.js
@@ -10,18 +10,17 @@ const ContextElementDependency = require("./ContextElementDependency");
const RequireContextDependencyParserPlugin = require("./RequireContextDependencyParserPlugin");
class RequireContextPlugin {
- constructor(modulesDirectories, extensions) {
+ constructor(modulesDirectories, extensions, mainFiles) {
if(!Array.isArray(modulesDirectories))
throw new Error("modulesDirectories must be an array");
if(!Array.isArray(extensions))
throw new Error("extensions must be an array");
this.modulesDirectories = modulesDirectories;
this.extensions = extensions;
+ this.mainFiles = mainFiles;
}
apply(compiler) {
- const modulesDirectories = this.modulesDirectories;
- const extensions = this.extensions;
compiler.plugin("compilation", (compilation, params) => {
const contextModuleFactory = params.contextModuleFactory;
const normalModuleFactory = params.normalModuleFactory;
@@ -43,7 +42,7 @@ class RequireContextPlugin {
if(items.length === 0) return callback(null, items);
callback(null, items.map((obj) => {
- return extensions.filter((ext) => {
+ return this.extensions.filter((ext) => {
const l = obj.request.length;
return l > ext.length && obj.request.substr(l - ext.length, l) === ext;
}).map((ext) => {
@@ -60,8 +59,28 @@ class RequireContextPlugin {
if(items.length === 0) return callback(null, items);
callback(null, items.map((obj) => {
- for(let i = 0; i < modulesDirectories.length; i++) {
- const dir = modulesDirectories[i];
+ return this.mainFiles.filter((mainFile) => {
+ const l = obj.request.length;
+ return l > mainFile.length + 1 && obj.request.substr(l - mainFile.length - 1, l) === "/" + mainFile;
+ }).map((mainFile) => {
+ const l = obj.request.length;
+ return [{
+ context: obj.context,
+ request: obj.request.substr(0, l - mainFile.length)
+ }, {
+ context: obj.context,
+ request: obj.request.substr(0, l - mainFile.length - 1)
+ }];
+ }).reduce((a, b) => a.concat(b), []).concat(obj);
+ }).reduce((a, b) => a.concat(b), []));
+ });
+
+ params.contextModuleFactory.plugin("alternatives", (items, callback) => {
+ if(items.length === 0) return callback(null, items);
+
+ callback(null, items.map((obj) => {
+ for(let i = 0; i < this.modulesDirectories.length; i++) {
+ const dir = this.modulesDirectories[i];
const idx = obj.request.indexOf("./" + dir + "/");
if(idx === 0) {
obj.request = obj.request.slice(dir.length + 3);
diff --git a/node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlock.js b/node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlock.js
index 4b3a378e9..4d72b07ab 100644
--- a/node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlock.js
+++ b/node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlock.js
@@ -11,14 +11,8 @@ module.exports = class RequireEnsureDependenciesBlock extends AsyncDependenciesB
super(chunkName, module, loc);
this.expr = expr;
const successBodyRange = successExpression && successExpression.body && successExpression.body.range;
- const errorBodyRange = errorExpression && errorExpression.body && errorExpression.body.range;
- this.range = null;
if(successBodyRange) {
- if(errorBodyRange) {
- this.range = [successBodyRange[0] + 1, errorBodyRange[1] - 1];
- } else {
- this.range = [successBodyRange[0] + 1, successBodyRange[1] - 1];
- }
+ this.range = [successBodyRange[0] + 1, successBodyRange[1] - 1];
}
this.chunkNameRange = chunkNameRange;
const dep = new RequireEnsureDependency(this);
diff --git a/node_modules/webpack/lib/dependencies/RequireResolveDependencyParserPlugin.js b/node_modules/webpack/lib/dependencies/RequireResolveDependencyParserPlugin.js
index 09dd60788..85451cf95 100644
--- a/node_modules/webpack/lib/dependencies/RequireResolveDependencyParserPlugin.js
+++ b/node_modules/webpack/lib/dependencies/RequireResolveDependencyParserPlugin.js
@@ -62,7 +62,7 @@ class RequireResolveDependencyParserPlugin {
if(!dep) return;
dep.loc = expr.loc;
dep.optional = !!parser.scope.inTry;
- dep.weak = weak;
+ dep.async = weak ? "weak" : false;
parser.state.current.addDependency(dep);
return true;
});
diff --git a/node_modules/webpack/lib/node/NodeMainTemplatePlugin.js b/node_modules/webpack/lib/node/NodeMainTemplatePlugin.js
index d4660dac1..9a64b57b5 100644
--- a/node_modules/webpack/lib/node/NodeMainTemplatePlugin.js
+++ b/node_modules/webpack/lib/node/NodeMainTemplatePlugin.js
@@ -2,190 +2,182 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var Template = require("../Template");
+"use strict";
-function NodeMainTemplatePlugin(asyncChunkLoading) {
- this.asyncChunkLoading = asyncChunkLoading;
-}
-module.exports = NodeMainTemplatePlugin;
-NodeMainTemplatePlugin.prototype.apply = function(mainTemplate) {
- var self = this;
- mainTemplate.plugin("local-vars", function(source, chunk) {
- if(chunk.chunks.length > 0) {
- return this.asString([
- source,
- "",
- "// object to store loaded chunks",
- "// \"0\" means \"already loaded\"",
- "var installedChunks = {",
- this.indent(
- chunk.ids.map(function(id) {
- return id + ": 0";
- }).join(",\n")
- ),
- "};"
- ]);
- }
- return source;
- });
- mainTemplate.plugin("require-extensions", function(source, chunk) {
- if(chunk.chunks.length > 0) {
- return this.asString([
- source,
- "",
- "// uncatched error handler for webpack runtime",
- this.requireFn + ".oe = function(err) {",
- this.indent([
- "process.nextTick(function() {",
- this.indent("throw err; // catch this error by using System.import().catch()"),
- "});"
- ]),
- "};"
- ]);
- }
- return source;
- });
- mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
- var chunkFilename = this.outputOptions.chunkFilename;
- var chunkMaps = chunk.getChunkMaps();
- var insertMoreModules = [
- "var moreModules = chunk.modules, chunkIds = chunk.ids;",
- "for(var moduleId in moreModules) {",
- this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
- "}"
- ];
- if(self.asyncChunkLoading) {
- return this.asString([
- "// \"0\" is the signal for \"already loaded\"",
- "if(installedChunks[chunkId] === 0)",
- this.indent([
- "return Promise.resolve();"
- ]),
- "// array of [resolve, reject, promise] means \"currently loading\"",
- "if(installedChunks[chunkId])",
- this.indent([
- "return installedChunks[chunkId][2];"
- ]),
- "// load the chunk and return promise to it",
- "var promise = new Promise(function(resolve, reject) {",
- this.indent([
- "installedChunks[chunkId] = [resolve, reject];",
- "var filename = __dirname + " + this.applyPluginsWaterfall("asset-path", JSON.stringify("/" + chunkFilename), {
- hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
- hashWithLength: function(length) {
- return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
- }.bind(this),
- chunk: {
- id: "\" + chunkId + \"",
- hash: "\" + " + JSON.stringify(chunkMaps.hash) + "[chunkId] + \"",
- hashWithLength: function(length) {
- var shortChunkHashMap = {};
- Object.keys(chunkMaps.hash).forEach(function(chunkId) {
- if(typeof chunkMaps.hash[chunkId] === "string")
- shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
- });
- return "\" + " + JSON.stringify(shortChunkHashMap) + "[chunkId] + \"";
- },
- name: "\" + (" + JSON.stringify(chunkMaps.name) + "[chunkId]||chunkId) + \""
- }
- }) + ";",
- "require('fs').readFile(filename, 'utf-8', function(err, content) {",
+const Template = require("../Template");
+
+module.exports = class NodeMainTemplatePlugin {
+ constructor(asyncChunkLoading) {
+ this.asyncChunkLoading = asyncChunkLoading;
+ }
+
+ apply(mainTemplate) {
+ const asyncChunkLoading = this.asyncChunkLoading;
+ mainTemplate.plugin("local-vars", function(source, chunk) {
+ if(chunk.chunks.length > 0) {
+ return this.asString([
+ source,
+ "",
+ "// object to store loaded chunks",
+ "// \"0\" means \"already loaded\"",
+ "var installedChunks = {",
+ this.indent(chunk.ids.map((id) => `${id}: 0`).join(",\n")),
+ "};"
+ ]);
+ }
+ return source;
+ });
+ mainTemplate.plugin("require-extensions", function(source, chunk) {
+ if(chunk.chunks.length > 0) {
+ return this.asString([
+ source,
+ "",
+ "// uncatched error handler for webpack runtime",
+ `${this.requireFn}.oe = function(err) {`,
this.indent([
- "if(err) return reject(err);",
- "var chunk = {};",
- "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
- "(chunk, require, require('path').dirname(filename), filename);"
- ].concat(insertMoreModules).concat([
- "var callbacks = [];",
- "for(var i = 0; i < chunkIds.length; i++) {",
+ "process.nextTick(function() {",
+ this.indent("throw err; // catch this error by using System.import().catch()"),
+ "});"
+ ]),
+ "};"
+ ]);
+ }
+ return source;
+ });
+ mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
+ const chunkFilename = this.outputOptions.chunkFilename;
+ const chunkMaps = chunk.getChunkMaps();
+ const insertMoreModules = [
+ "var moreModules = chunk.modules, chunkIds = chunk.ids;",
+ "for(var moduleId in moreModules) {",
+ this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
+ "}"
+ ];
+ if(asyncChunkLoading) {
+ return this.asString([
+ "// \"0\" is the signal for \"already loaded\"",
+ "if(installedChunks[chunkId] === 0)",
+ this.indent([
+ "return Promise.resolve();"
+ ]),
+ "// array of [resolve, reject, promise] means \"currently loading\"",
+ "if(installedChunks[chunkId])",
+ this.indent([
+ "return installedChunks[chunkId][2];"
+ ]),
+ "// load the chunk and return promise to it",
+ "var promise = new Promise(function(resolve, reject) {",
+ this.indent([
+ "installedChunks[chunkId] = [resolve, reject];",
+ "var filename = __dirname + " + this.applyPluginsWaterfall("asset-path", JSON.stringify(`/${chunkFilename}`), {
+ hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
+ chunk: {
+ id: "\" + chunkId + \"",
+ hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
+ hashWithLength: (length) => {
+ const shortChunkHashMap = {};
+ Object.keys(chunkMaps.hash).forEach((chunkId) => {
+ if(typeof chunkMaps.hash[chunkId] === "string")
+ shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
+ });
+ return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
+ },
+ name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "`
+ }
+ }) + ";",
+ "require('fs').readFile(filename, 'utf-8', function(err, content) {",
this.indent([
- "if(installedChunks[chunkIds[i]])",
+ "if(err) return reject(err);",
+ "var chunk = {};",
+ "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" +
+ "(chunk, require, require('path').dirname(filename), filename);"
+ ].concat(insertMoreModules).concat([
+ "var callbacks = [];",
+ "for(var i = 0; i < chunkIds.length; i++) {",
this.indent([
- "callbacks = callbacks.concat(installedChunks[chunkIds[i]][0]);"
+ "if(installedChunks[chunkIds[i]])",
+ this.indent([
+ "callbacks = callbacks.concat(installedChunks[chunkIds[i]][0]);"
+ ]),
+ "installedChunks[chunkIds[i]] = 0;"
]),
- "installedChunks[chunkIds[i]] = 0;"
- ]),
- "}",
- "for(i = 0; i < callbacks.length; i++)",
- this.indent("callbacks[i]();")
+ "}",
+ "for(i = 0; i < callbacks.length; i++)",
+ this.indent("callbacks[i]();")
+ ])),
+ "});"
+ ]),
+ "});",
+ "return installedChunks[chunkId][2] = promise;"
+ ]);
+ } else {
+ const request = this.applyPluginsWaterfall("asset-path", JSON.stringify(`./${chunkFilename}`), {
+ hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
+ chunk: {
+ id: "\" + chunkId + \"",
+ hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
+ hashWithLength: (length) => {
+ const shortChunkHashMap = {};
+ Object.keys(chunkMaps.hash).forEach((chunkId) => {
+ if(typeof chunkMaps.hash[chunkId] === "string")
+ shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
+ });
+ return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
+ },
+ name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "`
+ }
+ });
+ return this.asString([
+ "// \"0\" is the signal for \"already loaded\"",
+ "if(installedChunks[chunkId] !== 0) {",
+ this.indent([
+ `var chunk = require(${request});`
+ ].concat(insertMoreModules).concat([
+ "for(var i = 0; i < chunkIds.length; i++)",
+ this.indent("installedChunks[chunkIds[i]] = 0;")
])),
- "});"
- ]),
- "});",
- "return installedChunks[chunkId][2] = promise;"
- ]);
- } else {
- var request = this.applyPluginsWaterfall("asset-path", JSON.stringify("./" + chunkFilename), {
- hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
- hashWithLength: function(length) {
- return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
- }.bind(this),
+ "}",
+ "return Promise.resolve();"
+ ]);
+ }
+ });
+ mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) {
+ const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
+ const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
+ const chunkMaps = chunk.getChunkMaps();
+ const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
+ hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
chunk: {
id: "\" + chunkId + \"",
- hash: "\" + " + JSON.stringify(chunkMaps.hash) + "[chunkId] + \"",
- hashWithLength: function(length) {
- var shortChunkHashMap = {};
- Object.keys(chunkMaps.hash).forEach(function(chunkId) {
+ hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
+ hashWithLength: (length) => {
+ const shortChunkHashMap = {};
+ Object.keys(chunkMaps.hash).forEach((chunkId) => {
if(typeof chunkMaps.hash[chunkId] === "string")
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
});
- return "\" + " + JSON.stringify(shortChunkHashMap) + "[chunkId] + \"";
+ return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
},
- name: "\" + (" + JSON.stringify(chunkMaps.name) + "[chunkId]||chunkId) + \""
+ name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "`
}
});
- return this.asString([
- "// \"0\" is the signal for \"already loaded\"",
- "if(installedChunks[chunkId] !== 0) {",
- this.indent([
- "var chunk = require(" + request + ");"
- ].concat(insertMoreModules).concat([
- "for(var i = 0; i < chunkIds.length; i++)",
- this.indent("installedChunks[chunkIds[i]] = 0;")
- ])),
- "}",
- "return Promise.resolve();"
- ]);
- }
- });
- mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) {
- var hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
- var hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
- var chunkMaps = chunk.getChunkMaps();
- var currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
- hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
- hashWithLength: function(length) {
- return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
- }.bind(this),
- chunk: {
- id: "\" + chunkId + \"",
- hash: "\" + " + JSON.stringify(chunkMaps.hash) + "[chunkId] + \"",
- hashWithLength: function(length) {
- var shortChunkHashMap = {};
- Object.keys(chunkMaps.hash).forEach(function(chunkId) {
- if(typeof chunkMaps.hash[chunkId] === "string")
- shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
- });
- return "\" + " + JSON.stringify(shortChunkHashMap) + "[chunkId] + \"";
- },
- name: "\" + (" + JSON.stringify(chunkMaps.name) + "[chunkId]||chunkId) + \""
- }
+ const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), {
+ hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`
+ });
+ return Template.getFunctionContent(asyncChunkLoading ? require("./NodeMainTemplateAsync.runtime.js") : require("./NodeMainTemplate.runtime.js"))
+ .replace(/\$require\$/g, this.requireFn)
+ .replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
+ .replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename);
});
- var currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), {
- hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
- hashWithLength: function(length) {
- return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
- }.bind(this)
+ mainTemplate.plugin("hash", function(hash) {
+ hash.update("node");
+ hash.update("3");
+ hash.update(this.outputOptions.filename + "");
+ hash.update(this.outputOptions.chunkFilename + "");
});
- return Template.getFunctionContent(self.asyncChunkLoading ? require("./NodeMainTemplateAsync.runtime.js") : require("./NodeMainTemplate.runtime.js"))
- .replace(/\$require\$/g, this.requireFn)
- .replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
- .replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename);
- });
- mainTemplate.plugin("hash", function(hash) {
- hash.update("node");
- hash.update("3");
- hash.update(this.outputOptions.filename + "");
- hash.update(this.outputOptions.chunkFilename + "");
- });
+ }
};
diff --git a/node_modules/webpack/lib/node/NodeSourcePlugin.js b/node_modules/webpack/lib/node/NodeSourcePlugin.js
index 14a375445..986160028 100644
--- a/node_modules/webpack/lib/node/NodeSourcePlugin.js
+++ b/node_modules/webpack/lib/node/NodeSourcePlugin.js
@@ -13,6 +13,8 @@ module.exports = class NodeSourcePlugin {
}
apply(compiler) {
const options = this.options;
+ if(options === false) // allow single kill switch to turn off this plugin
+ return;
function getPathToModule(module, type) {
if(type === true || (type === undefined && nodeLibsBrowser[module])) {
diff --git a/node_modules/webpack/lib/node/NodeWatchFileSystem.js b/node_modules/webpack/lib/node/NodeWatchFileSystem.js
index a4ff6c6b5..1c13a9b29 100644
--- a/node_modules/webpack/lib/node/NodeWatchFileSystem.js
+++ b/node_modules/webpack/lib/node/NodeWatchFileSystem.js
@@ -48,7 +48,7 @@ class NodeWatchFileSystem {
changes.filter(file => missing.indexOf(file) >= 0).sort(), times, times);
});
- this.watcher.watch(files.concat(missing), dirs, startTime);
+ this.watcher.watch(files.concat(missing), dirs.concat(missing), startTime);
if(oldWatcher) {
oldWatcher.close();
diff --git a/node_modules/webpack/lib/optimize/AggressiveMergingPlugin.js b/node_modules/webpack/lib/optimize/AggressiveMergingPlugin.js
index 826a6baa9..dc14ac300 100644
--- a/node_modules/webpack/lib/optimize/AggressiveMergingPlugin.js
+++ b/node_modules/webpack/lib/optimize/AggressiveMergingPlugin.js
@@ -23,7 +23,7 @@ class AggressiveMergingPlugin {
return a + b;
}, 0);
}
- compiler.plugin("compilation", (compilation) => {
+ compiler.plugin("this-compilation", (compilation) => {
compilation.plugin("optimize-chunks-advanced", (chunks) => {
let combinations = [];
chunks.forEach((a, idx) => {
@@ -31,86 +31,80 @@ class AggressiveMergingPlugin {
for(let i = 0; i < idx; i++) {
const b = chunks[i];
if(b.isInitial()) continue;
- combinations.push([b, a]);
+ combinations.push({
+ a,
+ b,
+ improvement: undefined
+ });
}
});
combinations.forEach((pair) => {
- const a = pair[0].size({
+ const a = pair.b.size({
chunkOverhead: 0
});
- const b = pair[1].size({
+ const b = pair.a.size({
chunkOverhead: 0
});
- const ab = pair[0].integratedSize(pair[1], {
+ const ab = pair.b.integratedSize(pair.a, {
chunkOverhead: 0
});
- pair.push({
- a: a,
- b: b,
- ab: ab
- });
let newSize;
if(ab === false) {
- pair.unshift(false);
+ pair.improvement = false;
+ return;
} else if(options.moveToParents) {
const aOnly = ab - b;
const bOnly = ab - a;
const common = a + b - ab;
- newSize = common + getParentsWeight(pair[0]) * aOnly + getParentsWeight(pair[1]) * bOnly;
- pair.push({
- aOnly: aOnly,
- bOnly: bOnly,
- common: common,
- newSize: newSize
- });
+ newSize = common + getParentsWeight(pair.b) * aOnly + getParentsWeight(pair.a) * bOnly;
} else {
newSize = ab;
}
- pair.unshift((a + b) / newSize);
+ pair.improvement = (a + b) / newSize;
});
combinations = combinations.filter((pair) => {
- return pair[0] !== false;
+ return pair.improvement !== false;
});
combinations.sort((a, b) => {
- return b[0] - a[0];
+ return b.improvement - a.improvement;
});
const pair = combinations[0];
if(!pair) return;
- if(pair[0] < minSizeReduce) return;
+ if(pair.improvement < minSizeReduce) return;
if(options.moveToParents) {
- const commonModules = pair[1].modules.filter((m) => {
- return pair[2].modules.indexOf(m) >= 0;
+ const commonModules = pair.b.modules.filter((m) => {
+ return pair.a.modules.indexOf(m) >= 0;
});
- const aOnlyModules = pair[1].modules.filter((m) => {
+ const aOnlyModules = pair.b.modules.filter((m) => {
return commonModules.indexOf(m) < 0;
});
- const bOnlyModules = pair[2].modules.filter((m) => {
+ const bOnlyModules = pair.a.modules.filter((m) => {
return commonModules.indexOf(m) < 0;
});
aOnlyModules.forEach((m) => {
- pair[1].removeModule(m);
- m.removeChunk(pair[1]);
- pair[1].parents.forEach((c) => {
+ pair.b.removeModule(m);
+ m.removeChunk(pair.b);
+ pair.b.parents.forEach((c) => {
c.addModule(m);
m.addChunk(c);
});
});
bOnlyModules.forEach((m) => {
- pair[2].removeModule(m);
- m.removeChunk(pair[2]);
- pair[2].parents.forEach((c) => {
+ pair.a.removeModule(m);
+ m.removeChunk(pair.a);
+ pair.a.parents.forEach((c) => {
c.addModule(m);
m.addChunk(c);
});
});
}
- if(pair[1].integrate(pair[2], "aggressive-merge")) {
- chunks.splice(chunks.indexOf(pair[2]), 1);
+ if(pair.b.integrate(pair.a, "aggressive-merge")) {
+ chunks.splice(chunks.indexOf(pair.a), 1);
return true;
}
});
diff --git a/node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js b/node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js
index e05b3eb4c..b6f566a1c 100644
--- a/node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js
+++ b/node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js
@@ -6,18 +6,6 @@
const identifierUtils = require("../util/identifier");
-function toIndexOf(list) {
- return function(item) {
- return list.indexOf(item);
- };
-}
-
-function toChunkModuleIndices(modules) {
- return function(idx) {
- return modules[idx];
- };
-}
-
function moveModuleBetween(oldChunk, newChunk) {
return function(module) {
oldChunk.moveModule(module, newChunk);
@@ -49,8 +37,15 @@ class AggressiveSplittingPlugin {
if(typeof this.options.entryChunkMultiplicator !== "number") this.options.entryChunkMultiplicator = 1;
}
apply(compiler) {
- compiler.plugin("compilation", (compilation) => {
+ compiler.plugin("this-compilation", (compilation) => {
compilation.plugin("optimize-chunks-advanced", (chunks) => {
+ // Precompute stuff
+ const nameToModuleMap = new Map();
+ compilation.modules.forEach(m => {
+ const name = identifierUtils.makePathsRelative(compiler.context, m.identifier(), compilation.cache);
+ nameToModuleMap.set(name, m);
+ });
+
const savedSplits = compilation.records && compilation.records.aggressiveSplits || [];
const usedSplits = compilation._aggressiveSplittingSplits ?
savedSplits.concat(compilation._aggressiveSplittingSplits) : savedSplits;
@@ -60,50 +55,58 @@ class AggressiveSplittingPlugin {
// 1. try to restore to recorded splitting
for(let j = 0; j < usedSplits.length; j++) {
const splitData = usedSplits[j];
- for(let i = 0; i < chunks.length; i++) {
- const chunk = chunks[i];
- const chunkModuleNames = chunk.modules.map(m => identifierUtils.makePathsRelative(compiler.context, m.identifier()));
+ const selectedModules = splitData.modules.map(name => nameToModuleMap.get(name));
- if(chunkModuleNames.length < splitData.modules.length)
- continue;
- const moduleIndicies = splitData.modules.map(toIndexOf(chunkModuleNames));
- const hasAllModules = moduleIndicies.every((idx) => {
- return idx >= 0;
- });
- if(hasAllModules) {
- if(chunkModuleNames.length > splitData.modules.length) {
- const selectedModules = moduleIndicies.map(toChunkModuleIndices(chunk.modules));
- const newChunk = compilation.addChunk();
- selectedModules.forEach(moveModuleBetween(chunk, newChunk));
- chunk.split(newChunk);
- chunk.name = null;
- newChunk._fromAggressiveSplitting = true;
- if(j < savedSplits.length)
- newChunk._fromAggressiveSplittingIndex = j;
- if(splitData.id !== null && splitData.id !== undefined) {
- newChunk.id = splitData.id;
- }
- newChunk.origins = chunk.origins.map(copyWithReason);
- chunk.origins = chunk.origins.map(copyWithReason);
- return true;
- } else {
- if(j < savedSplits.length)
- chunk._fromAggressiveSplittingIndex = j;
- chunk.name = null;
- if(splitData.id !== null && splitData.id !== undefined) {
- chunk.id = splitData.id;
+ // Does the modules exist at all?
+ if(selectedModules.every(Boolean)) {
+
+ // Find all chunks containing all modules in the split
+ for(let i = 0; i < chunks.length; i++) {
+ const chunk = chunks[i];
+
+ // Cheap check if chunk is suitable at all
+ if(chunk.getNumberOfModules() < splitData.modules.length)
+ continue;
+
+ // Check if all modules are in the chunk
+ if(selectedModules.every(m => chunk.containsModule(m))) {
+
+ // Is chunk identical to the split or do we need to split it?
+ if(chunk.getNumberOfModules() > splitData.modules.length) {
+ // split the chunk into two parts
+ const newChunk = compilation.addChunk();
+ selectedModules.forEach(moveModuleBetween(chunk, newChunk));
+ chunk.split(newChunk);
+ chunk.name = null;
+ newChunk._fromAggressiveSplitting = true;
+ if(j < savedSplits.length)
+ newChunk._fromAggressiveSplittingIndex = j;
+ if(splitData.id !== null && splitData.id !== undefined) {
+ newChunk.id = splitData.id;
+ }
+ newChunk.origins = chunk.origins.map(copyWithReason);
+ chunk.origins = chunk.origins.map(copyWithReason);
+ return true;
+ } else { // chunk is identical to the split
+ if(j < savedSplits.length)
+ chunk._fromAggressiveSplittingIndex = j;
+ chunk.name = null;
+ if(splitData.id !== null && splitData.id !== undefined) {
+ chunk.id = splitData.id;
+ }
}
}
}
}
}
+
// 2. for any other chunk which isn't splitted yet, split it
for(let i = 0; i < chunks.length; i++) {
const chunk = chunks[i];
const size = chunk.size(this.options);
- if(size > maxSize && chunk.modules.length > 1) {
+ if(size > maxSize && chunk.getNumberOfModules() > 1) {
const newChunk = compilation.addChunk();
- const modules = chunk.modules
+ const modules = chunk.getModules()
.filter(isNotAEntryModule(chunk.entryModule))
.sort((a, b) => {
a = a.identifier();
@@ -131,13 +134,13 @@ class AggressiveSplittingPlugin {
break;
}
}
- if(newChunk.modules.length > 0) {
+ if(newChunk.getNumberOfModules() > 0) {
chunk.split(newChunk);
chunk.name = null;
newChunk.origins = chunk.origins.map(copyWithReason);
chunk.origins = chunk.origins.map(copyWithReason);
compilation._aggressiveSplittingSplits = (compilation._aggressiveSplittingSplits || []).concat({
- modules: newChunk.modules.map(m => identifierUtils.makePathsRelative(compiler.context, m.identifier()))
+ modules: newChunk.mapModules(m => identifierUtils.makePathsRelative(compiler.context, m.identifier(), compilation.cache))
});
return true;
} else {
@@ -154,7 +157,7 @@ class AggressiveSplittingPlugin {
if(chunk.hasEntryModule()) return;
const size = chunk.size(this.options);
const incorrectSize = size < minSize;
- const modules = chunk.modules.map(m => identifierUtils.makePathsRelative(compiler.context, m.identifier()));
+ const modules = chunk.mapModules(m => identifierUtils.makePathsRelative(compiler.context, m.identifier(), compilation.cache));
if(typeof chunk._fromAggressiveSplittingIndex === "undefined") {
if(incorrectSize) return;
chunk.recorded = true;
diff --git a/node_modules/webpack/lib/optimize/ChunkModuleIdRangePlugin.js b/node_modules/webpack/lib/optimize/ChunkModuleIdRangePlugin.js
index 8166fc315..262014dc5 100644
--- a/node_modules/webpack/lib/optimize/ChunkModuleIdRangePlugin.js
+++ b/node_modules/webpack/lib/optimize/ChunkModuleIdRangePlugin.js
@@ -11,9 +11,7 @@ class ChunkModuleIdRangePlugin {
const options = this.options;
compiler.plugin("compilation", (compilation) => {
compilation.plugin("module-ids", (modules) => {
- const chunk = this.chunks.filter((chunk) => {
- return chunk.name === options.name;
- })[0];
+ const chunk = this.chunks.find((chunk) => chunk.name === options.name);
if(!chunk) throw new Error("ChunkModuleIdRangePlugin: Chunk with name '" + options.name + "' was not found");
let currentId = options.start;
let chunkModules;
diff --git a/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js b/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js
index 3ef414198..465b7ff7a 100644
--- a/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js
+++ b/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js
@@ -60,8 +60,8 @@ The available options are:
* that webpack will take care of loading this file.
*/
if(options.async && options.filename) {
- throw new Error(`You can not specify a filename if you use the \"async\" option.
-You can however specify the name of the async chunk by passing the desired string as the \"async\" option.`);
+ throw new Error(`You can not specify a filename if you use the "async" option.
+You can however specify the name of the async chunk by passing the desired string as the "async" option.`);
}
/**
@@ -115,7 +115,18 @@ You can however specify the name of the async chunk by passing the desired strin
// override the "commonChunk" with the newly created async one and use it as commonChunk from now on
let asyncChunk;
if(this.async) {
- asyncChunk = this.createAsyncChunk(compilation, this.async, targetChunk);
+ // If async chunk is one of the affected chunks, just use it
+ asyncChunk = affectedChunks.filter(c => c.name === this.async)[0];
+ // Elsewise create a new one
+ if(!asyncChunk) {
+ asyncChunk = this.createAsyncChunk(
+ compilation,
+ targetChunks.length <= 1 || typeof this.async !== "string" ? this.async :
+ targetChunk.name ? `${this.async}-${targetChunk.name}` :
+ true,
+ targetChunk
+ );
+ }
targetChunk = asyncChunk;
}
@@ -190,7 +201,7 @@ You can however specify the name of the async chunk by passing the desired strin
// we dont have named chunks specified, so we just take all of them
if(asyncOrNoSelectedChunk) {
- return allChunks.filter(chunk => !chunk.isInitial());
+ return allChunks;
}
/**
@@ -218,8 +229,15 @@ Take a look at the "name"/"names" or async/children option.`);
}
return targetChunk.chunks.filter((chunk) => {
+ // we only are interested in on-demand chunks
+ if(chunk.isInitial())
+ return false;
+
// we can only move modules from this chunk if the "commonChunk" is the only parent
- return asyncOption || chunk.parents.length === 1;
+ if(!asyncOption)
+ return chunk.parents.length === 1;
+
+ return true;
});
}
@@ -275,7 +293,7 @@ Take a look at the "name"/"names" or async/children option.`);
// count how many chunks contain a module
const commonModulesToCountMap = usedChunks.reduce((map, chunk) => {
- for(let module of chunk.modules) {
+ for(const module of chunk.modulesIterable) {
const count = map.has(module) ? map.get(module) : 0;
map.set(module, count + 1);
}
@@ -306,7 +324,7 @@ Take a look at the "name"/"names" or async/children option.`);
extractModulesAndReturnAffectedChunks(reallyUsedModules, usedChunks) {
return reallyUsedModules.reduce((affectedChunksSet, module) => {
- for(let chunk of usedChunks) {
+ for(const chunk of usedChunks) {
// removeChunk returns true if the chunk was contained and succesfully removed
// false if the module did not have a connection to the chunk in question
if(module.removeChunk(chunk)) {
@@ -318,29 +336,32 @@ Take a look at the "name"/"names" or async/children option.`);
}
addExtractedModulesToTargetChunk(chunk, modules) {
- for(let module of modules) {
+ for(const module of modules) {
chunk.addModule(module);
module.addChunk(chunk);
}
}
makeTargetChunkParentOfAffectedChunks(usedChunks, commonChunk) {
- for(let chunk of usedChunks) {
+ for(const chunk of usedChunks) {
// set commonChunk as new sole parent
chunk.parents = [commonChunk];
// add chunk to commonChunk
commonChunk.addChunk(chunk);
- for(let entrypoint of chunk.entrypoints) {
+ for(const entrypoint of chunk.entrypoints) {
entrypoint.insertChunk(commonChunk, chunk);
}
}
}
moveExtractedChunkBlocksToTargetChunk(chunks, targetChunk) {
- for(let chunk of chunks) {
- for(let block of chunk.blocks) {
- block.chunks.unshift(targetChunk);
+ for(const chunk of chunks) {
+ if(chunk === targetChunk) continue;
+ for(const block of chunk.blocks) {
+ if(block.chunks.indexOf(targetChunk) === -1) {
+ block.chunks.unshift(targetChunk);
+ }
targetChunk.addBlock(block);
}
}
@@ -348,8 +369,8 @@ Take a look at the "name"/"names" or async/children option.`);
extractOriginsOfChunksWithExtractedModules(chunks) {
const origins = [];
- for(let chunk of chunks) {
- for(let origin of chunk.origins) {
+ for(const chunk of chunks) {
+ for(const origin of chunk.origins) {
const newOrigin = Object.create(origin);
newOrigin.reasons = (origin.reasons || []).concat("async commons");
origins.push(newOrigin);
diff --git a/node_modules/webpack/lib/optimize/ConcatenatedModule.js b/node_modules/webpack/lib/optimize/ConcatenatedModule.js
new file mode 100644
index 000000000..6cb503f0d
--- /dev/null
+++ b/node_modules/webpack/lib/optimize/ConcatenatedModule.js
@@ -0,0 +1,816 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const Module = require("../Module");
+const Template = require("../Template");
+const Parser = require("../Parser");
+const acorn = require("acorn");
+const escope = require("escope");
+const ReplaceSource = require("webpack-sources/lib/ReplaceSource");
+const ConcatSource = require("webpack-sources/lib/ConcatSource");
+const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
+const HarmonyImportSpecifierDependency = require("../dependencies/HarmonyImportSpecifierDependency");
+const HarmonyExportSpecifierDependency = require("../dependencies/HarmonyExportSpecifierDependency");
+const HarmonyExportExpressionDependency = require("../dependencies/HarmonyExportExpressionDependency");
+const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
+const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
+const HarmonyModulesHelpers = require("../dependencies/HarmonyModulesHelpers");
+
+function ensureNsObjSource(info, moduleToInfoMap, requestShortener) {
+ if(!info.hasNamespaceObject) {
+ info.hasNamespaceObject = true;
+ const name = info.exportMap.get(true);
+ const nsObj = [`var ${name} = {};`];
+ for(const exportName of info.module.providedExports) {
+ const finalName = getFinalName(info, exportName, moduleToInfoMap, requestShortener, false);
+ nsObj.push(`__webpack_require__.d(${name}, ${JSON.stringify(exportName)}, function() { return ${finalName}; });`);
+ }
+ info.namespaceObjectSource = nsObj.join("\n") + "\n";
+ }
+}
+
+function getExternalImport(importedModule, info, exportName, asCall) {
+ if(exportName === true) return info.name;
+ const used = importedModule.isUsed(exportName);
+ if(!used) return "/* unused reexport */undefined";
+ if(info.interop && exportName === "default") {
+ return asCall ? `${info.interopName}()` : `${info.interopName}.a`;
+ }
+ // TODO use Template.toNormalComment when merging with pure-module
+ const comment = used !== exportName ? ` /* ${exportName} */` : "";
+ const reference = `${info.name}[${JSON.stringify(used)}${comment}]`;
+ if(asCall)
+ return `Object(${reference})`;
+ return reference;
+}
+
+function getFinalName(info, exportName, moduleToInfoMap, requestShortener, asCall) {
+ switch(info.type) {
+ case "concatenated":
+ {
+ const directExport = info.exportMap.get(exportName);
+ if(directExport) {
+ if(exportName === true)
+ ensureNsObjSource(info, moduleToInfoMap, requestShortener);
+ const name = info.internalNames.get(directExport);
+ if(!name)
+ throw new Error(`The export "${directExport}" in "${info.module.readableIdentifier(requestShortener)}" has no internal name`);
+ return name;
+ }
+ const reexport = info.reexportMap.get(exportName);
+ if(reexport) {
+ const refInfo = moduleToInfoMap.get(reexport.module);
+ if(refInfo) {
+ // module is in the concatenation
+ return getFinalName(refInfo, reexport.exportName, moduleToInfoMap, requestShortener, asCall);
+ }
+ }
+ const problem = `Cannot get final name for export "${exportName}" in "${info.module.readableIdentifier(requestShortener)}"` +
+ ` (known exports: ${Array.from(info.exportMap.keys()).filter(name => name !== true).join(" ")}, ` +
+ `known reexports: ${Array.from(info.reexportMap.keys()).join(" ")})`;
+ // TODO use Template.toNormalComment when merging with pure-module
+ return `/* ${problem} */ undefined`;
+ }
+ case "external":
+ {
+ const importedModule = info.module;
+ return getExternalImport(importedModule, info, exportName, asCall);
+ }
+ }
+}
+
+function getSymbolsFromScope(s, untilScope) {
+ const allUsedNames = new Set();
+ let scope = s;
+ while(scope) {
+ if(untilScope === scope) break;
+ scope.variables.forEach(variable => allUsedNames.add(variable.name));
+ scope = scope.upper;
+ }
+ return allUsedNames;
+}
+
+function getAllReferences(variable) {
+ let set = variable.references;
+ // Look for inner scope variables too (like in class Foo { t() { Foo } })
+ const identifiers = new Set(variable.identifiers);
+ for(const scope of variable.scope.childScopes) {
+ for(const innerVar of scope.variables) {
+ if(innerVar.identifiers.some(id => identifiers.has(id))) {
+ set = set.concat(innerVar.references);
+ break;
+ }
+ }
+ }
+ return set;
+}
+
+function reduceSet(a, b) {
+ for(const item of b)
+ a.add(item);
+ return a;
+}
+
+function getPathInAst(ast, node) {
+ if(ast === node) {
+ return [];
+ }
+ const nr = node.range;
+ var i;
+ if(Array.isArray(ast)) {
+ for(i = 0; i < ast.length; i++) {
+ const enterResult = enterNode(ast[i]);
+ if(typeof enterResult !== "undefined")
+ return enterResult;
+ }
+ } else if(ast && typeof ast === "object") {
+ const keys = Object.keys(ast);
+ for(i = 0; i < keys.length; i++) {
+ const value = ast[keys[i]];
+ if(Array.isArray(value)) {
+ const pathResult = getPathInAst(value, node);
+ if(typeof pathResult !== "undefined")
+ return pathResult;
+ } else if(value && typeof value === "object") {
+ const enterResult = enterNode(value);
+ if(typeof enterResult !== "undefined")
+ return enterResult;
+ }
+ }
+ }
+
+ function enterNode(n) {
+ const r = n.range;
+ if(r) {
+ if(r[0] <= nr[0] && r[1] >= nr[1]) {
+ const path = getPathInAst(n, node);
+ if(path) {
+ path.push(n);
+ return path;
+ }
+ }
+ }
+ return undefined;
+ }
+}
+
+class ConcatenatedModule extends Module {
+ constructor(rootModule, modules) {
+ super();
+ super.setChunks(rootModule._chunks);
+ this.rootModule = rootModule;
+ this.usedExports = rootModule.usedExports;
+ this.providedExports = rootModule.providedExports;
+ this.optimizationBailout = rootModule.optimizationBailout;
+ this.used = rootModule.used;
+ this.index = rootModule.index;
+ this.index2 = rootModule.index2;
+ this.depth = rootModule.depth;
+ this.built = modules.some(m => m.built);
+ this.cacheable = modules.every(m => m.cacheable);
+ const modulesSet = new Set(modules);
+ this.reasons = rootModule.reasons.filter(reason => !modulesSet.has(reason.module));
+ this.meta = rootModule.meta;
+ this.moduleArgument = rootModule.moduleArgument;
+ this.exportsArgument = rootModule.exportsArgument;
+ this.strict = true;
+ this._numberOfConcatenatedModules = modules.length;
+
+ this.dependencies = [];
+ this.dependenciesWarnings = [];
+ this.dependenciesErrors = [];
+ this.fileDependencies = [];
+ this.contextDependencies = [];
+ this.warnings = [];
+ this.errors = [];
+ this.assets = {};
+ this._orderedConcatenationList = this._createOrderedConcatenationList(rootModule, modulesSet);
+ for(const info of this._orderedConcatenationList) {
+ if(info.type === "concatenated") {
+ const m = info.module;
+
+ // populate dependencies
+ m.dependencies.filter(dep => !modulesSet.has(dep.module))
+ .forEach(d => this.dependencies.push(d));
+ // populate dep warning
+ m.dependenciesWarnings.forEach(depWarning => this.dependenciesWarnings.push(depWarning));
+ // populate dep errors
+ m.dependenciesErrors.forEach(depError => this.dependenciesErrors.push(depError));
+ // populate file dependencies
+ if(m.fileDependencies) m.fileDependencies.forEach(file => this.fileDependencies.push(file));
+ // populate context dependencies
+ if(m.contextDependencies) m.contextDependencies.forEach(context => this.contextDependencies.push(context));
+ // populate warnings
+ m.warnings.forEach(warning => this.warnings.push(warning));
+ // populate errors
+ m.errors.forEach(error => this.errors.push(error));
+
+ Object.assign(this.assets, m.assets);
+ }
+ }
+ }
+
+ get modules() {
+ return this._orderedConcatenationList
+ .filter(info => info.type === "concatenated")
+ .map(info => info.module);
+ }
+
+ identifier() {
+ return this._orderedConcatenationList.map(info => {
+ switch(info.type) {
+ case "concatenated":
+ return info.module.identifier();
+ }
+ }).filter(Boolean).join(" ");
+ }
+
+ readableIdentifier(requestShortener) {
+ return this.rootModule.readableIdentifier(requestShortener) + ` + ${this._numberOfConcatenatedModules - 1} modules`;
+ }
+
+ libIdent(options) {
+ return this.rootModule.libIdent(options);
+ }
+
+ nameForCondition() {
+ return this.rootModule.nameForCondition();
+ }
+
+ build(options, compilation, resolver, fs, callback) {
+ throw new Error("Cannot build this module. It should be already built.");
+ }
+
+ size() {
+ // Guess size from embedded modules
+ return this._orderedConcatenationList.reduce((sum, info) => {
+ switch(info.type) {
+ case "concatenated":
+ return sum + info.module.size();
+ case "external":
+ return sum + 5;
+ }
+ return sum;
+ }, 0);
+ }
+
+ _createOrderedConcatenationList(rootModule, modulesSet) {
+ const list = [];
+ const set = new Set();
+
+ function getConcatenatedImports(module) {
+ // TODO need changes when merging with the pure-module branch
+ const allDeps = module.dependencies
+ .filter(dep => dep instanceof HarmonyImportDependency && dep.module);
+
+ return allDeps.map(dep => () => dep.module);
+ }
+
+ function enterModule(getModule) {
+ const module = getModule();
+ if(set.has(module)) return;
+ set.add(module);
+ if(modulesSet.has(module)) {
+ const imports = getConcatenatedImports(module);
+ imports.forEach(enterModule);
+ list.push({
+ type: "concatenated",
+ module
+ });
+ } else {
+ list.push({
+ type: "external",
+ get module() {
+ // We need to use a getter here, because the module in the dependency
+ // could be replaced by some other process (i. e. also replaced with a
+ // concatenated module)
+ return getModule();
+ }
+ });
+ }
+ }
+
+ enterModule(() => rootModule);
+
+ return list;
+ }
+
+ source(dependencyTemplates, outputOptions, requestShortener) {
+ // Metainfo for each module
+ const modulesWithInfo = this._orderedConcatenationList.map((info, idx) => {
+ switch(info.type) {
+ case "concatenated":
+ {
+ const exportMap = new Map();
+ const reexportMap = new Map();
+ info.module.dependencies.forEach(dep => {
+ if(dep instanceof HarmonyExportSpecifierDependency) {
+ exportMap.set(dep.name, dep.id);
+ } else if(dep instanceof HarmonyExportExpressionDependency) {
+ exportMap.set("default", "__WEBPACK_MODULE_DEFAULT_EXPORT__");
+ } else if(dep instanceof HarmonyExportImportedSpecifierDependency) {
+ const exportName = dep.name;
+ const importName = dep.id;
+ const importedModule = dep.importDependency.module;
+ if(exportName && importName) {
+ reexportMap.set(exportName, {
+ module: importedModule,
+ exportName: importName,
+ dependency: dep
+ });
+ } else if(exportName) {
+ reexportMap.set(exportName, {
+ module: importedModule,
+ exportName: true,
+ dependency: dep
+ });
+ } else {
+ var activeExports = new Set(HarmonyModulesHelpers.getActiveExports(dep.originModule, dep));
+ importedModule.providedExports.forEach(name => {
+ if(activeExports.has(name) || name === "default")
+ return;
+ reexportMap.set(name, {
+ module: importedModule,
+ exportName: name,
+ dependency: dep
+ });
+ });
+ }
+ }
+ });
+ return {
+ type: "concatenated",
+ module: info.module,
+ index: idx,
+ ast: undefined,
+ source: undefined,
+ globalScope: undefined,
+ moduleScope: undefined,
+ internalNames: new Map(),
+ exportMap: exportMap,
+ reexportMap: reexportMap,
+ needCompatibilityFlag: false,
+ hasNamespaceObject: false,
+ namespaceObjectSource: null
+ };
+ }
+ case "external":
+ return {
+ type: "external",
+ module: info.module,
+ index: idx,
+ name: undefined,
+ interopName: undefined,
+ interop: undefined
+ };
+ default:
+ throw new Error(`Unsupported concatenation entry type ${info.type}`);
+ }
+ });
+
+ // Create mapping from module to info
+ const moduleToInfoMap = new Map();
+ modulesWithInfo.forEach(m => moduleToInfoMap.set(m.module, m));
+
+ // Configure template decorators for dependencies
+ const innerDependencyTemplates = new Map(dependencyTemplates);
+
+ innerDependencyTemplates.set(HarmonyImportSpecifierDependency, new HarmonyImportSpecifierDependencyConcatenatedTemplate(
+ dependencyTemplates.get(HarmonyImportSpecifierDependency),
+ moduleToInfoMap
+ ));
+ innerDependencyTemplates.set(HarmonyImportDependency, new HarmonyImportDependencyConcatenatedTemplate(
+ dependencyTemplates.get(HarmonyImportDependency),
+ moduleToInfoMap
+ ));
+ innerDependencyTemplates.set(HarmonyExportSpecifierDependency, new HarmonyExportSpecifierDependencyConcatenatedTemplate(
+ dependencyTemplates.get(HarmonyExportSpecifierDependency),
+ this.rootModule
+ ));
+ innerDependencyTemplates.set(HarmonyExportExpressionDependency, new HarmonyExportExpressionDependencyConcatenatedTemplate(
+ dependencyTemplates.get(HarmonyExportExpressionDependency),
+ this.rootModule,
+ moduleToInfoMap
+ ));
+ innerDependencyTemplates.set(HarmonyExportImportedSpecifierDependency, new HarmonyExportImportedSpecifierDependencyConcatenatedTemplate(
+ dependencyTemplates.get(HarmonyExportImportedSpecifierDependency),
+ this.rootModule,
+ moduleToInfoMap
+ ));
+ innerDependencyTemplates.set(HarmonyCompatibilityDependency, new HarmonyCompatibilityDependencyConcatenatedTemplate(
+ dependencyTemplates.get(HarmonyCompatibilityDependency),
+ this.rootModule,
+ moduleToInfoMap
+ ));
+ innerDependencyTemplates.set("hash", innerDependencyTemplates.get("hash") + this.rootModule.identifier());
+
+ // Generate source code and analyse scopes
+ // Prepare a ReplaceSource for the final source
+ modulesWithInfo.forEach(info => {
+ if(info.type === "concatenated") {
+ const m = info.module;
+ const source = m.source(innerDependencyTemplates, outputOptions, requestShortener);
+ const code = source.source();
+ let ast;
+ try {
+ ast = acorn.parse(code, {
+ ranges: true,
+ locations: true,
+ ecmaVersion: Parser.ECMA_VERSION,
+ sourceType: "module"
+ });
+ } catch(err) {
+ if(err.loc && typeof err.loc === "object" && typeof err.loc.line === "number") {
+ const lineNumber = err.loc.line;
+ const lines = code.split("\n");
+ err.message += "\n| " + lines.slice(Math.max(0, lineNumber - 3), lineNumber + 2).join("\n| ");
+ }
+ throw err;
+ }
+ const scopeManager = escope.analyze(ast, {
+ ecmaVersion: 6,
+ sourceType: "module",
+ optimistic: true,
+ ignoreEval: true,
+ impliedStrict: true
+ });
+ const globalScope = scopeManager.acquire(ast);
+ const moduleScope = globalScope.childScopes[0];
+ const resultSource = new ReplaceSource(source);
+ info.ast = ast;
+ info.source = resultSource;
+ info.globalScope = globalScope;
+ info.moduleScope = moduleScope;
+ }
+ });
+
+ // List of all used names to avoid conflicts
+ const allUsedNames = new Set([
+ "__WEBPACK_MODULE_DEFAULT_EXPORT__", // avoid using this internal name
+
+ "abstract", "arguments", "await", "boolean", "break", "byte", "case", "catch", "char", "class",
+ "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "eval",
+ "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if",
+ "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new",
+ "null", "package", "private", "protected", "public", "return", "short", "static", "super",
+ "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof",
+ "var", "void", "volatile", "while", "with", "yield",
+
+ "module", "__dirname", "__filename", "exports",
+
+ "Array", "Date", "eval", "function", "hasOwnProperty", "Infinity", "isFinite", "isNaN",
+ "isPrototypeOf", "length", "Math", "NaN", "name", "Number", "Object", "prototype", "String",
+ "toString", "undefined", "valueOf",
+
+ "alert", "all", "anchor", "anchors", "area", "assign", "blur", "button", "checkbox",
+ "clearInterval", "clearTimeout", "clientInformation", "close", "closed", "confirm", "constructor",
+ "crypto", "decodeURI", "decodeURIComponent", "defaultStatus", "document", "element", "elements",
+ "embed", "embeds", "encodeURI", "encodeURIComponent", "escape", "event", "fileUpload", "focus",
+ "form", "forms", "frame", "innerHeight", "innerWidth", "layer", "layers", "link", "location",
+ "mimeTypes", "navigate", "navigator", "frames", "frameRate", "hidden", "history", "image",
+ "images", "offscreenBuffering", "open", "opener", "option", "outerHeight", "outerWidth",
+ "packages", "pageXOffset", "pageYOffset", "parent", "parseFloat", "parseInt", "password", "pkcs11",
+ "plugin", "prompt", "propertyIsEnum", "radio", "reset", "screenX", "screenY", "scroll", "secure",
+ "select", "self", "setInterval", "setTimeout", "status", "submit", "taint", "text", "textarea",
+ "top", "unescape", "untaint", "window",
+
+ "onblur", "onclick", "onerror", "onfocus", "onkeydown", "onkeypress", "onkeyup", "onmouseover",
+ "onload", "onmouseup", "onmousedown", "onsubmit"
+ ]);
+
+ // get all global names
+ modulesWithInfo.forEach(info => {
+ if(info.globalScope) {
+ info.globalScope.through.forEach(reference => {
+ const name = reference.identifier.name;
+ if(/^__WEBPACK_MODULE_REFERENCE__\d+_([\da-f]+|ns)(_call)?__$/.test(name)) {
+ for(const s of getSymbolsFromScope(reference.from, info.moduleScope)) {
+ allUsedNames.add(s);
+ }
+ } else {
+ allUsedNames.add(name);
+ }
+ });
+ }
+ });
+
+ // generate names for symbols
+ modulesWithInfo.forEach(info => {
+ switch(info.type) {
+ case "concatenated":
+ {
+ const namespaceObjectName = this.findNewName("namespaceObject", allUsedNames, null, info.module.readableIdentifier(requestShortener));
+ allUsedNames.add(namespaceObjectName);
+ info.internalNames.set(namespaceObjectName, namespaceObjectName);
+ info.exportMap.set(true, namespaceObjectName);
+ info.moduleScope.variables.forEach(variable => {
+ const name = variable.name;
+ if(allUsedNames.has(name)) {
+ const references = getAllReferences(variable);
+ const symbolsInReferences = references.map(ref => getSymbolsFromScope(ref.from, info.moduleScope)).reduce(reduceSet, new Set());
+ const newName = this.findNewName(name, allUsedNames, symbolsInReferences, info.module.readableIdentifier(requestShortener));
+ allUsedNames.add(newName);
+ info.internalNames.set(name, newName);
+ const source = info.source;
+ const allIdentifiers = new Set(references.map(r => r.identifier).concat(variable.identifiers));
+ for(const identifier of allIdentifiers) {
+ const r = identifier.range;
+ const path = getPathInAst(info.ast, identifier);
+ if(path && path.length > 1 && path[1].type === "Property" && path[1].shorthand) {
+ source.insert(r[1], `: ${newName}`);
+ } else {
+ source.replace(r[0], r[1] - 1, newName);
+ }
+ }
+ } else {
+ allUsedNames.add(name);
+ info.internalNames.set(name, name);
+ }
+ });
+ break;
+ }
+ case "external":
+ {
+ info.interop = info.module.meta && !info.module.meta.harmonyModule;
+ const externalName = this.findNewName("", allUsedNames, null, info.module.readableIdentifier(requestShortener));
+ allUsedNames.add(externalName);
+ info.name = externalName;
+ if(info.interop) {
+ const externalNameInterop = this.findNewName("default", allUsedNames, null, info.module.readableIdentifier(requestShortener));
+ allUsedNames.add(externalNameInterop);
+ info.interopName = externalNameInterop;
+ }
+ break;
+ }
+ }
+ });
+
+ // Find and replace referenced to modules
+ modulesWithInfo.forEach(info => {
+ if(info.type === "concatenated") {
+ info.globalScope.through.forEach(reference => {
+ const name = reference.identifier.name;
+ const match = /^__WEBPACK_MODULE_REFERENCE__(\d+)_([\da-f]+|ns)(_call)?__$/.exec(name);
+ if(match) {
+ const referencedModule = modulesWithInfo[+match[1]];
+ let exportName;
+ if(match[2] === "ns") {
+ exportName = true;
+ } else {
+ const exportData = match[2];
+ exportName = new Buffer(exportData, "hex").toString("utf-8"); // eslint-disable-line node/no-deprecated-api
+ }
+ const asCall = !!match[3];
+ const finalName = getFinalName(referencedModule, exportName, moduleToInfoMap, requestShortener, asCall);
+ const r = reference.identifier.range;
+ const source = info.source;
+ source.replace(r[0], r[1] - 1, finalName);
+ }
+ });
+ }
+ });
+
+ const result = new ConcatSource();
+
+ // add harmony compatibility flag (must be first because of possible circular dependencies)
+ if(moduleToInfoMap.get(this.rootModule).needCompatibilityFlag) {
+ result.add(`Object.defineProperty(${this.exportsArgument || "exports"}, "__esModule", { value: true });\n`);
+ }
+
+ // define required namespace objects (must be before evaluation modules)
+ modulesWithInfo.forEach(info => {
+ if(info.namespaceObjectSource) {
+ result.add(info.namespaceObjectSource);
+ }
+ });
+
+ // evaluate modules in order
+ modulesWithInfo.forEach(info => {
+ switch(info.type) {
+ case "concatenated":
+ result.add(`\n// CONCATENATED MODULE: ${info.module.readableIdentifier(requestShortener)}\n`);
+ result.add(info.source);
+ break;
+ case "external":
+ result.add(`\n// EXTERNAL MODULE: ${info.module.readableIdentifier(requestShortener)}\n`);
+ result.add(`var ${info.name} = __webpack_require__(${JSON.stringify(info.module.id)});\n`);
+ if(info.interop) {
+ result.add(`var ${info.interopName} = /*#__PURE__*/__webpack_require__.n(${info.name});\n`);
+ }
+ break;
+ default:
+ throw new Error(`Unsupported concatenation entry type ${info.type}`);
+ }
+ });
+
+ return result;
+ }
+
+ findNewName(oldName, usedNamed1, usedNamed2, extraInfo) {
+ let name = oldName;
+
+ if(name === "__WEBPACK_MODULE_DEFAULT_EXPORT__")
+ name = "";
+
+ // Remove uncool stuff
+ extraInfo = extraInfo.replace(/\.+\/|(\/index)?\.([a-zA-Z0-9]{1,4})($|\s|\?)|\s*\+\s*\d+\s*modules/g, "");
+
+ const splittedInfo = extraInfo.split("/");
+ while(splittedInfo.length) {
+ name = splittedInfo.pop() + (name ? "_" + name : "");
+ const nameIdent = Template.toIdentifier(name);
+ if(!usedNamed1.has(nameIdent) && (!usedNamed2 || !usedNamed2.has(nameIdent))) return nameIdent;
+ }
+
+ let i = 0;
+ let nameWithNumber = Template.toIdentifier(`${name}_${i}`);
+ while(usedNamed1.has(nameWithNumber) || (usedNamed2 && usedNamed2.has(nameWithNumber))) {
+ i++;
+ nameWithNumber = Template.toIdentifier(`${name}_${i}`);
+ }
+ return nameWithNumber;
+ }
+
+ updateHash(hash) {
+ for(const info of this._orderedConcatenationList) {
+ switch(info.type) {
+ case "concatenated":
+ info.module.updateHash(hash);
+ break;
+ case "external":
+ hash.update(`${info.module.id}`);
+ break;
+ }
+ }
+ super.updateHash(hash);
+ }
+
+}
+
+class HarmonyImportSpecifierDependencyConcatenatedTemplate {
+ constructor(originalTemplate, modulesMap) {
+ this.originalTemplate = originalTemplate;
+ this.modulesMap = modulesMap;
+ }
+
+ apply(dep, source, outputOptions, requestShortener, dependencyTemplates) {
+ const module = dep.importDependency.module;
+ const info = this.modulesMap.get(module);
+ if(!info) {
+ this.originalTemplate.apply(dep, source, outputOptions, requestShortener, dependencyTemplates);
+ return;
+ }
+ let content;
+ if(dep.id === null) {
+ content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns__`;
+ } else if(dep.namespaceObjectAsContext) {
+ content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns__[${JSON.stringify(dep.id)}]`;
+ } else {
+ const exportData = new Buffer(dep.id, "utf-8").toString("hex"); // eslint-disable-line node/no-deprecated-api
+ content = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${dep.call ? "_call" : ""}__`;
+ }
+ if(dep.shorthand) {
+ content = dep.name + ": " + content;
+ }
+ source.replace(dep.range[0], dep.range[1] - 1, content);
+ }
+}
+
+class HarmonyImportDependencyConcatenatedTemplate {
+ constructor(originalTemplate, modulesMap) {
+ this.originalTemplate = originalTemplate;
+ this.modulesMap = modulesMap;
+ }
+
+ apply(dep, source, outputOptions, requestShortener, dependencyTemplates) {
+ const module = dep.module;
+ const info = this.modulesMap.get(module);
+ if(!info) {
+ this.originalTemplate.apply(dep, source, outputOptions, requestShortener, dependencyTemplates);
+ return;
+ }
+ source.replace(dep.range[0], dep.range[1] - 1, "");
+ }
+}
+
+class HarmonyExportSpecifierDependencyConcatenatedTemplate {
+ constructor(originalTemplate, rootModule) {
+ this.originalTemplate = originalTemplate;
+ this.rootModule = rootModule;
+ }
+
+ apply(dep, source, outputOptions, requestShortener, dependencyTemplates) {
+ if(dep.originModule === this.rootModule) {
+ this.originalTemplate.apply(dep, source, outputOptions, requestShortener, dependencyTemplates);
+ }
+ }
+}
+
+class HarmonyExportExpressionDependencyConcatenatedTemplate {
+ constructor(originalTemplate, rootModule) {
+ this.originalTemplate = originalTemplate;
+ this.rootModule = rootModule;
+ }
+
+ apply(dep, source, outputOptions, requestShortener, dependencyTemplates) {
+ let content = "/* harmony default export */ var __WEBPACK_MODULE_DEFAULT_EXPORT__ = ";
+ if(dep.originModule === this.rootModule) {
+ const used = dep.originModule.isUsed("default");
+ const exportsName = dep.originModule.exportsArgument || "exports";
+ if(used) content += `${exportsName}[${JSON.stringify(used)}] = `;
+ }
+
+ if(dep.range) {
+ source.replace(dep.rangeStatement[0], dep.range[0] - 1, content + "(");
+ source.replace(dep.range[1], dep.rangeStatement[1] - 1, ");");
+ return;
+ }
+
+ source.replace(dep.rangeStatement[0], dep.rangeStatement[1] - 1, content);
+ }
+}
+
+class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {
+ constructor(originalTemplate, rootModule, modulesMap) {
+ this.originalTemplate = originalTemplate;
+ this.rootModule = rootModule;
+ this.modulesMap = modulesMap;
+ }
+
+ getExports(dep) {
+ const active = HarmonyModulesHelpers.isActive(dep.originModule, dep);
+ if(!active) return [];
+ const importModule = dep.importDependency.module;
+ if(dep.id) {
+ // export { named } from "module"
+ return [{
+ name: dep.name,
+ id: dep.id,
+ module: importModule
+ }];
+ }
+ if(dep.name) {
+ // export * as abc from "module"
+ return [{
+ name: dep.name,
+ id: true,
+ module: importModule
+ }];
+ }
+ // export * from "module"
+ const activeExports = new Set(HarmonyModulesHelpers.getActiveExports(dep.originModule, dep));
+ return importModule.providedExports.filter(exp => exp !== "default" && !activeExports.has(exp)).map(exp => {
+ return {
+ name: exp,
+ id: exp,
+ module: importModule
+ };
+ });
+ }
+
+ apply(dep, source, outputOptions, requestShortener, dependencyTemplates) {
+ if(dep.originModule === this.rootModule) {
+ if(this.modulesMap.get(dep.importDependency.module)) {
+ const exportDefs = this.getExports(dep);
+ exportDefs.forEach(def => {
+ const info = this.modulesMap.get(def.module);
+ const used = dep.originModule.isUsed(def.name);
+ if(!used) {
+ source.insert(-1, `/* unused concated harmony import ${dep.name} */\n`);
+ }
+ let finalName;
+ if(def.id === true) {
+ finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns__`;
+ } else {
+ const exportData = new Buffer(def.id, "utf-8").toString("hex"); // eslint-disable-line node/no-deprecated-api
+ finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}__`;
+ }
+ const exportsName = this.rootModule.exportsArgument || "exports";
+ const content = `/* concated harmony reexport */__webpack_require__.d(${exportsName}, ${JSON.stringify(used)}, function() { return ${finalName}; });\n`;
+ source.insert(-1, content);
+ });
+ } else {
+ this.originalTemplate.apply(dep, source, outputOptions, requestShortener, dependencyTemplates);
+ }
+ }
+ }
+}
+
+class HarmonyCompatibilityDependencyConcatenatedTemplate {
+ constructor(originalTemplate, rootModule, modulesMap) {
+ this.originalTemplate = originalTemplate;
+ this.rootModule = rootModule;
+ this.modulesMap = modulesMap;
+ }
+
+ apply(dep, source, outputOptions, requestShortener, dependencyTemplates) {
+ if(dep.originModule === this.rootModule) {
+ this.modulesMap.get(this.rootModule).needCompatibilityFlag = true;
+ }
+ }
+}
+
+module.exports = ConcatenatedModule;
diff --git a/node_modules/webpack/lib/optimize/EnsureChunkConditionsPlugin.js b/node_modules/webpack/lib/optimize/EnsureChunkConditionsPlugin.js
index 71ee18533..46324c4e9 100644
--- a/node_modules/webpack/lib/optimize/EnsureChunkConditionsPlugin.js
+++ b/node_modules/webpack/lib/optimize/EnsureChunkConditionsPlugin.js
@@ -8,16 +8,19 @@ class EnsureChunkConditionsPlugin {
apply(compiler) {
compiler.plugin("compilation", (compilation) => {
+ const triesMap = new Map();
compilation.plugin(["optimize-chunks-basic", "optimize-extracted-chunks-basic"], (chunks) => {
let changed = false;
chunks.forEach((chunk) => {
- chunk.modules.slice().forEach((module) => {
+ chunk.forEachModule((module) => {
if(!module.chunkCondition) return;
if(!module.chunkCondition(chunk)) {
- const usedChunks = module._EnsureChunkConditionsPlugin_usedChunks = (module._EnsureChunkConditionsPlugin_usedChunks || []).concat(chunk);
+ let usedChunks = triesMap.get(module);
+ if(!usedChunks) triesMap.set(module, usedChunks = new Set());
+ usedChunks.add(chunk);
const newChunks = [];
chunk.parents.forEach((parent) => {
- if(usedChunks.indexOf(parent) < 0) {
+ if(!usedChunks.has(parent)) {
parent.addModule(module);
newChunks.push(parent);
}
diff --git a/node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js b/node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js
index e8b5a9457..75277b5aa 100644
--- a/node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js
+++ b/node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js
@@ -17,13 +17,13 @@ class FlagIncludedChunksPlugin {
// instead of swapping A and B just bail
// as we loop twice the current A will be B and B then A
- if(chunkA.modules.length < chunkB.modules.length) return;
+ if(chunkA.getNumberOfModules() < chunkB.getNumberOfModules()) return;
- if(chunkB.modules.length === 0) return;
+ if(chunkB.getNumberOfModules() === 0) return;
// is chunkB in chunkA?
- for(let i = 0; i < chunkB.modules.length; i++) {
- if(chunkA.modules.indexOf(chunkB.modules[i]) < 0) return;
+ for(const m of chunkB.modulesIterable) {
+ if(!chunkA.containsModule(m)) return;
}
chunkA.ids.push(chunkB.id);
});
diff --git a/node_modules/webpack/lib/optimize/MergeDuplicateChunksPlugin.js b/node_modules/webpack/lib/optimize/MergeDuplicateChunksPlugin.js
index 90df06b51..7b006fd17 100644
--- a/node_modules/webpack/lib/optimize/MergeDuplicateChunksPlugin.js
+++ b/node_modules/webpack/lib/optimize/MergeDuplicateChunksPlugin.js
@@ -4,23 +4,18 @@
*/
"use strict";
-function getChunkIdentifier(chunk) {
- return chunk.modules.map((m) => {
- return m.identifier();
- }).sort().join(", ");
-}
-
class MergeDuplicateChunksPlugin {
apply(compiler) {
compiler.plugin("compilation", (compilation) => {
compilation.plugin("optimize-chunks-basic", (chunks) => {
- const map = {};
+ const map = Object.create(null);
chunks.slice().forEach((chunk) => {
if(chunk.hasRuntime() || chunk.hasEntryModule()) return;
- const ident = getChunkIdentifier(chunk);
- if(map[ident]) {
- if(map[ident].integrate(chunk, "duplicate"))
+ const ident = chunk.getModulesIdent();
+ const otherChunk = map[ident];
+ if(otherChunk) {
+ if(otherChunk.integrate(chunk, "duplicate"))
chunks.splice(chunks.indexOf(chunk), 1);
return;
}
diff --git a/node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js b/node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js
new file mode 100644
index 000000000..9e797c75e
--- /dev/null
+++ b/node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js
@@ -0,0 +1,307 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
+const ModuleHotAcceptDependency = require("../dependencies/ModuleHotAcceptDependency");
+const ModuleHotDeclineDependency = require("../dependencies/ModuleHotDeclineDependency");
+const ConcatenatedModule = require("./ConcatenatedModule");
+const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
+const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
+
+function formatBailoutReason(msg) {
+ return "ModuleConcatenation bailout: " + msg;
+}
+
+class ModuleConcatenationPlugin {
+ constructor(options) {
+ if(typeof options !== "object") options = {};
+ this.options = options;
+ }
+
+ apply(compiler) {
+ compiler.plugin("compilation", (compilation, params) => {
+ params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
+ parser.plugin("call eval", () => {
+ parser.state.module.meta.hasEval = true;
+ });
+ });
+ const bailoutReasonMap = new Map();
+
+ function setBailoutReason(module, reason) {
+ bailoutReasonMap.set(module, reason);
+ module.optimizationBailout.push(typeof reason === "function" ? (rs) => formatBailoutReason(reason(rs)) : formatBailoutReason(reason));
+ }
+
+ function getBailoutReason(module, requestShortener) {
+ const reason = bailoutReasonMap.get(module);
+ if(typeof reason === "function") return reason(requestShortener);
+ return reason;
+ }
+
+ compilation.plugin("optimize-chunk-modules", (chunks, modules) => {
+ const relevantModules = [];
+ const possibleInners = new Set();
+ for(const module of modules) {
+ // Only harmony modules are valid for optimization
+ if(!module.meta || !module.meta.harmonyModule || !module.dependencies.some(d => d instanceof HarmonyCompatibilityDependency)) {
+ setBailoutReason(module, "Module is not an ECMAScript module");
+ continue;
+ }
+
+ // Because of variable renaming we can't use modules with eval
+ if(module.meta && module.meta.hasEval) {
+ setBailoutReason(module, "Module uses eval()");
+ continue;
+ }
+
+ // Exports must be known (and not dynamic)
+ if(!Array.isArray(module.providedExports)) {
+ setBailoutReason(module, "Module exports are unknown");
+ continue;
+ }
+
+ // Using dependency variables is not possible as this wraps the code in a function
+ if(module.variables.length > 0) {
+ setBailoutReason(module, `Module uses injected variables (${module.variables.map(v => v.name).join(", ")})`);
+ continue;
+ }
+
+ // Hot Module Replacement need it's own module to work correctly
+ if(module.dependencies.some(dep => dep instanceof ModuleHotAcceptDependency || dep instanceof ModuleHotDeclineDependency)) {
+ setBailoutReason(module, "Module uses Hot Module Replacement");
+ continue;
+ }
+
+ relevantModules.push(module);
+
+ // Module must not be the entry points
+ if(module.getChunks().some(chunk => chunk.entryModule === module)) {
+ setBailoutReason(module, "Module is an entry point");
+ continue;
+ }
+
+ // Module must only be used by Harmony Imports
+ const nonHarmonyReasons = module.reasons.filter(reason => !(reason.dependency instanceof HarmonyImportDependency));
+ if(nonHarmonyReasons.length > 0) {
+ const importingModules = new Set(nonHarmonyReasons.map(r => r.module));
+ const importingModuleTypes = new Map(Array.from(importingModules).map(m => [m, new Set(nonHarmonyReasons.filter(r => r.module === m).map(r => r.dependency.type).sort())]));
+ setBailoutReason(module, (requestShortener) => {
+ const names = Array.from(importingModules).map(m => `${m.readableIdentifier(requestShortener)} (referenced with ${Array.from(importingModuleTypes.get(m)).join(", ")})`).sort();
+ return `Module is referenced from these modules with unsupported syntax: ${names.join(", ")}`;
+ });
+ continue;
+ }
+
+ possibleInners.add(module);
+ }
+ // sort by depth
+ // modules with lower depth are more likely suited as roots
+ // this improves performance, because modules already selected as inner are skipped
+ relevantModules.sort((a, b) => {
+ return a.depth - b.depth;
+ });
+ const concatConfigurations = [];
+ const usedAsInner = new Set();
+ for(const currentRoot of relevantModules) {
+ // when used by another configuration as inner:
+ // the other configuration is better and we can skip this one
+ if(usedAsInner.has(currentRoot))
+ continue;
+
+ // create a configuration with the root
+ const currentConfiguration = new ConcatConfiguration(currentRoot);
+
+ // cache failures to add modules
+ const failureCache = new Map();
+
+ // try to add all imports
+ for(const imp of this.getImports(currentRoot)) {
+ const problem = this.tryToAdd(currentConfiguration, imp, possibleInners, failureCache);
+ if(problem) {
+ failureCache.set(imp, problem);
+ currentConfiguration.addWarning(imp, problem);
+ }
+ }
+ if(!currentConfiguration.isEmpty()) {
+ concatConfigurations.push(currentConfiguration);
+ for(const module of currentConfiguration.modules) {
+ if(module !== currentConfiguration.rootModule)
+ usedAsInner.add(module);
+ }
+ }
+ }
+ // HACK: Sort configurations by length and start with the longest one
+ // to get the biggers groups possible. Used modules are marked with usedModules
+ // TODO: Allow to reuse existing configuration while trying to add dependencies.
+ // This would improve performance. O(n^2) -> O(n)
+ concatConfigurations.sort((a, b) => {
+ return b.modules.size - a.modules.size;
+ });
+ const usedModules = new Set();
+ for(const concatConfiguration of concatConfigurations) {
+ if(usedModules.has(concatConfiguration.rootModule))
+ continue;
+ const newModule = new ConcatenatedModule(concatConfiguration.rootModule, Array.from(concatConfiguration.modules));
+ concatConfiguration.sortWarnings();
+ for(const warning of concatConfiguration.warnings) {
+ newModule.optimizationBailout.push((requestShortener) => {
+ const reason = getBailoutReason(warning[0], requestShortener);
+ const reasonWithPrefix = reason ? ` (<- ${reason})` : "";
+ if(warning[0] === warning[1])
+ return formatBailoutReason(`Cannot concat with ${warning[0].readableIdentifier(requestShortener)}${reasonWithPrefix}`);
+ else
+ return formatBailoutReason(`Cannot concat with ${warning[0].readableIdentifier(requestShortener)} because of ${warning[1].readableIdentifier(requestShortener)}${reasonWithPrefix}`);
+ });
+ }
+ const chunks = concatConfiguration.rootModule.getChunks();
+ for(const m of concatConfiguration.modules) {
+ usedModules.add(m);
+ chunks.forEach(chunk => chunk.removeModule(m));
+ }
+ chunks.forEach(chunk => {
+ chunk.addModule(newModule);
+ if(chunk.entryModule === concatConfiguration.rootModule)
+ chunk.entryModule = newModule;
+ });
+ compilation.modules.push(newModule);
+ newModule.reasons.forEach(reason => reason.dependency.module = newModule);
+ newModule.dependencies.forEach(dep => {
+ if(dep.module) {
+ dep.module.reasons.forEach(reason => {
+ if(reason.dependency === dep)
+ reason.module = newModule;
+ });
+ }
+ });
+ }
+ compilation.modules = compilation.modules.filter(m => !usedModules.has(m));
+ });
+ });
+ }
+
+ getImports(module) {
+ return Array.from(new Set(module.dependencies
+
+ // Only harmony Dependencies
+ .filter(dep => dep instanceof HarmonyImportDependency && dep.module)
+
+ // Dependencies are simple enough to concat them
+ .filter(dep => {
+ return !module.dependencies.some(d =>
+ d instanceof HarmonyExportImportedSpecifierDependency &&
+ d.importDependency === dep &&
+ !d.id &&
+ !Array.isArray(dep.module.providedExports)
+ );
+ })
+
+ // Take the imported module
+ .map(dep => dep.module)
+ ));
+ }
+
+ tryToAdd(config, module, possibleModules, failureCache) {
+ const cacheEntry = failureCache.get(module);
+ if(cacheEntry) {
+ return cacheEntry;
+ }
+
+ // Already added?
+ if(config.has(module)) {
+ return null;
+ }
+
+ // Not possible to add?
+ if(!possibleModules.has(module)) {
+ failureCache.set(module, module); // cache failures for performance
+ return module;
+ }
+
+ // module must be in the same chunks
+ if(!config.rootModule.hasEqualsChunks(module)) {
+ failureCache.set(module, module); // cache failures for performance
+ return module;
+ }
+
+ // Clone config to make experimental changes
+ const testConfig = config.clone();
+
+ // Add the module
+ testConfig.add(module);
+
+ // Every module which depends on the added module must be in the configuration too.
+ for(const reason of module.reasons) {
+ const problem = this.tryToAdd(testConfig, reason.module, possibleModules, failureCache);
+ if(problem) {
+ failureCache.set(module, problem); // cache failures for performance
+ return problem;
+ }
+ }
+
+ // Eagerly try to add imports too if possible
+ for(const imp of this.getImports(module)) {
+ const problem = this.tryToAdd(testConfig, imp, possibleModules, failureCache);
+ if(problem) {
+ config.addWarning(module, problem);
+ }
+ }
+
+ // Commit experimental changes
+ config.set(testConfig);
+ return null;
+ }
+}
+
+class ConcatConfiguration {
+ constructor(rootModule) {
+ this.rootModule = rootModule;
+ this.modules = new Set([rootModule]);
+ this.warnings = new Map();
+ }
+
+ add(module) {
+ this.modules.add(module);
+ }
+
+ has(module) {
+ return this.modules.has(module);
+ }
+
+ isEmpty() {
+ return this.modules.size === 1;
+ }
+
+ addWarning(module, problem) {
+ this.warnings.set(module, problem);
+ }
+
+ sortWarnings() {
+ this.warnings = new Map(Array.from(this.warnings).sort((a, b) => {
+ const ai = a[0].identifier();
+ const bi = b[0].identifier();
+ if(ai < bi) return -1;
+ if(ai > bi) return 1;
+ return 0;
+ }));
+ }
+
+ clone() {
+ const clone = new ConcatConfiguration(this.rootModule);
+ for(const module of this.modules)
+ clone.add(module);
+ for(const pair of this.warnings)
+ clone.addWarning(pair[0], pair[1]);
+ return clone;
+ }
+
+ set(config) {
+ this.rootModule = config.rootModule;
+ this.modules = new Set(config.modules);
+ this.warnings = new Map(config.warnings);
+ }
+}
+
+module.exports = ModuleConcatenationPlugin;
diff --git a/node_modules/webpack/lib/optimize/OccurrenceOrderPlugin.js b/node_modules/webpack/lib/optimize/OccurrenceOrderPlugin.js
index a6bb30b34..45ec34719 100644
--- a/node_modules/webpack/lib/optimize/OccurrenceOrderPlugin.js
+++ b/node_modules/webpack/lib/optimize/OccurrenceOrderPlugin.js
@@ -15,98 +15,84 @@ class OccurrenceOrderPlugin {
const preferEntry = this.preferEntry;
compiler.plugin("compilation", (compilation) => {
compilation.plugin("optimize-module-order", (modules) => {
- function entryChunks(m) {
- return m.chunks.map((c) => {
- const sum = (c.isInitial() ? 1 : 0) + (c.entryModule === m ? 1 : 0);
- return sum;
- }).reduce((a, b) => {
- return a + b;
- }, 0);
- }
+ const occursInInitialChunksMap = new Map();
+ const occursInAllChunksMap = new Map();
- function occursInEntry(m) {
- if(typeof m.__OccurenceOrderPlugin_occursInEntry === "number") return m.__OccurenceOrderPlugin_occursInEntry;
- const result = m.reasons.map((r) => {
- if(!r.module) return 0;
- return entryChunks(r.module);
- }).reduce((a, b) => {
- return a + b;
- }, 0) + entryChunks(m);
- return m.__OccurenceOrderPlugin_occursInEntry = result;
- }
+ const initialChunkChunkMap = new Map();
+ const entryCountMap = new Map();
+ modules.forEach(m => {
+ let initial = 0;
+ let entry = 0;
+ m.forEachChunk(c => {
+ if(c.isInitial()) initial++;
+ if(c.entryModule === m) entry++;
+ });
+ initialChunkChunkMap.set(m, initial);
+ entryCountMap.set(m, entry);
+ });
+
+ const countOccursInEntry = (sum, r) => {
+ if(!r.module) return sum;
+ return sum + initialChunkChunkMap.get(r.module);
+ };
+ const countOccurs = (sum, r) => {
+ if(!r.module) return sum;
+ return sum + r.module.getNumberOfChunks();
+ };
- function occurs(m) {
- if(typeof m.__OccurenceOrderPlugin_occurs === "number") return m.__OccurenceOrderPlugin_occurs;
- const result = m.reasons.map((r) => {
- if(!r.module) return 0;
- return r.module.chunks.length;
- }).reduce((a, b) => {
- return a + b;
- }, 0) + m.chunks.length + m.chunks.filter((c) => {
- return c.entryModule === m;
- }).length;
- return m.__OccurenceOrderPlugin_occurs = result;
+ if(preferEntry) {
+ modules.forEach(m => {
+ const result = m.reasons.reduce(countOccursInEntry, 0) + initialChunkChunkMap.get(m) + entryCountMap.get(m);
+ occursInInitialChunksMap.set(m, result);
+ });
}
+
+ modules.forEach(m => {
+ const result = m.reasons.reduce(countOccurs, 0) + m.getNumberOfChunks() + entryCountMap.get(m);
+ occursInAllChunksMap.set(m, result);
+ });
+
modules.sort((a, b) => {
if(preferEntry) {
- const aEntryOccurs = occursInEntry(a);
- const bEntryOccurs = occursInEntry(b);
+ const aEntryOccurs = occursInInitialChunksMap.get(a);
+ const bEntryOccurs = occursInInitialChunksMap.get(b);
if(aEntryOccurs > bEntryOccurs) return -1;
if(aEntryOccurs < bEntryOccurs) return 1;
}
- const aOccurs = occurs(a);
- const bOccurs = occurs(b);
+ const aOccurs = occursInAllChunksMap.get(a);
+ const bOccurs = occursInAllChunksMap.get(b);
if(aOccurs > bOccurs) return -1;
if(aOccurs < bOccurs) return 1;
- if(a.identifier() > b.identifier()) return 1;
- if(a.identifier() < b.identifier()) return -1;
+ if(a.index > b.index) return 1;
+ if(a.index < b.index) return -1;
return 0;
});
- // TODO refactor to Map
- modules.forEach((m) => {
- m.__OccurenceOrderPlugin_occursInEntry = undefined;
- m.__OccurenceOrderPlugin_occurs = undefined;
- });
});
compilation.plugin("optimize-chunk-order", (chunks) => {
- function occursInEntry(c) {
- if(typeof c.__OccurenceOrderPlugin_occursInEntry === "number") return c.__OccurenceOrderPlugin_occursInEntry;
- const result = c.parents.filter((p) => {
- return p.isInitial();
- }).length;
- return c.__OccurenceOrderPlugin_occursInEntry = result;
- }
+ const occursInInitialChunksMap = new Map();
+
+ chunks.forEach(c => {
+ const result = c.parents.reduce((sum, p) => {
+ if(p.isInitial()) return sum + 1;
+ return sum;
+ }, 0);
+ return occursInInitialChunksMap.set(c, result);
+ });
function occurs(c) {
return c.blocks.length;
}
- chunks.forEach((c) => {
- c.modules.sort((a, b) => {
- if(a.identifier() > b.identifier()) return 1;
- if(a.identifier() < b.identifier()) return -1;
- return 0;
- });
- });
+
chunks.sort((a, b) => {
- const aEntryOccurs = occursInEntry(a);
- const bEntryOccurs = occursInEntry(b);
+ const aEntryOccurs = occursInInitialChunksMap.get(a);
+ const bEntryOccurs = occursInInitialChunksMap.get(b);
if(aEntryOccurs > bEntryOccurs) return -1;
if(aEntryOccurs < bEntryOccurs) return 1;
const aOccurs = occurs(a);
const bOccurs = occurs(b);
if(aOccurs > bOccurs) return -1;
if(aOccurs < bOccurs) return 1;
- if(a.modules.length > b.modules.length) return -1;
- if(a.modules.length < b.modules.length) return 1;
- for(let i = 0; i < a.modules.length; i++) {
- if(a.modules[i].identifier() > b.modules[i].identifier()) return -1;
- if(a.modules[i].identifier() < b.modules[i].identifier()) return 1;
- }
- return 0;
- });
- // TODO refactor to Map
- chunks.forEach((c) => {
- c.__OccurenceOrderPlugin_occursInEntry = undefined;
+ return a.compareTo(b);
});
});
});
diff --git a/node_modules/webpack/lib/optimize/RemoveParentModulesPlugin.js b/node_modules/webpack/lib/optimize/RemoveParentModulesPlugin.js
index e73add989..43550819c 100644
--- a/node_modules/webpack/lib/optimize/RemoveParentModulesPlugin.js
+++ b/node_modules/webpack/lib/optimize/RemoveParentModulesPlugin.js
@@ -4,59 +4,31 @@
*/
"use strict";
-function chunkContainsModule(chunk, module) {
- const chunks = module.chunks;
- const modules = chunk.modules;
- if(chunks.length < modules.length) {
- return chunks.indexOf(chunk) >= 0;
- } else {
- return modules.indexOf(module) >= 0;
- }
-}
-
function hasModule(chunk, module, checkedChunks) {
- if(chunkContainsModule(chunk, module)) return [chunk];
+ if(chunk.containsModule(module)) return [chunk];
if(chunk.parents.length === 0) return false;
return allHaveModule(chunk.parents.filter((c) => {
- return checkedChunks.indexOf(c) < 0;
+ return !checkedChunks.has(c);
}), module, checkedChunks);
}
function allHaveModule(someChunks, module, checkedChunks) {
- if(!checkedChunks) checkedChunks = [];
- var chunks = [];
+ if(!checkedChunks) checkedChunks = new Set();
+ var chunks = new Set();
for(var i = 0; i < someChunks.length; i++) {
- checkedChunks.push(someChunks[i]);
+ checkedChunks.add(someChunks[i]);
var subChunks = hasModule(someChunks[i], module, checkedChunks);
if(!subChunks) return false;
for(var index = 0; index < subChunks.length; index++) {
var item = subChunks[index];
- if(!chunks.length || chunks.indexOf(item) < 0) {
- chunks.push(item);
- }
+ chunks.add(item);
}
}
return chunks;
}
-function debugIds(chunks) {
- var list = [];
- for(var i = 0; i < chunks.length; i++) {
- var debugId = chunks[i].debugId;
-
- if(typeof debugId !== "number") {
- return "no";
- }
-
- list.push(debugId);
- }
-
- list.sort();
- return list.join(",");
-}
-
class RemoveParentModulesPlugin {
apply(compiler) {
compiler.plugin("compilation", (compilation) => {
@@ -67,19 +39,21 @@ class RemoveParentModulesPlugin {
// TODO consider Map when performance has improved https://gist.github.com/sokra/b36098368da7b8f6792fd7c85fca6311
var cache = Object.create(null);
- var modules = chunk.modules.slice();
+ var modules = chunk.getModules();
for(var i = 0; i < modules.length; i++) {
var module = modules[i];
- var dId = debugIds(module.chunks);
+ var dId = module.getChunkIdsIdent();
var parentChunksWithModule;
- if((dId in cache) && dId !== "no") {
+ if(dId === null) {
+ parentChunksWithModule = allHaveModule(chunk.parents, module);
+ } else if(dId in cache) {
parentChunksWithModule = cache[dId];
} else {
parentChunksWithModule = cache[dId] = allHaveModule(chunk.parents, module);
}
if(parentChunksWithModule) {
- module.rewriteChunkInReasons(chunk, parentChunksWithModule);
+ module.rewriteChunkInReasons(chunk, Array.from(parentChunksWithModule));
chunk.removeModule(module);
}
}
diff --git a/node_modules/webpack/lib/optimize/UglifyJsPlugin.js b/node_modules/webpack/lib/optimize/UglifyJsPlugin.js
index f95dc8eef..1caa10817 100644
--- a/node_modules/webpack/lib/optimize/UglifyJsPlugin.js
+++ b/node_modules/webpack/lib/optimize/UglifyJsPlugin.js
@@ -4,233 +4,6 @@
*/
"use strict";
-const SourceMapConsumer = require("source-map").SourceMapConsumer;
-const SourceMapSource = require("webpack-sources").SourceMapSource;
-const RawSource = require("webpack-sources").RawSource;
-const ConcatSource = require("webpack-sources").ConcatSource;
-const RequestShortener = require("../RequestShortener");
-const ModuleFilenameHelpers = require("../ModuleFilenameHelpers");
-const uglify = require("uglify-js");
-
-class UglifyJsPlugin {
- constructor(options) {
- if(typeof options !== "object" || Array.isArray(options)) options = {};
- if(typeof options.compressor !== "undefined") options.compress = options.compressor;
- this.options = options;
- }
-
- apply(compiler) {
- const options = this.options;
- options.test = options.test || /\.js($|\?)/i;
- const warningsFilter = options.warningsFilter || (() => true);
-
- const requestShortener = new RequestShortener(compiler.context);
- compiler.plugin("compilation", (compilation) => {
- if(options.sourceMap) {
- compilation.plugin("build-module", (module) => {
- // to get detailed location info about errors
- module.useSourceMap = true;
- });
- }
- compilation.plugin("optimize-chunk-assets", (chunks, callback) => {
- const files = [];
- chunks.forEach((chunk) => files.push.apply(files, chunk.files));
- files.push.apply(files, compilation.additionalChunkAssets);
- const filterdFiles = files.filter(ModuleFilenameHelpers.matchObject.bind(undefined, options));
- filterdFiles.forEach((file) => {
- const oldWarnFunction = uglify.AST_Node.warn_function;
- const warnings = [];
- let sourceMap;
- try {
- const asset = compilation.assets[file];
- if(asset.__UglifyJsPlugin) {
- compilation.assets[file] = asset.__UglifyJsPlugin;
- return;
- }
- let input;
- let inputSourceMap;
- if(options.sourceMap) {
- if(asset.sourceAndMap) {
- const sourceAndMap = asset.sourceAndMap();
- inputSourceMap = sourceAndMap.map;
- input = sourceAndMap.source;
- } else {
- inputSourceMap = asset.map();
- input = asset.source();
- }
- sourceMap = new SourceMapConsumer(inputSourceMap);
- uglify.AST_Node.warn_function = (warning) => { // eslint-disable-line camelcase
- const match = /\[.+:([0-9]+),([0-9]+)\]/.exec(warning);
- const line = +match[1];
- const column = +match[2];
- const original = sourceMap.originalPositionFor({
- line: line,
- column: column
- });
- if(!original || !original.source || original.source === file) return;
- if(!warningsFilter(original.source)) return;
- warnings.push(warning.replace(/\[.+:([0-9]+),([0-9]+)\]/, "") +
- "[" + requestShortener.shorten(original.source) + ":" + original.line + "," + original.column + "]");
- };
- } else {
- input = asset.source();
- uglify.AST_Node.warn_function = (warning) => { // eslint-disable-line camelcase
- warnings.push(warning);
- };
- }
- uglify.base54.reset();
- let ast = uglify.parse(input, {
- filename: file
- });
- if(options.compress !== false) {
- ast.figure_out_scope();
- const compress = uglify.Compressor(options.compress || {
- warnings: false
- }); // eslint-disable-line new-cap
- ast = compress.compress(ast);
- }
- if(options.mangle !== false) {
- ast.figure_out_scope(options.mangle || {});
- ast.compute_char_frequency(options.mangle || {});
- ast.mangle_names(options.mangle || {});
- if(options.mangle && options.mangle.props) {
- uglify.mangle_properties(ast, options.mangle.props);
- }
- }
- const output = {};
- output.comments = Object.prototype.hasOwnProperty.call(options, "comments") ? options.comments : /^\**!|@preserve|@license/;
- output.beautify = options.beautify;
- for(let k in options.output) {
- output[k] = options.output[k];
- }
- const extractedComments = [];
- if(options.extractComments) {
- const condition = {};
- if(typeof options.extractComments === "string" || options.extractComments instanceof RegExp) {
- // extractComments specifies the extract condition and output.comments specifies the preserve condition
- condition.preserve = output.comments;
- condition.extract = options.extractComments;
- } else if(Object.prototype.hasOwnProperty.call(options.extractComments, "condition")) {
- // Extract condition is given in extractComments.condition
- condition.preserve = output.comments;
- condition.extract = options.extractComments.condition;
- } else {
- // No extract condition is given. Extract comments that match output.comments instead of preserving them
- condition.preserve = false;
- condition.extract = output.comments;
- }
-
- // Ensure that both conditions are functions
- ["preserve", "extract"].forEach(key => {
- switch(typeof condition[key]) {
- case "boolean":
- var b = condition[key];
- condition[key] = () => b;
- break;
- case "function":
- break;
- case "string":
- if(condition[key] === "all") {
- condition[key] = () => true;
- break;
- }
- var regex = new RegExp(condition[key]);
- condition[key] = (astNode, comment) => regex.test(comment.value);
- break;
- default:
- regex = condition[key];
- condition[key] = (astNode, comment) => regex.test(comment.value);
- }
- });
-
- // Redefine the comments function to extract and preserve
- // comments according to the two conditions
- output.comments = (astNode, comment) => {
- if(condition.extract(astNode, comment)) {
- extractedComments.push(
- comment.type === "comment2" ? "/*" + comment.value + "*/" : "//" + comment.value
- );
- }
- return condition.preserve(astNode, comment);
- };
- }
- let map;
- if(options.sourceMap) {
- map = uglify.SourceMap({ // eslint-disable-line new-cap
- file: file,
- root: ""
- });
- output.source_map = map; // eslint-disable-line camelcase
- }
- const stream = uglify.OutputStream(output); // eslint-disable-line new-cap
- ast.print(stream);
- if(map) map = map + "";
- const stringifiedStream = stream + "";
- let outputSource = (map ?
- new SourceMapSource(stringifiedStream, file, JSON.parse(map), input, inputSourceMap) :
- new RawSource(stringifiedStream));
- if(extractedComments.length > 0) {
- let commentsFile = options.extractComments.filename || file + ".LICENSE";
- if(typeof commentsFile === "function") {
- commentsFile = commentsFile(file);
- }
-
- // Write extracted comments to commentsFile
- const commentsSource = new RawSource(extractedComments.join("\n\n") + "\n");
- if(commentsFile in compilation.assets) {
- // commentsFile already exists, append new comments...
- if(compilation.assets[commentsFile] instanceof ConcatSource) {
- compilation.assets[commentsFile].add("\n");
- compilation.assets[commentsFile].add(commentsSource);
- } else {
- compilation.assets[commentsFile] = new ConcatSource(
- compilation.assets[commentsFile], "\n", commentsSource
- );
- }
- } else {
- compilation.assets[commentsFile] = commentsSource;
- }
-
- // Add a banner to the original file
- if(options.extractComments.banner !== false) {
- let banner = options.extractComments.banner || "For license information please see " + commentsFile;
- if(typeof banner === "function") {
- banner = banner(commentsFile);
- }
- if(banner) {
- outputSource = new ConcatSource(
- "/*! " + banner + " */\n", outputSource
- );
- }
- }
- }
- asset.__UglifyJsPlugin = compilation.assets[file] = outputSource;
- if(warnings.length > 0) {
- compilation.warnings.push(new Error(file + " from UglifyJs\n" + warnings.join("\n")));
- }
- } catch(err) {
- if(err.line) {
- const original = sourceMap && sourceMap.originalPositionFor({
- line: err.line,
- column: err.col
- });
- if(original && original.source) {
- compilation.errors.push(new Error(file + " from UglifyJs\n" + err.message + " [" + requestShortener.shorten(original.source) + ":" + original.line + "," + original.column + "][" + file + ":" + err.line + "," + err.col + "]"));
- } else {
- compilation.errors.push(new Error(file + " from UglifyJs\n" + err.message + " [" + file + ":" + err.line + "," + err.col + "]"));
- }
- } else if(err.msg) {
- compilation.errors.push(new Error(file + " from UglifyJs\n" + err.msg));
- } else
- compilation.errors.push(new Error(file + " from UglifyJs\n" + err.stack));
- } finally {
- uglify.AST_Node.warn_function = oldWarnFunction; // eslint-disable-line camelcase
- }
- });
- callback();
- });
- });
- }
-}
+const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
module.exports = UglifyJsPlugin;
diff --git a/node_modules/webpack/lib/prepareOptions.js b/node_modules/webpack/lib/prepareOptions.js
new file mode 100644
index 000000000..0b063a03b
--- /dev/null
+++ b/node_modules/webpack/lib/prepareOptions.js
@@ -0,0 +1,29 @@
+"use strict";
+
+module.exports = function prepareOptions(options, argv) {
+ argv = argv || {};
+
+ options = handleExport(options);
+
+ if(Array.isArray(options)) {
+ options = options.map(_options => handleFunction(_options, argv));
+ } else {
+ options = handleFunction(options, argv);
+ }
+ return options;
+};
+
+function handleExport(options) {
+ const isES6DefaultExported = (
+ typeof options === "object" && options !== null && typeof options.default !== "undefined"
+ );
+ options = isES6DefaultExported ? options.default : options;
+ return options;
+}
+
+function handleFunction(options, argv) {
+ if(typeof options === "function") {
+ options = options(argv.env, argv);
+ }
+ return options;
+}
diff --git a/node_modules/webpack/lib/util/Semaphore.js b/node_modules/webpack/lib/util/Semaphore.js
new file mode 100644
index 000000000..de9b69dde
--- /dev/null
+++ b/node_modules/webpack/lib/util/Semaphore.js
@@ -0,0 +1,32 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+class Semaphore {
+ constructor(available) {
+ this.available = available;
+ this.waiters = [];
+ }
+
+ acquire(callback) {
+ if(this.available > 0) {
+ this.available--;
+ callback();
+ } else {
+ this.waiters.push(callback);
+ }
+ }
+
+ release() {
+ if(this.waiters.length > 0) {
+ const callback = this.waiters.pop();
+ process.nextTick(callback);
+ } else {
+ this.available++;
+ }
+ }
+}
+
+module.exports = Semaphore;
diff --git a/node_modules/webpack/lib/util/SortableSet.js b/node_modules/webpack/lib/util/SortableSet.js
new file mode 100644
index 000000000..15c7ecb87
--- /dev/null
+++ b/node_modules/webpack/lib/util/SortableSet.js
@@ -0,0 +1,45 @@
+"use strict";
+
+module.exports = class SortableSet extends Set {
+
+ constructor(initialIterable, defaultSort) {
+ super(initialIterable);
+ this._sortFn = defaultSort;
+ this._lastActiveSortFn = null;
+ }
+
+ /**
+ * @param {any} value - value to add to set
+ * @returns {SortableSet} - returns itself
+ */
+ add(value) {
+ this._lastActiveSortFn = null;
+ super.add(value);
+ return this;
+ }
+
+ /**
+ * @param {Function} sortFn - function to sort the set
+ * @returns {void}
+ */
+ sortWith(sortFn) {
+ if(this.size === 0 || sortFn === this._lastActiveSortFn) {
+ // already sorted - nothing to do
+ return;
+ }
+
+ const sortedArray = Array.from(this).sort(sortFn);
+ super.clear();
+ for(let i = 0; i < sortedArray.length; i += 1) {
+ this.add(sortedArray[i]);
+ }
+ this._lastActiveSortFn = sortFn;
+ }
+
+ /**
+ * @returns {void}
+ */
+ sort() {
+ this.sortWith(this._sortFn);
+ }
+};
diff --git a/node_modules/webpack/lib/util/identifier.js b/node_modules/webpack/lib/util/identifier.js
index b1bcbf5df..82e5b811f 100644
--- a/node_modules/webpack/lib/util/identifier.js
+++ b/node_modules/webpack/lib/util/identifier.js
@@ -7,10 +7,32 @@ const looksLikeAbsolutePath = (maybeAbsolutePath) => {
const normalizePathSeparator = (p) => p.replace(/\\/g, "/");
-exports.makePathsRelative = (context, identifier) => {
+const _makePathsRelative = (context, identifier) => {
return identifier
.split(/([|! ])/)
.map(str => looksLikeAbsolutePath(str) ?
normalizePathSeparator(path.relative(context, str)) : str)
.join("");
};
+
+exports.makePathsRelative = (context, identifier, cache) => {
+ if(!cache) return _makePathsRelative(context, identifier);
+
+ const relativePaths = cache.relativePaths || (cache.relativePaths = new Map());
+
+ let cachedResult;
+ let contextCache = relativePaths.get(context);
+ if(typeof contextCache === "undefined") {
+ relativePaths.set(context, contextCache = new Map());
+ } else {
+ cachedResult = contextCache.get(identifier);
+ }
+
+ if(typeof cachedResult !== "undefined") {
+ return cachedResult;
+ } else {
+ const relativePath = _makePathsRelative(context, identifier);
+ contextCache.set(identifier, relativePath);
+ return relativePath;
+ }
+};
diff --git a/node_modules/webpack/lib/webpack.js b/node_modules/webpack/lib/webpack.js
index 3e2353c49..fb8c68b7f 100644
--- a/node_modules/webpack/lib/webpack.js
+++ b/node_modules/webpack/lib/webpack.js
@@ -58,63 +58,61 @@ webpack.validate = validateSchema.bind(this, webpackOptionsSchema);
webpack.validateSchema = validateSchema;
webpack.WebpackOptionsValidationError = WebpackOptionsValidationError;
-function exportPlugins(exports, path, plugins) {
- plugins.forEach(name => {
- Object.defineProperty(exports, name, {
+function exportPlugins(obj, mappings) {
+ Object.keys(mappings).forEach(name => {
+ Object.defineProperty(obj, name, {
configurable: false,
enumerable: true,
- get() {
- return require(`${path}/${name}`);
- }
+ get: mappings[name]
});
});
}
-exportPlugins(exports, ".", [
- "DefinePlugin",
- "NormalModuleReplacementPlugin",
- "ContextReplacementPlugin",
- "IgnorePlugin",
- "WatchIgnorePlugin",
- "BannerPlugin",
- "PrefetchPlugin",
- "AutomaticPrefetchPlugin",
- "ProvidePlugin",
- "HotModuleReplacementPlugin",
- "SourceMapDevToolPlugin",
- "EvalSourceMapDevToolPlugin",
- "EvalDevToolModulePlugin",
- "CachePlugin",
- "ExtendedAPIPlugin",
- "ExternalsPlugin",
- "JsonpTemplatePlugin",
- "LibraryTemplatePlugin",
- "LoaderTargetPlugin",
- "MemoryOutputFileSystem",
- "ProgressPlugin",
- "SetVarMainTemplatePlugin",
- "UmdMainTemplatePlugin",
- "NoErrorsPlugin",
- "NoEmitOnErrorsPlugin",
- "NewWatchingPlugin",
- "EnvironmentPlugin",
- "DllPlugin",
- "DllReferencePlugin",
- "LoaderOptionsPlugin",
- "NamedModulesPlugin",
- "NamedChunksPlugin",
- "HashedModuleIdsPlugin",
- "ModuleFilenameHelpers"
-]);
-exportPlugins(exports.optimize = {}, "./optimize", [
- "AggressiveMergingPlugin",
- "AggressiveSplittingPlugin",
- "CommonsChunkPlugin",
- "ChunkModuleIdRangePlugin",
- "DedupePlugin",
- "LimitChunkCountPlugin",
- "MinChunkSizePlugin",
- "OccurrenceOrderPlugin",
- "UglifyJsPlugin"
-]);
-exportPlugins(exports.dependencies = {}, "./dependencies", []);
+exportPlugins(exports, {
+ "DefinePlugin": () => require("./DefinePlugin"),
+ "NormalModuleReplacementPlugin": () => require("./NormalModuleReplacementPlugin"),
+ "ContextReplacementPlugin": () => require("./ContextReplacementPlugin"),
+ "IgnorePlugin": () => require("./IgnorePlugin"),
+ "WatchIgnorePlugin": () => require("./WatchIgnorePlugin"),
+ "BannerPlugin": () => require("./BannerPlugin"),
+ "PrefetchPlugin": () => require("./PrefetchPlugin"),
+ "AutomaticPrefetchPlugin": () => require("./AutomaticPrefetchPlugin"),
+ "ProvidePlugin": () => require("./ProvidePlugin"),
+ "HotModuleReplacementPlugin": () => require("./HotModuleReplacementPlugin"),
+ "SourceMapDevToolPlugin": () => require("./SourceMapDevToolPlugin"),
+ "EvalSourceMapDevToolPlugin": () => require("./EvalSourceMapDevToolPlugin"),
+ "EvalDevToolModulePlugin": () => require("./EvalDevToolModulePlugin"),
+ "CachePlugin": () => require("./CachePlugin"),
+ "ExtendedAPIPlugin": () => require("./ExtendedAPIPlugin"),
+ "ExternalsPlugin": () => require("./ExternalsPlugin"),
+ "JsonpTemplatePlugin": () => require("./JsonpTemplatePlugin"),
+ "LibraryTemplatePlugin": () => require("./LibraryTemplatePlugin"),
+ "LoaderTargetPlugin": () => require("./LoaderTargetPlugin"),
+ "MemoryOutputFileSystem": () => require("./MemoryOutputFileSystem"),
+ "ProgressPlugin": () => require("./ProgressPlugin"),
+ "SetVarMainTemplatePlugin": () => require("./SetVarMainTemplatePlugin"),
+ "UmdMainTemplatePlugin": () => require("./UmdMainTemplatePlugin"),
+ "NoErrorsPlugin": () => require("./NoErrorsPlugin"),
+ "NoEmitOnErrorsPlugin": () => require("./NoEmitOnErrorsPlugin"),
+ "NewWatchingPlugin": () => require("./NewWatchingPlugin"),
+ "EnvironmentPlugin": () => require("./EnvironmentPlugin"),
+ "DllPlugin": () => require("./DllPlugin"),
+ "DllReferencePlugin": () => require("./DllReferencePlugin"),
+ "LoaderOptionsPlugin": () => require("./LoaderOptionsPlugin"),
+ "NamedModulesPlugin": () => require("./NamedModulesPlugin"),
+ "NamedChunksPlugin": () => require("./NamedChunksPlugin"),
+ "HashedModuleIdsPlugin": () => require("./HashedModuleIdsPlugin"),
+ "ModuleFilenameHelpers": () => require("./ModuleFilenameHelpers")
+});
+exportPlugins(exports.optimize = {}, {
+ "AggressiveMergingPlugin": () => require("./optimize/AggressiveMergingPlugin"),
+ "AggressiveSplittingPlugin": () => require("./optimize/AggressiveSplittingPlugin"),
+ "CommonsChunkPlugin": () => require("./optimize/CommonsChunkPlugin"),
+ "ChunkModuleIdRangePlugin": () => require("./optimize/ChunkModuleIdRangePlugin"),
+ "DedupePlugin": () => require("./optimize/DedupePlugin"),
+ "LimitChunkCountPlugin": () => require("./optimize/LimitChunkCountPlugin"),
+ "MinChunkSizePlugin": () => require("./optimize/MinChunkSizePlugin"),
+ "ModuleConcatenationPlugin": () => require("./optimize/ModuleConcatenationPlugin"),
+ "OccurrenceOrderPlugin": () => require("./optimize/OccurrenceOrderPlugin"),
+ "UglifyJsPlugin": () => require("./optimize/UglifyJsPlugin")
+});
diff --git a/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js b/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js
index 0b7fa525b..3944f3cfc 100644
--- a/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js
+++ b/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js
@@ -4,8 +4,8 @@
*/
"use strict";
-var ConcatSource = require("webpack-sources").ConcatSource;
-var Template = require("../Template");
+const ConcatSource = require("webpack-sources").ConcatSource;
+const Template = require("../Template");
class WebWorkerChunkTemplatePlugin {
diff --git a/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js b/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js
index bcead37e4..9b6c59fea 100644
--- a/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js
+++ b/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js
@@ -13,7 +13,8 @@ module.exports = function() {
importScripts($require$.p + $hotChunkFilename$);
}
- function hotDownloadManifest(callback) { // eslint-disable-line no-unused-vars
+ function hotDownloadManifest(requestTimeout) { // eslint-disable-line no-unused-vars
+ requestTimeout = requestTimeout || 10000;
return new Promise(function(resolve, reject) {
if(typeof XMLHttpRequest === "undefined")
return reject(new Error("No browser support"));
@@ -21,7 +22,7 @@ module.exports = function() {
var request = new XMLHttpRequest();
var requestPath = $require$.p + $hotMainFilename$;
request.open("GET", requestPath, true);
- request.timeout = 10000;
+ request.timeout = requestTimeout;
request.send(null);
} catch(err) {
return reject(err);
diff --git a/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js b/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js
index 429e2c3d4..cc7615497 100644
--- a/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js
+++ b/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js
@@ -17,13 +17,9 @@ class WebWorkerMainTemplatePlugin {
"// \"1\" means \"already loaded\"",
"var installedChunks = {",
this.indent(
- chunk.ids.map(function(id) {
- return id + ": 1";
- }).join(",\n")
+ chunk.ids.map((id) => `${id}: 1`).join(",\n")
),
- "};",
- "",
- "var resolvedPromise = new Promise(function(resolve) { resolve(); });"
+ "};"
]);
}
return source;
@@ -31,22 +27,24 @@ class WebWorkerMainTemplatePlugin {
mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
const chunkFilename = this.outputOptions.chunkFilename;
return this.asString([
- "// \"1\" is the signal for \"already loaded\"",
- "if(!installedChunks[chunkId]) {",
+ "return new Promise(function(resolve) {",
this.indent([
- "importScripts(" +
- this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), {
- hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
- hashWithLength: function(length) {
- return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
- }.bind(this),
- chunk: {
- id: "\" + chunkId + \""
- }
- }) + ");"
+ "// \"1\" is the signal for \"already loaded\"",
+ "if(!installedChunks[chunkId]) {",
+ this.indent([
+ "importScripts(" +
+ this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), {
+ hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
+ chunk: {
+ id: "\" + chunkId + \""
+ }
+ }) + ");"
+ ]),
+ "}",
+ "resolve();"
]),
- "}",
- "return resolvedPromise;"
+ "});"
]);
});
mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
@@ -54,7 +52,7 @@ class WebWorkerMainTemplatePlugin {
const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || ""));
return this.asString([
source,
- "this[" + JSON.stringify(chunkCallbackName) + "] = function webpackChunkCallback(chunkIds, moreModules) {",
+ `this[${JSON.stringify(chunkCallbackName)}] = function webpackChunkCallback(chunkIds, moreModules) {`,
this.indent([
"for(var moduleId in moreModules) {",
this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
@@ -72,24 +70,21 @@ class WebWorkerMainTemplatePlugin {
const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
const hotUpdateFunction = this.outputOptions.hotUpdateFunction || Template.toIdentifier("webpackHotUpdate" + (this.outputOptions.library || ""));
const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
- hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
- hashWithLength: function(length) {
- return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
- }.bind(this),
+ hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
chunk: {
id: "\" + chunkId + \""
}
});
const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), {
- hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
- hashWithLength: function(length) {
- return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
- }.bind(this)
+ hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
});
return source + "\n" +
- "var parentHotUpdateCallback = this[" + JSON.stringify(hotUpdateFunction) + "];\n" +
- "this[" + JSON.stringify(hotUpdateFunction) + "] = " + Template.getFunctionContent(require("./WebWorkerMainTemplate.runtime.js"))
+ `var parentHotUpdateCallback = this[${JSON.stringify(hotUpdateFunction)}];\n` +
+ `this[${JSON.stringify(hotUpdateFunction)}] = ` +
+ Template.getFunctionContent(require("./WebWorkerMainTemplate.runtime.js"))
.replace(/\/\/\$semicolon/g, ";")
.replace(/\$require\$/g, this.requireFn)
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
diff --git a/node_modules/webpack/node_modules/.bin/uglifyjs b/node_modules/webpack/node_modules/.bin/uglifyjs
deleted file mode 120000
index aaaeee8ac..000000000
--- a/node_modules/webpack/node_modules/.bin/uglifyjs
+++ /dev/null
@@ -1 +0,0 @@
-../../../uglify-js/bin/uglifyjs \ No newline at end of file
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/README.md b/node_modules/webpack/node_modules/enhanced-resolve/README.md
new file mode 100644
index 000000000..95ad6d4ce
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/README.md
@@ -0,0 +1,118 @@
+# enhanced-resolve
+
+Offers an async require.resolve function. It's highly configurable.
+
+## Features
+
+* plugin system
+* provide a custom filesystem
+* sync and async node.js filesystems included
+
+
+## Getting Started
+### Install
+```sh
+# npm
+npm install enhanced-resolve
+# or Yarn
+yarn add enhanced-resolve
+```
+
+### Creating a Resolver
+The easiest way to create a resolver is to use the `createResolver` function on `ResolveFactory`, along with one of the supplied File System implementations.
+```js
+const {
+ NodeJsInputFileSystem,
+ CachedInputFileSystem,
+ ResolverFactory
+} = require('enhanced-resolve');
+
+// create a resolver
+const myResolver = ResolverFactory.createResolver({
+ // Typical usage will consume the `NodeJsInputFileSystem` + `CachedInputFileSystem`, which wraps the Node.js `fs` wrapper to add resilience + caching.
+ fileSystem: new CachedInputFileSystem(new NodeJsInputFileSystem(), 4000),
+ extensions: ['.js', '.json']
+ /* any other resolver options here. Options/defaults can be seen below */
+});
+
+// resolve a file with the new resolver
+const context = {};
+const lookupStartPath = '/Users/webpack/some/root/dir';
+const request = './path/to-look-up.js';
+myResolver.resolve({}, lookupStartPath, request, (err/*Error*/, filepath/*string*/) => {
+ // Do something with the path
+});
+```
+
+For more examples creating different types resolvers (sync/async, context, etc) see `lib/node.js`.
+#### Resolver Options
+| Field | Default | Description |
+| ------------------------ | --------------------------- | ---------------------------------------------------------------------------------- |
+| modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name |
+| descriptionFiles | ["package.json"] | A list of description files to read from |
+| plugins | [] | A list of additional resolve plugins which should be applied |
+| mainFields | ["main"] | A list of main fields in description files |
+| aliasFields | [] | A list of alias fields in description files |
+| mainFiles | ["index"] | A list of main files in directories |
+| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
+| enforceExtension | false | Enforce that a extension from extensions must be used |
+| moduleExtensions | [] | A list of module extensions which should be tried for modules |
+| enforceModuleExtension | false | Enforce that a extension from moduleExtensions must be used |
+| alias | [] | A list of module alias configurations or an object which maps key to value |
+| resolveToContext | false | Resolve to a context instead of a file |
+| unsafeCache | false | Use this cache object to unsafely cache the successful requests |
+| cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key |
+| cachePredicate | function() { return true }; | A function which decides whether a request should be cached or not. An object is passed to the function with `path` and `request` properties. |
+| fileSystem | | The file system which should be used |
+| resolver | undefined | A prepared Resolver to which the plugins are attached |
+
+## Plugins
+Similar to `webpack`, the core of `enhanced-resolve` functionality is implemented as individual plugins that are executed using [`Tapable`](https://github.com/webpack/tapable). These plugins can extend the functionality of the library, adding other ways for files/contexts to be resolved.
+
+A plugin should be a `class` (or its ES5 equivalent) with an `apply` method. The `apply` method will receive a `resolver` instance, that can be used to hook in to the event system.
+
+### Plugin Boilerplate
+```js
+class MyResolverPlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ resolver.plugin(this.source, (request, callback) => {
+ // Any logic you need to create a new `request` can go here
+ resolver.doResolve(this.target, request, null, callback);
+ });
+ }
+}
+```
+
+Plugins are executed in a pipeline, and register which event they should be executed before/after. In the example above, `source` is the name of the event that starts the pipeline, and `target` is what event this plugin should fire, which is what continues the execution of the pipeline. For an example of how these different plugin events create a chain, see `lib/ResolverFactory.js`, in the `//// pipeline ////` section.
+
+## Tests
+
+``` javascript
+npm test
+```
+
+[![Build Status](https://secure.travis-ci.org/webpack/enhanced-resolve.png?branch=master)](http://travis-ci.org/webpack/enhanced-resolve)
+
+
+## Passing options from webpack
+If you are using `webpack`, and you want to pass custom options to `enhanced-resolve`, the options are passed from the `resolve` key of your webpack configuration e.g.:
+
+```
+resolve: {
+ extensions: ['', '.js', '.jsx'],
+ modules: ['src', 'node_modules'],
+ plugins: [new DirectoryNamedWebpackPlugin()]
+ ...
+},
+```
+
+## License
+
+Copyright (c) 2012-2016 Tobias Koppers
+
+MIT (http://www.opensource.org/licenses/mit-license.php)
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js
new file mode 100644
index 000000000..70b6b97d6
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js
@@ -0,0 +1,51 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+
+var DescriptionFileUtils = require("./DescriptionFileUtils");
+var createInnerCallback = require("./createInnerCallback");
+var getInnerRequest = require("./getInnerRequest");
+
+function AliasFieldPlugin(source, field, target) {
+ this.source = source;
+ this.field = field;
+ this.target = target;
+}
+module.exports = AliasFieldPlugin;
+
+AliasFieldPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ var field = this.field;
+ resolver.plugin(this.source, function(request, callback) {
+ if(!request.descriptionFileData) return callback();
+ var innerRequest = getInnerRequest(resolver, request);
+ if(!innerRequest) return callback();
+ var fieldData = DescriptionFileUtils.getField(request.descriptionFileData, field);
+ if(typeof fieldData !== "object") {
+ if(callback.log) callback.log("Field '" + field + "' doesn't contain a valid alias configuration");
+ return callback();
+ }
+ var data1 = fieldData[innerRequest];
+ var data2 = fieldData[innerRequest.replace(/^\.\//, "")];
+ var data = typeof data1 !== "undefined" ? data1 : data2;
+ if(data === innerRequest) return callback();
+ if(data === undefined) return callback();
+ if(data === false) {
+ var ignoreObj = Object.assign({}, request, {
+ path: false
+ });
+ return callback(null, ignoreObj);
+ }
+ var obj = Object.assign({}, request, {
+ path: request.descriptionFileRoot,
+ request: data
+ });
+ resolver.doResolve(target, obj, "aliased from description file " + request.descriptionFilePath + " with mapping '" + innerRequest + "' to '" + data + "'", createInnerCallback(function(err, result) {
+ if(arguments.length > 0) return callback(err, result);
+
+ // Don't allow other aliasing or raw request
+ callback(null, null);
+ }, callback));
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/AliasPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/AliasPlugin.js
new file mode 100644
index 000000000..86f2a6fba
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/AliasPlugin.js
@@ -0,0 +1,57 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var createInnerCallback = require("./createInnerCallback");
+
+function startsWith(string, searchString) {
+ var stringLength = string.length;
+ var searchLength = searchString.length;
+
+ // early out if the search length is greater than the search string
+ if(searchLength > stringLength) {
+ return false;
+ }
+ var index = -1;
+ while(++index < searchLength) {
+ if(string.charCodeAt(index) !== searchString.charCodeAt(index)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+function AliasPlugin(source, options, target) {
+ this.source = source;
+ this.name = options.name;
+ this.alias = options.alias;
+ this.onlyModule = options.onlyModule;
+ this.target = target;
+}
+module.exports = AliasPlugin;
+
+AliasPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ var name = this.name;
+ var alias = this.alias;
+ var onlyModule = this.onlyModule;
+ resolver.plugin(this.source, function(request, callback) {
+ var innerRequest = request.request;
+ if(!innerRequest) return callback();
+ if(innerRequest === name || (!onlyModule && startsWith(innerRequest, name + "/"))) {
+ if(innerRequest !== alias && !startsWith(innerRequest, alias + "/")) {
+ var newRequestStr = alias + innerRequest.substr(name.length);
+ var obj = Object.assign({}, request, {
+ request: newRequestStr
+ });
+ return resolver.doResolve(target, obj, "aliased with mapping '" + name + "': '" + alias + "' to '" + newRequestStr + "'", createInnerCallback(function(err, result) {
+ if(arguments.length > 0) return callback(err, result);
+
+ // don't allow other aliasing or raw request
+ callback(null, null);
+ }, callback));
+ }
+ }
+ return callback();
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/AppendPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/AppendPlugin.js
new file mode 100644
index 000000000..a42ff3679
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/AppendPlugin.js
@@ -0,0 +1,22 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function AppendPlugin(source, appending, target) {
+ this.source = source;
+ this.appending = appending;
+ this.target = target;
+}
+module.exports = AppendPlugin;
+
+AppendPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ var appending = this.appending;
+ resolver.plugin(this.source, function(request, callback) {
+ var obj = Object.assign({}, request, {
+ path: request.path + appending,
+ relativePath: request.relativePath && (request.relativePath + appending)
+ });
+ resolver.doResolve(target, obj, appending, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js
new file mode 100644
index 000000000..69e75d2c3
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js
@@ -0,0 +1,271 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function Storage(duration) {
+ this.duration = duration;
+ this.running = new Map();
+ this.data = new Map();
+ this.levels = [];
+ if(duration > 0) {
+ this.levels.push(new Set(), new Set(), new Set(), new Set(), new Set(), new Set(), new Set(), new Set(), new Set());
+ for(var i = 8000; i < duration; i += 500)
+ this.levels.push(new Set());
+ }
+ this.count = 0;
+ this.interval = null;
+ this.needTickCheck = false;
+ this.nextTick = null;
+ this.passive = true;
+ this.tick = this.tick.bind(this);
+}
+
+Storage.prototype.ensureTick = function() {
+ if(!this.interval && this.duration > 0 && !this.nextTick)
+ this.interval = setInterval(this.tick, Math.floor(this.duration / this.levels.length));
+};
+
+Storage.prototype.finished = function(name, err, result) {
+ var callbacks = this.running.get(name);
+ this.running.delete(name);
+ if(this.duration > 0) {
+ this.data.set(name, [err, result]);
+ var levelData = this.levels[0];
+ this.count -= levelData.size;
+ levelData.add(name);
+ this.count += levelData.size;
+ this.ensureTick();
+ }
+ for(var i = 0; i < callbacks.length; i++) {
+ callbacks[i](err, result);
+ }
+};
+
+Storage.prototype.finishedSync = function(name, err, result) {
+ if(this.duration > 0) {
+ this.data.set(name, [err, result]);
+ var levelData = this.levels[0];
+ this.count -= levelData.size;
+ levelData.add(name);
+ this.count += levelData.size;
+ this.ensureTick();
+ }
+};
+
+Storage.prototype.provide = function(name, provider, callback) {
+ if(typeof name !== "string") {
+ callback(new TypeError("path must be a string"));
+ return;
+ }
+ var running = this.running.get(name);
+ if(running) {
+ running.push(callback);
+ return;
+ }
+ if(this.duration > 0) {
+ this.checkTicks();
+ var data = this.data.get(name);
+ if(data) {
+ return process.nextTick(function() {
+ callback.apply(null, data);
+ });
+ }
+ }
+ this.running.set(name, running = [callback]);
+ var _this = this;
+ provider(name, function(err, result) {
+ _this.finished(name, err, result);
+ });
+};
+
+Storage.prototype.provideSync = function(name, provider) {
+ if(typeof name !== "string") {
+ throw new TypeError("path must be a string");
+ }
+ if(this.duration > 0) {
+ this.checkTicks();
+ var data = this.data.get(name);
+ if(data) {
+ if(data[0])
+ throw data[0];
+ return data[1];
+ }
+ }
+ try {
+ var result = provider(name);
+ } catch(e) {
+ this.finishedSync(name, e);
+ throw e;
+ }
+ this.finishedSync(name, null, result);
+ return result;
+};
+
+Storage.prototype.tick = function() {
+ var decay = this.levels.pop();
+ for(var item of decay) {
+ this.data.delete(item);
+ }
+ this.count -= decay.size;
+ decay.clear();
+ this.levels.unshift(decay);
+ if(this.count === 0) {
+ clearInterval(this.interval);
+ this.interval = null;
+ this.nextTick = null;
+ return true;
+ } else if(this.nextTick) {
+ this.nextTick += Math.floor(this.duration / this.levels.length);
+ var time = new Date().getTime();
+ if(this.nextTick > time) {
+ this.nextTick = null;
+ this.interval = setInterval(this.tick, Math.floor(this.duration / this.levels.length));
+ return true;
+ }
+ } else if(this.passive) {
+ clearInterval(this.interval);
+ this.interval = null;
+ this.nextTick = new Date().getTime() + Math.floor(this.duration / this.levels.length);
+ } else {
+ this.passive = true;
+ }
+};
+
+Storage.prototype.checkTicks = function() {
+ this.passive = false;
+ if(this.nextTick) {
+ while(!this.tick());
+ }
+};
+
+Storage.prototype.purge = function(what) {
+ if(!what) {
+ this.count = 0;
+ clearInterval(this.interval);
+ this.nextTick = null;
+ this.data.clear();
+ this.levels.forEach(function(level) {
+ level.clear();
+ });
+ } else if(typeof what === "string") {
+ for(var key of this.data.keys()) {
+ if(key.startsWith(what))
+ this.data.delete(key);
+ }
+ } else {
+ for(var i = what.length - 1; i >= 0; i--) {
+ this.purge(what[i]);
+ }
+ }
+};
+
+function CachedInputFileSystem(fileSystem, duration) {
+ this.fileSystem = fileSystem;
+ this._statStorage = new Storage(duration);
+ this._readdirStorage = new Storage(duration);
+ this._readFileStorage = new Storage(duration);
+ this._readJsonStorage = new Storage(duration);
+ this._readlinkStorage = new Storage(duration);
+
+ this._stat = this.fileSystem.stat ? this.fileSystem.stat.bind(this.fileSystem) : null;
+ if(!this._stat) this.stat = null;
+
+ this._statSync = this.fileSystem.statSync ? this.fileSystem.statSync.bind(this.fileSystem) : null;
+ if(!this._statSync) this.statSync = null;
+
+ this._readdir = this.fileSystem.readdir ? this.fileSystem.readdir.bind(this.fileSystem) : null;
+ if(!this._readdir) this.readdir = null;
+
+ this._readdirSync = this.fileSystem.readdirSync ? this.fileSystem.readdirSync.bind(this.fileSystem) : null;
+ if(!this._readdirSync) this.readdirSync = null;
+
+ this._readFile = this.fileSystem.readFile ? this.fileSystem.readFile.bind(this.fileSystem) : null;
+ if(!this._readFile) this.readFile = null;
+
+ this._readFileSync = this.fileSystem.readFileSync ? this.fileSystem.readFileSync.bind(this.fileSystem) : null;
+ if(!this._readFileSync) this.readFileSync = null;
+
+ if(this.fileSystem.readJson) {
+ this._readJson = this.fileSystem.readJson.bind(this.fileSystem);
+ } else if(this.readFile) {
+ this._readJson = function(path, callback) {
+ this.readFile(path, function(err, buffer) {
+ if(err) return callback(err);
+ try {
+ var data = JSON.parse(buffer.toString("utf-8"));
+ } catch(e) {
+ return callback(e);
+ }
+ callback(null, data);
+ });
+ }.bind(this);
+ } else {
+ this.readJson = null;
+ }
+ if(this.fileSystem.readJsonSync) {
+ this._readJsonSync = this.fileSystem.readJsonSync.bind(this.fileSystem);
+ } else if(this.readFileSync) {
+ this._readJsonSync = function(path) {
+ var buffer = this.readFileSync(path);
+ var data = JSON.parse(buffer.toString("utf-8"));
+ return data;
+ }.bind(this);
+ } else {
+ this.readJsonSync = null;
+ }
+
+ this._readlink = this.fileSystem.readlink ? this.fileSystem.readlink.bind(this.fileSystem) : null;
+ if(!this._readlink) this.readlink = null;
+
+ this._readlinkSync = this.fileSystem.readlinkSync ? this.fileSystem.readlinkSync.bind(this.fileSystem) : null;
+ if(!this._readlinkSync) this.readlinkSync = null;
+}
+module.exports = CachedInputFileSystem;
+
+CachedInputFileSystem.prototype.stat = function(path, callback) {
+ this._statStorage.provide(path, this._stat, callback);
+};
+
+CachedInputFileSystem.prototype.readdir = function(path, callback) {
+ this._readdirStorage.provide(path, this._readdir, callback);
+};
+
+CachedInputFileSystem.prototype.readFile = function(path, callback) {
+ this._readFileStorage.provide(path, this._readFile, callback);
+};
+
+CachedInputFileSystem.prototype.readJson = function(path, callback) {
+ this._readJsonStorage.provide(path, this._readJson, callback);
+};
+
+CachedInputFileSystem.prototype.readlink = function(path, callback) {
+ this._readlinkStorage.provide(path, this._readlink, callback);
+};
+
+CachedInputFileSystem.prototype.statSync = function(path) {
+ return this._statStorage.provideSync(path, this._statSync);
+};
+
+CachedInputFileSystem.prototype.readdirSync = function(path) {
+ return this._readdirStorage.provideSync(path, this._readdirSync);
+};
+
+CachedInputFileSystem.prototype.readFileSync = function(path) {
+ return this._readFileStorage.provideSync(path, this._readFileSync);
+};
+
+CachedInputFileSystem.prototype.readJsonSync = function(path) {
+ return this._readJsonStorage.provideSync(path, this._readJsonSync);
+};
+
+CachedInputFileSystem.prototype.readlinkSync = function(path) {
+ return this._readlinkStorage.provideSync(path, this._readlinkSync);
+};
+
+CachedInputFileSystem.prototype.purge = function(what) {
+ this._statStorage.purge(what);
+ this._readdirStorage.purge(what);
+ this._readFileStorage.purge(what);
+ this._readlinkStorage.purge(what);
+ this._readJsonStorage.purge(what);
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js
new file mode 100644
index 000000000..d6ad4bc06
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js
@@ -0,0 +1,24 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var basename = require("./getPaths").basename;
+
+function CloneBasenamePlugin(source, target) {
+ this.source = source;
+ this.target = target;
+}
+module.exports = CloneBasenamePlugin;
+
+CloneBasenamePlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var filename = basename(request.path);
+ var filePath = resolver.join(request.path, filename);
+ var obj = Object.assign({}, request, {
+ path: filePath,
+ relativePath: request.relativePath && resolver.join(request.relativePath, filename)
+ });
+ resolver.doResolve(target, obj, "using path: " + filePath, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordExtensionsPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordExtensionsPlugin.js
new file mode 100644
index 000000000..2a3c41a94
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordExtensionsPlugin.js
@@ -0,0 +1,37 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var concord = require("./concord");
+var DescriptionFileUtils = require("./DescriptionFileUtils");
+var forEachBail = require("./forEachBail");
+var createInnerCallback = require("./createInnerCallback");
+
+function ConcordExtensionsPlugin(source, options, target) {
+ this.source = source;
+ this.options = options;
+ this.target = target;
+}
+module.exports = ConcordExtensionsPlugin;
+
+ConcordExtensionsPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var concordField = DescriptionFileUtils.getField(request.descriptionFileData, "concord");
+ if(!concordField) return callback();
+ var extensions = concord.getExtensions(request.context, concordField);
+ if(!extensions) return callback();
+ var topLevelCallback = callback;
+ forEachBail(extensions, function(appending, callback) {
+ var obj = Object.assign({}, request, {
+ path: request.path + appending,
+ relativePath: request.relativePath && (request.relativePath + appending)
+ });
+ resolver.doResolve(target, obj, "concord extension: " + appending, createInnerCallback(callback, topLevelCallback));
+ }, function(err, result) {
+ if(arguments.length > 0) return callback(err, result);
+
+ callback(null, null);
+ });
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordMainPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordMainPlugin.js
new file mode 100644
index 000000000..b3b672d8a
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordMainPlugin.js
@@ -0,0 +1,30 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var path = require("path");
+var concord = require("./concord");
+var DescriptionFileUtils = require("./DescriptionFileUtils");
+
+function ConcordMainPlugin(source, options, target) {
+ this.source = source;
+ this.options = options;
+ this.target = target;
+}
+module.exports = ConcordMainPlugin;
+
+ConcordMainPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ if(request.path !== request.descriptionFileRoot) return callback();
+ var concordField = DescriptionFileUtils.getField(request.descriptionFileData, "concord");
+ if(!concordField) return callback();
+ var mainModule = concord.getMain(request.context, concordField);
+ if(!mainModule) return callback();
+ var obj = Object.assign({}, request, {
+ request: mainModule
+ });
+ var filename = path.basename(request.descriptionFilePath);
+ return resolver.doResolve(target, obj, "use " + mainModule + " from " + filename, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordModulesPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordModulesPlugin.js
new file mode 100644
index 000000000..2aa35ab87
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/ConcordModulesPlugin.js
@@ -0,0 +1,44 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var concord = require("./concord");
+var DescriptionFileUtils = require("./DescriptionFileUtils");
+var createInnerCallback = require("./createInnerCallback");
+var getInnerRequest = require("./getInnerRequest");
+
+function ConcordModulesPlugin(source, options, target) {
+ this.source = source;
+ this.options = options;
+ this.target = target;
+}
+module.exports = ConcordModulesPlugin;
+
+ConcordModulesPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var innerRequest = getInnerRequest(resolver, request);
+ if(!innerRequest) return callback();
+ var concordField = DescriptionFileUtils.getField(request.descriptionFileData, "concord");
+ if(!concordField) return callback();
+ var data = concord.matchModule(request.context, concordField, innerRequest);
+ if(data === innerRequest) return callback();
+ if(data === undefined) return callback();
+ if(data === false) {
+ var ignoreObj = Object.assign({}, request, {
+ path: false
+ });
+ return callback(null, ignoreObj);
+ }
+ var obj = Object.assign({}, request, {
+ path: request.descriptionFileRoot,
+ request: data
+ });
+ resolver.doResolve(target, obj, "aliased from description file " + request.descriptionFilePath + " with mapping '" + innerRequest + "' to '" + data + "'", createInnerCallback(function(err, result) {
+ if(arguments.length > 0) return callback(err, result);
+
+ // Don't allow other aliasing or raw request
+ callback(null, null);
+ }, callback));
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
new file mode 100644
index 000000000..ad4a9a3c6
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
@@ -0,0 +1,51 @@
+"use strict";
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+const createInnerCallback = require("./createInnerCallback");
+const DescriptionFileUtils = require("./DescriptionFileUtils");
+
+class DescriptionFilePlugin {
+ constructor(source, filenames, target) {
+ this.source = source;
+ this.filenames = [].concat(filenames);
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const filenames = this.filenames;
+ const target = this.target;
+ resolver.plugin(this.source, (request, callback) => {
+ const directory = request.path;
+ DescriptionFileUtils.loadDescriptionFile(resolver, directory, filenames, ((err, result) => {
+ if(err) return callback(err);
+ if(!result) {
+ if(callback.missing) {
+ filenames.forEach((filename) => {
+ callback.missing.push(resolver.join(directory, filename));
+ });
+ }
+ if(callback.log) callback.log("No description file found");
+ return callback();
+ }
+ const relativePath = "." + request.path.substr(result.directory.length).replace(/\\/g, "/");
+ const obj = Object.assign({}, request, {
+ descriptionFilePath: result.path,
+ descriptionFileData: result.content,
+ descriptionFileRoot: result.directory,
+ relativePath: relativePath
+ });
+ resolver.doResolve(target, obj, "using description file: " + result.path + " (relative path: " + relativePath + ")", createInnerCallback((err, result) => {
+ if(err) return callback(err);
+ if(result) return callback(null, result);
+
+ // Don't allow other description files or none at all
+ callback(null, null);
+ }, callback));
+ }));
+ });
+ }
+}
+
+module.exports = DescriptionFilePlugin;
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js
new file mode 100644
index 000000000..084d29ec9
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js
@@ -0,0 +1,93 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var forEachBail = require("./forEachBail");
+
+function loadDescriptionFile(resolver, directory, filenames, callback) {
+ (function findDescriptionFile() {
+ forEachBail(filenames, function(filename, callback) {
+ var descriptionFilePath = resolver.join(directory, filename);
+ if(resolver.fileSystem.readJson) {
+ resolver.fileSystem.readJson(descriptionFilePath, function(err, content) {
+ if(err) {
+ if(typeof err.code !== "undefined") return callback();
+ return onJson(err);
+ }
+ onJson(null, content);
+ });
+ } else {
+ resolver.fileSystem.readFile(descriptionFilePath, function(err, content) {
+ if(err) return callback();
+ try {
+ var json = JSON.parse(content);
+ } catch(e) {
+ onJson(e);
+ }
+ onJson(null, json);
+ });
+ }
+
+ function onJson(err, content) {
+ if(err) {
+ if(callback.log)
+ callback.log(descriptionFilePath + " (directory description file): " + err);
+ else
+ err.message = descriptionFilePath + " (directory description file): " + err;
+ return callback(err);
+ }
+ callback(null, {
+ content: content,
+ directory: directory,
+ path: descriptionFilePath
+ });
+ }
+ }, function(err, result) {
+ if(err) return callback(err);
+ if(result) {
+ return callback(null, result);
+ } else {
+ directory = cdUp(directory);
+ if(!directory) {
+ return callback();
+ } else {
+ return findDescriptionFile();
+ }
+ }
+ });
+ }());
+}
+
+function getField(content, field) {
+ if(!content) return undefined;
+ if(Array.isArray(field)) {
+ var current = content;
+ for(var j = 0; j < field.length; j++) {
+ if(current === null || typeof current !== "object") {
+ current = null;
+ break;
+ }
+ current = current[field[j]];
+ }
+ if(typeof current === "object") {
+ return current;
+ }
+ } else {
+ if(typeof content[field] === "object") {
+ return content[field];
+ }
+ }
+}
+
+function cdUp(directory) {
+ if(directory === "/") return null;
+ var i = directory.lastIndexOf("/"),
+ j = directory.lastIndexOf("\\");
+ var p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
+ if(p < 0) return null;
+ return directory.substr(0, p || 1);
+}
+
+exports.loadDescriptionFile = loadDescriptionFile;
+exports.getField = getField;
+exports.cdUp = cdUp;
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js
new file mode 100644
index 000000000..7e88d68d0
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js
@@ -0,0 +1,30 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function DirectoryExistsPlugin(source, target) {
+ this.source = source;
+ this.target = target;
+}
+module.exports = DirectoryExistsPlugin;
+
+DirectoryExistsPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var fs = this.fileSystem;
+ var directory = request.path;
+ fs.stat(directory, function(err, stat) {
+ if(err || !stat) {
+ if(callback.missing) callback.missing.push(directory);
+ if(callback.log) callback.log(directory + " doesn't exist");
+ return callback();
+ }
+ if(!stat.isDirectory()) {
+ if(callback.missing) callback.missing.push(directory);
+ if(callback.log) callback.log(directory + " is not a directory");
+ return callback();
+ }
+ this.doResolve(target, request, "existing directory", callback);
+ }.bind(this));
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/FileExistsPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/FileExistsPlugin.js
new file mode 100644
index 000000000..59fc6a5f1
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/FileExistsPlugin.js
@@ -0,0 +1,30 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function FileExistsPlugin(source, target) {
+ this.source = source;
+ this.target = target;
+}
+module.exports = FileExistsPlugin;
+
+FileExistsPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var fs = this.fileSystem;
+ var file = request.path;
+ fs.stat(file, function(err, stat) {
+ if(err || !stat) {
+ if(callback.missing) callback.missing.push(file);
+ if(callback.log) callback.log(file + " doesn't exist");
+ return callback();
+ }
+ if(!stat.isFile()) {
+ if(callback.missing) callback.missing.push(file);
+ if(callback.log) callback.log(file + " is not a file");
+ return callback();
+ }
+ this.doResolve(target, request, "existing file: " + file, callback, true);
+ }.bind(this));
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/FileKindPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/FileKindPlugin.js
new file mode 100644
index 000000000..d42bc22f3
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/FileKindPlugin.js
@@ -0,0 +1,19 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function FileKindPlugin(source, target) {
+ this.source = source;
+ this.target = target;
+}
+module.exports = FileKindPlugin;
+
+FileKindPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ if(request.directory) return callback();
+ var obj = Object.assign({}, request);
+ delete obj.directory;
+ resolver.doResolve(target, obj, null, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js
new file mode 100644
index 000000000..ac828eb31
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js
@@ -0,0 +1,21 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function JoinRequestPlugin(source, target) {
+ this.source = source;
+ this.target = target;
+}
+module.exports = JoinRequestPlugin;
+
+JoinRequestPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var obj = Object.assign({}, request, {
+ path: resolver.join(request.path, request.request),
+ relativePath: request.relativePath && resolver.join(request.relativePath, request.request),
+ request: undefined
+ });
+ resolver.doResolve(target, obj, null, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/LogInfoPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/LogInfoPlugin.js
new file mode 100644
index 000000000..1ebc837ce
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/LogInfoPlugin.js
@@ -0,0 +1,25 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function LogInfoPlugin(source) {
+ this.source = source;
+}
+module.exports = LogInfoPlugin;
+
+LogInfoPlugin.prototype.apply = function(resolver) {
+ var source = this.source;
+ resolver.plugin(this.source, function(request, callback) {
+ if(!callback.log) return callback();
+ var log = callback.log;
+ var prefix = "[" + source + "] ";
+ if(request.path) log(prefix + "Resolving in directory: " + request.path);
+ if(request.request) log(prefix + "Resolving request: " + request.request);
+ if(request.module) log(prefix + "Request is an module request.");
+ if(request.directory) log(prefix + "Request is a directory request.");
+ if(request.query) log(prefix + "Resolving request query: " + request.query);
+ if(request.descriptionFilePath) log(prefix + "Has description data from " + request.descriptionFilePath);
+ if(request.relativePath) log(prefix + "Relative path from description file is: " + request.relativePath);
+ callback();
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/MainFieldPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/MainFieldPlugin.js
new file mode 100644
index 000000000..45ecd4b23
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/MainFieldPlugin.js
@@ -0,0 +1,48 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var path = require("path");
+
+function MainFieldPlugin(source, options, target) {
+ this.source = source;
+ this.options = options;
+ this.target = target;
+}
+module.exports = MainFieldPlugin;
+
+MainFieldPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ var options = this.options;
+ resolver.plugin(this.source, function mainField(request, callback) {
+ if(request.path !== request.descriptionFileRoot) return callback();
+ var content = request.descriptionFileData;
+ var filename = path.basename(request.descriptionFilePath);
+ var mainModule;
+ var field = options.name;
+ if(Array.isArray(field)) {
+ var current = content;
+ for(var j = 0; j < field.length; j++) {
+ if(current === null || typeof current !== "object") {
+ current = null;
+ break;
+ }
+ current = current[field[j]];
+ }
+ if(typeof current === "string") {
+ mainModule = current;
+ }
+ } else {
+ if(typeof content[field] === "string") {
+ mainModule = content[field];
+ }
+ }
+ if(!mainModule) return callback();
+ if(options.forceRelative && !/^\.\.?\//.test(mainModule))
+ mainModule = "./" + mainModule;
+ var obj = Object.assign({}, request, {
+ request: mainModule
+ });
+ return resolver.doResolve(target, obj, "use " + mainModule + " from " + options.name + " in " + filename, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/ModuleAppendPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/ModuleAppendPlugin.js
new file mode 100644
index 000000000..55ebcb937
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/ModuleAppendPlugin.js
@@ -0,0 +1,35 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function ModuleAppendPlugin(source, appending, target) {
+ this.source = source;
+ this.appending = appending;
+ this.target = target;
+}
+module.exports = ModuleAppendPlugin;
+
+ModuleAppendPlugin.prototype.apply = function(resolver) {
+ var appending = this.appending;
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var i = request.request.indexOf("/"),
+ j = request.request.indexOf("\\");
+ var p = i < 0 ? j : j < 0 ? i : i < j ? i : j;
+ var moduleName, remainingRequest;
+ if(p < 0) {
+ moduleName = request.request;
+ remainingRequest = "";
+ } else {
+ moduleName = request.request.substr(0, p);
+ remainingRequest = request.request.substr(p);
+ }
+ if(moduleName === "." || moduleName === "..")
+ return callback();
+ var moduleFinalName = moduleName + appending;
+ var obj = Object.assign({}, request, {
+ request: moduleFinalName + remainingRequest
+ });
+ resolver.doResolve(target, obj, "module variation " + moduleFinalName, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js
new file mode 100644
index 000000000..e6d920108
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js
@@ -0,0 +1,26 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var createInnerCallback = require("./createInnerCallback");
+
+function ModuleKindPlugin(source, target) {
+ this.source = source;
+ this.target = target;
+}
+module.exports = ModuleKindPlugin;
+
+ModuleKindPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ if(!request.module) return callback();
+ var obj = Object.assign({}, request);
+ delete obj.module;
+ resolver.doResolve(target, obj, "resolve as module", createInnerCallback(function(err, result) {
+ if(arguments.length > 0) return callback(err, result);
+
+ // Don't allow other alternatives
+ callback(null, null);
+ }, callback));
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js
new file mode 100644
index 000000000..cb942ce94
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js
@@ -0,0 +1,46 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var createInnerCallback = require("./createInnerCallback");
+var forEachBail = require("./forEachBail");
+var getPaths = require("./getPaths");
+
+function ModulesInHierachicDirectoriesPlugin(source, directories, target) {
+ this.source = source;
+ this.directories = [].concat(directories);
+ this.target = target;
+}
+module.exports = ModulesInHierachicDirectoriesPlugin;
+
+ModulesInHierachicDirectoriesPlugin.prototype.apply = function(resolver) {
+ var directories = this.directories;
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var fs = this.fileSystem;
+ var topLevelCallback = callback;
+ var addrs = getPaths(request.path).paths.map(function(p) {
+ return directories.map(function(d) {
+ return this.join(p, d);
+ }, this);
+ }, this).reduce(function(array, p) {
+ array.push.apply(array, p);
+ return array;
+ }, []);
+ forEachBail(addrs, function(addr, callback) {
+ fs.stat(addr, function(err, stat) {
+ if(!err && stat && stat.isDirectory()) {
+ var obj = Object.assign({}, request, {
+ path: addr,
+ request: "./" + request.request
+ });
+ var message = "looking for modules in " + addr;
+ return resolver.doResolve(target, obj, message, createInnerCallback(callback, topLevelCallback));
+ }
+ if(topLevelCallback.log) topLevelCallback.log(addr + " doesn't exist or is not a directory");
+ if(topLevelCallback.missing) topLevelCallback.missing.push(addr);
+ return callback();
+ });
+ }, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js
new file mode 100644
index 000000000..1d7de20fb
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js
@@ -0,0 +1,22 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function ModulesInRootPlugin(source, path, target) {
+ this.source = source;
+ this.path = path;
+ this.target = target;
+}
+module.exports = ModulesInRootPlugin;
+
+ModulesInRootPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ var path = this.path;
+ resolver.plugin(this.source, function(request, callback) {
+ var obj = Object.assign({}, request, {
+ path: path,
+ request: "./" + request.request
+ });
+ resolver.doResolve(target, obj, "looking for modules in " + path, callback, true);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/NextPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/NextPlugin.js
new file mode 100644
index 000000000..0db218c81
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/NextPlugin.js
@@ -0,0 +1,16 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function NextPlugin(source, target) {
+ this.source = source;
+ this.target = target;
+}
+module.exports = NextPlugin;
+
+NextPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ resolver.doResolve(target, request, null, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/NodeJsInputFileSystem.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/NodeJsInputFileSystem.js
new file mode 100644
index 000000000..28c78ca8a
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/NodeJsInputFileSystem.js
@@ -0,0 +1,29 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var fs = require("graceful-fs");
+
+function NodeJsInputFileSystem() {}
+module.exports = NodeJsInputFileSystem;
+
+NodeJsInputFileSystem.prototype.stat = fs.stat.bind(fs);
+NodeJsInputFileSystem.prototype.readdir = function readdir(path, callback) {
+ fs.readdir(path, function(err, files) {
+ callback(err, files && files.map(function(file) {
+ return file.normalize ? file.normalize("NFC") : file;
+ }));
+ });
+};
+NodeJsInputFileSystem.prototype.readFile = fs.readFile.bind(fs);
+NodeJsInputFileSystem.prototype.readlink = fs.readlink.bind(fs);
+
+NodeJsInputFileSystem.prototype.statSync = fs.statSync.bind(fs);
+NodeJsInputFileSystem.prototype.readdirSync = function readdirSync(path) {
+ var files = fs.readdirSync(path);
+ return files && files.map(function(file) {
+ return file.normalize ? file.normalize("NFC") : file;
+ });
+};
+NodeJsInputFileSystem.prototype.readFileSync = fs.readFileSync.bind(fs);
+NodeJsInputFileSystem.prototype.readlinkSync = fs.readlinkSync.bind(fs);
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/ParsePlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/ParsePlugin.js
new file mode 100644
index 000000000..f4117fac9
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/ParsePlugin.js
@@ -0,0 +1,27 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function ParsePlugin(source, target) {
+ this.source = source;
+ this.target = target;
+}
+module.exports = ParsePlugin;
+
+ParsePlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var parsed = resolver.parse(request.request);
+ var obj = Object.assign({}, request, parsed);
+ if(request.query && !parsed.query) {
+ obj.query = request.query;
+ }
+ if(parsed && callback.log) {
+ if(parsed.module)
+ callback.log("Parsed request is a module");
+ if(parsed.directory)
+ callback.log("Parsed request is a directory");
+ }
+ resolver.doResolve(target, obj, null, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js
new file mode 100644
index 000000000..35266b172
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js
@@ -0,0 +1,227 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var Tapable = require("tapable");
+var createInnerCallback = require("./createInnerCallback");
+
+function Resolver(fileSystem) {
+ Tapable.call(this);
+ this.fileSystem = fileSystem;
+}
+module.exports = Resolver;
+
+Resolver.prototype = Object.create(Tapable.prototype);
+
+Resolver.prototype.constructor = Resolver;
+
+Resolver.prototype.resolveSync = function resolveSync(context, path, request) {
+ var err, result, sync = false;
+ this.resolve(context, path, request, function(e, r) {
+ err = e;
+ result = r;
+ sync = true;
+ });
+ if(!sync) throw new Error("Cannot 'resolveSync' because the fileSystem is not sync. Use 'resolve'!");
+ if(err) throw err;
+ return result;
+};
+
+Resolver.prototype.resolve = function resolve(context, path, request, callback) {
+ if(arguments.length === 3) {
+ throw new Error("Signature changed: context parameter added");
+ }
+ var resolver = this;
+ var obj = {
+ context: context,
+ path: path,
+ request: request
+ };
+
+ var localMissing;
+ var log;
+ var message = "resolve '" + request + "' in '" + path + "'";
+
+ function writeLog(msg) {
+ log.push(msg);
+ }
+
+ function logAsString() {
+ return log.join("\n");
+ }
+
+ function onError(err, result) {
+ if(callback.log) {
+ for(var i = 0; i < log.length; i++)
+ callback.log(log[i]);
+ }
+
+ if(err) return callback(err);
+
+ var error = new Error("Can't " + message);
+ error.details = logAsString();
+ error.missing = localMissing;
+ resolver.applyPlugins("no-resolve", obj, error);
+ return callback(error);
+ }
+
+ function onResolve(err, result) {
+ if(!err && result) {
+ return callback(null, result.path === false ? false : result.path + (result.query || ""), result);
+ }
+
+ localMissing = [];
+ log = [];
+
+ return resolver.doResolve("resolve", obj, message, createInnerCallback(onError, {
+ log: writeLog,
+ missing: localMissing,
+ stack: callback.stack
+ }));
+ }
+
+ onResolve.missing = callback.missing;
+ onResolve.stack = callback.stack;
+
+ return this.doResolve("resolve", obj, message, onResolve);
+};
+
+Resolver.prototype.doResolve = function doResolve(type, request, message, callback) {
+ var resolver = this;
+ var stackLine = type + ": (" + request.path + ") " +
+ (request.request || "") + (request.query || "") +
+ (request.directory ? " directory" : "") +
+ (request.module ? " module" : "");
+ var newStack = [stackLine];
+ if(callback.stack) {
+ newStack = callback.stack.concat(newStack);
+ if(callback.stack.indexOf(stackLine) >= 0) {
+ // Prevent recursion
+ var recursionError = new Error("Recursion in resolving\nStack:\n " + newStack.join("\n "));
+ recursionError.recursion = true;
+ if(callback.log) callback.log("abort resolving because of recursion");
+ return callback(recursionError);
+ }
+ }
+ resolver.applyPlugins("resolve-step", type, request);
+
+ var beforePluginName = "before-" + type;
+ if(resolver.hasPlugins(beforePluginName)) {
+ resolver.applyPluginsAsyncSeriesBailResult1(beforePluginName, request, createInnerCallback(beforeInnerCallback, {
+ log: callback.log,
+ missing: callback.missing,
+ stack: newStack
+ }, message && ("before " + message), true));
+ } else {
+ runNormal();
+ }
+
+ function beforeInnerCallback(err, result) {
+ if(arguments.length > 0) {
+ if(err) return callback(err);
+ if(result) return callback(null, result);
+ return callback();
+ }
+ runNormal();
+ }
+
+ function runNormal() {
+ if(resolver.hasPlugins(type)) {
+ return resolver.applyPluginsAsyncSeriesBailResult1(type, request, createInnerCallback(innerCallback, {
+ log: callback.log,
+ missing: callback.missing,
+ stack: newStack
+ }, message));
+ } else {
+ runAfter();
+ }
+ }
+
+ function innerCallback(err, result) {
+ if(arguments.length > 0) {
+ if(err) return callback(err);
+ if(result) return callback(null, result);
+ return callback();
+ }
+ runAfter();
+ }
+
+ function runAfter() {
+ var afterPluginName = "after-" + type;
+ if(resolver.hasPlugins(afterPluginName)) {
+ return resolver.applyPluginsAsyncSeriesBailResult1(afterPluginName, request, createInnerCallback(afterInnerCallback, {
+ log: callback.log,
+ missing: callback.missing,
+ stack: newStack
+ }, message && ("after " + message), true));
+ } else {
+ callback();
+ }
+ }
+
+ function afterInnerCallback(err, result) {
+ if(arguments.length > 0) {
+ if(err) return callback(err);
+ if(result) return callback(null, result);
+ return callback();
+ }
+ return callback();
+ }
+};
+
+Resolver.prototype.parse = function parse(identifier) {
+ if(identifier === "") return null;
+ var part = {
+ request: "",
+ query: "",
+ module: false,
+ directory: false,
+ file: false
+ };
+ var idxQuery = identifier.indexOf("?");
+ if(idxQuery === 0) {
+ part.query = identifier;
+ } else if(idxQuery > 0) {
+ part.request = identifier.slice(0, idxQuery);
+ part.query = identifier.slice(idxQuery);
+ } else {
+ part.request = identifier;
+ }
+ if(part.request) {
+ part.module = this.isModule(part.request);
+ part.directory = this.isDirectory(part.request);
+ if(part.directory) {
+ part.request = part.request.substr(0, part.request.length - 1);
+ }
+ }
+ return part;
+};
+
+var notModuleRegExp = /^\.$|^\.[\\\/]|^\.\.$|^\.\.[\/\\]|^\/|^[A-Z]:[\\\/]/i;
+Resolver.prototype.isModule = function isModule(path) {
+ return !notModuleRegExp.test(path);
+};
+
+var directoryRegExp = /[\/\\]$/i;
+Resolver.prototype.isDirectory = function isDirectory(path) {
+ return directoryRegExp.test(path);
+};
+
+var memoryFsJoin = require("memory-fs/lib/join");
+var memoizedJoin = new Map();
+Resolver.prototype.join = function(path, request) {
+ var cacheEntry;
+ var pathCache = memoizedJoin.get(path);
+ if(typeof pathCache === "undefined") {
+ memoizedJoin.set(path, pathCache = new Map());
+ } else {
+ cacheEntry = pathCache.get(request);
+ if(typeof cacheEntry !== "undefined")
+ return cacheEntry;
+ }
+ cacheEntry = memoryFsJoin(path, request);
+ pathCache.set(request, cacheEntry);
+ return cacheEntry;
+};
+
+Resolver.prototype.normalize = require("memory-fs/lib/normalize");
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/ResolverFactory.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/ResolverFactory.js
new file mode 100644
index 000000000..cd167aaf7
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/ResolverFactory.js
@@ -0,0 +1,273 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var Resolver = require("./Resolver");
+
+var SyncAsyncFileSystemDecorator = require("./SyncAsyncFileSystemDecorator");
+
+var ParsePlugin = require("./ParsePlugin");
+var DescriptionFilePlugin = require("./DescriptionFilePlugin");
+var NextPlugin = require("./NextPlugin");
+var TryNextPlugin = require("./TryNextPlugin");
+var ModuleKindPlugin = require("./ModuleKindPlugin");
+var FileKindPlugin = require("./FileKindPlugin");
+var JoinRequestPlugin = require("./JoinRequestPlugin");
+var ModulesInHierachicDirectoriesPlugin = require("./ModulesInHierachicDirectoriesPlugin");
+var ModulesInRootPlugin = require("./ModulesInRootPlugin");
+var AliasPlugin = require("./AliasPlugin");
+var AliasFieldPlugin = require("./AliasFieldPlugin");
+var ConcordExtensionsPlugin = require("./ConcordExtensionsPlugin");
+var ConcordMainPlugin = require("./ConcordMainPlugin");
+var ConcordModulesPlugin = require("./ConcordModulesPlugin");
+var DirectoryExistsPlugin = require("./DirectoryExistsPlugin");
+var FileExistsPlugin = require("./FileExistsPlugin");
+var SymlinkPlugin = require("./SymlinkPlugin");
+var MainFieldPlugin = require("./MainFieldPlugin");
+var UseFilePlugin = require("./UseFilePlugin");
+var AppendPlugin = require("./AppendPlugin");
+var ResultPlugin = require("./ResultPlugin");
+var ModuleAppendPlugin = require("./ModuleAppendPlugin");
+var UnsafeCachePlugin = require("./UnsafeCachePlugin");
+
+exports.createResolver = function(options) {
+
+ //// OPTIONS ////
+
+ // A list of directories to resolve modules from, can be absolute path or folder name
+ var modules = options.modules || ["node_modules"];
+
+ // A list of description files to read from
+ var descriptionFiles = options.descriptionFiles || ["package.json"];
+
+ // A list of additional resolve plugins which should be applied
+ // The slice is there to create a copy, because otherwise pushing into plugins
+ // changes the original options.plugins array, causing duplicate plugins
+ var plugins = (options.plugins && options.plugins.slice()) || [];
+
+ // A list of main fields in description files
+ var mainFields = options.mainFields || ["main"];
+
+ // A list of alias fields in description files
+ var aliasFields = options.aliasFields || [];
+
+ // A list of main files in directories
+ var mainFiles = options.mainFiles || ["index"];
+
+ // A list of extensions which should be tried for files
+ var extensions = options.extensions || [".js", ".json", ".node"];
+
+ // Enforce that a extension from extensions must be used
+ var enforceExtension = options.enforceExtension || false;
+
+ // A list of module extensions which should be tried for modules
+ var moduleExtensions = options.moduleExtensions || [];
+
+ // Enforce that a extension from moduleExtensions must be used
+ var enforceModuleExtension = options.enforceModuleExtension || false;
+
+ // A list of module alias configurations or an object which maps key to value
+ var alias = options.alias || [];
+
+ // Resolve symlinks to their symlinked location
+ var symlinks = typeof options.symlinks !== "undefined" ? options.symlinks : true;
+
+ // Resolve to a context instead of a file
+ var resolveToContext = options.resolveToContext || false;
+
+ // Use this cache object to unsafely cache the successful requests
+ var unsafeCache = options.unsafeCache || false;
+
+ // Whether or not the unsafeCache should include request context as part of the cache key.
+ var cacheWithContext = typeof options.cacheWithContext !== "undefined" ? options.cacheWithContext : true;
+
+ // A function which decides whether a request should be cached or not.
+ // an object is passed with `path` and `request` properties.
+ var cachePredicate = options.cachePredicate || function() {
+ return true;
+ };
+
+ // The file system which should be used
+ var fileSystem = options.fileSystem;
+
+ // Use only the sync variants of the file system calls
+ var useSyncFileSystemCalls = options.useSyncFileSystemCalls;
+
+ // A prepared Resolver to which the plugins are attached
+ var resolver = options.resolver;
+
+ //// options processing ////
+
+ if(!resolver) {
+ resolver = new Resolver(useSyncFileSystemCalls ? new SyncAsyncFileSystemDecorator(fileSystem) : fileSystem);
+ }
+
+ extensions = [].concat(extensions);
+ moduleExtensions = [].concat(moduleExtensions);
+
+ modules = mergeFilteredToArray([].concat(modules), function(item) {
+ return !isAbsolutePath(item);
+ });
+
+ mainFields = mainFields.map(function(item) {
+ if(typeof item === "string") {
+ item = {
+ name: item,
+ forceRelative: true
+ };
+ }
+ return item;
+ });
+
+ if(typeof alias === "object" && !Array.isArray(alias)) {
+ alias = Object.keys(alias).map(function(key) {
+ var onlyModule = false;
+ var obj = alias[key];
+ if(/\$$/.test(key)) {
+ onlyModule = true;
+ key = key.substr(0, key.length - 1);
+ }
+ if(typeof obj === "string") {
+ obj = {
+ alias: obj
+ };
+ }
+ obj = Object.assign({
+ name: key,
+ onlyModule: onlyModule
+ }, obj);
+ return obj;
+ });
+ }
+
+ if(unsafeCache && typeof unsafeCache !== "object") {
+ unsafeCache = {};
+ }
+
+ //// pipeline ////
+
+ // resolve
+ if(unsafeCache) {
+ plugins.push(new UnsafeCachePlugin("resolve", cachePredicate, unsafeCache, cacheWithContext, "new-resolve"));
+ plugins.push(new ParsePlugin("new-resolve", "parsed-resolve"));
+ } else {
+ plugins.push(new ParsePlugin("resolve", "parsed-resolve"));
+ }
+
+ // parsed-resolve
+ plugins.push(new DescriptionFilePlugin("parsed-resolve", descriptionFiles, "described-resolve"));
+ plugins.push(new NextPlugin("after-parsed-resolve", "described-resolve"));
+
+ // described-resolve
+ alias.forEach(function(item) {
+ plugins.push(new AliasPlugin("described-resolve", item, "resolve"));
+ });
+ plugins.push(new ConcordModulesPlugin("described-resolve", {}, "resolve"));
+ aliasFields.forEach(function(item) {
+ plugins.push(new AliasFieldPlugin("described-resolve", item, "resolve"));
+ });
+ plugins.push(new ModuleKindPlugin("after-described-resolve", "raw-module"));
+ plugins.push(new JoinRequestPlugin("after-described-resolve", "relative"));
+
+ // raw-module
+ moduleExtensions.forEach(function(item) {
+ plugins.push(new ModuleAppendPlugin("raw-module", item, "module"));
+ });
+ if(!enforceModuleExtension)
+ plugins.push(new TryNextPlugin("raw-module", null, "module"));
+
+ // module
+ modules.forEach(function(item) {
+ if(Array.isArray(item))
+ plugins.push(new ModulesInHierachicDirectoriesPlugin("module", item, "resolve"));
+ else
+ plugins.push(new ModulesInRootPlugin("module", item, "resolve"));
+ });
+
+ // relative
+ plugins.push(new DescriptionFilePlugin("relative", descriptionFiles, "described-relative"));
+ plugins.push(new NextPlugin("after-relative", "described-relative"));
+
+ // described-relative
+ plugins.push(new FileKindPlugin("described-relative", "raw-file"));
+ plugins.push(new TryNextPlugin("described-relative", "as directory", "directory"));
+
+ // directory
+ plugins.push(new DirectoryExistsPlugin("directory", "existing-directory"));
+
+ if(resolveToContext) {
+
+ // existing-directory
+ plugins.push(new NextPlugin("existing-directory", "resolved"));
+
+ } else {
+
+ // existing-directory
+ plugins.push(new ConcordMainPlugin("existing-directory", {}, "resolve"));
+ mainFields.forEach(function(item) {
+ plugins.push(new MainFieldPlugin("existing-directory", item, "resolve"));
+ });
+ mainFiles.forEach(function(item) {
+ plugins.push(new UseFilePlugin("existing-directory", item, "undescribed-raw-file"));
+ });
+
+ // undescribed-raw-file
+ plugins.push(new DescriptionFilePlugin("undescribed-raw-file", descriptionFiles, "raw-file"));
+ plugins.push(new NextPlugin("after-undescribed-raw-file", "raw-file"));
+
+ // raw-file
+ if(!enforceExtension)
+ plugins.push(new TryNextPlugin("raw-file", "no extension", "file"));
+ plugins.push(new ConcordExtensionsPlugin("raw-file", {}, "file"));
+ extensions.forEach(function(item) {
+ plugins.push(new AppendPlugin("raw-file", item, "file"));
+ });
+
+ // file
+ alias.forEach(function(item) {
+ plugins.push(new AliasPlugin("file", item, "resolve"));
+ });
+ plugins.push(new ConcordModulesPlugin("file", {}, "resolve"));
+ aliasFields.forEach(function(item) {
+ plugins.push(new AliasFieldPlugin("file", item, "resolve"));
+ });
+ if(symlinks)
+ plugins.push(new SymlinkPlugin("file", "relative"));
+ plugins.push(new FileExistsPlugin("file", "existing-file"));
+
+ // existing-file
+ plugins.push(new NextPlugin("existing-file", "resolved"));
+
+ }
+
+ // resolved
+ plugins.push(new ResultPlugin("resolved"));
+
+ //// RESOLVER ////
+
+ plugins.forEach(function(plugin) {
+ resolver.apply(plugin);
+ });
+ return resolver;
+};
+
+function mergeFilteredToArray(array, filter) {
+ return array.reduce(function(array, item) {
+ if(filter(item)) {
+ var lastElement = array[array.length - 1];
+ if(Array.isArray(lastElement)) {
+ lastElement.push(item);
+ } else {
+ array.push([item]);
+ }
+ return array;
+ } else {
+ array.push(item);
+ return array;
+ }
+ }, []);
+}
+
+function isAbsolutePath(path) {
+ return /^[A-Z]:|^\//.test(path);
+}
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/ResultPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/ResultPlugin.js
new file mode 100644
index 000000000..7e262cc17
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/ResultPlugin.js
@@ -0,0 +1,18 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function ResultPlugin(source) {
+ this.source = source;
+}
+module.exports = ResultPlugin;
+
+ResultPlugin.prototype.apply = function(resolver) {
+ resolver.plugin(this.source, function(request, callback) {
+ var obj = Object.assign({}, request);
+ resolver.applyPluginsAsyncSeries1("result", obj, function(err) {
+ if(err) return callback(err);
+ callback(null, obj);
+ });
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/SymlinkPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/SymlinkPlugin.js
new file mode 100644
index 000000000..c79da04b2
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/SymlinkPlugin.js
@@ -0,0 +1,47 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var getPaths = require("./getPaths");
+var forEachBail = require("./forEachBail");
+
+function SymlinkPlugin(source, target) {
+ this.source = source;
+ this.target = target;
+}
+module.exports = SymlinkPlugin;
+
+SymlinkPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var _this = this;
+ var fs = _this.fileSystem;
+ var pathsResult = getPaths(request.path);
+ var pathSeqments = pathsResult.seqments;
+ var paths = pathsResult.paths;
+
+ var containsSymlink = false;
+ forEachBail.withIndex(paths, function(path, idx, callback) {
+ fs.readlink(path, function(err, result) {
+ if(!err && result) {
+ pathSeqments[idx] = result;
+ containsSymlink = true;
+ // Shortcut when absolute symlink found
+ if(/^(\/|[a-zA-z]:($|\\))/.test(result))
+ return callback(null, idx);
+ }
+ callback();
+ });
+ }, function(err, idx) {
+ if(!containsSymlink) return callback();
+ var resultSeqments = typeof idx === "number" ? pathSeqments.slice(0, idx + 1) : pathSeqments.slice();
+ var result = resultSeqments.reverse().reduce(function(a, b) {
+ return _this.join(a, b);
+ });
+ var obj = Object.assign({}, request, {
+ path: result
+ });
+ resolver.doResolve(target, obj, "resolved symlink to " + result, callback);
+ });
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js
new file mode 100644
index 000000000..f5b26c465
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js
@@ -0,0 +1,58 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function SyncAsyncFileSystemDecorator(fs) {
+ this.fs = fs;
+ if(fs.statSync) {
+ this.stat = function(arg, callback) {
+ try {
+ var result = fs.statSync(arg);
+ } catch(e) {
+ return callback(e);
+ }
+ callback(null, result);
+ };
+ }
+ if(fs.readdirSync) {
+ this.readdir = function(arg, callback) {
+ try {
+ var result = fs.readdirSync(arg);
+ } catch(e) {
+ return callback(e);
+ }
+ callback(null, result);
+ };
+ }
+ if(fs.readFileSync) {
+ this.readFile = function(arg, callback) {
+ try {
+ var result = fs.readFileSync(arg);
+ } catch(e) {
+ return callback(e);
+ }
+ callback(null, result);
+ };
+ }
+ if(fs.readlinkSync) {
+ this.readlink = function(arg, callback) {
+ try {
+ var result = fs.readlinkSync(arg);
+ } catch(e) {
+ return callback(e);
+ }
+ callback(null, result);
+ };
+ }
+ if(fs.readJsonSync) {
+ this.readJson = function(arg, callback) {
+ try {
+ var result = fs.readJsonSync(arg);
+ } catch(e) {
+ return callback(e);
+ }
+ callback(null, result);
+ };
+ }
+}
+module.exports = SyncAsyncFileSystemDecorator;
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/TryNextPlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/TryNextPlugin.js
new file mode 100644
index 000000000..e4c9f9c0f
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/TryNextPlugin.js
@@ -0,0 +1,18 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function TryNextPlugin(source, message, target) {
+ this.source = source;
+ this.message = message;
+ this.target = target;
+}
+module.exports = TryNextPlugin;
+
+TryNextPlugin.prototype.apply = function(resolver) {
+ var target = this.target;
+ var message = this.message;
+ resolver.plugin(this.source, function(request, callback) {
+ resolver.doResolve(target, request, message, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js
new file mode 100644
index 000000000..ed07fd561
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js
@@ -0,0 +1,43 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var createInnerCallback = require("./createInnerCallback");
+
+function UnsafeCachePlugin(source, filterPredicate, cache, withContext, target) {
+ this.source = source;
+ this.filterPredicate = filterPredicate;
+ this.withContext = withContext;
+ this.cache = cache || {};
+ this.target = target;
+}
+module.exports = UnsafeCachePlugin;
+
+function getCacheId(request, withContext) {
+ return JSON.stringify({
+ context: withContext ? request.context : "",
+ path: request.path,
+ query: request.query,
+ request: request.request
+ });
+}
+
+UnsafeCachePlugin.prototype.apply = function(resolver) {
+ var filterPredicate = this.filterPredicate;
+ var cache = this.cache;
+ var target = this.target;
+ var withContext = this.withContext;
+ resolver.plugin(this.source, function(request, callback) {
+ if(!filterPredicate(request)) return callback();
+ var cacheId = getCacheId(request, withContext);
+ var cacheEntry = cache[cacheId];
+ if(cacheEntry) {
+ return callback(null, cacheEntry);
+ }
+ resolver.doResolve(target, request, null, createInnerCallback(function(err, result) {
+ if(err) return callback(err);
+ if(result) return callback(null, cache[cacheId] = result);
+ callback();
+ }, callback));
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/UseFilePlugin.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/UseFilePlugin.js
new file mode 100644
index 000000000..2413824f4
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/UseFilePlugin.js
@@ -0,0 +1,23 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function UseFilePlugin(source, filename, target) {
+ this.source = source;
+ this.filename = filename;
+ this.target = target;
+}
+module.exports = UseFilePlugin;
+
+UseFilePlugin.prototype.apply = function(resolver) {
+ var filename = this.filename;
+ var target = this.target;
+ resolver.plugin(this.source, function(request, callback) {
+ var filePath = resolver.join(request.path, filename);
+ var obj = Object.assign({}, request, {
+ path: filePath,
+ relativePath: request.relativePath && resolver.join(request.relativePath, filename)
+ });
+ resolver.doResolve(target, obj, "using path: " + filePath, callback);
+ });
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/concord.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/concord.js
new file mode 100644
index 000000000..c8db37940
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/concord.js
@@ -0,0 +1,189 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var globToRegExp = require("./globToRegExp").globToRegExp;
+
+function parseType(type) {
+ var items = type.split("+");
+ var t = items.shift();
+ return {
+ type: t === "*" ? null : t,
+ features: items
+ };
+}
+
+function isTypeMatched(baseType, testedType) {
+ if(typeof baseType === "string") baseType = parseType(baseType);
+ if(typeof testedType === "string") testedType = parseType(testedType);
+ if(testedType.type && testedType.type !== baseType.type) return false;
+ return testedType.features.every(function(requiredFeature) {
+ return baseType.features.indexOf(requiredFeature) >= 0;
+ });
+}
+
+function isResourceTypeMatched(baseType, testedType) {
+ baseType = baseType.split("/");
+ testedType = testedType.split("/");
+ if(baseType.length !== testedType.length) return false;
+ for(var i = 0; i < baseType.length; i++) {
+ if(!isTypeMatched(baseType[i], testedType[i]))
+ return false;
+ }
+ return true;
+}
+
+function isResourceTypeSupported(context, type) {
+ return context.supportedResourceTypes && context.supportedResourceTypes.some(function(supportedType) {
+ return isResourceTypeMatched(supportedType, type);
+ });
+}
+
+function isEnvironment(context, env) {
+ return context.environments && context.environments.every(function(environment) {
+ return isTypeMatched(environment, env);
+ });
+}
+
+var globCache = {};
+
+function getGlobRegExp(glob) {
+ var regExp = globCache[glob] || (globCache[glob] = globToRegExp(glob));
+ return regExp;
+}
+
+function matchGlob(glob, relativePath) {
+ var regExp = getGlobRegExp(glob);
+ return regExp.exec(relativePath);
+}
+
+function isGlobMatched(glob, relativePath) {
+ return !!matchGlob(glob, relativePath);
+}
+
+function isConditionMatched(context, condition) {
+ var items = condition.split("|");
+ return items.some(function testFn(item) {
+ item = item.trim();
+ var inverted = /^!/.test(item);
+ if(inverted) return !testFn(item.substr(1));
+ if(/^[a-z]+:/.test(item)) {
+ // match named condition
+ var match = /^([a-z]+):\s*/.exec(item);
+ var value = item.substr(match[0].length);
+ var name = match[1];
+ switch(name) {
+ case "referrer":
+ return isGlobMatched(value, context.referrer);
+ default:
+ return false;
+ }
+ } else if(item.indexOf("/") >= 0) {
+ // match supported type
+ return isResourceTypeSupported(context, item);
+ } else {
+ // match environment
+ return isEnvironment(context, item);
+ }
+ });
+}
+
+function isKeyMatched(context, key) {
+ while(true) { //eslint-disable-line
+ var match = /^\[([^\]]+)\]\s*/.exec(key);
+ if(!match) return key;
+ key = key.substr(match[0].length);
+ var condition = match[1];
+ if(!isConditionMatched(context, condition)) {
+ return false;
+ }
+ }
+}
+
+function getField(context, configuration, field) {
+ var value;
+ Object.keys(configuration).forEach(function(key) {
+ var pureKey = isKeyMatched(context, key);
+ if(pureKey === field) {
+ value = configuration[key];
+ }
+ });
+ return value;
+}
+
+function getMain(context, configuration) {
+ return getField(context, configuration, "main");
+}
+
+function getExtensions(context, configuration) {
+ return getField(context, configuration, "extensions");
+}
+
+function matchModule(context, configuration, request) {
+ var modulesField = getField(context, configuration, "modules");
+ if(!modulesField) return request;
+ var newRequest = request;
+ var keys = Object.keys(modulesField);
+ var iteration = 0;
+ for(var i = 0; i < keys.length; i++) {
+ var key = keys[i];
+ var pureKey = isKeyMatched(context, key);
+ var match = matchGlob(pureKey, newRequest);
+ if(match) {
+ var value = modulesField[key];
+ if(typeof value !== "string") {
+ return value;
+ } else if(/^\(.+\)$/.test(pureKey)) {
+ newRequest = newRequest.replace(getGlobRegExp(pureKey), value);
+ } else {
+ var index = 1;
+ newRequest = value.replace(/(\/?\*)?\*/g, replaceMatcher);
+ }
+ i = -1;
+ if(iteration++ > keys.length) {
+ throw new Error("Request '" + request + "' matches recursively");
+ }
+ }
+ }
+ return newRequest;
+
+ function replaceMatcher(find) {
+ switch(find) {
+ case "/**":
+ var m = match[index++];
+ return m ? "/" + m : "";
+ case "**":
+ case "*":
+ return match[index++];
+ }
+ }
+}
+
+function matchType(context, configuration, relativePath) {
+ var typesField = getField(context, configuration, "types");
+ if(!typesField) return undefined;
+ var type;
+ Object.keys(typesField).forEach(function(key) {
+ var pureKey = isKeyMatched(context, key);
+ if(isGlobMatched(pureKey, relativePath)) {
+ var value = typesField[key];
+ if(!type && /\/\*$/.test(value))
+ throw new Error("value ('" + value + "') of key '" + key + "' contains '*', but there is no previous value defined");
+ type = value.replace(/\/\*$/, "/" + type);
+ }
+ });
+ return type;
+}
+
+exports.parseType = parseType;
+exports.isTypeMatched = isTypeMatched;
+exports.isResourceTypeSupported = isResourceTypeSupported;
+exports.isEnvironment = isEnvironment;
+exports.isGlobMatched = isGlobMatched;
+exports.isConditionMatched = isConditionMatched;
+exports.isKeyMatched = isKeyMatched;
+exports.getField = getField;
+exports.getMain = getMain;
+exports.getExtensions = getExtensions;
+exports.matchModule = matchModule;
+exports.matchType = matchType;
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js
new file mode 100644
index 000000000..0acea4662
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/createInnerCallback.js
@@ -0,0 +1,41 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+module.exports = function createInnerCallback(callback, options, message, messageOptional) {
+ var log = options.log;
+ if(!log) {
+ if(options.stack !== callback.stack) {
+ var callbackWrapper = function callbackWrapper() {
+ return callback.apply(this, arguments);
+ };
+ callbackWrapper.stack = options.stack;
+ callbackWrapper.missing = options.missing;
+ return callbackWrapper;
+ }
+ return callback;
+ }
+
+ function loggingCallbackWrapper() {
+ var i;
+ if(message) {
+ if(!messageOptional || theLog.length > 0) {
+ log(message);
+ for(i = 0; i < theLog.length; i++)
+ log(" " + theLog[i]);
+ }
+ } else {
+ for(i = 0; i < theLog.length; i++)
+ log(theLog[i]);
+ }
+ return callback.apply(this, arguments);
+
+ }
+ var theLog = [];
+ loggingCallbackWrapper.log = function writeLog(msg) {
+ theLog.push(msg);
+ };
+ loggingCallbackWrapper.stack = options.stack;
+ loggingCallbackWrapper.missing = options.missing;
+ return loggingCallbackWrapper;
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/forEachBail.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/forEachBail.js
new file mode 100644
index 000000000..59e98ce91
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/forEachBail.js
@@ -0,0 +1,65 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+module.exports = function forEachBail(array, iterator, callback) {
+ if(array.length === 0) return callback();
+ var currentPos = array.length;
+ var currentResult;
+ var done = [];
+ for(var i = 0; i < array.length; i++) {
+ var itCb = createIteratorCallback(i);
+ iterator(array[i], itCb);
+ if(currentPos === 0) break;
+ }
+
+ function createIteratorCallback(i) {
+ return function() {
+ if(i >= currentPos) return; // ignore
+ var args = Array.prototype.slice.call(arguments);
+ done.push(i);
+ if(args.length > 0) {
+ currentPos = i + 1;
+ done = done.filter(function(item) {
+ return item <= i;
+ });
+ currentResult = args;
+ }
+ if(done.length === currentPos) {
+ callback.apply(null, currentResult);
+ currentPos = 0;
+ }
+ };
+ }
+};
+
+module.exports.withIndex = function forEachBailWithIndex(array, iterator, callback) {
+ if(array.length === 0) return callback();
+ var currentPos = array.length;
+ var currentResult;
+ var done = [];
+ for(var i = 0; i < array.length; i++) {
+ var itCb = createIteratorCallback(i);
+ iterator(array[i], i, itCb);
+ if(currentPos === 0) break;
+ }
+
+ function createIteratorCallback(i) {
+ return function() {
+ if(i >= currentPos) return; // ignore
+ var args = Array.prototype.slice.call(arguments);
+ done.push(i);
+ if(args.length > 0) {
+ currentPos = i + 1;
+ done = done.filter(function(item) {
+ return item <= i;
+ });
+ currentResult = args;
+ }
+ if(done.length === currentPos) {
+ callback.apply(null, currentResult);
+ currentPos = 0;
+ }
+ };
+ }
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/getInnerRequest.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/getInnerRequest.js
new file mode 100644
index 000000000..3f6ac148c
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/getInnerRequest.js
@@ -0,0 +1,22 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+module.exports = function getInnerRequest(resolver, request) {
+ if(typeof request.__innerRequest === "string" &&
+ request.__innerRequest_request === request.request &&
+ request.__innerRequest_relativePath === request.relativePath)
+ return request.__innerRequest;
+ var innerRequest;
+ if(request.request) {
+ innerRequest = request.request;
+ if(/^\.\.?\//.test(innerRequest) && request.relativePath) {
+ innerRequest = resolver.join(request.relativePath, innerRequest);
+ }
+ } else {
+ innerRequest = request.relativePath;
+ }
+ request.__innerRequest_request = request.request;
+ request.__innerRequest_relativePath = request.relativePath;
+ return request.__innerRequest = innerRequest;
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/getPaths.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/getPaths.js
new file mode 100644
index 000000000..695fbcd5f
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/getPaths.js
@@ -0,0 +1,33 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+module.exports = function getPaths(path) {
+ var parts = path.split(/(.*?[\\\/]+)/);
+ var paths = [path];
+ var seqments = [parts[parts.length - 1]];
+ var part = parts[parts.length - 1];
+ path = path.substr(0, path.length - part.length - 1);
+ paths.push(path);
+ for(var i = parts.length - 2; i > 2; i -= 2) {
+ part = parts[i];
+ path = path.substr(0, path.length - part.length) || "/";
+ paths.push(path);
+ seqments.push(part.substr(0, part.length - 1));
+ }
+ part = parts[1];
+ seqments.push(part.length > 1 ? part.substr(0, part.length - 1) : part);
+ return {
+ paths: paths,
+ seqments: seqments
+ };
+};
+
+module.exports.basename = function basename(path) {
+ var i = path.lastIndexOf("/"),
+ j = path.lastIndexOf("\\");
+ var p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
+ if(p < 0) return null;
+ var s = path.substr(p + 1);
+ return s;
+};
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/globToRegExp.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/globToRegExp.js
new file mode 100644
index 000000000..7b97a6924
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/globToRegExp.js
@@ -0,0 +1,188 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+function globToRegExp(glob) {
+ // * [^\\\/]*
+ // /**/ /.+/
+ // ^* \./.+ (concord special)
+ // ? [^\\\/]
+ // [!...] [^...]
+ // [^...] [^...]
+ // / [\\\/]
+ // {...,...} (...|...)
+ // ?(...|...) (...|...)?
+ // +(...|...) (...|...)+
+ // *(...|...) (...|...)*
+ // @(...|...) (...|...)
+ if(/^\(.+\)$/.test(glob)) {
+ // allow to pass an RegExp in brackets
+ return new RegExp(glob.substr(1, glob.length - 2));
+ }
+ var tokens = tokenize(glob);
+ var process = createRoot();
+ var regExpStr = tokens.map(process).join("");
+ return new RegExp("^" + regExpStr + "$");
+}
+
+var SIMPLE_TOKENS = {
+ "@(": "one",
+ "?(": "zero-one",
+ "+(": "one-many",
+ "*(": "zero-many",
+ "|": "segment-sep",
+ "/**/": "any-path-segments",
+ "**": "any-path",
+ "*": "any-path-segment",
+ "?": "any-char",
+ "{": "or",
+ "/": "path-sep",
+ ",": "comma",
+ ")": "closing-segment",
+ "}": "closing-or"
+};
+
+function tokenize(glob) {
+ return glob.split(/([@?+*]\(|\/\*\*\/|\*\*|[?*]|\[[\!\^]?(?:[^\]\\]|\\.)+\]|\{|,|\/|[|)}])/g).map(function(item) {
+ if(!item)
+ return null;
+ var t = SIMPLE_TOKENS[item];
+ if(t) {
+ return {
+ type: t
+ };
+ }
+ if(item[0] === "[") {
+ if(item[1] === "^" || item[1] === "!") {
+ return {
+ type: "inverted-char-set",
+ value: item.substr(2, item.length - 3)
+ };
+ } else {
+ return {
+ type: "char-set",
+ value: item.substr(1, item.length - 2)
+ };
+ }
+ }
+ return {
+ type: "string",
+ value: item
+ };
+ }).filter(Boolean).concat({
+ type: "end"
+ });
+}
+
+function createRoot() {
+ var inOr = [];
+ var process = createSeqment();
+ var initial = true;
+ return function(token) {
+ switch(token.type) {
+ case "or":
+ inOr.push(initial);
+ return "(";
+ case "comma":
+ if(inOr.length) {
+ initial = inOr[inOr.length - 1];
+ return "|";
+ } else {
+ return process({
+ type: "string",
+ value: ","
+ }, initial);
+ }
+ case "closing-or":
+ if(inOr.length === 0)
+ throw new Error("Unmatched '}'");
+ inOr.pop();
+ return ")";
+ case "end":
+ if(inOr.length)
+ throw new Error("Unmatched '{'");
+ return process(token, initial);
+ default:
+ var result = process(token, initial);
+ initial = false;
+ return result;
+ }
+ };
+}
+
+function createSeqment() {
+ var inSeqment = [];
+ var process = createSimple();
+ return function(token, initial) {
+ switch(token.type) {
+ case "one":
+ case "one-many":
+ case "zero-many":
+ case "zero-one":
+ inSeqment.push(token.type);
+ return "(";
+ case "segment-sep":
+ if(inSeqment.length) {
+ return "|";
+ } else {
+ return process({
+ type: "string",
+ value: "|"
+ }, initial);
+ }
+ case "closing-segment":
+ var segment = inSeqment.pop();
+ switch(segment) {
+ case "one":
+ return ")";
+ case "one-many":
+ return ")+";
+ case "zero-many":
+ return ")*";
+ case "zero-one":
+ return ")?";
+ }
+ throw new Error("Unexcepted segment " + segment);
+ case "end":
+ if(inSeqment.length > 0) {
+ throw new Error("Unmatched segment, missing ')'");
+ }
+ return process(token, initial);
+ default:
+ return process(token, initial);
+ }
+ };
+}
+
+function createSimple() {
+ return function(token, initial) {
+ switch(token.type) {
+ case "path-sep":
+ return "[\\\\/]+";
+ case "any-path-segments":
+ return "[\\\\/]+(?:(.+)[\\\\/]+)?";
+ case "any-path":
+ return "(.*)";
+ case "any-path-segment":
+ if(initial) {
+ return "\\.[\\\\/]+(?:.*[\\\\/]+)?([^\\\\/]+)";
+ } else {
+ return "([^\\\\/]*)";
+ }
+ case "any-char":
+ return "[^\\\\/]";
+ case "inverted-char-set":
+ return "[^" + token.value + "]";
+ case "char-set":
+ return "[" + token.value + "]";
+ case "string":
+ return token.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+ case "end":
+ return "";
+ default:
+ throw new Error("Unsupported token '" + token.type + "'");
+ }
+ };
+}
+
+exports.globToRegExp = globToRegExp;
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/lib/node.js b/node_modules/webpack/node_modules/enhanced-resolve/lib/node.js
new file mode 100644
index 000000000..1e79cdc25
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/lib/node.js
@@ -0,0 +1,144 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var ResolverFactory = require("./ResolverFactory");
+
+var NodeJsInputFileSystem = require("./NodeJsInputFileSystem");
+var CachedInputFileSystem = require("./CachedInputFileSystem");
+
+var nodeFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 4000);
+
+var nodeContext = {
+ environments: [
+ "node+es3+es5+process+native"
+ ]
+};
+
+var asyncResolver = ResolverFactory.createResolver({
+ extensions: [".js", ".json", ".node"],
+ fileSystem: nodeFileSystem
+});
+module.exports = function resolve(context, path, request, callback) {
+ if(typeof context === "string") {
+ callback = request;
+ request = path;
+ path = context;
+ context = nodeContext;
+ }
+ asyncResolver.resolve(context, path, request, callback);
+};
+
+var syncResolver = ResolverFactory.createResolver({
+ extensions: [".js", ".json", ".node"],
+ useSyncFileSystemCalls: true,
+ fileSystem: nodeFileSystem
+});
+module.exports.sync = function resolveSync(context, path, request) {
+ if(typeof context === "string") {
+ request = path;
+ path = context;
+ context = nodeContext;
+ }
+ return syncResolver.resolveSync(context, path, request);
+};
+
+var asyncContextResolver = ResolverFactory.createResolver({
+ extensions: [".js", ".json", ".node"],
+ resolveToContext: true,
+ fileSystem: nodeFileSystem
+});
+module.exports.context = function resolveContext(context, path, request, callback) {
+ if(typeof context === "string") {
+ callback = request;
+ request = path;
+ path = context;
+ context = nodeContext;
+ }
+ asyncContextResolver.resolve(context, path, request, callback);
+};
+
+var syncContextResolver = ResolverFactory.createResolver({
+ extensions: [".js", ".json", ".node"],
+ resolveToContext: true,
+ useSyncFileSystemCalls: true,
+ fileSystem: nodeFileSystem
+});
+module.exports.context.sync = function resolveContextSync(context, path, request) {
+ if(typeof context === "string") {
+ request = path;
+ path = context;
+ context = nodeContext;
+ }
+ return syncContextResolver.resolveSync(context, path, request);
+};
+
+var asyncLoaderResolver = ResolverFactory.createResolver({
+ extensions: [".js", ".json", ".node"],
+ moduleExtensions: ["-loader"],
+ mainFields: ["loader", "main"],
+ fileSystem: nodeFileSystem
+});
+module.exports.loader = function resolveLoader(context, path, request, callback) {
+ if(typeof context === "string") {
+ callback = request;
+ request = path;
+ path = context;
+ context = nodeContext;
+ }
+ asyncLoaderResolver.resolve(context, path, request, callback);
+};
+
+var syncLoaderResolver = ResolverFactory.createResolver({
+ extensions: [".js", ".json", ".node"],
+ moduleExtensions: ["-loader"],
+ mainFields: ["loader", "main"],
+ useSyncFileSystemCalls: true,
+ fileSystem: nodeFileSystem
+});
+module.exports.loader.sync = function resolveLoaderSync(context, path, request) {
+ if(typeof context === "string") {
+ request = path;
+ path = context;
+ context = nodeContext;
+ }
+ return syncLoaderResolver.resolveSync(context, path, request);
+};
+
+module.exports.create = function create(options) {
+ options = Object.assign({
+ fileSystem: nodeFileSystem
+ }, options);
+ var resolver = ResolverFactory.createResolver(options);
+ return function(context, path, request, callback) {
+ if(typeof context === "string") {
+ callback = request;
+ request = path;
+ path = context;
+ context = nodeContext;
+ }
+ resolver.resolve(context, path, request, callback);
+ };
+};
+
+module.exports.create.sync = function createSync(options) {
+ options = Object.assign({
+ useSyncFileSystemCalls: true,
+ fileSystem: nodeFileSystem
+ }, options);
+ var resolver = ResolverFactory.createResolver(options);
+ return function(context, path, request) {
+ if(typeof context === "string") {
+ request = path;
+ path = context;
+ context = nodeContext;
+ }
+ return resolver.resolveSync(context, path, request);
+ };
+};
+
+// Export Resolver, FileSystems and Plugins
+module.exports.ResolverFactory = ResolverFactory;
+
+module.exports.NodeJsInputFileSystem = NodeJsInputFileSystem;
+module.exports.CachedInputFileSystem = CachedInputFileSystem;
diff --git a/node_modules/webpack/node_modules/enhanced-resolve/package.json b/node_modules/webpack/node_modules/enhanced-resolve/package.json
new file mode 100644
index 000000000..3d721fac0
--- /dev/null
+++ b/node_modules/webpack/node_modules/enhanced-resolve/package.json
@@ -0,0 +1,52 @@
+{
+ "name": "enhanced-resolve",
+ "version": "3.4.1",
+ "author": "Tobias Koppers @sokra",
+ "description": "Offers a async require.resolve function. It's highly configurable.",
+ "files": [
+ "lib"
+ ],
+ "dependencies": {
+ "graceful-fs": "^4.1.2",
+ "memory-fs": "^0.4.0",
+ "object-assign": "^4.0.1",
+ "tapable": "^0.2.7"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "http://www.opensource.org/licenses/mit-license.php"
+ }
+ ],
+ "devDependencies": {
+ "beautify-lint": "^1.0.3",
+ "codecov.io": "^0.1.6",
+ "coveralls": "^2.11.6",
+ "eslint": "^3.14.1",
+ "eslint-plugin-node": "^3.0.5",
+ "eslint-plugin-nodeca": "^1.0.3",
+ "istanbul": "^0.4.1",
+ "js-beautify": "^1.5.10",
+ "mocha": "^2.3.4",
+ "should": "^8.0.2"
+ },
+ "engines": {
+ "node": ">=4.3.0 <5.0.0 || >=5.10"
+ },
+ "main": "lib/node.js",
+ "homepage": "http://github.com/webpack/enhanced-resolve",
+ "scripts": {
+ "beautify-lint": "beautify-lint lib/**.js test/*.js",
+ "beautify": "beautify-rewrite lib/**.js test/*.js",
+ "lint": "eslint lib test",
+ "pretest": "npm run lint && npm run beautify-lint",
+ "test": "mocha --full-trace --check-leaks",
+ "precover": "npm run lint && npm run beautify-lint",
+ "cover": "istanbul cover node_modules/mocha/bin/_mocha",
+ "travis": "npm run cover -- --report lcovonly"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/webpack/enhanced-resolve.git"
+ }
+}
diff --git a/node_modules/webpack/package.json b/node_modules/webpack/package.json
index f65508dc7..1cc78da0d 100644
--- a/node_modules/webpack/package.json
+++ b/node_modules/webpack/package.json
@@ -1,30 +1,31 @@
{
"name": "webpack",
- "version": "2.6.0",
+ "version": "3.5.4",
"author": "Tobias Koppers @sokra",
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
"dependencies": {
"acorn": "^5.0.0",
"acorn-dynamic-import": "^2.0.0",
- "ajv": "^4.7.0",
- "ajv-keywords": "^1.1.1",
+ "ajv": "^5.1.5",
+ "ajv-keywords": "^2.0.0",
"async": "^2.1.2",
- "enhanced-resolve": "^3.0.0",
+ "enhanced-resolve": "^3.4.0",
+ "escope": "^3.6.0",
"interpret": "^1.0.0",
"json-loader": "^0.5.4",
"json5": "^0.5.1",
"loader-runner": "^2.3.0",
- "loader-utils": "^0.2.16",
+ "loader-utils": "^1.1.0",
"memory-fs": "~0.4.1",
"mkdirp": "~0.5.0",
"node-libs-browser": "^2.0.0",
"source-map": "^0.5.3",
- "supports-color": "^3.1.0",
- "tapable": "~0.2.5",
- "uglify-js": "^2.8.27",
- "watchpack": "^1.3.1",
- "webpack-sources": "^0.2.3",
- "yargs": "^6.0.0"
+ "supports-color": "^4.2.1",
+ "tapable": "^0.2.7",
+ "uglifyjs-webpack-plugin": "^0.4.6",
+ "watchpack": "^1.4.0",
+ "webpack-sources": "^1.0.1",
+ "yargs": "^8.0.2"
},
"license": "MIT",
"devDependencies": {
@@ -36,20 +37,20 @@
"coffee-loader": "~0.7.1",
"coffee-script": "^1.10.0",
"coveralls": "^2.11.2",
- "css-loader": "~0.25.0",
+ "css-loader": "^0.28.3",
"es6-promise-polyfill": "^1.1.1",
- "eslint": "3.12.2",
- "eslint-plugin-node": "^3.0.5",
+ "eslint": "^4.3.0",
+ "eslint-plugin-node": "^5.1.1",
"express": "~4.13.1",
- "extract-text-webpack-plugin": "^2.0.0-beta",
- "file-loader": "~0.9.0",
- "i18n-webpack-plugin": "^0.3.0",
+ "extract-text-webpack-plugin": "^3.0.0",
+ "file-loader": "^0.11.2",
+ "i18n-webpack-plugin": "^1.0.0",
"istanbul": "^0.4.5",
"jade": "^1.11.0",
"jade-loader": "~0.8.0",
"js-beautify": "^1.5.10",
"less": "^2.5.1",
- "less-loader": "^2.0.0",
+ "less-loader": "^4.0.3",
"lodash": "^4.17.4",
"mocha": "^3.2.0",
"mocha-lcov-reporter": "^1.0.0",
@@ -60,13 +61,13 @@
"script-loader": "~0.7.0",
"should": "^11.1.1",
"simple-git": "^1.65.0",
- "sinon": "^1.17.7",
- "style-loader": "~0.13.0",
+ "sinon": "^2.3.2",
+ "style-loader": "^0.18.1",
"url-loader": "~0.5.0",
- "val-loader": "~0.5.0",
+ "val-loader": "^1.0.2",
"vm-browserify": "~0.0.0",
"webpack-dev-middleware": "^1.9.0",
- "worker-loader": "~0.7.0"
+ "worker-loader": "^0.8.0"
},
"engines": {
"node": ">=4.3.0 <5.0.0 || >=5.10"
@@ -88,23 +89,24 @@
"schemas/"
],
"scripts": {
- "test": "mocha test/*.test.js --harmony --check-leaks",
+ "test": "mocha test/*.test.js --max-old-space-size=4096 --harmony --check-leaks",
"travis:test": "npm run cover:min",
"travis:lint": "npm run lint-files && npm run nsp",
"travis:benchmark": "npm run benchmark",
- "appveyor:test": "node --max_old_space_size=4096 node_modules\\mocha\\bin\\mocha --harmony test/*.test.js",
+ "appveyor:test": "node node_modules\\mocha\\bin\\mocha --max-old-space-size=4096 --harmony test/*.test.js",
"appveyor:benchmark": "npm run benchmark",
- "circleci:test": "node --max_old_space_size=4096 node_modules/mocha/bin/mocha --harmony test/*.test.js",
+ "circleci:test": "node node_modules/mocha/bin/mocha --max-old-space-size=4096 --harmony test/*.test.js",
"circleci:lint": "npm run lint-files && npm run nsp",
"build:examples": "cd examples && node buildAll.js",
"pretest": "npm run lint-files",
"lint-files": "npm run lint && npm run beautify-lint",
"lint": "eslint lib bin hot buildin \"test/**/webpack.config.js\" \"test/binCases/**/test.js\" \"examples/**/webpack.config.js\"",
+ "fix": "npm run lint -- --fix",
"beautify-lint": "beautify-lint \"lib/**/*.js\" \"hot/**/*.js\" \"bin/**/*.js\" \"benchmark/*.js\" \"test/*.js\"",
"nsp": "nsp check --output summary",
- "benchmark": "mocha test/*.benchmark.js --harmony -R spec",
- "cover": "node --harmony ./node_modules/istanbul/lib/cli.js cover -x '**/*.runtime.js' node_modules/mocha/bin/_mocha -- test/*.test.js",
- "cover:min": "node --harmony ./node_modules/.bin/istanbul cover -x '**/*.runtime.js' --report lcovonly node_modules/mocha/bin/_mocha -- test/*.test.js",
+ "benchmark": "mocha --max-old-space-size=4096 --harmony test/*.benchmark.js -R spec",
+ "cover": "node --max-old-space-size=4096 --harmony ./node_modules/istanbul/lib/cli.js cover -x '**/*.runtime.js' node_modules/mocha/bin/_mocha -- test/*.test.js",
+ "cover:min": "node --max-old-space-size=4096 --harmony ./node_modules/.bin/istanbul cover -x '**/*.runtime.js' --report lcovonly node_modules/mocha/bin/_mocha -- test/*.test.js",
"publish-patch": "npm run lint && npm run beautify-lint && mocha && npm version patch && git push && git push --tags && npm publish"
}
}
diff --git a/node_modules/webpack/schemas/webpackOptionsSchema.json b/node_modules/webpack/schemas/webpackOptionsSchema.json
index 19ace1f99..1e5941d74 100644
--- a/node_modules/webpack/schemas/webpackOptionsSchema.json
+++ b/node_modules/webpack/schemas/webpackOptionsSchema.json
@@ -160,6 +160,9 @@
"instanceof": "RegExp"
},
{
+ "instanceof": "Function"
+ },
+ {
"items": {
"type": "string",
"absolutePath": true
@@ -221,6 +224,9 @@
},
"strictExportPresence": {
"type": "boolean"
+ },
+ "strictThisContextOnImports": {
+ "type": "boolean"
}
},
"type": "object"
@@ -369,6 +375,14 @@
"type": "string"
},
"type": "array"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "root": { "type": "string" },
+ "amd": { "type": "string" },
+ "commonjs": { "type": "string" }
+ }
}
],
"description": "If set, export the bundle as library. `output.library` is the name."
@@ -389,6 +403,16 @@
"jsonp"
]
},
+ "libraryExport": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "$ref": "#/definitions/common.arrayOfStringValues"
+ }
+ ]
+ },
"path": {
"description": "The output directory as **absolute path** (required).",
"type": "string",
@@ -459,6 +483,9 @@
"cachePredicate": {
"instanceof": "Function"
},
+ "cacheWithContext": {
+ "type": "boolean"
+ },
"descriptionFiles": {
"$ref": "#/definitions/common.arrayOfStringValues"
},
@@ -716,7 +743,7 @@
}
]
},
- "warning-filters-types": {
+ "filter-item-types": {
"anyOf": [
{
"instanceof": "RegExp"
@@ -728,6 +755,19 @@
"instanceof": "Function"
}
]
+ },
+ "filter-types": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/filter-item-types"
+ },
+ {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/filter-item-types"
+ }
+ }
+ ]
}
},
"properties": {
@@ -798,59 +838,73 @@
},
"node": {
"description": "Include polyfills or mocks for various node stuff.",
- "additionalProperties": {
- "enum": [
- false,
- true,
- "mock",
- "empty"
- ]
- },
- "properties": {
- "Buffer": {
- "enum": [
- false,
- true,
- "mock"
- ]
- },
- "__dirname": {
- "enum": [
- false,
- true,
- "mock"
- ]
- },
- "__filename": {
- "enum": [
- false,
- true,
- "mock"
- ]
- },
- "console": {
+ "anyOf": [
+ {
"enum": [
- false,
- true,
- "mock"
+ false
]
},
- "global": {
- "type": "boolean"
- },
- "process": {
- "enum": [
- false,
- true,
- "mock"
- ]
+ {
+ "additionalProperties": {
+ "enum": [
+ false,
+ true,
+ "mock",
+ "empty"
+ ]
+ },
+ "properties": {
+ "Buffer": {
+ "enum": [
+ false,
+ true,
+ "mock"
+ ]
+ },
+ "__dirname": {
+ "enum": [
+ false,
+ true,
+ "mock"
+ ]
+ },
+ "__filename": {
+ "enum": [
+ false,
+ true,
+ "mock"
+ ]
+ },
+ "console": {
+ "enum": [
+ false,
+ true,
+ "mock"
+ ]
+ },
+ "global": {
+ "type": "boolean"
+ },
+ "process": {
+ "enum": [
+ false,
+ true,
+ "mock"
+ ]
+ }
+ },
+ "type": "object"
}
- },
- "type": "object"
+ ]
},
"output": {
"$ref": "#/definitions/output"
},
+ "parallelism": {
+ "description": "The number of parallel processed modules in the compilation.",
+ "minimum": 1,
+ "type": "number"
+ },
"performance": {
"description": "Configuration for web performance recommendations.",
"anyOf": [
@@ -973,17 +1027,19 @@
},
"warningsFilter": {
"description": "Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions",
- "anyOf": [
- {
- "type": "array",
- "items": {
- "$ref": "#/definitions/warning-filters-types"
- }
- },
- {
- "$ref": "#/definitions/warning-filters-types"
- }
- ]
+ "$ref": "#/definitions/filter-types"
+ },
+ "excludeAssets": {
+ "description": "Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions",
+ "$ref": "#/definitions/filter-types"
+ },
+ "excludeModules": {
+ "description": "Suppress modules that match the specified filters. Filters can be Strings, RegExps or Functions",
+ "$ref": "#/definitions/filter-types"
+ },
+ "exclude": {
+ "description": "Please use excludeModules instead.",
+ "$ref": "#/definitions/filter-types"
},
"errorDetails": {
"type": "boolean",
@@ -1008,6 +1064,18 @@
"assetsSort": {
"type": "string",
"description": "sort the assets by that field"
+ },
+ "providedExports": {
+ "type": "boolean",
+ "description": "show exports provided by modules"
+ },
+ "usedExports": {
+ "type": "boolean",
+ "description": "show exports used by modules"
+ },
+ "optimizationBailout": {
+ "type": "boolean",
+ "description": "show reasons why optimization bailed out for modules"
}
}
},
@@ -1020,6 +1088,7 @@
"errors-only",
"minimal",
"normal",
+ "detailed",
"verbose"
]
}