Merge tag 'v4.29.2' into next

4.29.2
This commit is contained in:
Tobias Koppers 2019-02-06 15:37:11 +01:00
commit 180f912493
31 changed files with 1174 additions and 2500 deletions

View File

@ -206,8 +206,8 @@ const tests = {
const suite = new Benchmark.Suite();
Object.keys(tests)
.filter(
name => (process.argv.length > 2 ? name.includes(process.argv[2]) : true)
.filter(name =>
process.argv.length > 2 ? name.includes(process.argv[2]) : true
)
.forEach(name => {
const test = tests[name];

View File

@ -162,5 +162,7 @@ if (installedClis.length === 0) {
" and "
)} together. To work with the "webpack" command you need only one CLI package, please remove one of them or use them directly via their binary.`
);
// @ts-ignore
process.exitCode = 1;
}

4
declarations.d.ts vendored
View File

@ -329,8 +329,8 @@ interface RuleSetConditionsRecursive
extends Array<import("./declarations/WebpackOptions").RuleSetCondition> {}
interface RuleSetConditionsAbsoluteRecursive
extends Array<
import("./declarations/WebpackOptions").RuleSetConditionAbsolute
> {}
import("./declarations/WebpackOptions").RuleSetConditionAbsolute
> {}
/**
* Global variable declarations

View File

@ -15,7 +15,7 @@ export type Entry = EntryDynamic | EntryStatic;
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryDynamic".
*/
export type EntryDynamic = (() => EntryStatic | Promise<EntryStatic>);
export type EntryDynamic = () => EntryStatic | Promise<EntryStatic>;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryStatic".
@ -237,12 +237,12 @@ export type RuleSetRules = RuleSetRule[];
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "OptimizationSplitChunksGetCacheGroups".
*/
export type OptimizationSplitChunksGetCacheGroups = ((
export type OptimizationSplitChunksGetCacheGroups = (
module: import("../lib/Module")
) =>
| OptimizationSplitChunksCacheGroup
| OptimizationSplitChunksCacheGroup[]
| void);
| void;
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "OptimizationSplitChunksSizes".

View File

@ -11,9 +11,11 @@ export type BannerPluginArgument =
/**
* The banner as function, it will be wrapped in a comment
*/
export type BannerFunction = (
data: {hash: string; chunk: import("../../lib/Chunk"); filename: string}
) => string;
export type BannerFunction = (data: {
hash: string;
chunk: import("../../lib/Chunk");
filename: string;
}) => string;
export type Rules = Rule[] | Rule;
export type Rule = RegExp | string;

View File

@ -19,9 +19,9 @@ export type IgnorePluginOptions =
/**
* A filter function for context
*/
checkContext?: ((context: string) => boolean);
checkContext?: (context: string) => boolean;
/**
* A filter function for resource and context
*/
checkResource?: ((resource: string, context: string) => boolean);
checkResource?: (resource: string, context: string) => boolean;
};

View File

@ -8,11 +8,11 @@ export type ProgressPluginArgument = ProgressPluginOptions | HandlerFunction;
/**
* Function that executes for every progress step
*/
export type HandlerFunction = ((
export type HandlerFunction = (
percentage: number,
msg: string,
...args: string[]
) => void);
) => void;
export interface ProgressPluginOptions {
/**

View File

@ -45,11 +45,10 @@ class AmdMainTemplatePlugin {
.filter(m => m instanceof ExternalModule);
const externals = /** @type {ExternalModule[]} */ (modules);
const externalsDepsArray = JSON.stringify(
externals.map(
m =>
typeof m.request === "object" && !Array.isArray(m.request)
? m.request.amd
: m.request
externals.map(m =>
typeof m.request === "object" && !Array.isArray(m.request)
? m.request.amd
: m.request
)
);
const externalsArguments = externals

View File

@ -991,8 +991,8 @@ class Compilation {
context: context
? context
: originModule
? originModule.context
: this.compiler.context,
? originModule.context
: this.compiler.context,
dependencies: dependencies
},
(err, result) => {
@ -1504,7 +1504,9 @@ class Compilation {
this.chunkGraph.connectChunkAndRuntimeModule(chunk, module);
// Setup internals
this.moduleGraph.getExportsInfo(module).setUsedForSideEffectsOnly();
const exportsInfo = this.moduleGraph.getExportsInfo(module);
exportsInfo.setHasProvideInfo();
exportsInfo.setUsedForSideEffectsOnly();
this.chunkGraph.addModuleRuntimeRequirements(module, [
RuntimeGlobals.require
]);

View File

@ -1323,8 +1323,8 @@ class JavascriptParser {
statement.kind === "const"
? this.hooks.varDeclarationConst
: statement.kind === "let"
? this.hooks.varDeclarationLet
: this.hooks.varDeclarationVar;
? this.hooks.varDeclarationLet
: this.hooks.varDeclarationVar;
for (const declarator of statement.declarations) {
switch (declarator.type) {
case "VariableDeclarator": {

View File

@ -19,9 +19,8 @@ const stringifySafe = data => {
return undefined; // Invalid JSON
}
return stringified.replace(
/\u2028|\u2029/g,
str => (str === "\u2029" ? "\\u2029" : "\\u2028")
return stringified.replace(/\u2028|\u2029/g, str =>
str === "\u2029" ? "\\u2029" : "\\u2028"
); // invalid in JavaScript but valid JSON
};

View File

@ -123,10 +123,10 @@ class RuntimeTemplate {
moduleId === null
? JSON.stringify("Module is not available (weak dependency)")
: idExpr
? `"Module '" + ${idExpr} + "' is not available (weak dependency)"`
: JSON.stringify(
`Module '${moduleId}' is not available (weak dependency)`
);
? `"Module '" + ${idExpr} + "' is not available (weak dependency)"`
: JSON.stringify(
`Module '${moduleId}' is not available (weak dependency)`
);
const comment = request ? Template.toNormalComment(request) + " " : "";
const errorStatements =
`var e = new Error(${errorMessage}); ` +

View File

@ -252,12 +252,12 @@ class UmdMainTemplatePlugin {
amdFactory +
");\n"
: this.names.amd && this.namedDefine === true
? " define(" +
libraryName(this.names.amd) +
", [], " +
amdFactory +
");\n"
: " define([], " + amdFactory + ");\n") +
? " define(" +
libraryName(this.names.amd) +
", [], " +
amdFactory +
");\n"
: " define([], " + amdFactory + ");\n") +
(this.names.root || this.names.commonjs
? getAuxilaryComment("commonjs") +
" else if(typeof exports === 'object')\n" +

View File

@ -19,8 +19,8 @@ class IgnoringWatchFileSystem {
watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
const ignored = path =>
this.paths.some(
p => (p instanceof RegExp ? p.test(path) : path.indexOf(p) === 0)
this.paths.some(p =>
p instanceof RegExp ? p.test(path) : path.indexOf(p) === 0
);
const notIgnored = path => !ignored(path);

View File

@ -273,10 +273,10 @@ class WebpackOptionsApply extends OptionsApply {
"MappingURL=[url]\n//# source" +
"MappingURL=[url]\n*/"
: legacy
? "\n/*\n//@ source" + "MappingURL=[url]\n*/"
: modern
? "\n//# source" + "MappingURL=[url]"
: null;
? "\n/*\n//@ source" + "MappingURL=[url]\n*/"
: modern
? "\n//# source" + "MappingURL=[url]"
: null;
const Plugin = evalWrapped
? EvalSourceMapDevToolPlugin
: SourceMapDevToolPlugin;
@ -298,10 +298,10 @@ class WebpackOptionsApply extends OptionsApply {
legacy && modern
? "\n//@ sourceURL=[url]\n//# sourceURL=[url]"
: legacy
? "\n//@ sourceURL=[url]"
: modern
? "\n//# sourceURL=[url]"
: null;
? "\n//@ sourceURL=[url]"
: modern
? "\n//# sourceURL=[url]"
: null;
new EvalDevToolModulePlugin({
sourceUrlComment: comment,
moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,

View File

@ -35,10 +35,8 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
this.set("entry", "./src");
this.set(
"devtool",
"make",
options => (options.mode === "development" ? "eval" : false)
this.set("devtool", "make", options =>
options.mode === "development" ? "eval" : false
);
this.set("cache", "call", (value, options) => {
if (value === undefined) {
@ -239,10 +237,8 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
});
this.set("performance.maxAssetSize", 250000);
this.set("performance.maxEntrypointSize", 250000);
this.set(
"performance.hints",
"make",
options => (isProductionLikeMode(options) ? "warning" : false)
this.set("performance.hints", "make", options =>
isProductionLikeMode(options) ? "warning" : false
);
this.set("optimization", "call", value => Object.assign({}, value));

View File

@ -102,11 +102,14 @@ class IdleFileCachePlugin {
};
let idleTimer = undefined;
compiler.cache.hooks.beginIdle.tap("IdleFileCachePlugin", () => {
idleTimer = setTimeout(() => {
idleTimer = undefined;
isIdle = true;
resolvedPromise.then(processIdleTasks);
}, isInitialStore ? idleTimeoutForInitialStore : idleTimeout);
idleTimer = setTimeout(
() => {
idleTimer = undefined;
isIdle = true;
resolvedPromise.then(processIdleTasks);
},
isInitialStore ? idleTimeoutForInitialStore : idleTimeout
);
idleTimer.unref();
});
compiler.cache.hooks.endIdle.tap("IdleFileCachePlugin", () => {

View File

@ -776,20 +776,20 @@ module.exports = class SplitChunksPlugin {
cacheGroupSource.minChunks !== undefined
? cacheGroupSource.minChunks
: cacheGroupSource.enforce
? 1
: this.options.minChunks,
? 1
: this.options.minChunks,
maxAsyncRequests:
cacheGroupSource.maxAsyncRequests !== undefined
? cacheGroupSource.maxAsyncRequests
: cacheGroupSource.enforce
? Infinity
: this.options.maxAsyncRequests,
? Infinity
: this.options.maxAsyncRequests,
maxInitialRequests:
cacheGroupSource.maxInitialRequests !== undefined
? cacheGroupSource.maxInitialRequests
: cacheGroupSource.enforce
? Infinity
: this.options.maxInitialRequests,
? Infinity
: this.options.maxInitialRequests,
getName:
cacheGroupSource.getName !== undefined
? cacheGroupSource.getName
@ -934,11 +934,11 @@ module.exports = class SplitChunksPlugin {
const maxRequests = chunk.isOnlyInitial()
? item.cacheGroup.maxInitialRequests
: chunk.canBeInitial()
? Math.min(
item.cacheGroup.maxInitialRequests,
item.cacheGroup.maxAsyncRequests
)
: item.cacheGroup.maxAsyncRequests;
? Math.min(
item.cacheGroup.maxInitialRequests,
item.cacheGroup.maxAsyncRequests
)
: item.cacheGroup.maxAsyncRequests;
return (
!isFinite(maxRequests) || getRequests(chunk) < maxRequests
);

View File

@ -147,23 +147,20 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
`return Object.prototype.hasOwnProperty.call(staticMapping, chunkId) ? staticMapping[chunkId] : ${url};`
]
: staticUrls.size > 0
? [
// if is shorter for 1 - 15 cases
// it minimizes to `x===1?"...":x===2?"...":"..."`
"// return url for filenames not based on template",
Template.asString(
Array.from(staticUrls).map(
([id, url]) =>
`if(chunkId === ${JSON.stringify(id)}) return ${url};`
)
),
"// return url for filenames based on template",
`return ${url};`
]
: [
"// return url for filenames based on template",
`return ${url};`
]
? [
// if is shorter for 1 - 15 cases
// it minimizes to `x===1?"...":x===2?"...":"..."`
"// return url for filenames not based on template",
Template.asString(
Array.from(staticUrls).map(
([id, url]) =>
`if(chunkId === ${JSON.stringify(id)}) return ${url};`
)
),
"// return url for filenames based on template",
`return ${url};`
]
: ["// return url for filenames based on template", `return ${url};`]
),
"};"
]);

View File

@ -67,25 +67,24 @@ class StartupChunkDependenciesRuntimeModule extends RuntimeModule {
chunkIds[0]
)}).then(next);`
: chunkIds.length > 2
? Template.asString([
// using map is shorter for 3 or more chunks
`return Promise.all(${JSON.stringify(chunkIds)}.map(${
RuntimeGlobals.ensureChunk
}, __webpack_require__)).then(next);`
])
: Template.asString([
// calling ensureChunk directly is shorter for 0 - 2 chunks
"return Promise.all([",
Template.indent(
chunkIds
.map(
id =>
`${RuntimeGlobals.ensureChunk}(${JSON.stringify(id)})`
)
.join(",\n")
),
"]).then(next);"
])
? Template.asString([
// using map is shorter for 3 or more chunks
`return Promise.all(${JSON.stringify(chunkIds)}.map(${
RuntimeGlobals.ensureChunk
}, __webpack_require__)).then(next);`
])
: Template.asString([
// calling ensureChunk directly is shorter for 0 - 2 chunks
"return Promise.all([",
Template.indent(
chunkIds
.map(
id => `${RuntimeGlobals.ensureChunk}(${JSON.stringify(id)})`
)
.join(",\n")
),
"]).then(next);"
])
]),
"}"
]);

View File

@ -24,37 +24,36 @@
"micromatch": "^3.1.8",
"mkdirp": "~0.5.0",
"neo-async": "^2.5.0",
"schema-utils": "^0.4.4",
"schema-utils": "^1.0.0",
"tapable": "^1.1.0",
"terser-webpack-plugin": "^1.2.1",
"watchpack": "2.0.0-beta.2",
"webpack-sources": "2.0.0-beta.1"
},
"devDependencies": {
"@types/node": "^10.12.3",
"@types/node": "^10.12.21",
"@types/tapable": "^1.0.1",
"benchmark": "^2.1.1",
"bundle-loader": "~0.5.0",
"codacy-coverage": "^3.1.0",
"coffee-loader": "^0.9.0",
"coffeescript": "^1.10.0",
"coffeescript": "^2.3.2",
"coveralls": "^3.0.2",
"css-loader": "^0.28.3",
"css-loader": "^2.1.0",
"es6-promise-polyfill": "^1.1.1",
"eslint": "^5.8.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-jest": "^21.26.2",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-jest": "^22.2.2",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.0",
"file-loader": "^1.1.6",
"file-loader": "^3.0.1",
"glob": "^7.1.3",
"husky": "^1.1.3",
"istanbul": "^0.4.5",
"jest": "24.0.0-alpha.1",
"jest-junit": "^5.2.0",
"jest": "24.1.0",
"jest-junit": "^6.2.1",
"json-loader": "^0.5.7",
"json-schema-to-typescript": "^6.0.1",
"less": "^2.5.1",
"less": "^3.9.0",
"less-loader": "^4.0.3",
"lint-staged": "^8.0.4",
"lodash": "^4.17.4",
@ -62,15 +61,15 @@
"pretty-format": "24.0.0-alpha.1",
"pug": "^2.0.3",
"pug-loader": "^2.4.0",
"raw-loader": "~0.5.0",
"react": "^15.2.1",
"react-dom": "^15.2.1",
"raw-loader": "^1.0.0",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"rimraf": "^2.6.2",
"script-loader": "~0.7.0",
"simple-git": "^1.65.0",
"style-loader": "^0.19.1",
"style-loader": "^0.23.1",
"typescript": "^3.2.2",
"url-loader": "^0.6.2",
"url-loader": "^1.1.2",
"wast-loader": "^1.5.5",
"worker-loader": "^2.0.0",
"xxhashjs": "^0.2.1"
@ -98,7 +97,7 @@
"test": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest",
"test:update-snapshots": "yarn jest -u",
"test:integration": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\"",
"test:basic": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/{TestCasesNormal,StatsTestCases,ConfigTestCases}.test.js\"",
"test:basic": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/te{st/TestCasesNormal,st/StatsTestCases,st/ConfigTestCases}.test.js\"",
"test:unit": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\"",
"travis:integration": "yarn cover:init && yarn cover:integration --ci $JEST",
"travis:basic": "yarn test:basic --ci $JEST",

View File

@ -1,6 +1,6 @@
"use strict";
/* globals describe expect it beforeAll */
/* globals describe expect it */
const path = require("path");
const fs = require("fs");
const vm = require("vm");

View File

@ -1,6 +1,6 @@
"use strict";
/* globals expect fit */
/* globals expect */
const path = require("path");
const fs = require("fs");
const vm = require("vm");

View File

@ -1,4 +1,4 @@
/* globals describe, it, beforeEach, afterEach */
/* globals describe it beforeEach */
"use strict";
const NormalModule = require("../lib/NormalModule");

View File

@ -1,4 +1,4 @@
/* globals describe, it, beforeEach */
/* globals describe it */
"use strict";
const { formatSize } = require("../lib/SizeFormatHelpers");

View File

@ -1,4 +1,4 @@
/* global describe it beforeAll expect */
/* global describe it expect */
"use strict";
const path = require("path");

View File

@ -1,4 +1,4 @@
/* global beforeAll expect fit */
/* global beforeAll expect */
"use strict";
const path = require("path");

View File

@ -738,9 +738,9 @@ Entrypoint main = main.js
`;
exports[`StatsTestCases should print correct stats for filter-warnings 1`] = `
"Hash: 2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f2f5b15eaf2a1fb80a33f
"Hash: a10789627d1863900586a10789627d1863900586a10789627d1863900586a10789627d1863900586a10789627d1863900586a10789627d1863900586a10789627d1863900586a10789627d1863900586a10789627d1863900586a10789627d1863900586a10789627d1863900586a10789627d1863900586a10789627d1863900586
Child undefined:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
@ -770,49 +770,49 @@ Child undefined:
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
Child Terser:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
bundle.js 1.32 KiB {404} [emitted] main
Entrypoint main = bundle.js
Child /Terser/:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
bundle.js 1.32 KiB {404} [emitted] main
Entrypoint main = bundle.js
Child warnings => true:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
bundle.js 1.32 KiB {404} [emitted] main
Entrypoint main = bundle.js
Child [Terser]:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
bundle.js 1.32 KiB {404} [emitted] main
Entrypoint main = bundle.js
Child [/Terser/]:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
bundle.js 1.32 KiB {404} [emitted] main
Entrypoint main = bundle.js
Child [warnings => true]:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
bundle.js 1.32 KiB {404} [emitted] main
Entrypoint main = bundle.js
Child should not filter:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
@ -842,7 +842,7 @@ Child should not filter:
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
Child /should not filter/:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
@ -872,7 +872,7 @@ Child /should not filter/:
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
Child warnings => false:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
@ -902,7 +902,7 @@ Child warnings => false:
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
Child [should not filter]:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
@ -932,7 +932,7 @@ Child [should not filter]:
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
Child [/should not filter/]:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
@ -962,7 +962,7 @@ Child [/should not filter/]:
WARNING in Terser Plugin: Dropping unused function someUnUsedFunction5 [./index.js:12,0]
Child [warnings => false]:
Hash: 2f5b15eaf2a1fb80a33f
Hash: a10789627d1863900586
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
@ -3460,7 +3460,7 @@ Entrypoint main = bundle.js
`;
exports[`StatsTestCases should print correct stats for warnings-terser 1`] = `
"Hash: a1c39c4e43eb7943bde9
"Hash: 498ee970af2d984c0084
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names

View File

@ -1 +1,2 @@
export { process };
const p = process;
export { p as process };

View File

@ -1,4 +1,4 @@
/* globals describe, beforeEach, it */
/* globals describe it */
"use strict";
const identifierUtil = require("../lib/util/identifier");

3381
yarn.lock

File diff suppressed because it is too large Load Diff