updated npm modules

This commit is contained in:
2019-05-20 20:43:45 -05:00
parent 2319197b81
commit f166b72b7d
1113 changed files with 8758 additions and 12227 deletions

12
node_modules/webpack/lib/Chunk.js generated vendored
View File

@@ -517,7 +517,7 @@ class Chunk {
* @param {Object} options the size display options
* @returns {number} the chunk size
*/
size(options) {
size(options = {}) {
return this.addMultiplierAndOverhead(this.modulesSize(), options);
}
@@ -688,7 +688,15 @@ class Chunk {
};
if (includeDirectChildren) {
addChildIdsByOrdersToMap(this);
const chunks = new Set();
for (const chunkGroup of this.groupsIterable) {
for (const chunk of chunkGroup.chunks) {
chunks.add(chunk);
}
}
for (const chunk of chunks) {
addChildIdsByOrdersToMap(chunk);
}
}
for (const chunk of this.getAllAsyncChunks()) {

View File

@@ -238,8 +238,8 @@ class Compilation extends Tapable {
"module"
]),
/** @type {SyncHook<Module[]>} */
finishModules: new SyncHook(["modules"]),
/** @type {AsyncSeriesHook<Module[]>} */
finishModules: new AsyncSeriesHook(["modules"]),
/** @type {SyncHook<Module>} */
finishRebuildingModule: new SyncHook(["module"]),
/** @type {SyncHook} */
@@ -1158,14 +1158,18 @@ class Compilation extends Tapable {
});
}
finish() {
finish(callback) {
const modules = this.modules;
this.hooks.finishModules.call(modules);
this.hooks.finishModules.callAsync(modules, err => {
if (err) return callback(err);
for (let index = 0; index < modules.length; index++) {
const module = modules[index];
this.reportDependencyErrorsAndWarnings(module, [module]);
}
for (let index = 0; index < modules.length; index++) {
const module = modules[index];
this.reportDependencyErrorsAndWarnings(module, [module]);
}
callback();
});
}
unseal() {

12
node_modules/webpack/lib/Compiler.js generated vendored
View File

@@ -619,15 +619,17 @@ class Compiler extends Tapable {
this.hooks.make.callAsync(compilation, err => {
if (err) return callback(err);
compilation.finish();
compilation.seal(err => {
compilation.finish(err => {
if (err) return callback(err);
this.hooks.afterCompile.callAsync(compilation, err => {
compilation.seal(err => {
if (err) return callback(err);
return callback(null, compilation);
this.hooks.afterCompile.callAsync(compilation, err => {
if (err) return callback(err);
return callback(null, compilation);
});
});
});
});

View File

@@ -137,6 +137,7 @@ class ExternalModule extends Module {
case "amd-require":
case "umd":
case "umd2":
case "system":
return this.getSourceForAmdOrUmdExternal(
this.id,
this.optional,

View File

@@ -41,9 +41,11 @@ class FunctionModuleTemplatePlugin {
const req = module.readableIdentifier(
moduleTemplate.runtimeTemplate.requestShortener
);
source.add("/*!****" + req.replace(/./g, "*") + "****!*\\\n");
source.add(" !*** " + req.replace(/\*\//g, "*_/") + " ***!\n");
source.add(" \\****" + req.replace(/./g, "*") + "****/\n");
const reqStr = req.replace(/\*\//g, "*_/");
const reqStrStar = "*".repeat(reqStr.length);
source.add("/*!****" + reqStrStar + "****!*\\\n");
source.add(" !*** " + reqStr + " ***!\n");
source.add(" \\****" + reqStrStar + "****/\n");
if (
Array.isArray(module.buildMeta.providedExports) &&
module.buildMeta.providedExports.length === 0

View File

@@ -169,6 +169,13 @@ class LibraryTemplatePlugin {
new JsonpExportMainTemplatePlugin(this.name).apply(compilation);
break;
}
case "system": {
const SystemMainTemplatePlugin = require("./SystemMainTemplatePlugin");
new SystemMainTemplatePlugin({
name: this.name
}).apply(compilation);
break;
}
default:
throw new Error(`${this.target} is not a valid Library target`);
}

View File

@@ -98,6 +98,8 @@ module.exports = class MainTemplate extends Tapable {
beforeStartup: new SyncWaterfallHook(["source", "chunk", "hash"]),
/** @type {SyncWaterfallHook<string, Chunk, string>} */
startup: new SyncWaterfallHook(["source", "chunk", "hash"]),
/** @type {SyncWaterfallHook<string, Chunk, string>} */
afterStartup: new SyncWaterfallHook(["source", "chunk", "hash"]),
render: new SyncWaterfallHook([
"source",
"chunk",
@@ -404,7 +406,20 @@ module.exports = class MainTemplate extends Tapable {
);
buf.push("");
buf.push(Template.asString(this.hooks.beforeStartup.call("", chunk, hash)));
const afterStartupCode = Template.asString(
this.hooks.afterStartup.call("", chunk, hash)
);
if (afterStartupCode) {
// TODO webpack 5: this is a bit hacky to avoid a breaking change
// change it to a better way
buf.push("var startupResult = (function() {");
}
buf.push(Template.asString(this.hooks.startup.call("", chunk, hash)));
if (afterStartupCode) {
buf.push("})();");
buf.push(afterStartupCode);
buf.push("return startupResult;");
}
return buf;
}

View File

@@ -58,38 +58,42 @@ class NodeStuffPlugin {
});
};
const context = compiler.context;
if (localOptions.__filename === "mock") {
setConstant("__filename", "/index.js");
} else if (localOptions.__filename) {
setModuleConstant("__filename", module =>
path.relative(context, module.resource)
);
if (localOptions.__filename) {
if (localOptions.__filename === "mock") {
setConstant("__filename", "/index.js");
} else {
setModuleConstant("__filename", module =>
path.relative(context, module.resource)
);
}
parser.hooks.evaluateIdentifier
.for("__filename")
.tap("NodeStuffPlugin", expr => {
if (!parser.state.module) return;
const resource = parser.state.module.resource;
const i = resource.indexOf("?");
return ParserHelpers.evaluateToString(
i < 0 ? resource : resource.substr(0, i)
)(expr);
});
}
parser.hooks.evaluateIdentifier
.for("__filename")
.tap("NodeStuffPlugin", expr => {
if (!parser.state.module) return;
const resource = parser.state.module.resource;
const i = resource.indexOf("?");
return ParserHelpers.evaluateToString(
i < 0 ? resource : resource.substr(0, i)
)(expr);
});
if (localOptions.__dirname === "mock") {
setConstant("__dirname", "/");
} else if (localOptions.__dirname) {
setModuleConstant("__dirname", module =>
path.relative(context, module.context)
);
if (localOptions.__dirname) {
if (localOptions.__dirname === "mock") {
setConstant("__dirname", "/");
} else {
setModuleConstant("__dirname", module =>
path.relative(context, module.context)
);
}
parser.hooks.evaluateIdentifier
.for("__dirname")
.tap("NodeStuffPlugin", expr => {
if (!parser.state.module) return;
return ParserHelpers.evaluateToString(
parser.state.module.context
)(expr);
});
}
parser.hooks.evaluateIdentifier
.for("__dirname")
.tap("NodeStuffPlugin", expr => {
if (!parser.state.module) return;
return ParserHelpers.evaluateToString(
parser.state.module.context
)(expr);
});
parser.hooks.expression
.for("require.main")
.tap(

View File

@@ -212,6 +212,7 @@ class NormalModule extends Module {
rootContext: options.context,
webpack: true,
sourceMap: !!this.useSourceMap,
mode: options.mode || "production",
_module: this,
_compilation: compilation,
_compiler: compilation.compiler,

26
node_modules/webpack/lib/Parser.js generated vendored
View File

@@ -1593,7 +1593,14 @@ class Parser extends Tapable {
walkFunctionExpression(expression) {
const wasTopLevel = this.scope.topLevelScope;
this.scope.topLevelScope = false;
this.inScope(expression.params, () => {
const scopeParams = expression.params;
// Add function name in scope for recursive calls
if (expression.id) {
scopeParams.push(expression.id.name);
}
this.inScope(scopeParams, () => {
for (const param of expression.params) {
this.walkPattern(param);
}
@@ -1777,7 +1784,14 @@ class Parser extends Tapable {
const args = options.map(renameArgOrThis);
const wasTopLevel = this.scope.topLevelScope;
this.scope.topLevelScope = false;
this.inScope(params.filter((identifier, idx) => !args[idx]), () => {
const scopeParams = params.filter((identifier, idx) => !args[idx]);
// Add function name in scope for recursive calls
if (functionExpression.id) {
scopeParams.push(functionExpression.id.name);
}
this.inScope(scopeParams, () => {
if (renameThis) {
this.scope.renames.set("this", renameThis);
}
@@ -1940,6 +1954,9 @@ class Parser extends Tapable {
case "RestElement":
this.enterRestElement(pattern, onIdent);
break;
case "Property":
this.enterPattern(pattern.value, onIdent);
break;
}
}
@@ -1954,7 +1971,7 @@ class Parser extends Tapable {
propIndex++
) {
const prop = pattern.properties[propIndex];
this.enterPattern(prop.value, onIdent);
this.enterPattern(prop, onIdent);
}
}
@@ -2224,6 +2241,8 @@ class Parser extends Tapable {
if (type === "auto") {
parserOptions.sourceType = "module";
} else if (parserOptions.sourceType === "script") {
parserOptions.allowReturnOutsideFunction = true;
}
let ast;
@@ -2238,6 +2257,7 @@ class Parser extends Tapable {
if (threw && type === "auto") {
parserOptions.sourceType = "script";
parserOptions.allowReturnOutsideFunction = true;
if (Array.isArray(parserOptions.onComment)) {
parserOptions.onComment.length = 0;
}

6
node_modules/webpack/lib/Stats.js generated vendored
View File

@@ -1408,6 +1408,12 @@ class Stats {
errors: true,
moduleTrace: true
};
case "errors-warnings":
return {
all: false,
errors: true,
warnings: true
};
default:
return {};
}

View File

@@ -21,8 +21,6 @@ const RecordIdsPlugin = require("./RecordIdsPlugin");
const APIPlugin = require("./APIPlugin");
const ConstPlugin = require("./ConstPlugin");
const RequireJsStuffPlugin = require("./RequireJsStuffPlugin");
const NodeStuffPlugin = require("./NodeStuffPlugin");
const CompatibilityPlugin = require("./CompatibilityPlugin");
const TemplatedPathPlugin = require("./TemplatedPathPlugin");
@@ -34,35 +32,10 @@ const CommonJsPlugin = require("./dependencies/CommonJsPlugin");
const HarmonyModulesPlugin = require("./dependencies/HarmonyModulesPlugin");
const SystemPlugin = require("./dependencies/SystemPlugin");
const ImportPlugin = require("./dependencies/ImportPlugin");
const AMDPlugin = require("./dependencies/AMDPlugin");
const RequireContextPlugin = require("./dependencies/RequireContextPlugin");
const RequireEnsurePlugin = require("./dependencies/RequireEnsurePlugin");
const RequireIncludePlugin = require("./dependencies/RequireIncludePlugin");
const WarnNoModeSetPlugin = require("./WarnNoModeSetPlugin");
const EnsureChunkConditionsPlugin = require("./optimize/EnsureChunkConditionsPlugin");
const RemoveParentModulesPlugin = require("./optimize/RemoveParentModulesPlugin");
const RemoveEmptyChunksPlugin = require("./optimize/RemoveEmptyChunksPlugin");
const MergeDuplicateChunksPlugin = require("./optimize/MergeDuplicateChunksPlugin");
const FlagIncludedChunksPlugin = require("./optimize/FlagIncludedChunksPlugin");
const OccurrenceChunkOrderPlugin = require("./optimize/OccurrenceChunkOrderPlugin");
const OccurrenceModuleOrderPlugin = require("./optimize/OccurrenceModuleOrderPlugin");
const NaturalChunkOrderPlugin = require("./optimize/NaturalChunkOrderPlugin");
const SideEffectsFlagPlugin = require("./optimize/SideEffectsFlagPlugin");
const FlagDependencyUsagePlugin = require("./FlagDependencyUsagePlugin");
const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
const ModuleConcatenationPlugin = require("./optimize/ModuleConcatenationPlugin");
const SplitChunksPlugin = require("./optimize/SplitChunksPlugin");
const RuntimeChunkPlugin = require("./optimize/RuntimeChunkPlugin");
const NoEmitOnErrorsPlugin = require("./NoEmitOnErrorsPlugin");
const NamedModulesPlugin = require("./NamedModulesPlugin");
const NamedChunksPlugin = require("./NamedChunksPlugin");
const HashedModuleIdsPlugin = require("./HashedModuleIdsPlugin");
const DefinePlugin = require("./DefinePlugin");
const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin");
const WasmFinalizeExportsPlugin = require("./wasm/WasmFinalizeExportsPlugin");
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
/** @typedef {import("./Compiler")} Compiler */
@@ -308,11 +281,18 @@ class WebpackOptionsApply extends OptionsApply {
new CompatibilityPlugin().apply(compiler);
new HarmonyModulesPlugin(options.module).apply(compiler);
new AMDPlugin(options.module, options.amd || {}).apply(compiler);
if (options.amd !== false) {
const AMDPlugin = require("./dependencies/AMDPlugin");
const RequireJsStuffPlugin = require("./RequireJsStuffPlugin");
new AMDPlugin(options.module, options.amd || {}).apply(compiler);
new RequireJsStuffPlugin().apply(compiler);
}
new CommonJsPlugin(options.module).apply(compiler);
new LoaderPlugin().apply(compiler);
new NodeStuffPlugin(options.node).apply(compiler);
new RequireJsStuffPlugin().apply(compiler);
if (options.node !== false) {
const NodeStuffPlugin = require("./NodeStuffPlugin");
new NodeStuffPlugin(options.node).apply(compiler);
}
new APIPlugin().apply(compiler);
new ConstPlugin().apply(compiler);
new UseStrictPlugin().apply(compiler);
@@ -327,44 +307,58 @@ class WebpackOptionsApply extends OptionsApply {
new SystemPlugin(options.module).apply(compiler);
if (typeof options.mode !== "string") {
const WarnNoModeSetPlugin = require("./WarnNoModeSetPlugin");
new WarnNoModeSetPlugin().apply(compiler);
}
const EnsureChunkConditionsPlugin = require("./optimize/EnsureChunkConditionsPlugin");
new EnsureChunkConditionsPlugin().apply(compiler);
if (options.optimization.removeAvailableModules) {
const RemoveParentModulesPlugin = require("./optimize/RemoveParentModulesPlugin");
new RemoveParentModulesPlugin().apply(compiler);
}
if (options.optimization.removeEmptyChunks) {
const RemoveEmptyChunksPlugin = require("./optimize/RemoveEmptyChunksPlugin");
new RemoveEmptyChunksPlugin().apply(compiler);
}
if (options.optimization.mergeDuplicateChunks) {
const MergeDuplicateChunksPlugin = require("./optimize/MergeDuplicateChunksPlugin");
new MergeDuplicateChunksPlugin().apply(compiler);
}
if (options.optimization.flagIncludedChunks) {
const FlagIncludedChunksPlugin = require("./optimize/FlagIncludedChunksPlugin");
new FlagIncludedChunksPlugin().apply(compiler);
}
if (options.optimization.sideEffects) {
const SideEffectsFlagPlugin = require("./optimize/SideEffectsFlagPlugin");
new SideEffectsFlagPlugin().apply(compiler);
}
if (options.optimization.providedExports) {
const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
new FlagDependencyExportsPlugin().apply(compiler);
}
if (options.optimization.usedExports) {
const FlagDependencyUsagePlugin = require("./FlagDependencyUsagePlugin");
new FlagDependencyUsagePlugin().apply(compiler);
}
if (options.optimization.concatenateModules) {
const ModuleConcatenationPlugin = require("./optimize/ModuleConcatenationPlugin");
new ModuleConcatenationPlugin().apply(compiler);
}
if (options.optimization.splitChunks) {
const SplitChunksPlugin = require("./optimize/SplitChunksPlugin");
new SplitChunksPlugin(options.optimization.splitChunks).apply(compiler);
}
if (options.optimization.runtimeChunk) {
const RuntimeChunkPlugin = require("./optimize/RuntimeChunkPlugin");
new RuntimeChunkPlugin(options.optimization.runtimeChunk).apply(compiler);
}
if (options.optimization.noEmitOnErrors) {
const NoEmitOnErrorsPlugin = require("./NoEmitOnErrorsPlugin");
new NoEmitOnErrorsPlugin().apply(compiler);
}
if (options.optimization.checkWasmTypes) {
const WasmFinalizeExportsPlugin = require("./wasm/WasmFinalizeExportsPlugin");
new WasmFinalizeExportsPlugin().apply(compiler);
}
let moduleIds = options.optimization.moduleIds;
@@ -384,6 +378,9 @@ class WebpackOptionsApply extends OptionsApply {
}
}
if (moduleIds) {
const NamedModulesPlugin = require("./NamedModulesPlugin");
const HashedModuleIdsPlugin = require("./HashedModuleIdsPlugin");
const OccurrenceModuleOrderPlugin = require("./optimize/OccurrenceModuleOrderPlugin");
switch (moduleIds) {
case "natural":
// TODO webpack 5: see hint in Compilation.sortModules
@@ -426,6 +423,9 @@ class WebpackOptionsApply extends OptionsApply {
}
}
if (chunkIds) {
const NaturalChunkOrderPlugin = require("./optimize/NaturalChunkOrderPlugin");
const NamedChunksPlugin = require("./NamedChunksPlugin");
const OccurrenceChunkOrderPlugin = require("./optimize/OccurrenceChunkOrderPlugin");
switch (chunkIds) {
case "natural":
new NaturalChunkOrderPlugin().apply(compiler);
@@ -456,6 +456,7 @@ class WebpackOptionsApply extends OptionsApply {
}
}
if (options.optimization.nodeEnv) {
const DefinePlugin = require("./DefinePlugin");
new DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(options.optimization.nodeEnv)
}).apply(compiler);
@@ -471,6 +472,7 @@ class WebpackOptionsApply extends OptionsApply {
}
if (options.performance) {
const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin");
new SizeLimitsPlugin(options.performance).apply(compiler);
}

View File

@@ -50,6 +50,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
) {
super(request, originModule, sourceOrder, parserScope);
this.id = id;
this.redirectedId = undefined;
this.name = name;
this.activeExports = activeExports;
this.otherStarExports = otherStarExports;
@@ -60,9 +61,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
return "harmony export imported specifier";
}
get _id() {
return this.redirectedId || this.id;
}
getMode(ignoreUnused) {
const name = this.name;
const id = this.id;
const id = this._id;
const used = this.originModule.isUsed(name);
const importedModule = this._module;
@@ -288,7 +293,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
};
}
const importedModule = this.module;
const importedModule = this._module;
if (!importedModule) {
// no imported module available
@@ -350,11 +355,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
// It's not an harmony module
if (
this.originModule.buildMeta.strictHarmonyModule &&
this.id !== "default"
this._id !== "default"
) {
// In strict harmony modules we only support the default export
const exportName = this.id
? `the named export '${this.id}'`
const exportName = this._id
? `the named export '${this._id}'`
: "the namespace object";
return [
new HarmonyLinkingError(
@@ -365,20 +370,20 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
return;
}
if (!this.id) {
if (!this._id) {
return;
}
if (importedModule.isProvided(this.id) !== false) {
if (importedModule.isProvided(this._id) !== false) {
// It's provided or we are not sure
return;
}
// We are sure that it's not provided
const idIsNotNameMessage =
this.id !== this.name ? ` (reexported as '${this.name}')` : "";
this._id !== this.name ? ` (reexported as '${this.name}')` : "";
const errorMessage = `"export '${
this.id
this._id
}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
return [new HarmonyLinkingError(errorMessage)];
}
@@ -402,6 +407,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
importedModule.used + stringifiedUsedExport + stringifiedProvidedExport
);
}
disconnect() {
super.disconnect();
this.redirectedId = undefined;
}
}
module.exports = HarmonyExportImportedSpecifierDependency;

View File

@@ -61,7 +61,7 @@ class ModuleConcatenationPlugin {
compilation.hooks.optimizeChunkModules.tap(
"ModuleConcatenationPlugin",
(chunks, modules) => {
(allChunks, modules) => {
const relevantModules = [];
const possibleInners = new Set();
for (const module of modules) {
@@ -287,6 +287,8 @@ class ModuleConcatenationPlugin {
for (const chunk of chunks) {
chunk.addModule(newModule);
newModule.addChunk(chunk);
}
for (const chunk of allChunks) {
if (chunk.entryModule === concatConfiguration.rootModule) {
chunk.entryModule = newModule;
}