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
* via the `definition` "NonEmptyArrayOfUniqueStringValues".
*/
export type NonEmptyArrayOfUniqueStringValues = [string, ...(string)[]];
export type NonEmptyArrayOfUniqueStringValues = [string, ...string[]];
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "EntryItem".
@ -50,7 +50,8 @@ export type Externals =
request: string,
callback: (err?: Error, result?: string) => void
) => void)
| ExternalItem)[];
| ExternalItem
)[];
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "ExternalItem".
@ -412,7 +413,8 @@ export interface WebpackOptions {
| "normal"
| "detailed"
| "verbose"
| "errors-warnings");
| "errors-warnings"
);
/**
* Environment to build for
*/
@ -425,7 +427,8 @@ export interface WebpackOptions {
| "node-webkit"
| "electron-main"
| "electron-renderer"
| "electron-preload")
| "electron-preload"
)
| ((compiler: import("../lib/Compiler")) => void);
/**
* 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.
*/
noParse?:
| [RegExp, ...(RegExp)[]]
| [RegExp, ...RegExp[]]
| RegExp
| Function
| [string, ...(string)[]]
| [string, ...string[]]
| string;
/**
* 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
*/
paths: [(string | RegExp), ...(string | RegExp)[]];
paths: [string | RegExp, ...(string | RegExp)[]];
}

View File

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

View File

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

View File

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

View File

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

View File

@ -42,7 +42,10 @@ const canMangle = (exportsInfo, canBeArray) => {
const comparator = concatComparators(
// 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
compareSelect(e => e.name, compareStringsNumeric)
);

View File

@ -26,15 +26,14 @@ class EnsureChunkRuntimeModule extends RuntimeModule {
`${handlers} = {};`,
"// This file contains only the entry chunk.",
"// The chunk loading function for additional chunks",
`${RuntimeGlobals.ensureChunk} = ${runtimeTemplate.basicFunction(
"chunkId",
[
`return Promise.all(Object.keys(${handlers}).reduce(${runtimeTemplate.basicFunction(
"promises, key",
[`${handlers}[key](chunkId, promises);`, "return promises;"]
)}, []));`
]
)};`
`${
RuntimeGlobals.ensureChunk
} = ${runtimeTemplate.basicFunction("chunkId", [
`return Promise.all(Object.keys(${handlers}).reduce(${runtimeTemplate.basicFunction(
"promises, key",
[`${handlers}[key](chunkId, promises);`, "return promises;"]
)}, []));`
])};`
]);
} else {
// 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}; })`
: promises.length === 1
? `${module.moduleArgument}.exports = Promise.resolve(${
promises[0]
}).then(function(${promises[0]}) { return ${instantiateCall}; })`
? `${module.moduleArgument}.exports = Promise.resolve(${promises[0]}).then(function(${promises[0]}) { return ${instantiateCall}; })`
: `${module.moduleArgument}.exports = ${instantiateCall}`
])
);

View File

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

View File

@ -49,7 +49,10 @@ function checkSymlinkExistsAsync() {
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-]+)*)?$/;
return execGetOutput("yarn", ["-v"], "Check yarn version")
.then(stdout => semverPattern.test(stdout), () => false)
.then(
stdout => semverPattern.test(stdout),
() => false
)
.then(hasYarn => hasYarn || installYarnAsync());
}