diff options
Diffstat (limited to 'node_modules/webpack/lib')
33 files changed, 558 insertions, 230 deletions
diff --git a/node_modules/webpack/lib/BannerPlugin.js b/node_modules/webpack/lib/BannerPlugin.js index c37a0d3ca..342a30328 100644 --- a/node_modules/webpack/lib/BannerPlugin.js +++ b/node_modules/webpack/lib/BannerPlugin.js @@ -8,10 +8,10 @@ const ConcatSource = require("webpack-sources").ConcatSource;
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
-function wrapComment(str) {
+const wrapComment = (str) => {
if(!str.includes("\n")) return `/*! ${str} */`;
return `/*!\n * ${str.split("\n").join("\n * ")}\n */`;
-}
+};
class BannerPlugin {
constructor(options) {
@@ -33,14 +33,36 @@ class BannerPlugin { compilation.plugin("optimize-chunk-assets", (chunks, callback) => {
chunks.forEach((chunk) => {
if(options.entryOnly && !chunk.isInitial()) return;
-
chunk.files
.filter(ModuleFilenameHelpers.matchObject.bind(undefined, options))
- .forEach((file) =>
- compilation.assets[file] = new ConcatSource(
- banner, "\n", compilation.assets[file]
- )
- );
+ .forEach((file) => {
+ let basename;
+ let query = "";
+ let filename = file;
+ const hash = compilation.hash;
+ const querySplit = filename.indexOf("?");
+
+ if(querySplit >= 0) {
+ query = filename.substr(querySplit);
+ filename = filename.substr(0, querySplit);
+ }
+
+ if(filename.indexOf("/") < 0) {
+ basename = filename;
+ } else {
+ basename = filename.substr(filename.lastIndexOf("/") + 1);
+ }
+
+ const comment = compilation.getPath(banner, {
+ hash,
+ chunk,
+ filename,
+ basename,
+ query,
+ });
+
+ return compilation.assets[file] = new ConcatSource(comment, "\n", compilation.assets[file]);
+ });
});
callback();
});
diff --git a/node_modules/webpack/lib/Compilation.js b/node_modules/webpack/lib/Compilation.js index 233ddd387..4ac48da50 100644 --- a/node_modules/webpack/lib/Compilation.js +++ b/node_modules/webpack/lib/Compilation.js @@ -14,7 +14,6 @@ const ModuleDependencyError = require("./ModuleDependencyError"); const Module = require("./Module");
const Chunk = require("./Chunk");
const Entrypoint = require("./Entrypoint");
-const Stats = require("./Stats");
const MainTemplate = require("./MainTemplate");
const ChunkTemplate = require("./ChunkTemplate");
const HotUpdateChunkTemplate = require("./HotUpdateChunkTemplate");
@@ -22,6 +21,7 @@ const ModuleTemplate = require("./ModuleTemplate"); const Dependency = require("./Dependency");
const ChunkRenderError = require("./ChunkRenderError");
const CachedSource = require("webpack-sources").CachedSource;
+const Stats = require("./Stats");
function byId(a, b) {
if(a.id < b.id) return -1;
@@ -82,6 +82,10 @@ class Compilation extends Tapable { this.dependencyTemplates = new Map();
}
+ getStats() {
+ return new Stats(this);
+ }
+
templatesPlugin(name, fn) {
this.mainTemplate.plugin(name, fn);
this.chunkTemplate.plugin(name, fn);
@@ -197,7 +201,7 @@ class Compilation extends Tapable { addModuleDependencies(module, dependencies, bail, cacheGroup, recursive, callback) {
let _this = this;
- const start = _this.profile && +new Date();
+ const start = _this.profile && Date.now();
const factories = [];
for(let i = 0; i < dependencies.length; i++) {
@@ -266,7 +270,7 @@ class Compilation extends Tapable { if(!dependentModule.profile) {
dependentModule.profile = {};
}
- afterFactory = +new Date();
+ afterFactory = Date.now();
dependentModule.profile.factory = afterFactory - start;
}
@@ -286,7 +290,7 @@ class Compilation extends Tapable { if(!module.profile) {
module.profile = {};
}
- const time = +new Date() - start;
+ const time = Date.now() - start;
if(!module.profile.dependencies || time > module.profile.dependencies) {
module.profile.dependencies = time;
}
@@ -307,7 +311,7 @@ class Compilation extends Tapable { iterationDependencies(dependencies);
if(_this.profile) {
- const afterBuilding = +new Date();
+ const afterBuilding = Date.now();
module.profile.building = afterBuilding - afterFactory;
}
@@ -328,7 +332,7 @@ class Compilation extends Tapable { }
if(_this.profile) {
- const afterBuilding = +new Date();
+ const afterBuilding = Date.now();
dependentModule.profile.building = afterBuilding - afterFactory;
}
@@ -356,7 +360,7 @@ class Compilation extends Tapable { }
_addModuleChain(context, dependency, onModule, callback) {
- const start = this.profile && +new Date();
+ const start = this.profile && Date.now();
const errorAndCallback = this.bail ? function errorAndCallback(err) {
callback(err);
@@ -393,7 +397,7 @@ class Compilation extends Tapable { if(!module.profile) {
module.profile = {};
}
- afterFactory = +new Date();
+ afterFactory = Date.now();
module.profile.factory = afterFactory - start;
}
@@ -404,7 +408,7 @@ class Compilation extends Tapable { onModule(module);
if(this.profile) {
- const afterBuilding = +new Date();
+ const afterBuilding = Date.now();
module.profile.building = afterBuilding - afterFactory;
}
@@ -432,7 +436,7 @@ class Compilation extends Tapable { }
if(this.profile) {
- const afterBuilding = +new Date();
+ const afterBuilding = Date.now();
module.profile.building = afterBuilding - afterFactory;
}
@@ -1214,10 +1218,6 @@ class Compilation extends Tapable { return this.mainTemplate.applyPluginsWaterfall("asset-path", filename, data);
}
- getStats() {
- return new Stats(this);
- }
-
createChildCompiler(name, outputOptions) {
return this.compiler.createChildCompiler(this, name, outputOptions);
}
diff --git a/node_modules/webpack/lib/Compiler.js b/node_modules/webpack/lib/Compiler.js index d9fa3d34b..dc17a89f3 100644 --- a/node_modules/webpack/lib/Compiler.js +++ b/node_modules/webpack/lib/Compiler.js @@ -6,15 +6,13 @@ var path = require("path"); var Tapable = require("tapable");
var Compilation = require("./Compilation");
-
+var Stats = require("./Stats");
var NormalModuleFactory = require("./NormalModuleFactory");
var ContextModuleFactory = require("./ContextModuleFactory");
function Watching(compiler, watchOptions, handler) {
this.startTime = null;
this.invalid = false;
- this.error = null;
- this.stats = null;
this.handler = handler;
this.closed = false;
if(typeof watchOptions === "number") {
@@ -38,7 +36,7 @@ function Watching(compiler, watchOptions, handler) { Watching.prototype._go = function() {
var self = this;
- self.startTime = new Date().getTime();
+ self.startTime = Date.now();
self.running = true;
self.invalid = false;
self.compiler.applyPluginsAsync("watch-run", self, function(err) {
@@ -61,9 +59,9 @@ Watching.prototype._go = function() { if(compilation.applyPluginsBailResult("need-additional-pass")) {
compilation.needAdditionalPass = true;
- var stats = compilation.getStats();
+ var stats = new Stats(compilation);
stats.startTime = self.startTime;
- stats.endTime = new Date().getTime();
+ stats.endTime = Date.now();
self.compiler.applyPlugins("done", stats);
self.compiler.applyPluginsAsync("additional-pass", function(err) {
@@ -79,22 +77,29 @@ Watching.prototype._go = function() { });
};
+Watching.prototype._getStats = function(compilation) {
+ var stats = new Stats(compilation);
+ stats.startTime = this.startTime;
+ stats.endTime = Date.now();
+ return stats;
+};
+
Watching.prototype._done = function(err, compilation) {
this.running = false;
if(this.invalid) return this._go();
- this.error = err || null;
- this.stats = compilation ? compilation.getStats() : null;
- if(this.stats) {
- this.stats.startTime = this.startTime;
- this.stats.endTime = new Date().getTime();
+
+ var stats = compilation ? this._getStats(compilation) : null;
+ if(err) {
+ this.compiler.applyPlugins("failed", err);
+ this.handler(err, stats);
+ return;
}
- if(this.stats)
- this.compiler.applyPlugins("done", this.stats);
- else
- this.compiler.applyPlugins("failed", this.error);
- this.handler(this.error, this.stats);
- if(!this.error && !this.closed)
+
+ this.compiler.applyPlugins("done", stats);
+ this.handler(null, stats);
+ if(!this.closed) {
this.watch(compilation.fileDependencies, compilation.contextDependencies, compilation.missingDependencies);
+ }
};
Watching.prototype.watch = function(files, dirs, missing) {
@@ -217,7 +222,7 @@ Compiler.prototype.watch = function(watchOptions, handler) { Compiler.prototype.run = function(callback) {
var self = this;
- var startTime = new Date().getTime();
+ var startTime = Date.now();
self.applyPluginsAsync("before-run", self, function(err) {
if(err) return callback(err);
@@ -232,9 +237,9 @@ Compiler.prototype.run = function(callback) { if(err) return callback(err);
if(self.applyPluginsBailResult("should-emit", compilation) === false) {
- var stats = compilation.getStats();
+ var stats = new Stats(compilation);
stats.startTime = startTime;
- stats.endTime = new Date().getTime();
+ stats.endTime = Date.now();
self.applyPlugins("done", stats);
return callback(null, stats);
}
@@ -245,9 +250,9 @@ Compiler.prototype.run = function(callback) { if(compilation.applyPluginsBailResult("need-additional-pass")) {
compilation.needAdditionalPass = true;
- var stats = compilation.getStats();
+ var stats = new Stats(compilation);
stats.startTime = startTime;
- stats.endTime = new Date().getTime();
+ stats.endTime = Date.now();
self.applyPlugins("done", stats);
self.applyPluginsAsync("additional-pass", function(err) {
@@ -260,9 +265,9 @@ Compiler.prototype.run = function(callback) { self.emitRecords(function(err) {
if(err) return callback(err);
- var stats = compilation.getStats();
+ var stats = new Stats(compilation);
stats.startTime = startTime;
- stats.endTime = new Date().getTime();
+ stats.endTime = Date.now();
self.applyPlugins("done", stats);
return callback(null, stats);
});
diff --git a/node_modules/webpack/lib/ContextModule.js b/node_modules/webpack/lib/ContextModule.js index ee7228bac..9771fcd80 100644 --- a/node_modules/webpack/lib/ContextModule.js +++ b/node_modules/webpack/lib/ContextModule.js @@ -8,16 +8,18 @@ const Module = require("./Module"); const OriginalSource = require("webpack-sources").OriginalSource;
const RawSource = require("webpack-sources").RawSource;
const AsyncDependenciesBlock = require("./AsyncDependenciesBlock");
+const DepBlockHelpers = require("./dependencies/DepBlockHelpers");
+const Template = require("./Template");
class ContextModule extends Module {
- constructor(resolveDependencies, context, recursive, regExp, addon, isAsync, chunkName) {
+ constructor(resolveDependencies, context, recursive, regExp, addon, asyncMode, chunkName) {
super();
this.resolveDependencies = resolveDependencies;
this.context = context;
this.recursive = recursive;
this.regExp = regExp;
this.addon = addon;
- this.async = !!isAsync;
+ this.async = asyncMode;
this.cacheable = true;
this.contextDependencies = [context];
this.built = false;
@@ -44,7 +46,7 @@ class ContextModule extends Module { identifier() {
let identifier = this.context;
if(this.async)
- identifier += " async";
+ identifier += ` ${this.async}`;
if(!this.recursive)
identifier += " nonrecursive";
if(this.addon)
@@ -58,7 +60,7 @@ class ContextModule extends Module { readableIdentifier(requestShortener) {
let identifier = requestShortener.shorten(this.context);
if(this.async)
- identifier += " async";
+ identifier += ` ${this.async}`;
if(!this.recursive)
identifier += " nonrecursive";
if(this.addon)
@@ -72,7 +74,7 @@ class ContextModule extends Module { libIdent(options) {
let identifier = this.contextify(options.context, this.context);
if(this.async)
- identifier += " async";
+ identifier += ` ${this.async}`;
if(this.recursive)
identifier += " recursive";
if(this.addon)
@@ -99,46 +101,71 @@ class ContextModule extends Module { build(options, compilation, resolver, fs, callback) {
this.built = true;
- this.builtTime = new Date().getTime();
+ this.builtTime = Date.now();
this.resolveDependencies(fs, this.context, this.recursive, this.regExp, (err, dependencies) => {
if(err) return callback(err);
+ // Reset children
+ this.dependencies = [];
+ this.blocks = [];
+
+ // abort if something failed
+ // this will create an empty context
if(!dependencies) {
- this.dependencies = [];
callback();
return;
}
- // enhance dependencies
+ // enhance dependencies with meta info
dependencies.forEach(dep => {
dep.loc = dep.userRequest;
dep.request = this.addon + dep.request;
});
- // if these we are not a async context
- // add dependencies and continue
- if(!this.async) {
+ if(!this.async || this.async === "eager") {
+
+ // if we have an sync or eager context
+ // just add all dependencies and continue
this.dependencies = dependencies;
- callback();
- return;
- }
- // if we are async however create a new async dependency block
- // and add that block to this context
- dependencies.forEach(dep => {
- const block = new AsyncDependenciesBlock(this.chunkName, dep.module, dep.loc);
- block.addDependency(dep);
- this.addBlock(block);
- });
+ } else if(this.async === "lazy-once") {
+
+ // for the lazy-once mode create a new async dependency block
+ // and add that block to this context
+ if(dependencies.length > 0) {
+ const block = new AsyncDependenciesBlock(this.chunkName, this);
+ dependencies.forEach(dep => {
+ block.addDependency(dep);
+ });
+ this.addBlock(block);
+ }
+
+ } else {
+
+ // if we are lazy create a new async dependency block per dependency
+ // and add all blocks to this context
+ dependencies.forEach((dep, idx) => {
+ let chunkName = this.chunkName;
+ if(chunkName) {
+ if(!/\[(index|request)\]/.test(chunkName))
+ chunkName += "[index]";
+ chunkName = chunkName.replace(/\[index\]/g, idx);
+ chunkName = chunkName.replace(/\[request\]/g, Template.toPath(dep.userRequest));
+ }
+ const block = new AsyncDependenciesBlock(chunkName, dep.module, dep.loc);
+ block.addDependency(dep);
+ this.addBlock(block);
+ });
+ }
callback();
});
}
- getSourceWithDependencies(dependencies, id) {
+ getUserRequestMap(dependencies) {
// if we filter first we get a new array
// therefor we dont need to create a clone of dependencies explicitly
// therefore the order of this is !important!
- const map = dependencies
+ return dependencies
.filter(dependency => dependency.module)
.sort((a, b) => {
if(a.userRequest === b.userRequest) {
@@ -149,6 +176,10 @@ class ContextModule extends Module { map[dep.userRequest] = dep.module.id;
return map;
}, Object.create(null));
+ }
+
+ getSyncSource(dependencies, id) {
+ const map = this.getUserRequestMap(dependencies);
return `var map = ${JSON.stringify(map, null, "\t")};
function webpackContext(req) {
return __webpack_require__(webpackContextResolve(req));
@@ -167,7 +198,53 @@ module.exports = webpackContext; webpackContext.id = ${JSON.stringify(id)};`;
}
- getSourceWithBlocks(blocks, id) {
+ getEagerSource(dependencies, id) {
+ const map = this.getUserRequestMap(dependencies);
+ return `var map = ${JSON.stringify(map, null, "\t")};
+function webpackAsyncContext(req) {
+ return webpackAsyncContextResolve(req).then(__webpack_require__);
+};
+function webpackAsyncContextResolve(req) {
+ return new Promise(function(resolve, reject) {
+ var id = map[req];
+ if(!(id + 1)) // check for number or string
+ reject(new Error("Cannot find module '" + req + "'."));
+ else
+ resolve(id);
+ });
+};
+webpackAsyncContext.keys = function webpackAsyncContextKeys() {
+ return Object.keys(map);
+};
+webpackAsyncContext.resolve = webpackAsyncContextResolve;
+module.exports = webpackAsyncContext;
+webpackAsyncContext.id = ${JSON.stringify(id)};`;
+ }
+
+ getLazyOnceSource(block, dependencies, id, outputOptions, requestShortener) {
+ const promise = DepBlockHelpers.getDepBlockPromise(block, outputOptions, requestShortener, "lazy-once context");
+ const map = this.getUserRequestMap(dependencies);
+ return `var map = ${JSON.stringify(map, null, "\t")};
+function webpackAsyncContext(req) {
+ return webpackAsyncContextResolve(req).then(__webpack_require__);
+};
+function webpackAsyncContextResolve(req) {
+ return ${promise}.then(function() {
+ var id = map[req];
+ if(!(id + 1)) // check for number or string
+ throw new Error("Cannot find module '" + req + "'.");
+ return id;
+ });
+};
+webpackAsyncContext.keys = function webpackAsyncContextKeys() {
+ return Object.keys(map);
+};
+webpackAsyncContext.resolve = webpackAsyncContextResolve;
+module.exports = webpackAsyncContext;
+webpackAsyncContext.id = ${JSON.stringify(id)};`;
+ }
+
+ getLazySource(blocks, id) {
let hasMultipleOrNoChunks = false;
const map = blocks
.filter(block => block.dependencies[0].module)
@@ -219,15 +296,38 @@ module.exports = webpackEmptyContext; webpackEmptyContext.id = ${JSON.stringify(id)};`;
}
- getSourceString() {
- if(this.dependencies && this.dependencies.length > 0) {
- return this.getSourceWithDependencies(this.dependencies, this.id);
- }
+ getSourceForEmptyAsyncContext(id) {
+ return `function webpackEmptyAsyncContext(req) {
+ return new Promise(function(resolve, reject) { reject(new Error("Cannot find module '" + req + "'.")); });
+}
+webpackEmptyAsyncContext.keys = function() { return []; };
+webpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;
+module.exports = webpackEmptyAsyncContext;
+webpackEmptyAsyncContext.id = ${JSON.stringify(id)};`;
+ }
- if(this.blocks && this.blocks.length > 0) {
- return this.getSourceWithBlocks(this.blocks, this.id);
+ getSourceString(asyncMode, outputOptions, requestShortener) {
+ if(asyncMode === "lazy") {
+ if(this.blocks && this.blocks.length > 0) {
+ return this.getLazySource(this.blocks, this.id);
+ }
+ return this.getSourceForEmptyAsyncContext(this.id);
+ }
+ if(asyncMode === "eager") {
+ if(this.dependencies && this.dependencies.length > 0) {
+ return this.getEagerSource(this.dependencies, this.id);
+ }
+ return this.getSourceForEmptyAsyncContext(this.id);
+ } else if(asyncMode === "lazy-once") {
+ const block = this.blocks[0];
+ if(block) {
+ return this.getLazyOnceSource(block, block.dependencies, this.id, outputOptions, requestShortener);
+ }
+ return this.getSourceForEmptyAsyncContext(this.id);
+ }
+ if(this.dependencies && this.dependencies.length > 0) {
+ return this.getSyncSource(this.dependencies, this.id);
}
-
return this.getSourceForEmptyContext(this.id);
}
@@ -238,9 +338,9 @@ webpackEmptyContext.id = ${JSON.stringify(id)};`; return new RawSource(sourceString);
}
- source() {
+ source(dependencyTemplates, outputOptions, requestShortener) {
return this.getSource(
- this.getSourceString()
+ this.getSourceString(this.async, outputOptions, requestShortener)
);
}
diff --git a/node_modules/webpack/lib/DelegatedModule.js b/node_modules/webpack/lib/DelegatedModule.js index 6fd4559b7..d06e82214 100644 --- a/node_modules/webpack/lib/DelegatedModule.js +++ b/node_modules/webpack/lib/DelegatedModule.js @@ -37,7 +37,7 @@ class DelegatedModule extends Module { build(options, compilation, resolver, fs, callback) {
this.built = true;
- this.builtTime = new Date().getTime();
+ this.builtTime = Date.now();
this.usedExports = true;
this.providedExports = this.delegateData.exports || true;
this.dependencies.length = 0;
@@ -67,6 +67,8 @@ class DelegatedModule extends Module { str += `[${JSON.stringify(this.request)}]`;
break;
}
+
+ str += ";";
}
if(this.useSourceMap) {
diff --git a/node_modules/webpack/lib/ExternalModule.js b/node_modules/webpack/lib/ExternalModule.js index 225d3c448..340d6b61e 100644 --- a/node_modules/webpack/lib/ExternalModule.js +++ b/node_modules/webpack/lib/ExternalModule.js @@ -35,7 +35,7 @@ class ExternalModule extends Module { }
build(options, compilation, resolver, fs, callback) {
- this.builtTime = new Date().getTime();
+ this.builtTime = Date.now();
callback();
}
diff --git a/node_modules/webpack/lib/HotModuleReplacement.runtime.js b/node_modules/webpack/lib/HotModuleReplacement.runtime.js index bf6f6f8bf..7df072ea8 100644 --- a/node_modules/webpack/lib/HotModuleReplacement.runtime.js +++ b/node_modules/webpack/lib/HotModuleReplacement.runtime.js @@ -578,6 +578,8 @@ module.exports = function() { }
hotSetStatus("idle");
- return Promise.resolve(outdatedModules);
+ return new Promise(function(resolve) {
+ resolve(outdatedModules);
+ });
}
};
diff --git a/node_modules/webpack/lib/IgnorePlugin.js b/node_modules/webpack/lib/IgnorePlugin.js index 9464f5746..d8f2db018 100644 --- a/node_modules/webpack/lib/IgnorePlugin.js +++ b/node_modules/webpack/lib/IgnorePlugin.js @@ -16,7 +16,7 @@ class IgnorePlugin { * Only returns true if a "resourceRegExp" exists
* and the resource given matches the regexp.
*/
- checkResouce(resource) {
+ checkResource(resource) {
if(!this.resourceRegExp) {
return false;
}
@@ -45,7 +45,7 @@ class IgnorePlugin { if(!result) {
return true;
}
- return this.checkResouce(result.request) && this.checkContext(result.context);
+ return this.checkResource(result.request) && this.checkContext(result.context);
}
checkIgnore(result, callback) {
diff --git a/node_modules/webpack/lib/JsonpMainTemplatePlugin.js b/node_modules/webpack/lib/JsonpMainTemplatePlugin.js index 8034ca5d5..daba5b3e3 100644 --- a/node_modules/webpack/lib/JsonpMainTemplatePlugin.js +++ b/node_modules/webpack/lib/JsonpMainTemplatePlugin.js @@ -19,7 +19,9 @@ class JsonpMainTemplatePlugin { this.indent(
chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(",\n")
),
- "};"
+ "};",
+ "",
+ "var resolvedPromise = new Promise(function(resolve) { resolve(); });"
]);
}
return source;
@@ -28,7 +30,7 @@ class JsonpMainTemplatePlugin { const chunkFilename = this.outputOptions.chunkFilename;
const chunkMaps = chunk.getChunkMaps();
const crossOriginLoading = this.outputOptions.crossOriginLoading;
- const chunkLoadTimeout = this.outputOptions.chunkLoadTimeout || 120000;
+ const chunkLoadTimeout = this.outputOptions.chunkLoadTimeout;
const scriptSrcPath = this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), {
hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
@@ -81,7 +83,7 @@ class JsonpMainTemplatePlugin { return this.asString([
"if(installedChunks[chunkId] === 0) {",
this.indent([
- "return Promise.resolve();"
+ "return resolvedPromise;"
]),
"}",
"",
diff --git a/node_modules/webpack/lib/LibManifestPlugin.js b/node_modules/webpack/lib/LibManifestPlugin.js index ba6b6d426..59558f406 100644 --- a/node_modules/webpack/lib/LibManifestPlugin.js +++ b/node_modules/webpack/lib/LibManifestPlugin.js @@ -46,7 +46,7 @@ class LibManifestPlugin { return obj;
}, {})
};
- const content = new Buffer(JSON.stringify(manifest, null, 2), "utf8"); //eslint-disable-line
+ const content = new Buffer(JSON.stringify(manifest), "utf8"); //eslint-disable-line
compiler.outputFileSystem.mkdirp(path.dirname(targetPath), err => {
if(err) return callback(err);
compiler.outputFileSystem.writeFile(targetPath, content, callback);
diff --git a/node_modules/webpack/lib/NormalModule.js b/node_modules/webpack/lib/NormalModule.js index 949bfef87..b3dda7e5a 100644 --- a/node_modules/webpack/lib/NormalModule.js +++ b/node_modules/webpack/lib/NormalModule.js @@ -257,7 +257,7 @@ class NormalModule extends Module { }
build(options, compilation, resolver, fs, callback) {
- this.buildTimestamp = new Date().getTime();
+ this.buildTimestamp = Date.now();
this.built = true;
this._source = null;
this.error = null;
diff --git a/node_modules/webpack/lib/Parser.js b/node_modules/webpack/lib/Parser.js index 02db5c562..bd81b55ab 100644 --- a/node_modules/webpack/lib/Parser.js +++ b/node_modules/webpack/lib/Parser.js @@ -636,6 +636,9 @@ class Parser extends Tapable { }
walkFunctionDeclaration(statement) {
+ statement.params.forEach(param => {
+ this.walkPattern(param);
+ });
this.inScope(statement.params, function() {
if(statement.body.type === "BlockStatement") {
this.prewalkStatement(statement.body);
@@ -797,24 +800,15 @@ class Parser extends Tapable { switch(declarator.type) {
case "VariableDeclarator":
{
- const renameIdentifier = declarator.init && this.getRenameIdentifier(declarator.init);
- if(renameIdentifier && declarator.id.type === "Identifier" && this.applyPluginsBailResult1("can-rename " + renameIdentifier, declarator.init)) {
- // renaming with "var a = b;"
- if(!this.applyPluginsBailResult1("rename " + renameIdentifier, declarator.init)) {
- this.scope.renames["$" + declarator.id.name] = this.scope.renames["$" + renameIdentifier] || renameIdentifier;
- const idx = this.scope.definitions.indexOf(declarator.id.name);
- if(idx >= 0) this.scope.definitions.splice(idx, 1);
- }
- } else {
- this.enterPattern(declarator.id, (name, decl) => {
- if(!this.applyPluginsBailResult1("var-" + declarator.kind + " " + name, decl)) {
- if(!this.applyPluginsBailResult1("var " + name, decl)) {
- this.scope.renames["$" + name] = undefined;
+ this.enterPattern(declarator.id, (name, decl) => {
+ if(!this.applyPluginsBailResult1("var-" + declarator.kind + " " + name, decl)) {
+ if(!this.applyPluginsBailResult1("var " + name, decl)) {
+ this.scope.renames["$" + name] = undefined;
+ if(this.scope.definitions.indexOf(name) < 0)
this.scope.definitions.push(name);
- }
}
- });
- }
+ }
+ });
break;
}
}
@@ -827,7 +821,14 @@ class Parser extends Tapable { case "VariableDeclarator":
{
const renameIdentifier = declarator.init && this.getRenameIdentifier(declarator.init);
- if(!renameIdentifier || declarator.id.type !== "Identifier" || !this.applyPluginsBailResult1("can-rename " + renameIdentifier, declarator.init)) {
+ if(renameIdentifier && declarator.id.type === "Identifier" && this.applyPluginsBailResult1("can-rename " + renameIdentifier, declarator.init)) {
+ // renaming with "var a = b;"
+ if(!this.applyPluginsBailResult1("rename " + renameIdentifier, declarator.init)) {
+ this.scope.renames["$" + declarator.id.name] = this.scope.renames["$" + renameIdentifier] || renameIdentifier;
+ const idx = this.scope.definitions.indexOf(declarator.id.name);
+ if(idx >= 0) this.scope.definitions.splice(idx, 1);
+ }
+ } else {
this.walkPattern(declarator.id);
if(declarator.init)
this.walkExpression(declarator.init);
@@ -845,6 +846,11 @@ class Parser extends Tapable { this["walk" + pattern.type](pattern);
}
+ walkAssignmentPattern(pattern) {
+ this.walkExpression(pattern.right);
+ this.walkPattern(pattern.left);
+ }
+
walkObjectPattern(pattern) {
for(let i = 0, len = pattern.properties.length; i < len; i++) {
const prop = pattern.properties[i];
@@ -912,6 +918,9 @@ class Parser extends Tapable { }
walkFunctionExpression(expression) {
+ expression.params.forEach(param => {
+ this.walkPattern(param);
+ });
this.inScope(expression.params, function() {
if(expression.body.type === "BlockStatement") {
this.prewalkStatement(expression.body);
@@ -923,6 +932,9 @@ class Parser extends Tapable { }
walkArrowFunctionExpression(expression) {
+ expression.params.forEach(param => {
+ this.walkPattern(param);
+ });
this.inScope(expression.params, function() {
if(expression.body.type === "BlockStatement") {
this.prewalkStatement(expression.body);
@@ -993,8 +1005,10 @@ class Parser extends Tapable { }
} else {
this.walkExpression(expression.right);
- this.scope.renames["$" + expression.left.name] = undefined;
- this.walkExpression(expression.left);
+ this.walkPattern(expression.left);
+ this.enterPattern(expression.left, (name, decl) => {
+ this.scope.renames["$" + name] = undefined;
+ });
}
}
@@ -1191,7 +1205,6 @@ class Parser extends Tapable { enterAssignmentPattern(pattern, onIdent) {
this.enterPattern(pattern.left, onIdent);
- this.walkExpression(pattern.right);
}
evaluateExpression(expression) {
diff --git a/node_modules/webpack/lib/ProgressPlugin.js b/node_modules/webpack/lib/ProgressPlugin.js index 44b8c65dd..5bb256f4b 100644 --- a/node_modules/webpack/lib/ProgressPlugin.js +++ b/node_modules/webpack/lib/ProgressPlugin.js @@ -157,9 +157,9 @@ class ProgressPlugin { state = state.replace(/^\d+\/\d+\s+/, "");
if(percentage === 0) {
lastState = null;
- lastStateTime = +new Date();
+ lastStateTime = Date.now();
} else if(state !== lastState || percentage === 1) {
- const now = +new Date();
+ const now = Date.now();
if(lastState) {
const stateMsg = `${now - lastStateTime}ms ${lastState}`;
goToLineStart(stateMsg);
diff --git a/node_modules/webpack/lib/RawModule.js b/node_modules/webpack/lib/RawModule.js index 0c828f6b2..3d29cdb98 100644 --- a/node_modules/webpack/lib/RawModule.js +++ b/node_modules/webpack/lib/RawModule.js @@ -36,7 +36,7 @@ module.exports = class RawModule extends Module { }
build(options, compilations, resolver, fs, callback) {
- this.builtTime = new Date().getTime();
+ this.builtTime = Date.now();
callback();
}
diff --git a/node_modules/webpack/lib/Stats.js b/node_modules/webpack/lib/Stats.js index f7e21777a..0b88faa64 100644 --- a/node_modules/webpack/lib/Stats.js +++ b/node_modules/webpack/lib/Stats.js @@ -95,6 +95,7 @@ class Stats { const showProvidedExports = optionOrFallback(options.providedExports, !forToString);
const showChildren = optionOrFallback(options.children, true);
const showSource = optionOrFallback(options.source, !forToString);
+ const showModuleTrace = optionOrFallback(options.moduleTrace, true);
const showErrors = optionOrFallback(options.errors, true);
const showErrorDetails = optionOrFallback(options.errorDetails, !forToString);
const showWarnings = optionOrFallback(options.warnings, true);
@@ -164,7 +165,7 @@ class Stats { text += e.message;
if(showErrorDetails && e.details) text += `\n${e.details}`;
if(showErrorDetails && e.missing) text += e.missing.map(item => `\n[${item}]`).join("");
- if(e.dependencies && e.origin) {
+ if(showModuleTrace && e.dependencies && e.origin) {
text += `\n @ ${e.origin.readableIdentifier(requestShortener)}`;
e.dependencies.forEach(dep => {
if(!dep.loc) return;
diff --git a/node_modules/webpack/lib/Template.js b/node_modules/webpack/lib/Template.js index 74f42b8fb..461a03679 100644 --- a/node_modules/webpack/lib/Template.js +++ b/node_modules/webpack/lib/Template.js @@ -26,6 +26,11 @@ module.exports = class Template extends Tapable { return str.replace(/^[^a-zA-Z$_]/, "_").replace(/[^a-zA-Z0-9$_]/g, "_");
}
+ static toPath(str) {
+ if(typeof str !== "string") return "";
+ return str.replace(/[^a-zA-Z0-9_!§$()=\-\^°]+/g, "-").replace(/^-|-$/, "");
+ }
+
// map number to a single character a-z, A-Z or <_ + number> if number is too big
static numberToIdentifer(n) {
// lower case
diff --git a/node_modules/webpack/lib/WebpackOptionsApply.js b/node_modules/webpack/lib/WebpackOptionsApply.js index ed37c7723..e9231447c 100644 --- a/node_modules/webpack/lib/WebpackOptionsApply.js +++ b/node_modules/webpack/lib/WebpackOptionsApply.js @@ -206,9 +206,9 @@ class WebpackOptionsApply extends OptionsApply { noSources = options.devtool.indexOf("nosources") >= 0;
legacy = options.devtool.indexOf("@") >= 0;
modern = options.devtool.indexOf("#") >= 0;
- comment = legacy && modern ? "\n/*\n//@ sourceMappingURL=[url]\n//# sourceMappingURL=[url]\n*/" :
- legacy ? "\n/*\n//@ sourceMappingURL=[url]\n*/" :
- modern ? "\n//# sourceMappingURL=[url]" :
+ comment = legacy && modern ? "\n/*\n//@ source" + "MappingURL=[url]\n//# source" + "MappingURL=[url]\n*/" :
+ legacy ? "\n/*\n//@ source" + "MappingURL=[url]\n*/" :
+ modern ? "\n//# source" + "MappingURL=[url]" :
null;
let Plugin = evalWrapped ? EvalSourceMapDevToolPlugin : SourceMapDevToolPlugin;
compiler.apply(new Plugin({
diff --git a/node_modules/webpack/lib/WebpackOptionsDefaulter.js b/node_modules/webpack/lib/WebpackOptionsDefaulter.js index 02dec7c63..48d8d472d 100644 --- a/node_modules/webpack/lib/WebpackOptionsDefaulter.js +++ b/node_modules/webpack/lib/WebpackOptionsDefaulter.js @@ -60,6 +60,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter { this.set("output.hotUpdateChunkFilename", "[id].[hash].hot-update.js");
this.set("output.hotUpdateMainFilename", "[hash].hot-update.json");
this.set("output.crossOriginLoading", false);
+ this.set("output.chunkLoadTimeout", 120000);
this.set("output.hashFunction", "md5");
this.set("output.hashDigest", "hex");
this.set("output.hashDigestLength", 20);
diff --git a/node_modules/webpack/lib/dependencies/DepBlockHelpers.js b/node_modules/webpack/lib/dependencies/DepBlockHelpers.js index aef63fded..d4a4014ec 100644 --- a/node_modules/webpack/lib/dependencies/DepBlockHelpers.js +++ b/node_modules/webpack/lib/dependencies/DepBlockHelpers.js @@ -33,7 +33,7 @@ DepBlockHelpers.getDepBlockPromise = function(depBlock, outputOptions, requestSh "])";
}
}
- return "Promise.resolve()";
+ return "new Promise(function(resolve) { resolve(); })";
};
function asComment(str) {
diff --git a/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js b/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js index 8016dac80..9407499dc 100644 --- a/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js +++ b/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js @@ -22,7 +22,7 @@ HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate if(usedExports && !Array.isArray(usedExports)) {
const exportName = dep.originModule.exportsArgument || "exports";
const content = `Object.defineProperty(${exportName}, \"__esModule\", { value: true });\n`;
- source.insert(-1, content);
+ source.insert(-10, content);
}
}
};
diff --git a/node_modules/webpack/lib/dependencies/HarmonyExportDependencyParserPlugin.js b/node_modules/webpack/lib/dependencies/HarmonyExportDependencyParserPlugin.js index 3edf6e642..d6f37fce1 100644 --- a/node_modules/webpack/lib/dependencies/HarmonyExportDependencyParserPlugin.js +++ b/node_modules/webpack/lib/dependencies/HarmonyExportDependencyParserPlugin.js @@ -45,7 +45,7 @@ module.exports = class HarmonyExportDependencyParserPlugin { } else {
const immutable = statement.declaration && isImmutableStatement(statement.declaration);
const hoisted = statement.declaration && isHoistedStatement(statement.declaration);
- dep = new HarmonyExportSpecifierDependency(parser.state.module, id, name, !immutable || hoisted ? -0.5 : (statement.range[1] + 0.5), immutable);
+ dep = new HarmonyExportSpecifierDependency(parser.state.module, id, name, !immutable || hoisted ? -2 : (statement.range[1] + 0.5), immutable);
}
dep.loc = Object.create(statement.loc);
dep.loc.index = idx;
diff --git a/node_modules/webpack/lib/dependencies/ImportContextDependency.js b/node_modules/webpack/lib/dependencies/ImportContextDependency.js index 7b688d5d9..252bc75a0 100644 --- a/node_modules/webpack/lib/dependencies/ImportContextDependency.js +++ b/node_modules/webpack/lib/dependencies/ImportContextDependency.js @@ -12,7 +12,6 @@ class ImportContextDependency extends ContextDependency { super(request, recursive, regExp);
this.range = range;
this.valueRange = valueRange;
- this.async = true;
this.chunkName = chunkName;
}
diff --git a/node_modules/webpack/lib/dependencies/ImportDependency.js b/node_modules/webpack/lib/dependencies/ImportDependency.js index 8858ba20b..4c2667756 100644 --- a/node_modules/webpack/lib/dependencies/ImportDependency.js +++ b/node_modules/webpack/lib/dependencies/ImportDependency.js @@ -44,7 +44,7 @@ ImportDependency.Template = class ImportDependencyTemplate { if(dep.module) {
const stringifiedId = JSON.stringify(dep.module.id);
- return `Promise.resolve(__webpack_require__(${comment}${stringifiedId}))`;
+ return `new Promise(function(resolve) { resolve(__webpack_require__(${comment}${stringifiedId})); })`;
}
return webpackMissingPromiseModule(dep.request);
diff --git a/node_modules/webpack/lib/dependencies/ImportEagerContextDependency.js b/node_modules/webpack/lib/dependencies/ImportEagerContextDependency.js new file mode 100644 index 000000000..a4b7388bc --- /dev/null +++ b/node_modules/webpack/lib/dependencies/ImportEagerContextDependency.js @@ -0,0 +1,22 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+const ImportContextDependency = require("./ImportContextDependency");
+const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
+
+class ImportEagerContextDependency extends ImportContextDependency {
+ constructor(request, recursive, regExp, range, valueRange, chunkName) {
+ super(request, recursive, regExp, range, valueRange, chunkName);
+ this.async = "eager";
+ }
+
+ get type() {
+ return "import() context eager";
+ }
+}
+
+ImportEagerContextDependency.Template = ContextDependencyTemplateAsRequireCall;
+
+module.exports = ImportEagerContextDependency;
diff --git a/node_modules/webpack/lib/dependencies/ImportEagerDependency.js b/node_modules/webpack/lib/dependencies/ImportEagerDependency.js new file mode 100644 index 000000000..9e1c2ace1 --- /dev/null +++ b/node_modules/webpack/lib/dependencies/ImportEagerDependency.js @@ -0,0 +1,46 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+const ModuleDependency = require("./ModuleDependency");
+const webpackMissingPromiseModule = require("./WebpackMissingModule").promise;
+
+class ImportEagerDependency extends ModuleDependency {
+ constructor(request, range) {
+ super(request);
+ this.range = range;
+ }
+
+ get type() {
+ return "import()";
+ }
+}
+
+ImportEagerDependency.Template = class ImportEagerDependencyTemplate {
+ apply(dep, source, outputOptions, requestShortener) {
+ const comment = this.getOptionalComment(outputOptions.pathinfo, requestShortener.shorten(dep.request));
+
+ const content = this.getContent(dep, comment);
+ source.replace(dep.range[0], dep.range[1] - 1, content);
+ }
+
+ getOptionalComment(pathinfo, shortenedRequest) {
+ if(!pathinfo) {
+ return "";
+ }
+
+ return `/*! ${shortenedRequest} */ `;
+ }
+
+ getContent(dep, comment) {
+ if(dep.module) {
+ const stringifiedId = JSON.stringify(dep.module.id);
+ return `new Promise(function(resolve) { resolve(__webpack_require__(${comment}${stringifiedId})); })`;
+ }
+
+ return webpackMissingPromiseModule(dep.request);
+ }
+};
+
+module.exports = ImportEagerDependency;
diff --git a/node_modules/webpack/lib/dependencies/ImportLazyContextDependency.js b/node_modules/webpack/lib/dependencies/ImportLazyContextDependency.js new file mode 100644 index 000000000..b6f9187c9 --- /dev/null +++ b/node_modules/webpack/lib/dependencies/ImportLazyContextDependency.js @@ -0,0 +1,22 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+const ImportContextDependency = require("./ImportContextDependency");
+const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
+
+class ImportLazyContextDependency extends ImportContextDependency {
+ constructor(request, recursive, regExp, range, valueRange, chunkName) {
+ super(request, recursive, regExp, range, valueRange, chunkName);
+ this.async = "lazy";
+ }
+
+ get type() {
+ return "import() context lazy";
+ }
+}
+
+ImportLazyContextDependency.Template = ContextDependencyTemplateAsRequireCall;
+
+module.exports = ImportLazyContextDependency;
diff --git a/node_modules/webpack/lib/dependencies/ImportLazyOnceContextDependency.js b/node_modules/webpack/lib/dependencies/ImportLazyOnceContextDependency.js new file mode 100644 index 000000000..607ac3f2d --- /dev/null +++ b/node_modules/webpack/lib/dependencies/ImportLazyOnceContextDependency.js @@ -0,0 +1,22 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+const ImportContextDependency = require("./ImportContextDependency");
+const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
+
+class ImportLazyOnceContextDependency extends ImportContextDependency {
+ constructor(request, recursive, regExp, range, valueRange, chunkName) {
+ super(request, recursive, regExp, range, valueRange, chunkName);
+ this.async = "lazy-once";
+ }
+
+ get type() {
+ return "import() context lazy-once";
+ }
+}
+
+ImportLazyOnceContextDependency.Template = ContextDependencyTemplateAsRequireCall;
+
+module.exports = ImportLazyOnceContextDependency;
diff --git a/node_modules/webpack/lib/dependencies/ImportParserPlugin.js b/node_modules/webpack/lib/dependencies/ImportParserPlugin.js index 73972ebee..d97355dc7 100644 --- a/node_modules/webpack/lib/dependencies/ImportParserPlugin.js +++ b/node_modules/webpack/lib/dependencies/ImportParserPlugin.js @@ -4,9 +4,13 @@ */
"use strict";
-const ImportContextDependency = require("./ImportContextDependency");
+const ImportEagerContextDependency = require("./ImportEagerContextDependency");
+const ImportLazyOnceContextDependency = require("./ImportLazyOnceContextDependency");
+const ImportLazyContextDependency = require("./ImportLazyContextDependency");
const ImportDependenciesBlock = require("./ImportDependenciesBlock");
+const ImportEagerDependency = require("./ImportEagerDependency");
const ContextDependencyHelpers = require("./ContextDependencyHelpers");
+const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");
class ImportParserPlugin {
constructor(options) {
@@ -23,22 +27,49 @@ class ImportParserPlugin { const param = parser.evaluateExpression(expr.arguments[0]);
let chunkName = null;
+ let mode = "lazy";
const importOptions = parser.getCommentOptions(expr.range);
if(importOptions) {
if(typeof importOptions.webpackChunkName !== "undefined") {
if(typeof importOptions.webpackChunkName !== "string")
- throw new Error(`\`webpackChunkName\` expected a string, but received: ${importOptions.webpackChunkName}.`);
- chunkName = importOptions.webpackChunkName;
+ parser.state.module.warnings.push(new UnsupportedFeatureWarning(parser.state.module, `\`webpackChunkName\` expected a string, but received: ${importOptions.webpackChunkName}.`));
+ else
+ chunkName = importOptions.webpackChunkName;
+ }
+ if(typeof importOptions.webpackMode !== "undefined") {
+ if(typeof importOptions.webpackMode !== "string")
+ parser.state.module.warnings.push(new UnsupportedFeatureWarning(parser.state.module, `\`webpackMode\` expected a string, but received: ${importOptions.webpackMode}.`));
+ else
+ mode = importOptions.webpackMode;
}
}
if(param.isString()) {
- const depBlock = new ImportDependenciesBlock(param.string, expr.range, chunkName, parser.state.module, expr.loc);
- parser.state.current.addBlock(depBlock);
+ if(mode !== "lazy" && mode !== "eager") {
+ parser.state.module.warnings.push(new UnsupportedFeatureWarning(parser.state.module, `\`webpackMode\` expected 'lazy' or 'eager', but received: ${mode}.`));
+ }
+
+ if(mode === "eager") {
+ const dep = new ImportEagerDependency(param.string, expr.range);
+ parser.state.current.addDependency(dep);
+ } else {
+ const depBlock = new ImportDependenciesBlock(param.string, expr.range, chunkName, parser.state.module, expr.loc);
+ parser.state.current.addBlock(depBlock);
+ }
return true;
} else {
- const dep = ContextDependencyHelpers.create(ImportContextDependency, expr.range, param, expr, options, chunkName);
+ if(mode !== "lazy" && mode !== "lazy-once" && mode !== "eager") {
+ parser.state.module.warnings.push(new UnsupportedFeatureWarning(parser.state.module, `\`webpackMode\` expected 'lazy', 'lazy-once' or 'eager', but received: ${mode}.`));
+ }
+
+ let Dep = ImportLazyContextDependency;
+ if(mode === "eager") {
+ Dep = ImportEagerContextDependency;
+ } else if(mode === "lazy-once") {
+ Dep = ImportLazyOnceContextDependency;
+ }
+ const dep = ContextDependencyHelpers.create(Dep, expr.range, param, expr, options, chunkName);
if(!dep) return;
dep.loc = expr.loc;
dep.optional = !!parser.scope.inTry;
diff --git a/node_modules/webpack/lib/dependencies/ImportPlugin.js b/node_modules/webpack/lib/dependencies/ImportPlugin.js index 487b97455..4905df183 100644 --- a/node_modules/webpack/lib/dependencies/ImportPlugin.js +++ b/node_modules/webpack/lib/dependencies/ImportPlugin.js @@ -5,7 +5,10 @@ "use strict";
const ImportDependency = require("./ImportDependency");
-const ImportContextDependency = require("./ImportContextDependency");
+const ImportEagerDependency = require("./ImportEagerDependency");
+const ImportEagerContextDependency = require("./ImportEagerContextDependency");
+const ImportLazyOnceContextDependency = require("./ImportLazyOnceContextDependency");
+const ImportLazyContextDependency = require("./ImportLazyContextDependency");
const ImportParserPlugin = require("./ImportParserPlugin");
class ImportPlugin {
@@ -22,8 +25,17 @@ class ImportPlugin { compilation.dependencyFactories.set(ImportDependency, normalModuleFactory);
compilation.dependencyTemplates.set(ImportDependency, new ImportDependency.Template());
- compilation.dependencyFactories.set(ImportContextDependency, contextModuleFactory);
- compilation.dependencyTemplates.set(ImportContextDependency, new ImportContextDependency.Template());
+ compilation.dependencyFactories.set(ImportEagerDependency, normalModuleFactory);
+ compilation.dependencyTemplates.set(ImportEagerDependency, new ImportEagerDependency.Template());
+
+ compilation.dependencyFactories.set(ImportEagerContextDependency, contextModuleFactory);
+ compilation.dependencyTemplates.set(ImportEagerContextDependency, new ImportEagerContextDependency.Template());
+
+ compilation.dependencyFactories.set(ImportLazyOnceContextDependency, contextModuleFactory);
+ compilation.dependencyTemplates.set(ImportLazyOnceContextDependency, new ImportLazyOnceContextDependency.Template());
+
+ compilation.dependencyFactories.set(ImportLazyContextDependency, contextModuleFactory);
+ compilation.dependencyTemplates.set(ImportLazyContextDependency, new ImportLazyContextDependency.Template());
params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
diff --git a/node_modules/webpack/lib/formatLocation.js b/node_modules/webpack/lib/formatLocation.js index da8c10e23..046887f6f 100644 --- a/node_modules/webpack/lib/formatLocation.js +++ b/node_modules/webpack/lib/formatLocation.js @@ -2,36 +2,53 @@ MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-module.exports = function formatLocation(loc) {
- if(typeof loc === "string")
- return loc;
- if(typeof loc === "number")
- return loc + "";
- if(loc && typeof loc === "object") {
- if(loc.start && loc.end) {
- if(typeof loc.start.line === "number" && typeof loc.end.line === "number" && typeof loc.end.column === "number" && loc.start.line === loc.end.line)
- return formatPosition(loc.start) + "-" + loc.end.column;
- return formatPosition(loc.start) + "-" + formatPosition(loc.end);
- }
- if(loc.start)
- return formatPosition(loc.start);
- return formatPosition(loc);
- }
- return "";
- function formatPosition(pos) {
- if(typeof pos === "string")
+"use strict";
+
+const formatPosition = (pos) => {
+ if(pos === null)
+ return "";
+ const typeOfPos = typeof pos;
+ switch(typeOfPos) {
+ case "string":
return pos;
- if(typeof pos === "number")
- return pos + "";
- if(pos && typeof pos === "object") {
+ case "number":
+ return `${pos}`;
+ case "object":
if(typeof pos.line === "number" && typeof pos.column === "number")
- return pos.line + ":" + pos.column;
- if(typeof pos.line === "number")
- return pos.line + ":?";
- if(typeof pos.index === "number")
- return "+" + pos.index;
- }
+ return `${pos.line}:${pos.column}`;
+ else if(typeof pos.line === "number")
+ return `${pos.line}:?`;
+ else if(typeof pos.index === "number")
+ return `+${pos.index}`;
+ else
+ return "";
+ default:
+ return "";
+ }
+};
+
+const formatLocation = (loc) => {
+ if(loc === null)
return "";
+ const typeOfLoc = typeof loc;
+ switch(typeOfLoc) {
+ case "string":
+ return loc;
+ case "number":
+ return `${loc}`;
+ case "object":
+ if(loc.start && loc.end) {
+ if(typeof loc.start.line === "number" && typeof loc.end.line === "number" && typeof loc.end.column === "number" && loc.start.line === loc.end.line)
+ return `${formatPosition(loc.start)}-${loc.end.column}`;
+ return `${formatPosition(loc.start)}-${formatPosition(loc.end)}`;
+ }
+ if(loc.start)
+ return formatPosition(loc.start);
+ return formatPosition(loc);
+ default:
+ return "";
}
};
+
+module.exports = formatLocation;
diff --git a/node_modules/webpack/lib/node/NodeSourcePlugin.js b/node_modules/webpack/lib/node/NodeSourcePlugin.js index 4e0716a25..14a375445 100644 --- a/node_modules/webpack/lib/node/NodeSourcePlugin.js +++ b/node_modules/webpack/lib/node/NodeSourcePlugin.js @@ -2,83 +2,85 @@ MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var AliasPlugin = require("enhanced-resolve/lib/AliasPlugin");
-var ParserHelpers = require("../ParserHelpers");
-var nodeLibsBrowser = require("node-libs-browser");
+"use strict";
+const AliasPlugin = require("enhanced-resolve/lib/AliasPlugin");
+const ParserHelpers = require("../ParserHelpers");
+const nodeLibsBrowser = require("node-libs-browser");
-function NodeSourcePlugin(options) {
- this.options = options;
-}
-module.exports = NodeSourcePlugin;
-NodeSourcePlugin.prototype.apply = function(compiler) {
- var options = this.options;
-
- function getPathToModule(module, type) {
- if(type === true || (type === undefined && nodeLibsBrowser[module])) {
- if(!nodeLibsBrowser[module]) throw new Error("No browser version for node.js core module '" + module + "' available");
- return nodeLibsBrowser[module];
- } else if(type === "mock") {
- return require.resolve("node-libs-browser/mock/" + module);
- } else if(type === "empty") {
- return require.resolve("node-libs-browser/mock/empty");
- } else return module;
+module.exports = class NodeSourcePlugin {
+ constructor(options) {
+ this.options = options;
}
+ apply(compiler) {
+ const options = this.options;
- function addExpression(parser, name, module, type, suffix) {
- suffix = suffix || "";
- parser.plugin("expression " + name, function() {
- if(this.state.module && this.state.module.resource === getPathToModule(module, type)) return;
- var mockModule = ParserHelpers.requireFileAsExpression(this.state.module.context, getPathToModule(module, type));
- return ParserHelpers.addParsedVariableToModule(this, name, mockModule + suffix);
- });
- }
+ function getPathToModule(module, type) {
+ if(type === true || (type === undefined && nodeLibsBrowser[module])) {
+ if(!nodeLibsBrowser[module]) throw new Error(`No browser version for node.js core module ${module} available`);
+ return nodeLibsBrowser[module];
+ } else if(type === "mock") {
+ return require.resolve(`node-libs-browser/mock/${module}`);
+ } else if(type === "empty") {
+ return require.resolve("node-libs-browser/mock/empty");
+ } else return module;
+ }
- compiler.plugin("compilation", function(compilation, params) {
- params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
+ function addExpression(parser, name, module, type, suffix) {
+ suffix = suffix || "";
+ parser.plugin(`expression ${name}`, function() {
+ if(this.state.module && this.state.module.resource === getPathToModule(module, type)) return;
+ const mockModule = ParserHelpers.requireFileAsExpression(this.state.module.context, getPathToModule(module, type));
+ return ParserHelpers.addParsedVariableToModule(this, name, mockModule + suffix);
+ });
+ }
- if(parserOptions.node === false)
- return;
+ compiler.plugin("compilation", function(compilation, params) {
+ params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
- var localOptions = options;
- if(parserOptions.node)
- localOptions = Object.assign({}, localOptions, parserOptions.node);
+ if(parserOptions.node === false)
+ return;
- if(localOptions.global) {
- parser.plugin("expression global", function() {
- var retrieveGlobalModule = ParserHelpers.requireFileAsExpression(this.state.module.context, require.resolve("../../buildin/global.js"));
- return ParserHelpers.addParsedVariableToModule(this, "global", retrieveGlobalModule);
- });
- }
- if(localOptions.process) {
- var processType = localOptions.process;
- addExpression(parser, "process", "process", processType);
- }
- if(localOptions.console) {
- var consoleType = localOptions.console;
- addExpression(parser, "console", "console", consoleType);
- }
- var bufferType = localOptions.Buffer;
- if(bufferType) {
- addExpression(parser, "Buffer", "buffer", bufferType, ".Buffer");
- }
- if(localOptions.setImmediate) {
- var setImmediateType = localOptions.setImmediate;
- addExpression(parser, "setImmediate", "timers", setImmediateType, ".setImmediate");
- addExpression(parser, "clearImmediate", "timers", setImmediateType, ".clearImmediate");
- }
+ let localOptions = options;
+ if(parserOptions.node)
+ localOptions = Object.assign({}, localOptions, parserOptions.node);
+
+ if(localOptions.global) {
+ parser.plugin("expression global", function() {
+ const retrieveGlobalModule = ParserHelpers.requireFileAsExpression(this.state.module.context, require.resolve("../../buildin/global.js"));
+ return ParserHelpers.addParsedVariableToModule(this, "global", retrieveGlobalModule);
+ });
+ }
+ if(localOptions.process) {
+ const processType = localOptions.process;
+ addExpression(parser, "process", "process", processType);
+ }
+ if(localOptions.console) {
+ const consoleType = localOptions.console;
+ addExpression(parser, "console", "console", consoleType);
+ }
+ const bufferType = localOptions.Buffer;
+ if(bufferType) {
+ addExpression(parser, "Buffer", "buffer", bufferType, ".Buffer");
+ }
+ if(localOptions.setImmediate) {
+ const setImmediateType = localOptions.setImmediate;
+ addExpression(parser, "setImmediate", "timers", setImmediateType, ".setImmediate");
+ addExpression(parser, "clearImmediate", "timers", setImmediateType, ".clearImmediate");
+ }
+ });
});
- });
- compiler.plugin("after-resolvers", function(compiler) {
- Object.keys(nodeLibsBrowser).forEach(function(lib) {
- if(options[lib] !== false) {
- compiler.resolvers.normal.apply(
- new AliasPlugin("described-resolve", {
- name: lib,
- onlyModule: true,
- alias: getPathToModule(lib, options[lib])
- }, "resolve")
- );
- }
+ compiler.plugin("after-resolvers", (compiler) => {
+ Object.keys(nodeLibsBrowser).forEach((lib) => {
+ if(options[lib] !== false) {
+ compiler.resolvers.normal.apply(
+ new AliasPlugin("described-resolve", {
+ name: lib,
+ onlyModule: true,
+ alias: getPathToModule(lib, options[lib])
+ }, "resolve")
+ );
+ }
+ });
});
- });
+ }
};
diff --git a/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js b/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js index d7c4849fe..3ef414198 100644 --- a/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js +++ b/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js @@ -190,7 +190,7 @@ You can however specify the name of the async chunk by passing the desired strin // we dont have named chunks specified, so we just take all of them
if(asyncOrNoSelectedChunk) {
- return allChunks;
+ return allChunks.filter(chunk => !chunk.isInitial());
}
/**
diff --git a/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js b/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js index a0e6cc2f3..429e2c3d4 100644 --- a/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js +++ b/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js @@ -21,7 +21,9 @@ class WebWorkerMainTemplatePlugin { return id + ": 1";
}).join(",\n")
),
- "};"
+ "};",
+ "",
+ "var resolvedPromise = new Promise(function(resolve) { resolve(); });"
]);
}
return source;
@@ -44,7 +46,7 @@ class WebWorkerMainTemplatePlugin { }) + ");"
]),
"}",
- "return Promise.resolve();"
+ "return resolvedPromise;"
]);
});
mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
|