aboutsummaryrefslogtreecommitdiff
path: root/node_modules/enhanced-resolve
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/enhanced-resolve
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/enhanced-resolve')
-rw-r--r--node_modules/enhanced-resolve/README.md181
-rw-r--r--node_modules/enhanced-resolve/lib/AliasFieldPlugin.js83
-rw-r--r--node_modules/enhanced-resolve/lib/AliasPlugin.js113
-rw-r--r--node_modules/enhanced-resolve/lib/AppendPlugin.js32
-rw-r--r--node_modules/enhanced-resolve/lib/CachedInputFileSystem.js441
-rw-r--r--node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js35
-rw-r--r--node_modules/enhanced-resolve/lib/ConcordExtensionsPlugin.js59
-rw-r--r--node_modules/enhanced-resolve/lib/ConcordMainPlugin.js47
-rw-r--r--node_modules/enhanced-resolve/lib/ConcordModulesPlugin.js73
-rw-r--r--node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js41
-rw-r--r--node_modules/enhanced-resolve/lib/DescriptionFileUtils.js31
-rw-r--r--node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js51
-rw-r--r--node_modules/enhanced-resolve/lib/FileExistsPlugin.js51
-rw-r--r--node_modules/enhanced-resolve/lib/FileKindPlugin.js29
-rw-r--r--node_modules/enhanced-resolve/lib/JoinRequestPlugin.js31
-rw-r--r--node_modules/enhanced-resolve/lib/LogInfoPlugin.js41
-rw-r--r--node_modules/enhanced-resolve/lib/MainFieldPlugin.js100
-rw-r--r--node_modules/enhanced-resolve/lib/ModuleAppendPlugin.js58
-rw-r--r--node_modules/enhanced-resolve/lib/ModuleKindPlugin.js38
-rw-r--r--node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js76
-rw-r--r--node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js32
-rw-r--r--node_modules/enhanced-resolve/lib/NextPlugin.js23
-rw-r--r--node_modules/enhanced-resolve/lib/NodeJsInputFileSystem.js72
-rw-r--r--node_modules/enhanced-resolve/lib/ParsePlugin.js45
-rw-r--r--node_modules/enhanced-resolve/lib/Resolver.js499
-rw-r--r--node_modules/enhanced-resolve/lib/ResolverFactory.js180
-rw-r--r--node_modules/enhanced-resolve/lib/ResultPlugin.js26
-rw-r--r--node_modules/enhanced-resolve/lib/SymlinkPlugin.js98
-rw-r--r--node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js17
-rw-r--r--node_modules/enhanced-resolve/lib/TryNextPlugin.js26
-rw-r--r--node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js54
-rw-r--r--node_modules/enhanced-resolve/lib/UseFilePlugin.js34
-rw-r--r--node_modules/enhanced-resolve/lib/concord.js80
-rw-r--r--node_modules/enhanced-resolve/lib/createInnerCallback.js88
-rw-r--r--node_modules/enhanced-resolve/lib/forEachBail.js99
-rw-r--r--node_modules/enhanced-resolve/lib/getInnerRequest.js4
-rw-r--r--node_modules/enhanced-resolve/lib/getPaths.js68
-rw-r--r--node_modules/enhanced-resolve/lib/globToRegExp.js56
-rw-r--r--node_modules/enhanced-resolve/lib/node.js68
-rw-r--r--node_modules/enhanced-resolve/package.json10
40 files changed, 1770 insertions, 1420 deletions
diff --git a/node_modules/enhanced-resolve/README.md b/node_modules/enhanced-resolve/README.md
index c701448d7..806b70a71 100644
--- a/node_modules/enhanced-resolve/README.md
+++ b/node_modules/enhanced-resolve/README.md
@@ -1,60 +1,121 @@
-# enhanced-resolve
-
-Offers a async require.resolve function. It's highly configurable.
-
-## Features
-
-* plugin system
-* provide a custom filesystem
-* sync and async node.js filesystems included
-
-
-## Tests
-
-``` javascript
-npm test
-```
-
-[![Build Status](https://secure.travis-ci.org/webpack/enhanced-resolve.png?branch=master)](http://travis-ci.org/webpack/enhanced-resolve)
-
-
-## Contributing
-
-Take a look at `lib/ResolveFactory.js` to understand how everything fits together. It provides a `createResolver(options)` function and these are the possible 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 |
-
-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)
+# 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 resolveContext = {};
+const lookupStartPath = '/Users/webpack/some/root/dir';
+const request = './path/to-look-up.js';
+myResolver.resolve({}, lookupStartPath, request, resolveContext, (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 |
+| ------------------------ | --------------------------- | ---------------------------------------------------------------------------------- |
+| alias | [] | A list of module alias configurations or an object which maps key to value |
+| aliasFields | [] | A list of alias fields in description files |
+| cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key |
+| descriptionFiles | ["package.json"] | A list of description files to read from |
+| enforceExtension | false | Enforce that a extension from extensions must be used |
+| enforceModuleExtension | false | Enforce that a extension from moduleExtensions must be used |
+| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
+| mainFields | ["main"] | A list of main fields in description files |
+| mainFiles | ["index"] | A list of main files in directories |
+| modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name |
+| unsafeCache | false | Use this cache object to unsafely cache the successful requests |
+| plugins | [] | A list of additional resolve plugins which should be applied |
+| symlinks | true | Whether to resolve symlinks to their symlinked location |
+| 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. |
+| moduleExtensions | [] | A list of module extensions which should be tried for modules |
+| resolveToContext | false | Resolve to a context instead of a file |
+| 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) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("MyResolverPlugin", (request, resolveContext, callback) => {
+ // Any logic you need to create a new `request` can go here
+ resolver.doResolve(target, request, null, resolveContext, 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/enhanced-resolve/lib/AliasFieldPlugin.js b/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js
index 70b6b97d6..922ee74e8 100644
--- a/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js
+++ b/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js
@@ -2,50 +2,51 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
+"use strict";
-var DescriptionFileUtils = require("./DescriptionFileUtils");
-var createInnerCallback = require("./createInnerCallback");
-var getInnerRequest = require("./getInnerRequest");
+const DescriptionFileUtils = require("./DescriptionFileUtils");
+const getInnerRequest = require("./getInnerRequest");
-function AliasFieldPlugin(source, field, target) {
- this.source = source;
- this.field = field;
- this.target = target;
-}
-module.exports = AliasFieldPlugin;
+module.exports = class AliasFieldPlugin {
+ constructor(source, field, target) {
+ this.source = source;
+ this.field = field;
+ this.target = target;
+ }
-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
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("AliasFieldPlugin", (request, resolveContext, callback) => {
+ if(!request.descriptionFileData) return callback();
+ const innerRequest = getInnerRequest(resolver, request);
+ if(!innerRequest) return callback();
+ const fieldData = DescriptionFileUtils.getField(request.descriptionFileData, this.field);
+ if(typeof fieldData !== "object") {
+ if(resolveContext.log) resolveContext.log("Field '" + this.field + "' doesn't contain a valid alias configuration");
+ return callback();
+ }
+ const data1 = fieldData[innerRequest];
+ const data2 = fieldData[innerRequest.replace(/^\.\//, "")];
+ const data = typeof data1 !== "undefined" ? data1 : data2;
+ if(data === innerRequest) return callback();
+ if(data === undefined) return callback();
+ if(data === false) {
+ const ignoreObj = Object.assign({}, request, {
+ path: false
+ });
+ return callback(null, ignoreObj);
+ }
+ const obj = Object.assign({}, request, {
+ path: request.descriptionFileRoot,
+ request: data
});
- 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);
+ resolver.doResolve(target, obj, "aliased from description file " + request.descriptionFilePath + " with mapping '" + innerRequest + "' to '" + data + "'", resolveContext, (err, result) => {
+ if(err) return callback(err);
- // Don't allow other aliasing or raw request
- callback(null, null);
- }, callback));
- });
+ // Don't allow other aliasing or raw request
+ if(result === undefined) return callback(null, null);
+ callback(null, result);
+ });
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/AliasPlugin.js b/node_modules/enhanced-resolve/lib/AliasPlugin.js
index 86f2a6fba..c9af4f56c 100644
--- a/node_modules/enhanced-resolve/lib/AliasPlugin.js
+++ b/node_modules/enhanced-resolve/lib/AliasPlugin.js
@@ -1,57 +1,56 @@
-/*
- 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();
- });
-};
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+function startsWith(string, searchString) {
+ const stringLength = string.length;
+ const searchLength = searchString.length;
+
+ // early out if the search length is greater than the search string
+ if(searchLength > stringLength) {
+ return false;
+ }
+ let index = -1;
+ while(++index < searchLength) {
+ if(string.charCodeAt(index) !== searchString.charCodeAt(index)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+module.exports = class AliasPlugin {
+ constructor(source, options, target) {
+ this.source = source;
+ this.options = Array.isArray(options) ? options : [options];
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("AliasPlugin", (request, resolveContext, callback) => {
+ const innerRequest = request.request || request.path;
+ if(!innerRequest) return callback();
+ for(const item of this.options) {
+ if(innerRequest === item.name || (!item.onlyModule && startsWith(innerRequest, item.name + "/"))) {
+ if(innerRequest !== item.alias && !startsWith(innerRequest, item.alias + "/")) {
+ const newRequestStr = item.alias + innerRequest.substr(item.name.length);
+ const obj = Object.assign({}, request, {
+ request: newRequestStr
+ });
+ return resolver.doResolve(target, obj, "aliased with mapping '" + item.name + "': '" + item.alias + "' to '" + newRequestStr + "'", resolveContext, (err, result) => {
+ if(err) return callback(err);
+
+ // Don't allow other aliasing or raw request
+ if(result === undefined) return callback(null, null);
+ callback(null, result);
+ });
+ }
+ }
+ }
+ return callback();
+ });
+ }
+};
diff --git a/node_modules/enhanced-resolve/lib/AppendPlugin.js b/node_modules/enhanced-resolve/lib/AppendPlugin.js
index a42ff3679..47366e348 100644
--- a/node_modules/enhanced-resolve/lib/AppendPlugin.js
+++ b/node_modules/enhanced-resolve/lib/AppendPlugin.js
@@ -2,21 +2,23 @@
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;
+"use strict";
-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)
+module.exports = class AppendPlugin {
+ constructor(source, appending, target) {
+ this.source = source;
+ this.appending = appending;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("AppendPlugin", (request, resolveContext, callback) => {
+ const obj = Object.assign({}, request, {
+ path: request.path + this.appending,
+ relativePath: request.relativePath && (request.relativePath + this.appending)
+ });
+ resolver.doResolve(target, obj, this.appending, resolveContext, callback);
});
- resolver.doResolve(target, obj, appending, callback);
- });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js b/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js
index 2ea7858a0..46de9d3d4 100644
--- a/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js
+++ b/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js
@@ -2,259 +2,276 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-function Storage(duration) {
- this.duration = duration;
- this.running = {};
- this.data = {};
- this.levels = [];
- if(duration > 0) {
- this.levels.push([], [], [], [], [], [], [], [], []);
- for(var i = 8000; i < duration; i += 500)
- this.levels.push([]);
- }
- this.count = 0;
- this.interval = null;
- this.needTickCheck = false;
- this.nextTick = null;
- this.passive = true;
- this.tick = this.tick.bind(this);
-}
+"use strict";
-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[name];
- delete this.running[name];
- if(this.duration > 0) {
- this.count++;
- this.data[name] = [err, result];
- this.levels[0].push(name);
- this.ensureTick();
- }
- for(var i = 0; i < callbacks.length; i++) {
- callbacks[i](err, result);
+class Storage {
+ constructor(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(let 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.finishedSync = function(name, err, result) {
- if(this.duration > 0) {
- this.count++;
- this.data[name] = [err, result];
- this.levels[0].push(name);
- this.ensureTick();
+ ensureTick() {
+ if(!this.interval && this.duration > 0 && !this.nextTick)
+ this.interval = setInterval(this.tick, Math.floor(this.duration / this.levels.length));
}
-};
-Storage.prototype.provide = function(name, provider, callback) {
- var running = this.running[name];
- if(running) {
- running.push(callback);
- return;
- }
- if(this.duration > 0) {
- this.checkTicks();
- var data = this.data[name];
- if(data) {
- return process.nextTick(function() {
- callback.apply(null, data);
- });
+ finished(name, err, result) {
+ const callbacks = this.running.get(name);
+ this.running.delete(name);
+ if(this.duration > 0) {
+ this.data.set(name, [err, result]);
+ const levelData = this.levels[0];
+ this.count -= levelData.size;
+ levelData.add(name);
+ this.count += levelData.size;
+ this.ensureTick();
+ }
+ for(let i = 0; i < callbacks.length; i++) {
+ callbacks[i](err, result);
}
}
- this.running[name] = running = [callback];
- var _this = this;
- provider(name, function(err, result) {
- _this.finished(name, err, result);
- });
-};
-Storage.prototype.provideSync = function(name, provider) {
- if(this.duration > 0) {
- this.checkTicks();
- var data = this.data[name];
- if(data) {
- if(data[0])
- throw data[0];
- return data[1];
+ finishedSync(name, err, result) {
+ if(this.duration > 0) {
+ this.data.set(name, [err, result]);
+ const levelData = this.levels[0];
+ this.count -= levelData.size;
+ levelData.add(name);
+ this.count += levelData.size;
+ this.ensureTick();
}
}
- try {
- var result = provider(name);
- } catch(e) {
- this.finishedSync(name, e);
- throw e;
+
+ provide(name, provider, callback) {
+ if(typeof name !== "string") {
+ callback(new TypeError("path must be a string"));
+ return;
+ }
+ let running = this.running.get(name);
+ if(running) {
+ running.push(callback);
+ return;
+ }
+ if(this.duration > 0) {
+ this.checkTicks();
+ const data = this.data.get(name);
+ if(data) {
+ return process.nextTick(() => {
+ callback.apply(null, data);
+ });
+ }
+ }
+ this.running.set(name, running = [callback]);
+ provider(name, (err, result) => {
+ this.finished(name, err, result);
+ });
}
- this.finishedSync(name, null, result);
- return result;
-};
-Storage.prototype.tick = function() {
- var decay = this.levels.pop();
- for(var i = decay.length - 1; i >= 0; i--) {
- delete this.data[decay[i]];
+ provideSync(name, provider) {
+ if(typeof name !== "string") {
+ throw new TypeError("path must be a string");
+ }
+ if(this.duration > 0) {
+ this.checkTicks();
+ const data = this.data.get(name);
+ if(data) {
+ if(data[0])
+ throw data[0];
+ return data[1];
+ }
+ }
+ let result;
+ try {
+ result = provider(name);
+ } catch(e) {
+ this.finishedSync(name, e);
+ throw e;
+ }
+ this.finishedSync(name, null, result);
+ return result;
}
- this.count -= decay.length;
- decay.length = 0;
- 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) {
+
+ tick() {
+ const decay = this.levels.pop();
+ for(let 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;
- this.interval = setInterval(this.tick, Math.floor(this.duration / this.levels.length));
return true;
+ } else if(this.nextTick) {
+ this.nextTick += Math.floor(this.duration / this.levels.length);
+ const 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;
}
- } 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());
+ checkTicks() {
+ 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 = {};
- this.levels.forEach(function(level) {
- level.length = 0;
- });
- } else if(typeof what === "string") {
- Object.keys(this.data).forEach(function(key) {
- if(key.indexOf(what) === 0)
- delete this.data[key];
- }, this);
- } else {
- for(var i = what.length - 1; i >= 0; i--) {
- this.purge(what[i]);
+ purge(what) {
+ if(!what) {
+ this.count = 0;
+ clearInterval(this.interval);
+ this.nextTick = null;
+ this.data.clear();
+ this.levels.forEach(level => {
+ level.clear();
+ });
+ } else if(typeof what === "string") {
+ for(let key of this.data.keys()) {
+ if(key.startsWith(what))
+ this.data.delete(key);
+ }
+ } else {
+ for(let 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);
+module.exports = class CachedInputFileSystem {
+ constructor(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._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._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._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._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._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;
+ 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;
- }
+ if(this.fileSystem.readJson) {
+ this._readJson = this.fileSystem.readJson.bind(this.fileSystem);
+ } else if(this.readFile) {
+ this._readJson = (path, callback) => {
+ this.readFile(path, (err, buffer) => {
+ if(err) return callback(err);
+ let data;
+ try {
+ data = JSON.parse(buffer.toString("utf-8"));
+ } catch(e) {
+ return callback(e);
+ }
+ callback(null, data);
+ });
+ };
+ } else {
+ this.readJson = null;
+ }
+ if(this.fileSystem.readJsonSync) {
+ this._readJsonSync = this.fileSystem.readJsonSync.bind(this.fileSystem);
+ } else if(this.readFileSync) {
+ this._readJsonSync = (path) => {
+ const buffer = this.readFileSync(path);
+ const data = JSON.parse(buffer.toString("utf-8"));
+ return data;
+ };
+ } else {
+ this.readJsonSync = null;
+ }
- this._readlink = this.fileSystem.readlink ? this.fileSystem.readlink.bind(this.fileSystem) : null;
- if(!this._readlink) this.readlink = 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;
+ this._readlinkSync = this.fileSystem.readlinkSync ? this.fileSystem.readlinkSync.bind(this.fileSystem) : null;
+ if(!this._readlinkSync) this.readlinkSync = null;
+ }
-CachedInputFileSystem.prototype.stat = function(path, callback) {
- this._statStorage.provide(path, this._stat, callback);
-};
+ stat(path, callback) {
+ this._statStorage.provide(path, this._stat, callback);
+ }
-CachedInputFileSystem.prototype.readdir = function(path, callback) {
- this._readdirStorage.provide(path, this._readdir, callback);
-};
+ readdir(path, callback) {
+ this._readdirStorage.provide(path, this._readdir, callback);
+ }
-CachedInputFileSystem.prototype.readFile = function(path, callback) {
- this._readFileStorage.provide(path, this._readFile, callback);
-};
+ readFile(path, callback) {
+ this._readFileStorage.provide(path, this._readFile, callback);
+ }
-CachedInputFileSystem.prototype.readJson = function(path, callback) {
- this._readJsonStorage.provide(path, this._readJson, callback);
-};
+ readJson(path, callback) {
+ this._readJsonStorage.provide(path, this._readJson, callback);
+ }
-CachedInputFileSystem.prototype.readlink = function(path, callback) {
- this._readlinkStorage.provide(path, this._readlink, callback);
-};
+ readlink(path, callback) {
+ this._readlinkStorage.provide(path, this._readlink, callback);
+ }
-CachedInputFileSystem.prototype.statSync = function(path) {
- return this._statStorage.provideSync(path, this._statSync);
-};
+ statSync(path) {
+ return this._statStorage.provideSync(path, this._statSync);
+ }
-CachedInputFileSystem.prototype.readdirSync = function(path) {
- return this._readdirStorage.provideSync(path, this._readdirSync);
-};
+ readdirSync(path) {
+ return this._readdirStorage.provideSync(path, this._readdirSync);
+ }
-CachedInputFileSystem.prototype.readFileSync = function(path) {
- return this._readFileStorage.provideSync(path, this._readFileSync);
-};
+ readFileSync(path) {
+ return this._readFileStorage.provideSync(path, this._readFileSync);
+ }
-CachedInputFileSystem.prototype.readJsonSync = function(path) {
- return this._readJsonStorage.provideSync(path, this._readJsonSync);
-};
+ readJsonSync(path) {
+ return this._readJsonStorage.provideSync(path, this._readJsonSync);
+ }
-CachedInputFileSystem.prototype.readlinkSync = function(path) {
- return this._readlinkStorage.provideSync(path, this._readlinkSync);
-};
+ readlinkSync(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);
+ purge(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/enhanced-resolve/lib/CloneBasenamePlugin.js b/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js
index d6ad4bc06..02a390386 100644
--- a/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js
+++ b/node_modules/enhanced-resolve/lib/CloneBasenamePlugin.js
@@ -2,23 +2,26 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var basename = require("./getPaths").basename;
+"use strict";
-function CloneBasenamePlugin(source, target) {
- this.source = source;
- this.target = target;
-}
-module.exports = CloneBasenamePlugin;
+const basename = require("./getPaths").basename;
-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)
+module.exports = class CloneBasenamePlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("CloneBasenamePlugin", (request, resolveContext, callback) => {
+ const filename = basename(request.path);
+ const filePath = resolver.join(request.path, filename);
+ const obj = Object.assign({}, request, {
+ path: filePath,
+ relativePath: request.relativePath && resolver.join(request.relativePath, filename)
+ });
+ resolver.doResolve(target, obj, "using path: " + filePath, resolveContext, callback);
});
- resolver.doResolve(target, obj, "using path: " + filePath, callback);
- });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/ConcordExtensionsPlugin.js b/node_modules/enhanced-resolve/lib/ConcordExtensionsPlugin.js
index 2a3c41a94..54a1ec4fe 100644
--- a/node_modules/enhanced-resolve/lib/ConcordExtensionsPlugin.js
+++ b/node_modules/enhanced-resolve/lib/ConcordExtensionsPlugin.js
@@ -2,36 +2,39 @@
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");
+"use strict";
-function ConcordExtensionsPlugin(source, options, target) {
- this.source = source;
- this.options = options;
- this.target = target;
-}
-module.exports = ConcordExtensionsPlugin;
+const concord = require("./concord");
+const DescriptionFileUtils = require("./DescriptionFileUtils");
+const forEachBail = require("./forEachBail");
-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);
+module.exports = class ConcordExtensionsPlugin {
+ constructor(source, options, target) {
+ this.source = source;
+ this.options = options;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("ConcordExtensionsPlugin", (request, resolveContext, callback) => {
+ const concordField = DescriptionFileUtils.getField(request.descriptionFileData, "concord");
+ if(!concordField) return callback();
+ const extensions = concord.getExtensions(request.context, concordField);
+ if(!extensions) return callback();
+ forEachBail(extensions, (appending, callback) => {
+ const obj = Object.assign({}, request, {
+ path: request.path + appending,
+ relativePath: request.relativePath && (request.relativePath + appending)
+ });
+ resolver.doResolve(target, obj, "concord extension: " + appending, resolveContext, callback);
+ }, (err, result) => {
+ if(err) return callback(err);
- callback(null, null);
+ // Don't allow other processing
+ if(result === undefined) return callback(null, null);
+ callback(null, result);
+ });
});
- });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/ConcordMainPlugin.js b/node_modules/enhanced-resolve/lib/ConcordMainPlugin.js
index b3b672d8a..0156e688f 100644
--- a/node_modules/enhanced-resolve/lib/ConcordMainPlugin.js
+++ b/node_modules/enhanced-resolve/lib/ConcordMainPlugin.js
@@ -2,29 +2,32 @@
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");
+"use strict";
-function ConcordMainPlugin(source, options, target) {
- this.source = source;
- this.options = options;
- this.target = target;
-}
-module.exports = ConcordMainPlugin;
+const path = require("path");
+const concord = require("./concord");
+const DescriptionFileUtils = require("./DescriptionFileUtils");
-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
+module.exports = class ConcordMainPlugin {
+ constructor(source, options, target) {
+ this.source = source;
+ this.options = options;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("ConcordMainPlugin", (request, resolveContext, callback) => {
+ if(request.path !== request.descriptionFileRoot) return callback();
+ const concordField = DescriptionFileUtils.getField(request.descriptionFileData, "concord");
+ if(!concordField) return callback();
+ const mainModule = concord.getMain(request.context, concordField);
+ if(!mainModule) return callback();
+ const obj = Object.assign({}, request, {
+ request: mainModule
+ });
+ const filename = path.basename(request.descriptionFilePath);
+ return resolver.doResolve(target, obj, "use " + mainModule + " from " + filename, resolveContext, callback);
});
- var filename = path.basename(request.descriptionFilePath);
- return resolver.doResolve(target, obj, "use " + mainModule + " from " + filename, callback);
- });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/ConcordModulesPlugin.js b/node_modules/enhanced-resolve/lib/ConcordModulesPlugin.js
index 2aa35ab87..9fbe579d1 100644
--- a/node_modules/enhanced-resolve/lib/ConcordModulesPlugin.js
+++ b/node_modules/enhanced-resolve/lib/ConcordModulesPlugin.js
@@ -2,43 +2,46 @@
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");
+"use strict";
-function ConcordModulesPlugin(source, options, target) {
- this.source = source;
- this.options = options;
- this.target = target;
-}
-module.exports = ConcordModulesPlugin;
+const concord = require("./concord");
+const DescriptionFileUtils = require("./DescriptionFileUtils");
+const getInnerRequest = require("./getInnerRequest");
-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
+module.exports = class ConcordModulesPlugin {
+ constructor(source, options, target) {
+ this.source = source;
+ this.options = options;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("ConcordModulesPlugin", (request, resolveContext, callback) => {
+ const innerRequest = getInnerRequest(resolver, request);
+ if(!innerRequest) return callback();
+ const concordField = DescriptionFileUtils.getField(request.descriptionFileData, "concord");
+ if(!concordField) return callback();
+ const data = concord.matchModule(request.context, concordField, innerRequest);
+ if(data === innerRequest) return callback();
+ if(data === undefined) return callback();
+ if(data === false) {
+ const ignoreObj = Object.assign({}, request, {
+ path: false
+ });
+ return callback(null, ignoreObj);
+ }
+ const obj = Object.assign({}, request, {
+ path: request.descriptionFileRoot,
+ request: data
});
- 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);
+ resolver.doResolve(target, obj, "aliased from description file " + request.descriptionFilePath + " with mapping '" + innerRequest + "' to '" + data + "'", resolveContext, (err, result) => {
+ if(err) return callback(err);
- // Don't allow other aliasing or raw request
- callback(null, null);
- }, callback));
- });
+ // Don't allow other aliasing or raw request
+ if(result === undefined) return callback(null, null);
+ callback(null, result);
+ });
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js b/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
index ad4a9a3c6..5d213c4ff 100644
--- a/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
+++ b/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js
@@ -1,12 +1,12 @@
-"use strict";
/*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
+MIT License http://www.opensource.org/licenses/mit-license.php
+Author Tobias Koppers @sokra
*/
-const createInnerCallback = require("./createInnerCallback");
+"use strict";
+
const DescriptionFileUtils = require("./DescriptionFileUtils");
-class DescriptionFilePlugin {
+module.exports = class DescriptionFilePlugin {
constructor(source, filenames, target) {
this.source = source;
this.filenames = [].concat(filenames);
@@ -14,19 +14,18 @@ class DescriptionFilePlugin {
}
apply(resolver) {
- const filenames = this.filenames;
- const target = this.target;
- resolver.plugin(this.source, (request, callback) => {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("DescriptionFilePlugin", (request, resolveContext, callback) => {
const directory = request.path;
- DescriptionFileUtils.loadDescriptionFile(resolver, directory, filenames, ((err, result) => {
+ DescriptionFileUtils.loadDescriptionFile(resolver, directory, this.filenames, resolveContext, (err, result) => {
if(err) return callback(err);
if(!result) {
- if(callback.missing) {
- filenames.forEach((filename) => {
- callback.missing.push(resolver.join(directory, filename));
+ if(resolveContext.missing) {
+ this.filenames.forEach((filename) => {
+ resolveContext.missing.add(resolver.join(directory, filename));
});
}
- if(callback.log) callback.log("No description file found");
+ if(resolveContext.log) resolveContext.log("No description file found");
return callback();
}
const relativePath = "." + request.path.substr(result.directory.length).replace(/\\/g, "/");
@@ -36,16 +35,14 @@ class DescriptionFilePlugin {
descriptionFileRoot: result.directory,
relativePath: relativePath
});
- resolver.doResolve(target, obj, "using description file: " + result.path + " (relative path: " + relativePath + ")", createInnerCallback((err, result) => {
+ resolver.doResolve(target, obj, "using description file: " + result.path + " (relative path: " + relativePath + ")", resolveContext, (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));
- }));
+ // Don't allow other processing
+ if(result === undefined) return callback(null, null);
+ callback(null, result);
+ });
+ });
});
}
-}
-
-module.exports = DescriptionFilePlugin;
+};
diff --git a/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js b/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js
index 084d29ec9..8cca5dbfe 100644
--- a/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js
+++ b/node_modules/enhanced-resolve/lib/DescriptionFileUtils.js
@@ -2,14 +2,16 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var forEachBail = require("./forEachBail");
+"use strict";
-function loadDescriptionFile(resolver, directory, filenames, callback) {
+const forEachBail = require("./forEachBail");
+
+function loadDescriptionFile(resolver, directory, filenames, resolveContext, callback) {
(function findDescriptionFile() {
- forEachBail(filenames, function(filename, callback) {
- var descriptionFilePath = resolver.join(directory, filename);
+ forEachBail(filenames, (filename, callback) => {
+ const descriptionFilePath = resolver.join(directory, filename);
if(resolver.fileSystem.readJson) {
- resolver.fileSystem.readJson(descriptionFilePath, function(err, content) {
+ resolver.fileSystem.readJson(descriptionFilePath, (err, content) => {
if(err) {
if(typeof err.code !== "undefined") return callback();
return onJson(err);
@@ -17,10 +19,11 @@ function loadDescriptionFile(resolver, directory, filenames, callback) {
onJson(null, content);
});
} else {
- resolver.fileSystem.readFile(descriptionFilePath, function(err, content) {
+ resolver.fileSystem.readFile(descriptionFilePath, (err, content) => {
if(err) return callback();
+ let json;
try {
- var json = JSON.parse(content);
+ json = JSON.parse(content);
} catch(e) {
onJson(e);
}
@@ -30,8 +33,8 @@ function loadDescriptionFile(resolver, directory, filenames, callback) {
function onJson(err, content) {
if(err) {
- if(callback.log)
- callback.log(descriptionFilePath + " (directory description file): " + err);
+ if(resolveContext.log)
+ resolveContext.log(descriptionFilePath + " (directory description file): " + err);
else
err.message = descriptionFilePath + " (directory description file): " + err;
return callback(err);
@@ -42,7 +45,7 @@ function loadDescriptionFile(resolver, directory, filenames, callback) {
path: descriptionFilePath
});
}
- }, function(err, result) {
+ }, (err, result) => {
if(err) return callback(err);
if(result) {
return callback(null, result);
@@ -61,8 +64,8 @@ function loadDescriptionFile(resolver, directory, filenames, callback) {
function getField(content, field) {
if(!content) return undefined;
if(Array.isArray(field)) {
- var current = content;
- for(var j = 0; j < field.length; j++) {
+ let current = content;
+ for(let j = 0; j < field.length; j++) {
if(current === null || typeof current !== "object") {
current = null;
break;
@@ -81,9 +84,9 @@ function getField(content, field) {
function cdUp(directory) {
if(directory === "/") return null;
- var i = directory.lastIndexOf("/"),
+ const i = directory.lastIndexOf("/"),
j = directory.lastIndexOf("\\");
- var p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
+ const p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
if(p < 0) return null;
return directory.substr(0, p || 1);
}
diff --git a/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js b/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js
index 7e88d68d0..37008637b 100644
--- a/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js
+++ b/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js
@@ -2,29 +2,32 @@
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;
+"use strict";
-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));
- });
+module.exports = class DirectoryExistsPlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("DirectoryExistsPlugin", (request, resolveContext, callback) => {
+ const fs = resolver.fileSystem;
+ const directory = request.path;
+ fs.stat(directory, (err, stat) => {
+ if(err || !stat) {
+ if(resolveContext.missing) resolveContext.missing.add(directory);
+ if(resolveContext.log) resolveContext.log(directory + " doesn't exist");
+ return callback();
+ }
+ if(!stat.isDirectory()) {
+ if(resolveContext.missing) resolveContext.missing.add(directory);
+ if(resolveContext.log) resolveContext.log(directory + " is not a directory");
+ return callback();
+ }
+ resolver.doResolve(target, request, "existing directory", resolveContext, callback);
+ });
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/FileExistsPlugin.js b/node_modules/enhanced-resolve/lib/FileExistsPlugin.js
index 59fc6a5f1..0fa3aa1de 100644
--- a/node_modules/enhanced-resolve/lib/FileExistsPlugin.js
+++ b/node_modules/enhanced-resolve/lib/FileExistsPlugin.js
@@ -2,29 +2,32 @@
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;
+"use strict";
-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));
- });
+module.exports = class FileExistsPlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ const fs = resolver.fileSystem;
+ resolver.getHook(this.source).tapAsync("FileExistsPlugin", (request, resolveContext, callback) => {
+ const file = request.path;
+ fs.stat(file, (err, stat) => {
+ if(err || !stat) {
+ if(resolveContext.missing) resolveContext.missing.add(file);
+ if(resolveContext.log) resolveContext.log(file + " doesn't exist");
+ return callback();
+ }
+ if(!stat.isFile()) {
+ if(resolveContext.missing) resolveContext.missing.add(file);
+ if(resolveContext.log) resolveContext.log(file + " is not a file");
+ return callback();
+ }
+ resolver.doResolve(target, request, "existing file: " + file, resolveContext, callback);
+ });
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/FileKindPlugin.js b/node_modules/enhanced-resolve/lib/FileKindPlugin.js
index d42bc22f3..3d1e271e5 100644
--- a/node_modules/enhanced-resolve/lib/FileKindPlugin.js
+++ b/node_modules/enhanced-resolve/lib/FileKindPlugin.js
@@ -2,18 +2,21 @@
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;
+"use strict";
-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);
- });
+module.exports = class FileKindPlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("FileKindPlugin", (request, resolveContext, callback) => {
+ if(request.directory) return callback();
+ const obj = Object.assign({}, request);
+ delete obj.directory;
+ resolver.doResolve(target, obj, null, resolveContext, callback);
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js b/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js
index ac828eb31..7a20bb2b0 100644
--- a/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js
+++ b/node_modules/enhanced-resolve/lib/JoinRequestPlugin.js
@@ -2,20 +2,23 @@
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;
+"use strict";
-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
+module.exports = class JoinRequestPlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("JoinRequestPlugin", (request, resolveContext, callback) => {
+ const 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, resolveContext, callback);
});
- resolver.doResolve(target, obj, null, callback);
- });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/LogInfoPlugin.js b/node_modules/enhanced-resolve/lib/LogInfoPlugin.js
index 1ebc837ce..b3eea2361 100644
--- a/node_modules/enhanced-resolve/lib/LogInfoPlugin.js
+++ b/node_modules/enhanced-resolve/lib/LogInfoPlugin.js
@@ -2,24 +2,27 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-function LogInfoPlugin(source) {
- this.source = source;
-}
-module.exports = LogInfoPlugin;
+"use strict";
-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();
- });
+module.exports = class LogInfoPlugin {
+ constructor(source) {
+ this.source = source;
+ }
+
+ apply(resolver) {
+ const source = this.source;
+ resolver.getHook(this.source).tapAsync("LogInfoPlugin", (request, resolveContext, callback) => {
+ if(!resolveContext.log) return callback();
+ const log = resolveContext.log;
+ const 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/enhanced-resolve/lib/MainFieldPlugin.js b/node_modules/enhanced-resolve/lib/MainFieldPlugin.js
index 45ecd4b23..3bcd36ce5 100644
--- a/node_modules/enhanced-resolve/lib/MainFieldPlugin.js
+++ b/node_modules/enhanced-resolve/lib/MainFieldPlugin.js
@@ -1,48 +1,52 @@
-/*
- 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);
- });
-};
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const path = require("path");
+
+module.exports = class MainFieldPlugin {
+ constructor(source, options, target) {
+ this.source = source;
+ this.options = options;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("MainFieldPlugin", (request, resolveContext, callback) => {
+ if(request.path !== request.descriptionFileRoot) return callback();
+ if(request.alreadyTriedMainField === request.descriptionFilePath) return callback();
+ const content = request.descriptionFileData;
+ const filename = path.basename(request.descriptionFilePath);
+ let mainModule;
+ const field = this.options.name;
+ if(Array.isArray(field)) {
+ let current = content;
+ for(let 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(this.options.forceRelative && !/^\.\.?\//.test(mainModule))
+ mainModule = "./" + mainModule;
+ const obj = Object.assign({}, request, {
+ request: mainModule,
+ alreadyTriedMainField: request.descriptionFilePath
+ });
+ return resolver.doResolve(target, obj, "use " + mainModule + " from " + this.options.name + " in " + filename, resolveContext, callback);
+ });
+ }
+};
diff --git a/node_modules/enhanced-resolve/lib/ModuleAppendPlugin.js b/node_modules/enhanced-resolve/lib/ModuleAppendPlugin.js
index 55ebcb937..e319e80dd 100644
--- a/node_modules/enhanced-resolve/lib/ModuleAppendPlugin.js
+++ b/node_modules/enhanced-resolve/lib/ModuleAppendPlugin.js
@@ -2,34 +2,36 @@
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;
+"use strict";
-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
+module.exports = class ModuleAppendPlugin {
+ constructor(source, appending, target) {
+ this.source = source;
+ this.appending = appending;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("ModuleAppendPlugin", (request, resolveContext, callback) => {
+ const i = request.request.indexOf("/"),
+ j = request.request.indexOf("\\");
+ const p = i < 0 ? j : j < 0 ? i : i < j ? i : j;
+ let 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();
+ const moduleFinalName = moduleName + this.appending;
+ const obj = Object.assign({}, request, {
+ request: moduleFinalName + remainingRequest
+ });
+ resolver.doResolve(target, obj, "module variation " + moduleFinalName, resolveContext, callback);
});
- resolver.doResolve(target, obj, "module variation " + moduleFinalName, callback);
- });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js b/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js
index e6d920108..6a4edf21c 100644
--- a/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js
+++ b/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js
@@ -2,25 +2,27 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var createInnerCallback = require("./createInnerCallback");
+"use strict";
-function ModuleKindPlugin(source, target) {
- this.source = source;
- this.target = target;
-}
-module.exports = ModuleKindPlugin;
+module.exports = class ModuleKindPlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
-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);
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("ModuleKindPlugin", (request, resolveContext, callback) => {
+ if(!request.module) return callback();
+ const obj = Object.assign({}, request);
+ delete obj.module;
+ resolver.doResolve(target, obj, "resolve as module", resolveContext, (err, result) => {
+ if(err) return callback(err);
- // Don't allow other alternatives
- callback(null, null);
- }, callback));
- });
+ // Don't allow other alternatives
+ if(result === undefined) return callback(null, null);
+ callback(null, result);
+ });
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js b/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js
index cb942ce94..4697827c7 100644
--- a/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js
+++ b/node_modules/enhanced-resolve/lib/ModulesInHierachicDirectoriesPlugin.js
@@ -2,45 +2,43 @@
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");
+"use strict";
-function ModulesInHierachicDirectoriesPlugin(source, directories, target) {
- this.source = source;
- this.directories = [].concat(directories);
- this.target = target;
-}
-module.exports = ModulesInHierachicDirectoriesPlugin;
+const forEachBail = require("./forEachBail");
+const getPaths = require("./getPaths");
-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);
- });
+module.exports = class ModulesInHierachicDirectoriesPlugin {
+ constructor(source, directories, target) {
+ this.source = source;
+ this.directories = [].concat(directories);
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("ModulesInHierachicDirectoriesPlugin", (request, resolveContext, callback) => {
+ const fs = resolver.fileSystem;
+ const addrs = getPaths(request.path).paths.map(p => {
+ return this.directories.map(d => resolver.join(p, d));
+ }).reduce((array, p) => {
+ array.push.apply(array, p);
+ return array;
+ }, []);
+ forEachBail(addrs, (addr, callback) => {
+ fs.stat(addr, (err, stat) => {
+ if(!err && stat && stat.isDirectory()) {
+ const obj = Object.assign({}, request, {
+ path: addr,
+ request: "./" + request.request
+ });
+ const message = "looking for modules in " + addr;
+ return resolver.doResolve(target, obj, message, resolveContext, callback);
+ }
+ if(resolveContext.log) resolveContext.log(addr + " doesn't exist or is not a directory");
+ if(resolveContext.missing) resolveContext.missing.add(addr);
+ return callback();
+ });
+ }, callback);
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js b/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js
index 1d7de20fb..1331dc864 100644
--- a/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js
+++ b/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js
@@ -2,21 +2,23 @@
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;
+"use strict";
-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
+module.exports = class ModulesInRootPlugin {
+ constructor(source, path, target) {
+ this.source = source;
+ this.path = path;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("ModulesInRootPlugin", (request, resolveContext, callback) => {
+ const obj = Object.assign({}, request, {
+ path: this.path,
+ request: "./" + request.request
+ });
+ resolver.doResolve(target, obj, "looking for modules in " + this.path, resolveContext, callback);
});
- resolver.doResolve(target, obj, "looking for modules in " + path, callback, true);
- });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/NextPlugin.js b/node_modules/enhanced-resolve/lib/NextPlugin.js
index 0db218c81..b72217d2b 100644
--- a/node_modules/enhanced-resolve/lib/NextPlugin.js
+++ b/node_modules/enhanced-resolve/lib/NextPlugin.js
@@ -2,15 +2,18 @@
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;
+"use strict";
-NextPlugin.prototype.apply = function(resolver) {
- var target = this.target;
- resolver.plugin(this.source, function(request, callback) {
- resolver.doResolve(target, request, null, callback);
- });
+module.exports = class NextPlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("NextPlugin", (request, resolveContext, callback) => {
+ resolver.doResolve(target, request, null, resolveContext, callback);
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/NodeJsInputFileSystem.js b/node_modules/enhanced-resolve/lib/NodeJsInputFileSystem.js
index 28c78ca8a..e090b20db 100644
--- a/node_modules/enhanced-resolve/lib/NodeJsInputFileSystem.js
+++ b/node_modules/enhanced-resolve/lib/NodeJsInputFileSystem.js
@@ -1,29 +1,43 @@
-/*
- 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);
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const fs = require("graceful-fs");
+
+class NodeJsInputFileSystem {
+ readdir(path, callback) {
+ fs.readdir(path, (err, files) => {
+ callback(err, files && files.map(file => {
+ return file.normalize ? file.normalize("NFC") : file;
+ }));
+ });
+ }
+
+ readdirSync(path) {
+ const files = fs.readdirSync(path);
+ return files && files.map(file => {
+ return file.normalize ? file.normalize("NFC") : file;
+ });
+ }
+}
+
+const fsMethods = [
+ "stat",
+ "statSync",
+ "readFile",
+ "readFileSync",
+ "readlink",
+ "readlinkSync"
+];
+
+for(const key of fsMethods) {
+ Object.defineProperty(NodeJsInputFileSystem.prototype, key, {
+ configurable: true,
+ writable: true,
+ value: fs[key].bind(fs)
+ });
+}
+
+module.exports = NodeJsInputFileSystem;
diff --git a/node_modules/enhanced-resolve/lib/ParsePlugin.js b/node_modules/enhanced-resolve/lib/ParsePlugin.js
index f4117fac9..44e50558c 100644
--- a/node_modules/enhanced-resolve/lib/ParsePlugin.js
+++ b/node_modules/enhanced-resolve/lib/ParsePlugin.js
@@ -2,26 +2,29 @@
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;
+"use strict";
-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);
- });
+module.exports = class ParsePlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("ParsePlugin", (request, resolveContext, callback) => {
+ const parsed = resolver.parse(request.request);
+ const obj = Object.assign({}, request, parsed);
+ if(request.query && !parsed.query) {
+ obj.query = request.query;
+ }
+ if(parsed && resolveContext.log) {
+ if(parsed.module)
+ resolveContext.log("Parsed request is a module");
+ if(parsed.directory)
+ resolveContext.log("Parsed request is a directory");
+ }
+ resolver.doResolve(target, obj, null, resolveContext, callback);
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/Resolver.js b/node_modules/enhanced-resolve/lib/Resolver.js
index 5994d5d61..814704037 100644
--- a/node_modules/enhanced-resolve/lib/Resolver.js
+++ b/node_modules/enhanced-resolve/lib/Resolver.js
@@ -1,198 +1,301 @@
-/*
- 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);
-
- resolver.applyPluginsAsyncSeriesBailResult1("before-" + type, request, createInnerCallback(beforeInnerCallback, {
- log: callback.log,
- missing: callback.missing,
- stack: newStack
- }, message && ("before " + message), true));
-
- function beforeInnerCallback(err, result) {
- if(arguments.length > 0) {
- if(err) return callback(err);
- if(result) return callback(null, result);
- return callback();
- }
- return resolver.applyPluginsParallelBailResult1(type, request, createInnerCallback(innerCallback, {
- log: callback.log,
- missing: callback.missing,
- stack: newStack
- }, message));
- }
-
- function innerCallback(err, result) {
- if(arguments.length > 0) {
- if(err) return callback(err);
- if(result) return callback(null, result);
- return callback();
- }
- return resolver.applyPluginsAsyncSeriesBailResult1("after-" + type, request, createInnerCallback(afterInnerCallback, {
- log: callback.log,
- missing: callback.missing,
- stack: newStack
- }, message && ("after " + message), true));
- }
-
- 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 = {};
-Resolver.prototype.join = function(path, request) {
- var memoizeKey = path + "|$" + request;
- if(!memoizedJoin[memoizeKey]) {
- memoizedJoin[memoizeKey] = memoryFsJoin(path, request);
- }
- return memoizedJoin[memoizeKey];
-};
-
-Resolver.prototype.normalize = require("memory-fs/lib/normalize");
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const util = require("util");
+
+const Tapable = require("tapable/lib/Tapable");
+const SyncHook = require("tapable/lib/SyncHook");
+const AsyncSeriesBailHook = require("tapable/lib/AsyncSeriesBailHook");
+const AsyncSeriesHook = require("tapable/lib/AsyncSeriesHook");
+const createInnerContext = require("./createInnerContext");
+
+const REGEXP_NOT_MODULE = /^\.$|^\.[\\\/]|^\.\.$|^\.\.[\/\\]|^\/|^[A-Z]:[\\\/]/i;
+const REGEXP_DIRECTORY = /[\/\\]$/i;
+
+const memoryFsJoin = require("memory-fs/lib/join");
+const memoizedJoin = new Map();
+const memoryFsNormalize = require("memory-fs/lib/normalize");
+
+function withName(name, hook) {
+ hook.name = name;
+ return hook;
+}
+
+function toCamelCase(str) {
+ return str.replace(/-([a-z])/g, str => str.substr(1).toUpperCase());
+}
+
+const deprecatedPushToMissing = util.deprecate((set, item) => {
+ set.add(item);
+}, "Resolver: 'missing' is now a Set. Use add instead of push.");
+
+const deprecatedResolveContextInCallback = util.deprecate((x) => {
+ return x;
+}, "Resolver: The callback argument was splitted into resolveContext and callback.");
+
+const deprecatedHookAsString = util.deprecate((x) => {
+ return x;
+}, "Resolver#doResolve: The type arguments (string) is now a hook argument (Hook). Pass a reference to the hook instead.");
+
+class Resolver extends Tapable {
+ constructor(fileSystem) {
+ super();
+ this.fileSystem = fileSystem;
+ this.hooks = {
+ resolveStep: withName("resolveStep", new SyncHook(["hook", "request"])),
+ noResolve: withName("noResolve", new SyncHook(["request", "error"])),
+ resolve: withName("resolve", new AsyncSeriesBailHook(["request", "resolveContext"])),
+ result: new AsyncSeriesHook(["result", "resolveContext"])
+ };
+ this._pluginCompat.tap("Resolver: before/after", options => {
+ if(/^before-/.test(options.name)) {
+ options.name = options.name.substr(7);
+ options.stage = -10;
+ } else if(/^after-/.test(options.name)) {
+ options.name = options.name.substr(6);
+ options.stage = 10;
+ }
+ });
+ this._pluginCompat.tap("Resolver: step hooks", options => {
+ const name = options.name;
+ const stepHook = !/^resolve(-s|S)tep$|^no(-r|R)esolve$/.test(name);
+ if(stepHook) {
+ options.async = true;
+ this.ensureHook(name);
+ const fn = options.fn;
+ options.fn = (request, resolverContext, callback) => {
+ const innerCallback = (err, result) => {
+ if(err) return callback(err);
+ if(result !== undefined) return callback(null, result);
+ callback();
+ };
+ for(const key in resolverContext) {
+ innerCallback[key] = resolverContext[key];
+ }
+ fn.call(this, request, innerCallback);
+ };
+ }
+ });
+ }
+
+ ensureHook(name) {
+ if(typeof name !== "string") return name;
+ name = toCamelCase(name);
+ if(/^before/.test(name)) {
+ return this.ensureHook(name[6].toLowerCase() + name.substr(7)).withOptions({
+ stage: -10
+ });
+ }
+ if(/^after/.test(name)) {
+ return this.ensureHook(name[5].toLowerCase() + name.substr(6)).withOptions({
+ stage: 10
+ });
+ }
+ const hook = this.hooks[name];
+ if(!hook) {
+ return this.hooks[name] = withName(name, new AsyncSeriesBailHook(["request", "resolveContext"]));
+ }
+ return hook;
+ }
+
+ getHook(name) {
+ if(typeof name !== "string") return name;
+ name = toCamelCase(name);
+ if(/^before/.test(name)) {
+ return this.getHook(name[6].toLowerCase() + name.substr(7)).withOptions({
+ stage: -10
+ });
+ }
+ if(/^after/.test(name)) {
+ return this.getHook(name[5].toLowerCase() + name.substr(6)).withOptions({
+ stage: 10
+ });
+ }
+ const hook = this.hooks[name];
+ if(!hook) {
+ throw new Error(`Hook ${name} doesn't exist`);
+ }
+ return hook;
+ }
+
+ resolveSync(context, path, request) {
+ let err, result, sync = false;
+ this.resolve(context, path, request, {}, (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;
+ }
+
+ resolve(context, path, request, resolveContext, callback) {
+ // TODO remove in enhanced-resolve 5
+ // For backward compatiblity START
+ if(typeof callback !== "function") {
+ callback = deprecatedResolveContextInCallback(resolveContext);
+ // resolveContext is a function containing additional properties
+ // It's now used for resolveContext and callback
+ }
+ // END
+ const obj = {
+ context: context,
+ path: path,
+ request: request
+ };
+
+ const message = "resolve '" + request + "' in '" + path + "'";
+
+ // Try to resolve assuming there is no error
+ // We don't log stuff in this case
+ return this.doResolve(this.hooks.resolve, obj, message, {
+ missing: resolveContext.missing,
+ stack: resolveContext.stack
+ }, (err, result) => {
+ if(!err && result) {
+ return callback(null, result.path === false ? false : result.path + (result.query || ""), result);
+ }
+
+ const localMissing = new Set();
+ // TODO remove in enhanced-resolve 5
+ localMissing.push = item => deprecatedPushToMissing(localMissing, item);
+ const log = [];
+
+ return this.doResolve(this.hooks.resolve, obj, message, {
+ log: msg => {
+ if(resolveContext.log) {
+ resolveContext.log(msg);
+ }
+ log.push(msg);
+ },
+ missing: localMissing,
+ stack: resolveContext.stack
+ }, (err, result) => {
+ if(err) return callback(err);
+
+ const error = new Error("Can't " + message);
+ error.details = log.join("\n");
+ error.missing = Array.from(localMissing);
+ this.hooks.noResolve.call(obj, error);
+ return callback(error);
+ });
+ });
+ }
+
+ doResolve(hook, request, message, resolveContext, callback) {
+ // TODO remove in enhanced-resolve 5
+ // For backward compatiblity START
+ if(typeof callback !== "function") {
+ callback = deprecatedResolveContextInCallback(resolveContext);
+ // resolveContext is a function containing additional properties
+ // It's now used for resolveContext and callback
+ }
+ if(typeof hook === "string") {
+ const name = toCamelCase(hook);
+ hook = deprecatedHookAsString(this.hooks[name]);
+ if(!hook) {
+ throw new Error(`Hook "${name}" doesn't exist`);
+ }
+ }
+ // END
+ if(typeof callback !== "function") throw new Error("callback is not a function " + Array.from(arguments));
+ if(!resolveContext) throw new Error("resolveContext is not an object " + Array.from(arguments));
+
+ const stackLine = hook.name + ": (" + request.path + ") " +
+ (request.request || "") + (request.query || "") +
+ (request.directory ? " directory" : "") +
+ (request.module ? " module" : "");
+
+ let newStack;
+ if(resolveContext.stack) {
+ newStack = new Set(resolveContext.stack);
+ if(resolveContext.stack.has(stackLine)) {
+ // Prevent recursion
+ const recursionError = new Error("Recursion in resolving\nStack:\n " + Array.from(newStack).join("\n "));
+ recursionError.recursion = true;
+ if(resolveContext.log) resolveContext.log("abort resolving because of recursion");
+ return callback(recursionError);
+ }
+ newStack.add(stackLine);
+ } else {
+ newStack = new Set([stackLine]);
+ }
+ this.hooks.resolveStep.call(hook, request);
+
+ if(hook.isUsed()) {
+ const innerContext = createInnerContext({
+ log: resolveContext.log,
+ missing: resolveContext.missing,
+ stack: newStack
+ }, message);
+ return hook.callAsync(request, innerContext, (err, result) => {
+ if(err) return callback(err);
+ if(result) return callback(null, result);
+ callback();
+ });
+ } else {
+ callback();
+ }
+ }
+
+ parse(identifier) {
+ if(identifier === "") return null;
+ const part = {
+ request: "",
+ query: "",
+ module: false,
+ directory: false,
+ file: false
+ };
+ const 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;
+ }
+
+ isModule(path) {
+ return !REGEXP_NOT_MODULE.test(path);
+ }
+
+ isDirectory(path) {
+ return REGEXP_DIRECTORY.test(path);
+ }
+
+ join(path, request) {
+ let cacheEntry;
+ let 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;
+ }
+
+ normalize(path) {
+ return memoryFsNormalize(path);
+ }
+}
+
+module.exports = Resolver;
diff --git a/node_modules/enhanced-resolve/lib/ResolverFactory.js b/node_modules/enhanced-resolve/lib/ResolverFactory.js
index cd167aaf7..4e935a72d 100644
--- a/node_modules/enhanced-resolve/lib/ResolverFactory.js
+++ b/node_modules/enhanced-resolve/lib/ResolverFactory.js
@@ -2,99 +2,104 @@
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");
+"use strict";
+
+const Resolver = require("./Resolver");
+
+const SyncAsyncFileSystemDecorator = require("./SyncAsyncFileSystemDecorator");
+
+const ParsePlugin = require("./ParsePlugin");
+const DescriptionFilePlugin = require("./DescriptionFilePlugin");
+const NextPlugin = require("./NextPlugin");
+const TryNextPlugin = require("./TryNextPlugin");
+const ModuleKindPlugin = require("./ModuleKindPlugin");
+const FileKindPlugin = require("./FileKindPlugin");
+const JoinRequestPlugin = require("./JoinRequestPlugin");
+const ModulesInHierachicDirectoriesPlugin = require("./ModulesInHierachicDirectoriesPlugin");
+const ModulesInRootPlugin = require("./ModulesInRootPlugin");
+const AliasPlugin = require("./AliasPlugin");
+const AliasFieldPlugin = require("./AliasFieldPlugin");
+const ConcordExtensionsPlugin = require("./ConcordExtensionsPlugin");
+const ConcordMainPlugin = require("./ConcordMainPlugin");
+const ConcordModulesPlugin = require("./ConcordModulesPlugin");
+const DirectoryExistsPlugin = require("./DirectoryExistsPlugin");
+const FileExistsPlugin = require("./FileExistsPlugin");
+const SymlinkPlugin = require("./SymlinkPlugin");
+const MainFieldPlugin = require("./MainFieldPlugin");
+const UseFilePlugin = require("./UseFilePlugin");
+const AppendPlugin = require("./AppendPlugin");
+const ResultPlugin = require("./ResultPlugin");
+const ModuleAppendPlugin = require("./ModuleAppendPlugin");
+const 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"];
+ let modules = options.modules || ["node_modules"];
// A list of description files to read from
- var descriptionFiles = options.descriptionFiles || ["package.json"];
+ const 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()) || [];
+ const plugins = (options.plugins && options.plugins.slice()) || [];
// A list of main fields in description files
- var mainFields = options.mainFields || ["main"];
+ let mainFields = options.mainFields || ["main"];
// A list of alias fields in description files
- var aliasFields = options.aliasFields || [];
+ const aliasFields = options.aliasFields || [];
// A list of main files in directories
- var mainFiles = options.mainFiles || ["index"];
+ const mainFiles = options.mainFiles || ["index"];
// A list of extensions which should be tried for files
- var extensions = options.extensions || [".js", ".json", ".node"];
+ let extensions = options.extensions || [".js", ".json", ".node"];
// Enforce that a extension from extensions must be used
- var enforceExtension = options.enforceExtension || false;
+ const enforceExtension = options.enforceExtension || false;
// A list of module extensions which should be tried for modules
- var moduleExtensions = options.moduleExtensions || [];
+ let moduleExtensions = options.moduleExtensions || [];
// Enforce that a extension from moduleExtensions must be used
- var enforceModuleExtension = options.enforceModuleExtension || false;
+ const enforceModuleExtension = options.enforceModuleExtension || false;
// A list of module alias configurations or an object which maps key to value
- var alias = options.alias || [];
+ let alias = options.alias || [];
// Resolve symlinks to their symlinked location
- var symlinks = typeof options.symlinks !== "undefined" ? options.symlinks : true;
+ const symlinks = typeof options.symlinks !== "undefined" ? options.symlinks : true;
// Resolve to a context instead of a file
- var resolveToContext = options.resolveToContext || false;
+ const resolveToContext = options.resolveToContext || false;
// Use this cache object to unsafely cache the successful requests
- var unsafeCache = options.unsafeCache || false;
+ let 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;
+ const cacheWithContext = typeof options.cacheWithContext !== "undefined" ? options.cacheWithContext : true;
+
+ // Enable concord description file instructions
+ const enableConcord = options.concord || false;
// 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() {
+ const cachePredicate = options.cachePredicate || function() {
return true;
};
// The file system which should be used
- var fileSystem = options.fileSystem;
+ const fileSystem = options.fileSystem;
- // Use only the sync variants of the file system calls
- var useSyncFileSystemCalls = options.useSyncFileSystemCalls;
+ // Use only the sync constiants of the file system calls
+ const useSyncFileSystemCalls = options.useSyncFileSystemCalls;
// A prepared Resolver to which the plugins are attached
- var resolver = options.resolver;
+ let resolver = options.resolver;
//// options processing ////
@@ -105,12 +110,12 @@ exports.createResolver = function(options) {
extensions = [].concat(extensions);
moduleExtensions = [].concat(moduleExtensions);
- modules = mergeFilteredToArray([].concat(modules), function(item) {
+ modules = mergeFilteredToArray([].concat(modules), item => {
return !isAbsolutePath(item);
});
- mainFields = mainFields.map(function(item) {
- if(typeof item === "string") {
+ mainFields = mainFields.map(item => {
+ if(typeof item === "string" || Array.isArray(item)) {
item = {
name: item,
forceRelative: true
@@ -120,9 +125,9 @@ exports.createResolver = function(options) {
});
if(typeof alias === "object" && !Array.isArray(alias)) {
- alias = Object.keys(alias).map(function(key) {
- var onlyModule = false;
- var obj = alias[key];
+ alias = Object.keys(alias).map(key => {
+ let onlyModule = false;
+ let obj = alias[key];
if(/\$$/.test(key)) {
onlyModule = true;
key = key.substr(0, key.length - 1);
@@ -146,6 +151,21 @@ exports.createResolver = function(options) {
//// pipeline ////
+ resolver.ensureHook("resolve");
+ resolver.ensureHook("parsedResolve");
+ resolver.ensureHook("describedResolve");
+ resolver.ensureHook("rawModule");
+ resolver.ensureHook("module");
+ resolver.ensureHook("relative");
+ resolver.ensureHook("describedRelative");
+ resolver.ensureHook("directory");
+ resolver.ensureHook("existingDirectory");
+ resolver.ensureHook("undescribedRawFile");
+ resolver.ensureHook("rawFile");
+ resolver.ensureHook("file");
+ resolver.ensureHook("existingFile");
+ resolver.ensureHook("resolved");
+
// resolve
if(unsafeCache) {
plugins.push(new UnsafeCachePlugin("resolve", cachePredicate, unsafeCache, cacheWithContext, "new-resolve"));
@@ -159,25 +179,26 @@ exports.createResolver = function(options) {
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) {
+ if(alias.length > 0)
+ plugins.push(new AliasPlugin("described-resolve", alias, "resolve"));
+ if(enableConcord) {
+ plugins.push(new ConcordModulesPlugin("described-resolve", {}, "resolve"));
+ }
+ aliasFields.forEach(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) {
+ moduleExtensions.forEach(item => {
plugins.push(new ModuleAppendPlugin("raw-module", item, "module"));
});
if(!enforceModuleExtension)
plugins.push(new TryNextPlugin("raw-module", null, "module"));
// module
- modules.forEach(function(item) {
+ modules.forEach(item => {
if(Array.isArray(item))
plugins.push(new ModulesInHierachicDirectoriesPlugin("module", item, "resolve"));
else
@@ -203,11 +224,13 @@ exports.createResolver = function(options) {
} else {
// existing-directory
- plugins.push(new ConcordMainPlugin("existing-directory", {}, "resolve"));
- mainFields.forEach(function(item) {
+ if(enableConcord) {
+ plugins.push(new ConcordMainPlugin("existing-directory", {}, "resolve"));
+ }
+ mainFields.forEach(item => {
plugins.push(new MainFieldPlugin("existing-directory", item, "resolve"));
});
- mainFiles.forEach(function(item) {
+ mainFiles.forEach(item => {
plugins.push(new UseFilePlugin("existing-directory", item, "undescribed-raw-file"));
});
@@ -216,19 +239,23 @@ exports.createResolver = function(options) {
plugins.push(new NextPlugin("after-undescribed-raw-file", "raw-file"));
// raw-file
- if(!enforceExtension)
+ if(!enforceExtension) {
plugins.push(new TryNextPlugin("raw-file", "no extension", "file"));
- plugins.push(new ConcordExtensionsPlugin("raw-file", {}, "file"));
- extensions.forEach(function(item) {
+ }
+ if(enableConcord) {
+ plugins.push(new ConcordExtensionsPlugin("raw-file", {}, "file"));
+ }
+ extensions.forEach(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) {
+ if(alias.length > 0)
+ plugins.push(new AliasPlugin("file", alias, "resolve"));
+ if(enableConcord) {
+ plugins.push(new ConcordModulesPlugin("file", {}, "resolve"));
+ }
+ aliasFields.forEach(item => {
plugins.push(new AliasFieldPlugin("file", item, "resolve"));
});
if(symlinks)
@@ -241,20 +268,21 @@ exports.createResolver = function(options) {
}
// resolved
- plugins.push(new ResultPlugin("resolved"));
+ plugins.push(new ResultPlugin(resolver.hooks.resolved));
//// RESOLVER ////
- plugins.forEach(function(plugin) {
- resolver.apply(plugin);
+ plugins.forEach(plugin => {
+ plugin.apply(resolver);
});
+
return resolver;
};
function mergeFilteredToArray(array, filter) {
- return array.reduce(function(array, item) {
+ return array.reduce((array, item) => {
if(filter(item)) {
- var lastElement = array[array.length - 1];
+ const lastElement = array[array.length - 1];
if(Array.isArray(lastElement)) {
lastElement.push(item);
} else {
diff --git a/node_modules/enhanced-resolve/lib/ResultPlugin.js b/node_modules/enhanced-resolve/lib/ResultPlugin.js
index 7e262cc17..3babfef88 100644
--- a/node_modules/enhanced-resolve/lib/ResultPlugin.js
+++ b/node_modules/enhanced-resolve/lib/ResultPlugin.js
@@ -2,17 +2,21 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-function ResultPlugin(source) {
- this.source = source;
-}
-module.exports = ResultPlugin;
+"use strict";
-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);
+module.exports = class ResultPlugin {
+ constructor(source) {
+ this.source = source;
+ }
+
+ apply(resolver) {
+ this.source.tapAsync("ResultPlugin", (request, resolverContext, callback) => {
+ const obj = Object.assign({}, request);
+ if(resolverContext.log) resolverContext.log("reporting result " + obj.path);
+ resolver.hooks.result.callAsync(obj, resolverContext, err => {
+ if(err) return callback(err);
+ callback(null, obj);
+ });
});
- });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/SymlinkPlugin.js b/node_modules/enhanced-resolve/lib/SymlinkPlugin.js
index 85caf36da..4aae688f7 100644
--- a/node_modules/enhanced-resolve/lib/SymlinkPlugin.js
+++ b/node_modules/enhanced-resolve/lib/SymlinkPlugin.js
@@ -1,49 +1,49 @@
-/*
- 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(paths.map(function(_, i) {
- return i;
- }), function(idx, callback) {
- fs.readlink(paths[idx], 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);
- });
- });
-};
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const getPaths = require("./getPaths");
+const forEachBail = require("./forEachBail");
+
+module.exports = class SymlinkPlugin {
+ constructor(source, target) {
+ this.source = source;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ const fs = resolver.fileSystem;
+ resolver.getHook(this.source).tapAsync("SymlinkPlugin", (request, resolveContext, callback) => {
+ const pathsResult = getPaths(request.path);
+ const pathSeqments = pathsResult.seqments;
+ const paths = pathsResult.paths;
+
+ let containsSymlink = false;
+ forEachBail.withIndex(paths, (path, idx, callback) => {
+ fs.readlink(path, (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();
+ });
+ }, (err, idx) => {
+ if(!containsSymlink) return callback();
+ const resultSeqments = typeof idx === "number" ? pathSeqments.slice(0, idx + 1) : pathSeqments.slice();
+ const result = resultSeqments.reverse().reduce((a, b) => {
+ return resolver.join(a, b);
+ });
+ const obj = Object.assign({}, request, {
+ path: result
+ });
+ resolver.doResolve(target, obj, "resolved symlink to " + result, resolveContext, callback);
+ });
+ });
+ }
+};
diff --git a/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js b/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js
index f5b26c465..19bcbff5f 100644
--- a/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js
+++ b/node_modules/enhanced-resolve/lib/SyncAsyncFileSystemDecorator.js
@@ -2,12 +2,15 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
+"use strict";
+
function SyncAsyncFileSystemDecorator(fs) {
this.fs = fs;
if(fs.statSync) {
this.stat = function(arg, callback) {
+ let result;
try {
- var result = fs.statSync(arg);
+ result = fs.statSync(arg);
} catch(e) {
return callback(e);
}
@@ -16,8 +19,9 @@ function SyncAsyncFileSystemDecorator(fs) {
}
if(fs.readdirSync) {
this.readdir = function(arg, callback) {
+ let result;
try {
- var result = fs.readdirSync(arg);
+ result = fs.readdirSync(arg);
} catch(e) {
return callback(e);
}
@@ -26,8 +30,9 @@ function SyncAsyncFileSystemDecorator(fs) {
}
if(fs.readFileSync) {
this.readFile = function(arg, callback) {
+ let result;
try {
- var result = fs.readFileSync(arg);
+ result = fs.readFileSync(arg);
} catch(e) {
return callback(e);
}
@@ -36,8 +41,9 @@ function SyncAsyncFileSystemDecorator(fs) {
}
if(fs.readlinkSync) {
this.readlink = function(arg, callback) {
+ let result;
try {
- var result = fs.readlinkSync(arg);
+ result = fs.readlinkSync(arg);
} catch(e) {
return callback(e);
}
@@ -46,8 +52,9 @@ function SyncAsyncFileSystemDecorator(fs) {
}
if(fs.readJsonSync) {
this.readJson = function(arg, callback) {
+ let result;
try {
- var result = fs.readJsonSync(arg);
+ result = fs.readJsonSync(arg);
} catch(e) {
return callback(e);
}
diff --git a/node_modules/enhanced-resolve/lib/TryNextPlugin.js b/node_modules/enhanced-resolve/lib/TryNextPlugin.js
index e4c9f9c0f..c81539d30 100644
--- a/node_modules/enhanced-resolve/lib/TryNextPlugin.js
+++ b/node_modules/enhanced-resolve/lib/TryNextPlugin.js
@@ -2,17 +2,19 @@
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;
+"use strict";
-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);
- });
+module.exports = class TryNextPlugin {
+ constructor(source, message, target) {
+ this.source = source;
+ this.message = message;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("TryNextPlugin", (request, resolveContext, callback) => {
+ resolver.doResolve(target, request, this.message, resolveContext, callback);
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js b/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js
index ed07fd561..9a80b3209 100644
--- a/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js
+++ b/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js
@@ -2,16 +2,7 @@
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;
+"use strict";
function getCacheId(request, withContext) {
return JSON.stringify({
@@ -22,22 +13,29 @@ function getCacheId(request, withContext) {
});
}
-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));
- });
+module.exports = class UnsafeCachePlugin {
+ constructor(source, filterPredicate, cache, withContext, target) {
+ this.source = source;
+ this.filterPredicate = filterPredicate;
+ this.withContext = withContext;
+ this.cache = cache || {};
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("UnsafeCachePlugin", (request, resolveContext, callback) => {
+ if(!this.filterPredicate(request)) return callback();
+ const cacheId = getCacheId(request, this.withContext);
+ const cacheEntry = this.cache[cacheId];
+ if(cacheEntry) {
+ return callback(null, cacheEntry);
+ }
+ resolver.doResolve(target, request, null, resolveContext, (err, result) => {
+ if(err) return callback(err);
+ if(result) return callback(null, this.cache[cacheId] = result);
+ callback();
+ });
+ });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/UseFilePlugin.js b/node_modules/enhanced-resolve/lib/UseFilePlugin.js
index 2413824f4..3c7b02684 100644
--- a/node_modules/enhanced-resolve/lib/UseFilePlugin.js
+++ b/node_modules/enhanced-resolve/lib/UseFilePlugin.js
@@ -2,22 +2,24 @@
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;
+"use strict";
-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)
+module.exports = class UseFilePlugin {
+ constructor(source, filename, target) {
+ this.source = source;
+ this.filename = filename;
+ this.target = target;
+ }
+
+ apply(resolver) {
+ const target = resolver.ensureHook(this.target);
+ resolver.getHook(this.source).tapAsync("UseFilePlugin", (request, resolveContext, callback) => {
+ const filePath = resolver.join(request.path, this.filename);
+ const obj = Object.assign({}, request, {
+ path: filePath,
+ relativePath: request.relativePath && resolver.join(request.relativePath, this.filename)
+ });
+ resolver.doResolve(target, obj, "using path: " + filePath, resolveContext, callback);
});
- resolver.doResolve(target, obj, "using path: " + filePath, callback);
- });
+ }
};
diff --git a/node_modules/enhanced-resolve/lib/concord.js b/node_modules/enhanced-resolve/lib/concord.js
index c8db37940..8327095ed 100644
--- a/node_modules/enhanced-resolve/lib/concord.js
+++ b/node_modules/enhanced-resolve/lib/concord.js
@@ -2,11 +2,13 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var globToRegExp = require("./globToRegExp").globToRegExp;
+"use strict";
+
+const globToRegExp = require("./globToRegExp").globToRegExp;
function parseType(type) {
- var items = type.split("+");
- var t = items.shift();
+ const items = type.split("+");
+ const t = items.shift();
return {
type: t === "*" ? null : t,
features: items
@@ -17,7 +19,7 @@ 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 testedType.features.every(requiredFeature => {
return baseType.features.indexOf(requiredFeature) >= 0;
});
}
@@ -26,7 +28,7 @@ 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++) {
+ for(let i = 0; i < baseType.length; i++) {
if(!isTypeMatched(baseType[i], testedType[i]))
return false;
}
@@ -34,26 +36,26 @@ function isResourceTypeMatched(baseType, testedType) {
}
function isResourceTypeSupported(context, type) {
- return context.supportedResourceTypes && context.supportedResourceTypes.some(function(supportedType) {
+ return context.supportedResourceTypes && context.supportedResourceTypes.some(supportedType => {
return isResourceTypeMatched(supportedType, type);
});
}
function isEnvironment(context, env) {
- return context.environments && context.environments.every(function(environment) {
+ return context.environments && context.environments.every(environment => {
return isTypeMatched(environment, env);
});
}
-var globCache = {};
+const globCache = {};
function getGlobRegExp(glob) {
- var regExp = globCache[glob] || (globCache[glob] = globToRegExp(glob));
+ const regExp = globCache[glob] || (globCache[glob] = globToRegExp(glob));
return regExp;
}
function matchGlob(glob, relativePath) {
- var regExp = getGlobRegExp(glob);
+ const regExp = getGlobRegExp(glob);
return regExp.exec(relativePath);
}
@@ -62,16 +64,16 @@ function isGlobMatched(glob, relativePath) {
}
function isConditionMatched(context, condition) {
- var items = condition.split("|");
+ const items = condition.split("|");
return items.some(function testFn(item) {
item = item.trim();
- var inverted = /^!/.test(item);
+ const 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];
+ const match = /^([a-z]+):\s*/.exec(item);
+ const value = item.substr(match[0].length);
+ const name = match[1];
switch(name) {
case "referrer":
return isGlobMatched(value, context.referrer);
@@ -90,10 +92,10 @@ function isConditionMatched(context, condition) {
function isKeyMatched(context, key) {
while(true) { //eslint-disable-line
- var match = /^\[([^\]]+)\]\s*/.exec(key);
+ const match = /^\[([^\]]+)\]\s*/.exec(key);
if(!match) return key;
key = key.substr(match[0].length);
- var condition = match[1];
+ const condition = match[1];
if(!isConditionMatched(context, condition)) {
return false;
}
@@ -101,9 +103,9 @@ function isKeyMatched(context, key) {
}
function getField(context, configuration, field) {
- var value;
- Object.keys(configuration).forEach(function(key) {
- var pureKey = isKeyMatched(context, key);
+ let value;
+ Object.keys(configuration).forEach(key => {
+ const pureKey = isKeyMatched(context, key);
if(pureKey === field) {
value = configuration[key];
}
@@ -120,23 +122,25 @@ function getExtensions(context, configuration) {
}
function matchModule(context, configuration, request) {
- var modulesField = getField(context, configuration, "modules");
+ const 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);
+ let newRequest = request;
+ const keys = Object.keys(modulesField);
+ let iteration = 0;
+ let match;
+ let index;
+ for(let i = 0; i < keys.length; i++) {
+ const key = keys[i];
+ const pureKey = isKeyMatched(context, key);
+ match = matchGlob(pureKey, newRequest);
if(match) {
- var value = modulesField[key];
+ const value = modulesField[key];
if(typeof value !== "string") {
return value;
} else if(/^\(.+\)$/.test(pureKey)) {
newRequest = newRequest.replace(getGlobRegExp(pureKey), value);
} else {
- var index = 1;
+ index = 1;
newRequest = value.replace(/(\/?\*)?\*/g, replaceMatcher);
}
i = -1;
@@ -150,8 +154,10 @@ function matchModule(context, configuration, request) {
function replaceMatcher(find) {
switch(find) {
case "/**":
- var m = match[index++];
- return m ? "/" + m : "";
+ {
+ const m = match[index++];
+ return m ? "/" + m : "";
+ }
case "**":
case "*":
return match[index++];
@@ -160,13 +166,13 @@ function matchModule(context, configuration, request) {
}
function matchType(context, configuration, relativePath) {
- var typesField = getField(context, configuration, "types");
+ const typesField = getField(context, configuration, "types");
if(!typesField) return undefined;
- var type;
- Object.keys(typesField).forEach(function(key) {
- var pureKey = isKeyMatched(context, key);
+ let type;
+ Object.keys(typesField).forEach(key => {
+ const pureKey = isKeyMatched(context, key);
if(isGlobMatched(pureKey, relativePath)) {
- var value = typesField[key];
+ const 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);
diff --git a/node_modules/enhanced-resolve/lib/createInnerCallback.js b/node_modules/enhanced-resolve/lib/createInnerCallback.js
index 0acea4662..c7252584d 100644
--- a/node_modules/enhanced-resolve/lib/createInnerCallback.js
+++ b/node_modules/enhanced-resolve/lib/createInnerCallback.js
@@ -1,41 +1,47 @@
-/*
- 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;
-};
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const util = require("util");
+
+// TODO remove in enhanced-resolve 5
+module.exports = util.deprecate(function createInnerCallback(callback, options, message, messageOptional) {
+ const log = options.log;
+ if(!log) {
+ if(options.stack !== callback.stack) {
+ const callbackWrapper = function callbackWrapper() {
+ return callback.apply(this, arguments);
+ };
+ callbackWrapper.stack = options.stack;
+ callbackWrapper.missing = options.missing;
+ return callbackWrapper;
+ }
+ return callback;
+ }
+
+ function loggingCallbackWrapper() {
+ return callback.apply(this, arguments);
+
+ }
+ if(message) {
+ if(!messageOptional) {
+ log(message);
+ }
+ loggingCallbackWrapper.log = function writeLog(msg) {
+ if(messageOptional) {
+ log(message);
+ messageOptional = false;
+ }
+ log(" " + msg);
+ };
+ } else {
+ loggingCallbackWrapper.log = function writeLog(msg) {
+ log(msg);
+ };
+ }
+ loggingCallbackWrapper.stack = options.stack;
+ loggingCallbackWrapper.missing = options.missing;
+ return loggingCallbackWrapper;
+}, "Pass resolveContext instead and use createInnerContext");
diff --git a/node_modules/enhanced-resolve/lib/forEachBail.js b/node_modules/enhanced-resolve/lib/forEachBail.js
index ce0893160..c99f7fd04 100644
--- a/node_modules/enhanced-resolve/lib/forEachBail.js
+++ b/node_modules/enhanced-resolve/lib/forEachBail.js
@@ -1,34 +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;
- }
- };
- }
-};
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+module.exports = function forEachBail(array, iterator, callback) {
+ if(array.length === 0) return callback();
+ let currentPos = array.length;
+ let currentResult;
+ let done = [];
+ for(let i = 0; i < array.length; i++) {
+ const itCb = createIteratorCallback(i);
+ iterator(array[i], itCb);
+ if(currentPos === 0) break;
+ }
+
+ function createIteratorCallback(i) {
+ return(...args) => { // eslint-disable-line
+ if(i >= currentPos) return; // ignore
+ done.push(i);
+ if(args.length > 0) {
+ currentPos = i + 1;
+ done = done.filter(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();
+ let currentPos = array.length;
+ let currentResult;
+ let done = [];
+ for(let i = 0; i < array.length; i++) {
+ const itCb = createIteratorCallback(i);
+ iterator(array[i], i, itCb);
+ if(currentPos === 0) break;
+ }
+
+ function createIteratorCallback(i) {
+ return(...args) => { // eslint-disable-line
+ if(i >= currentPos) return; // ignore
+ done.push(i);
+ if(args.length > 0) {
+ currentPos = i + 1;
+ done = done.filter(item => {
+ return item <= i;
+ });
+ currentResult = args;
+ }
+ if(done.length === currentPos) {
+ callback.apply(null, currentResult);
+ currentPos = 0;
+ }
+ };
+ }
+};
diff --git a/node_modules/enhanced-resolve/lib/getInnerRequest.js b/node_modules/enhanced-resolve/lib/getInnerRequest.js
index 3f6ac148c..06f956dd9 100644
--- a/node_modules/enhanced-resolve/lib/getInnerRequest.js
+++ b/node_modules/enhanced-resolve/lib/getInnerRequest.js
@@ -2,12 +2,14 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
+"use strict";
+
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;
+ let innerRequest;
if(request.request) {
innerRequest = request.request;
if(/^\.\.?\//.test(innerRequest) && request.relativePath) {
diff --git a/node_modules/enhanced-resolve/lib/getPaths.js b/node_modules/enhanced-resolve/lib/getPaths.js
index 695fbcd5f..c1bd787e9 100644
--- a/node_modules/enhanced-resolve/lib/getPaths.js
+++ b/node_modules/enhanced-resolve/lib/getPaths.js
@@ -1,33 +1,35 @@
-/*
- 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;
-};
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+module.exports = function getPaths(path) {
+ const parts = path.split(/(.*?[\\\/]+)/);
+ const paths = [path];
+ const seqments = [parts[parts.length - 1]];
+ let part = parts[parts.length - 1];
+ path = path.substr(0, path.length - part.length - 1);
+ for(let i = parts.length - 2; i > 2; i -= 2) {
+ paths.push(path);
+ part = parts[i];
+ path = path.substr(0, path.length - part.length) || "/";
+ seqments.push(part.substr(0, part.length - 1));
+ }
+ part = parts[1];
+ seqments.push(part);
+ paths.push(part);
+ return {
+ paths: paths,
+ seqments: seqments
+ };
+};
+
+module.exports.basename = function basename(path) {
+ const i = path.lastIndexOf("/"),
+ j = path.lastIndexOf("\\");
+ const p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
+ if(p < 0) return null;
+ const s = path.substr(p + 1);
+ return s;
+};
diff --git a/node_modules/enhanced-resolve/lib/globToRegExp.js b/node_modules/enhanced-resolve/lib/globToRegExp.js
index 7b97a6924..296e9bc87 100644
--- a/node_modules/enhanced-resolve/lib/globToRegExp.js
+++ b/node_modules/enhanced-resolve/lib/globToRegExp.js
@@ -2,6 +2,8 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
+"use strict";
+
function globToRegExp(glob) {
// * [^\\\/]*
// /**/ /.+/
@@ -19,13 +21,13 @@ function globToRegExp(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("");
+ const tokens = tokenize(glob);
+ const process = createRoot();
+ const regExpStr = tokens.map(process).join("");
return new RegExp("^" + regExpStr + "$");
}
-var SIMPLE_TOKENS = {
+const SIMPLE_TOKENS = {
"@(": "one",
"?(": "zero-one",
"+(": "one-many",
@@ -43,10 +45,10 @@ var SIMPLE_TOKENS = {
};
function tokenize(glob) {
- return glob.split(/([@?+*]\(|\/\*\*\/|\*\*|[?*]|\[[\!\^]?(?:[^\]\\]|\\.)+\]|\{|,|\/|[|)}])/g).map(function(item) {
+ return glob.split(/([@?+*]\(|\/\*\*\/|\*\*|[?*]|\[[\!\^]?(?:[^\]\\]|\\.)+\]|\{|,|\/|[|)}])/g).map(item => {
if(!item)
return null;
- var t = SIMPLE_TOKENS[item];
+ const t = SIMPLE_TOKENS[item];
if(t) {
return {
type: t
@@ -75,9 +77,9 @@ function tokenize(glob) {
}
function createRoot() {
- var inOr = [];
- var process = createSeqment();
- var initial = true;
+ const inOr = [];
+ const process = createSeqment();
+ let initial = true;
return function(token) {
switch(token.type) {
case "or":
@@ -103,16 +105,18 @@ function createRoot() {
throw new Error("Unmatched '{'");
return process(token, initial);
default:
- var result = process(token, initial);
- initial = false;
- return result;
+ {
+ const result = process(token, initial);
+ initial = false;
+ return result;
+ }
}
};
}
function createSeqment() {
- var inSeqment = [];
- var process = createSimple();
+ const inSeqment = [];
+ const process = createSimple();
return function(token, initial) {
switch(token.type) {
case "one":
@@ -131,18 +135,20 @@ function createSeqment() {
}, 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 ")?";
+ {
+ const 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);
}
- throw new Error("Unexcepted segment " + segment);
case "end":
if(inSeqment.length > 0) {
throw new Error("Unmatched segment, missing ')'");
diff --git a/node_modules/enhanced-resolve/lib/node.js b/node_modules/enhanced-resolve/lib/node.js
index 1e79cdc25..c47708d8a 100644
--- a/node_modules/enhanced-resolve/lib/node.js
+++ b/node_modules/enhanced-resolve/lib/node.js
@@ -2,34 +2,40 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var ResolverFactory = require("./ResolverFactory");
+"use strict";
-var NodeJsInputFileSystem = require("./NodeJsInputFileSystem");
-var CachedInputFileSystem = require("./CachedInputFileSystem");
+const ResolverFactory = require("./ResolverFactory");
-var nodeFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 4000);
+const NodeJsInputFileSystem = require("./NodeJsInputFileSystem");
+const CachedInputFileSystem = require("./CachedInputFileSystem");
-var nodeContext = {
+const nodeFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 4000);
+
+const nodeContext = {
environments: [
"node+es3+es5+process+native"
]
};
-var asyncResolver = ResolverFactory.createResolver({
+const asyncResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
fileSystem: nodeFileSystem
});
-module.exports = function resolve(context, path, request, callback) {
+module.exports = function resolve(context, path, request, resolveContext, callback) {
if(typeof context === "string") {
- callback = request;
+ callback = resolveContext;
+ resolveContext = request;
request = path;
path = context;
context = nodeContext;
}
- asyncResolver.resolve(context, path, request, callback);
+ if(typeof callback !== "function") {
+ callback = resolveContext;
+ }
+ asyncResolver.resolve(context, path, request, resolveContext, callback);
};
-var syncResolver = ResolverFactory.createResolver({
+const syncResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
useSyncFileSystemCalls: true,
fileSystem: nodeFileSystem
@@ -43,22 +49,26 @@ module.exports.sync = function resolveSync(context, path, request) {
return syncResolver.resolveSync(context, path, request);
};
-var asyncContextResolver = ResolverFactory.createResolver({
+const asyncContextResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
resolveToContext: true,
fileSystem: nodeFileSystem
});
-module.exports.context = function resolveContext(context, path, request, callback) {
+module.exports.context = function resolveContext(context, path, request, resolveContext, callback) {
if(typeof context === "string") {
- callback = request;
+ callback = resolveContext;
+ resolveContext = request;
request = path;
path = context;
context = nodeContext;
}
- asyncContextResolver.resolve(context, path, request, callback);
+ if(typeof callback !== "function") {
+ callback = resolveContext;
+ }
+ asyncContextResolver.resolve(context, path, request, resolveContext, callback);
};
-var syncContextResolver = ResolverFactory.createResolver({
+const syncContextResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
resolveToContext: true,
useSyncFileSystemCalls: true,
@@ -73,23 +83,27 @@ module.exports.context.sync = function resolveContextSync(context, path, request
return syncContextResolver.resolveSync(context, path, request);
};
-var asyncLoaderResolver = ResolverFactory.createResolver({
+const asyncLoaderResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
moduleExtensions: ["-loader"],
mainFields: ["loader", "main"],
fileSystem: nodeFileSystem
});
-module.exports.loader = function resolveLoader(context, path, request, callback) {
+module.exports.loader = function resolveLoader(context, path, request, resolveContext, callback) {
if(typeof context === "string") {
- callback = request;
+ callback = resolveContext;
+ resolveContext = request;
request = path;
path = context;
context = nodeContext;
}
- asyncLoaderResolver.resolve(context, path, request, callback);
+ if(typeof callback !== "function") {
+ callback = resolveContext;
+ }
+ asyncLoaderResolver.resolve(context, path, request, resolveContext, callback);
};
-var syncLoaderResolver = ResolverFactory.createResolver({
+const syncLoaderResolver = ResolverFactory.createResolver({
extensions: [".js", ".json", ".node"],
moduleExtensions: ["-loader"],
mainFields: ["loader", "main"],
@@ -109,15 +123,19 @@ module.exports.create = function create(options) {
options = Object.assign({
fileSystem: nodeFileSystem
}, options);
- var resolver = ResolverFactory.createResolver(options);
- return function(context, path, request, callback) {
+ const resolver = ResolverFactory.createResolver(options);
+ return function(context, path, request, resolveContext, callback) {
if(typeof context === "string") {
- callback = request;
+ callback = resolveContext;
+ resolveContext = request;
request = path;
path = context;
context = nodeContext;
}
- resolver.resolve(context, path, request, callback);
+ if(typeof callback !== "function") {
+ callback = resolveContext;
+ }
+ resolver.resolve(context, path, request, resolveContext, callback);
};
};
@@ -126,7 +144,7 @@ module.exports.create.sync = function createSync(options) {
useSyncFileSystemCalls: true,
fileSystem: nodeFileSystem
}, options);
- var resolver = ResolverFactory.createResolver(options);
+ const resolver = ResolverFactory.createResolver(options);
return function(context, path, request) {
if(typeof context === "string") {
request = path;
diff --git a/node_modules/enhanced-resolve/package.json b/node_modules/enhanced-resolve/package.json
index 74c95f18d..a5c3ef008 100644
--- a/node_modules/enhanced-resolve/package.json
+++ b/node_modules/enhanced-resolve/package.json
@@ -1,16 +1,16 @@
{
"name": "enhanced-resolve",
- "version": "3.3.0",
+ "version": "4.1.0",
"author": "Tobias Koppers @sokra",
"description": "Offers a async require.resolve function. It's highly configurable.",
"files": [
- "lib"
+ "lib",
+ "LICENSE"
],
"dependencies": {
"graceful-fs": "^4.1.2",
"memory-fs": "^0.4.0",
- "object-assign": "^4.0.1",
- "tapable": "^0.2.5"
+ "tapable": "^1.0.0"
},
"licenses": [
{
@@ -31,7 +31,7 @@
"should": "^8.0.2"
},
"engines": {
- "node": ">=4.3.0 <5.0.0 || >=5.10"
+ "node": ">=6.9.0"
},
"main": "lib/node.js",
"homepage": "http://github.com/webpack/enhanced-resolve",