run prettier

This commit is contained in:
Tobias Koppers 2019-11-15 10:20:45 +01:00
parent e351d1d0d3
commit 497b65e122
12 changed files with 59 additions and 57 deletions

View File

@ -27,7 +27,7 @@ export type EntryStatic = EntryObject | EntryItem;
* This interface was referenced by `WebpackOptions`'s JSON-Schema * This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "NonEmptyArrayOfUniqueStringValues". * via the `definition` "NonEmptyArrayOfUniqueStringValues".
*/ */
export type NonEmptyArrayOfUniqueStringValues = [string, ...(string)[]]; export type NonEmptyArrayOfUniqueStringValues = [string, ...string[]];
/** /**
* This interface was referenced by `WebpackOptions`'s JSON-Schema * This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryItem". * via the `definition` "EntryItem".
@ -50,7 +50,8 @@ export type Externals =
request: string, request: string,
callback: (err?: Error, result?: string) => void callback: (err?: Error, result?: string) => void
) => void) ) => void)
| ExternalItem)[]; | ExternalItem
)[];
/** /**
* This interface was referenced by `WebpackOptions`'s JSON-Schema * This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "ExternalItem". * via the `definition` "ExternalItem".
@ -412,7 +413,8 @@ export interface WebpackOptions {
| "normal" | "normal"
| "detailed" | "detailed"
| "verbose" | "verbose"
| "errors-warnings"); | "errors-warnings"
);
/** /**
* Environment to build for * Environment to build for
*/ */
@ -425,7 +427,8 @@ export interface WebpackOptions {
| "node-webkit" | "node-webkit"
| "electron-main" | "electron-main"
| "electron-renderer" | "electron-renderer"
| "electron-preload") | "electron-preload"
)
| ((compiler: import("../lib/Compiler")) => void); | ((compiler: import("../lib/Compiler")) => void);
/** /**
* Enter watch mode, which rebuilds on file change. * Enter watch mode, which rebuilds on file change.
@ -594,10 +597,10 @@ export interface ModuleOptions {
* Don't parse files matching. It's matched against the full resolved request. * Don't parse files matching. It's matched against the full resolved request.
*/ */
noParse?: noParse?:
| [RegExp, ...(RegExp)[]] | [RegExp, ...RegExp[]]
| RegExp | RegExp
| Function | Function
| [string, ...(string)[]] | [string, ...string[]]
| string; | string;
/** /**
* An array of rules applied for modules. * An array of rules applied for modules.

View File

@ -8,5 +8,5 @@ export interface WatchIgnorePluginOptions {
/** /**
* A list of RegExps or absolute paths to directories or files that should be ignored * A list of RegExps or absolute paths to directories or files that should be ignored
*/ */
paths: [(string | RegExp), ...(string | RegExp)[]]; paths: [string | RegExp, ...(string | RegExp)[]];
} }

View File

@ -149,12 +149,10 @@ class CommonJsStuffPlugin {
])(expr); ])(expr);
} }
}); });
parser.hooks.evaluateIdentifier parser.hooks.evaluateIdentifier.for("module.hot").tap(
.for("module.hot") "CommonJsStuffPlugin",
.tap( evaluateToIdentifier("module.hot", "module", () => ["hot"], false)
"CommonJsStuffPlugin", );
evaluateToIdentifier("module.hot", "module", () => ["hot"], false)
);
parser.hooks.expression parser.hooks.expression
.for("module") .for("module")
.tap("CommonJsStuffPlugin", expr => { .tap("CommonJsStuffPlugin", expr => {
@ -236,26 +234,25 @@ class NodeModuleDecoratorRuntimeModule extends RuntimeModule {
generate() { generate() {
const { runtimeTemplate } = this.compilation; const { runtimeTemplate } = this.compilation;
return Template.asString([ return Template.asString([
`${RuntimeGlobals.nodeModuleDecorator} = ${runtimeTemplate.basicFunction( `${
"module", RuntimeGlobals.nodeModuleDecorator
[ } = ${runtimeTemplate.basicFunction("module", [
"module.paths = [];", "module.paths = [];",
"if (!module.children) module.children = [];", "if (!module.children) module.children = [];",
"Object.defineProperty(module, 'loaded', {", "Object.defineProperty(module, 'loaded', {",
Template.indent([ Template.indent([
"enumerable: true,", "enumerable: true,",
`get: ${runtimeTemplate.returningFunction("module.l")}` `get: ${runtimeTemplate.returningFunction("module.l")}`
]), ]),
"});", "});",
"Object.defineProperty(module, 'id', {", "Object.defineProperty(module, 'id', {",
Template.indent([ Template.indent([
"enumerable: true,", "enumerable: true,",
`get: ${runtimeTemplate.returningFunction("module.i")}` `get: ${runtimeTemplate.returningFunction("module.i")}`
]), ]),
"});", "});",
"return module;" "return module;"
] ])};`
)};`
]); ]);
} }
} }

View File

@ -76,9 +76,7 @@ class CompatibilityPlugin {
statement.id && statement.id &&
statement.id.name === "__webpack_require__" statement.id.name === "__webpack_require__"
) { ) {
const newName = `__nested_webpack_require_${ const newName = `__nested_webpack_require_${statement.range[0]}__`;
statement.range[0]
}__`;
const dep = new ConstDependency(newName, statement.id.range); const dep = new ConstDependency(newName, statement.id.range);
dep.loc = statement.id.loc; dep.loc = statement.id.loc;
parser.state.module.addPresentationalDependency(dep); parser.state.module.addPresentationalDependency(dep);

View File

@ -234,7 +234,9 @@ class HotModuleReplacementPlugin {
} }
records.chunkModuleIds = {}; records.chunkModuleIds = {};
for (const chunk of compilation.chunks) { for (const chunk of compilation.chunks) {
records.chunkModuleIds[chunk.id] = Array.from( records.chunkModuleIds[
chunk.id
] = Array.from(
chunkGraph.getOrderedChunkModulesIterable( chunkGraph.getOrderedChunkModulesIterable(
chunk, chunk,
compareModulesById(chunkGraph) compareModulesById(chunkGraph)

View File

@ -22,9 +22,7 @@ const prepareId = id => {
if (/^"\s\+*.*\+\s*"$/.test(id)) { if (/^"\s\+*.*\+\s*"$/.test(id)) {
const match = /^"\s\+*\s*(.*)\s*\+\s*"$/.exec(id); const match = /^"\s\+*\s*(.*)\s*\+\s*"$/.exec(id);
return `" + (${ return `" + (${match[1]} + "").replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_") + "`;
match[1]
} + "").replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_") + "`;
} }
return id.replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_"); return id.replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_");

View File

@ -100,7 +100,8 @@ class HarmonyImportDependency extends ModuleDependency {
// It's not an harmony module // It's not an harmony module
if ( if (
moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule && moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule &&
(ids.length > 0 && ids[0] !== "default") ids.length > 0 &&
ids[0] !== "default"
) { ) {
// In strict harmony modules we only support the default export // In strict harmony modules we only support the default export
return [ return [

View File

@ -42,7 +42,10 @@ const canMangle = (exportsInfo, canBeArray) => {
const comparator = concatComparators( const comparator = concatComparators(
// Sort used before unused fields // Sort used before unused fields
compareSelect(e => e.used !== false, (a, b) => (a === b ? 0 : a ? -1 : 1)), compareSelect(
e => e.used !== false,
(a, b) => (a === b ? 0 : a ? -1 : 1)
),
// Sort by name // Sort by name
compareSelect(e => e.name, compareStringsNumeric) compareSelect(e => e.name, compareStringsNumeric)
); );

View File

@ -26,15 +26,14 @@ class EnsureChunkRuntimeModule extends RuntimeModule {
`${handlers} = {};`, `${handlers} = {};`,
"// This file contains only the entry chunk.", "// This file contains only the entry chunk.",
"// The chunk loading function for additional chunks", "// The chunk loading function for additional chunks",
`${RuntimeGlobals.ensureChunk} = ${runtimeTemplate.basicFunction( `${
"chunkId", RuntimeGlobals.ensureChunk
[ } = ${runtimeTemplate.basicFunction("chunkId", [
`return Promise.all(Object.keys(${handlers}).reduce(${runtimeTemplate.basicFunction( `return Promise.all(Object.keys(${handlers}).reduce(${runtimeTemplate.basicFunction(
"promises, key", "promises, key",
[`${handlers}[key](chunkId, promises);`, "return promises;"] [`${handlers}[key](chunkId, promises);`, "return promises;"]
)}, []));` )}, []));`
] ])};`
)};`
]); ]);
} else { } else {
// There ensureChunk is used somewhere in the tree, so we need an empty requireEnsure // There ensureChunk is used somewhere in the tree, so we need an empty requireEnsure

View File

@ -154,9 +154,7 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
", " ", "
)}]) { return ${instantiateCall}; })` )}]) { return ${instantiateCall}; })`
: promises.length === 1 : promises.length === 1
? `${module.moduleArgument}.exports = Promise.resolve(${ ? `${module.moduleArgument}.exports = Promise.resolve(${promises[0]}).then(function(${promises[0]}) { return ${instantiateCall}; })`
promises[0]
}).then(function(${promises[0]}) { return ${instantiateCall}; })`
: `${module.moduleArgument}.exports = ${instantiateCall}` : `${module.moduleArgument}.exports = ${instantiateCall}`
]) ])
); );

View File

@ -660,9 +660,9 @@ rules:
title: "Backport to webpack 4: {{{pull_request.title}}}" title: "Backport to webpack 4: {{{pull_request.title}}}"
body: |- body: |-
{{{pull_request.html_url}}} needs to be backported to webpack 4. {{{pull_request.html_url}}} needs to be backported to webpack 4.
Send a PR. Send a PR.
cc @{{pull_request.user.login}} cc @{{pull_request.user.login}}
comment: comment:
identifier: admin-action-webpack-4-backport-executed identifier: admin-action-webpack-4-backport-executed

View File

@ -49,7 +49,10 @@ function checkSymlinkExistsAsync() {
function ensureYarnInstalledAsync() { function ensureYarnInstalledAsync() {
const semverPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/; const semverPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/;
return execGetOutput("yarn", ["-v"], "Check yarn version") return execGetOutput("yarn", ["-v"], "Check yarn version")
.then(stdout => semverPattern.test(stdout), () => false) .then(
stdout => semverPattern.test(stdout),
() => false
)
.then(hasYarn => hasYarn || installYarnAsync()); .then(hasYarn => hasYarn || installYarnAsync());
} }