Update prettier toolchain

This commit is contained in:
Florent Cailhol 2018-03-26 16:56:10 +02:00
parent fc2feaf6d7
commit f1092ad516
38 changed files with 203 additions and 253 deletions

View File

@ -1,7 +1,7 @@
module.exports = {
root: true,
plugins: ["prettier", "node"],
extends: ["eslint:recommended", "plugin:node/recommended"],
extends: ["eslint:recommended", "plugin:node/recommended", "plugin:prettier/recommended"],
env: {
node: true,
es6: true
@ -16,6 +16,7 @@ module.exports = {
"semi": "error",
"no-template-curly-in-string": "error",
"no-caller": "error",
"no-control-regex": "off",
"yoda": "error",
"eqeqeq": "error",
"global-require": "off",

View File

@ -1,4 +0,0 @@
{
"tabWidth": 2,
"useTabs": true
}

5
.prettierrc.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
printWidth: 80,
useTabs: true,
tabWidth: 2
};

View File

@ -52,11 +52,11 @@ class APIPlugin {
? ParserHelpers.toConstantDependency(
parser,
REPLACEMENTS[key]
)
)
: ParserHelpers.toConstantDependencyWithWebpackRequire(
parser,
REPLACEMENTS[key]
)
)
);
parser.hooks.evaluateTypeof
.for(key)

View File

@ -36,17 +36,15 @@ class AmdMainTemplatePlugin {
});
return new ConcatSource(
`define(${JSON.stringify(name)}, ${externalsDepsArray}, function(${
externalsArguments
}) { return `,
`define(${JSON.stringify(
name
)}, ${externalsDepsArray}, function(${externalsArguments}) { return `,
source,
"});"
);
} else if (externalsArguments) {
return new ConcatSource(
`define(${externalsDepsArray}, function(${
externalsArguments
}) { return `,
`define(${externalsDepsArray}, function(${externalsArguments}) { return `,
source,
"});"
);

View File

@ -11,9 +11,7 @@ module.exports = class AsyncDependencyToInitialChunkError extends WebpackError {
super();
this.name = "AsyncDependencyToInitialChunkError";
this.message = `It's not allowed to load an initial chunk on demand. The chunk name "${
chunkName
}" is already used by an entrypoint.`;
this.message = `It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`;
this.module = module;
this.origin = module;
this.originLoc = loc;

View File

@ -624,12 +624,12 @@ class Compilation extends Tapable {
const errorAndCallback = this.bail
? err => {
callback(err);
}
}
: err => {
err.dependencies = [dependency];
this.errors.push(err);
callback();
};
};
if (
typeof dependency !== "object" ||

View File

@ -281,9 +281,11 @@ class ContextModule extends Module {
getReturnModuleObjectSource(fakeMap, fakeMapDataExpression = "fakeMap[id]") {
if (typeof fakeMap === "number")
return `return ${this.getReturn(fakeMap)};`;
return `return ${fakeMapDataExpression} === 1 ? ${this.getReturn(1)} : ${
fakeMapDataExpression
} ? ${this.getReturn(2)} : ${this.getReturn(0)};`;
return `return ${fakeMapDataExpression} === 1 ? ${this.getReturn(
1
)} : ${fakeMapDataExpression} ? ${this.getReturn(2)} : ${this.getReturn(
0
)};`;
}
getSyncSource(dependencies, id) {
@ -500,9 +502,7 @@ module.exports = webpackAsyncContext;`;
const chunksStartPosition = typeof fakeMap === "object" ? 2 : 1;
const requestPrefix = hasMultipleOrNoChunks
? `Promise.all(ids.slice(${
chunksStartPosition
}).map(__webpack_require__.e))`
? `Promise.all(ids.slice(${chunksStartPosition}).map(__webpack_require__.e))`
: `__webpack_require__.e(ids[${chunksStartPosition}])`;
const returnModuleObject = this.getReturnModuleObjectSource(
fakeMap,

View File

@ -112,7 +112,7 @@ class DefinePlugin {
? ParserHelpers.toConstantDependencyWithWebpackRequire(
parser,
code
)
)
: ParserHelpers.toConstantDependency(parser, code)
);
}
@ -164,7 +164,7 @@ class DefinePlugin {
? ParserHelpers.toConstantDependencyWithWebpackRequire(
parser,
code
)
)
: ParserHelpers.toConstantDependency(parser, code)
);
parser.hooks.typeof

View File

@ -42,9 +42,7 @@ class EnvironmentPlugin {
if (value === undefined) {
compiler.hooks.thisCompilation.tap("EnvironmentPlugin", compilation => {
const error = new Error(
`EnvironmentPlugin - ${
key
} environment variable is undefined.\n\n` +
`EnvironmentPlugin - ${key} environment variable is undefined.\n\n` +
"You can pass an object with default values to suppress this warning.\n" +
"See https://webpack.js.org/plugins/environment-plugin for example."
);

View File

@ -76,9 +76,9 @@ class ExternalModule extends Module {
}
checkExternalVariable(variableToCheck, request) {
return `if(typeof ${
variableToCheck
} === 'undefined') {${WebpackMissingModule.moduleCode(request)}}\n`;
return `if(typeof ${variableToCheck} === 'undefined') {${WebpackMissingModule.moduleCode(
request
)}}\n`;
}
getSourceForAmdOrUmdExternal(id, optional, request) {

View File

@ -179,7 +179,7 @@ module.exports = class MainTemplate extends Tapable {
"if(threw) delete installedModules[moduleId];"
]),
"}"
]
]
: [
"// Execute the module function",
`modules[moduleId].call(module.exports, module, module.exports, ${this.renderRequireFunctionForModule(
@ -187,7 +187,7 @@ module.exports = class MainTemplate extends Tapable {
chunk,
"moduleId"
)});`
]
]
),
"",
"// Flag the module as loaded",

View File

@ -63,7 +63,7 @@ ModuleFilenameHelpers.createFilename = (module, options, requestShortener) => {
? options
: {
moduleFilenameTemplate: options
}
}
);
let absoluteResourcePath;

View File

@ -412,7 +412,7 @@ class NormalModuleFactory extends Tapable {
const optionsOnly = item.options
? {
options: item.options
}
}
: undefined;
return callback(
null,

View File

@ -26,7 +26,7 @@ class RecordIdsPlugin {
compiler.context,
module.identifier(),
compilation.cache
)
)
: module.identifier();
records.modules.byIdentifier[identifier] = module.id;
records.modules.usedIds[module.id] = module.id;
@ -46,7 +46,7 @@ class RecordIdsPlugin {
compiler.context,
module.identifier(),
compilation.cache
)
)
: module.identifier();
const id = records.modules.byIdentifier[identifier];
if (id === undefined) continue;

View File

@ -86,15 +86,11 @@ module.exports = class RuntimeTemplate {
if (exportsType === "namespace") {
return rawModule;
} else if (exportsType === "named") {
return `Object.assign({/* fake namespace object */}, ${
rawModule
}, { "default": ${rawModule} })`;
return `Object.assign({/* fake namespace object */}, ${rawModule}, { "default": ${rawModule} })`;
} else if (strict) {
return `Object({ /* fake namespace object */ "default": ${rawModule} })`;
} else {
return `Object(function() { var module = ${
rawModule
}; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }())`;
return `Object(function() { var module = ${rawModule}; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }())`;
}
}
@ -120,11 +116,7 @@ module.exports = class RuntimeTemplate {
header += `var id = ${idExpr}; `;
idExpr = "id";
}
header += `if(!__webpack_require__.m[${
idExpr
}]) { var e = new Error("Module '" + ${
idExpr
} + "' is not available (weak dependency)"); e.code = 'MODULE_NOT_FOUND'; throw e; } `;
header += `if(!__webpack_require__.m[${idExpr}]) { var e = new Error("Module '" + ${idExpr} + "' is not available (weak dependency)"); e.code = 'MODULE_NOT_FOUND'; throw e; } `;
}
const rawModule = this.moduleRaw({
module,
@ -135,22 +127,14 @@ module.exports = class RuntimeTemplate {
if (header) {
getModuleFunction = `function() { ${header}return ${rawModule}; }`;
} else {
getModuleFunction = `__webpack_require__.bind(null, ${comment}${
idExpr
})`;
getModuleFunction = `__webpack_require__.bind(null, ${comment}${idExpr})`;
}
} else if (exportsType === "named") {
getModuleFunction = `function() { ${header}var module = ${
rawModule
}; return Object.assign({/* fake namespace object */}, module, { "default": module }); }`;
getModuleFunction = `function() { ${header}var module = ${rawModule}; return Object.assign({/* fake namespace object */}, module, { "default": module }); }`;
} else if (strict) {
getModuleFunction = `function() { ${
header
}return { /* fake namespace object */ "default": ${rawModule} }; }`;
getModuleFunction = `function() { ${header}return { /* fake namespace object */ "default": ${rawModule} }; }`;
} else {
getModuleFunction = `function() { ${header}var module = ${
rawModule
}; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }`;
getModuleFunction = `function() { ${header}var module = ${rawModule}; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }`;
}
return `${promise || "Promise.resolve()"}.then(${getModuleFunction})`;
@ -167,28 +151,18 @@ module.exports = class RuntimeTemplate {
const optDeclaration = update ? "" : "var ";
const exportsType = module.buildMeta && module.buildMeta.exportsType;
let content = `/* harmony import */ ${optDeclaration}${
importVar
} = __webpack_require__(${comment}${JSON.stringify(module.id)});\n`;
let content = `/* harmony import */ ${optDeclaration}${importVar} = __webpack_require__(${comment}${JSON.stringify(
module.id
)});\n`;
if (!exportsType && !originModule.buildMeta.strictHarmonyModule) {
content += `/* harmony import */ ${optDeclaration}${
importVar
}_default = /*#__PURE__*/__webpack_require__.n(${importVar});\n`;
content += `/* harmony import */ ${optDeclaration}${importVar}_default = /*#__PURE__*/__webpack_require__.n(${importVar});\n`;
}
if (exportsType === "named") {
if (Array.isArray(module.buildMeta.providedExports))
content += `${optDeclaration}${
importVar
}_namespace = /*#__PURE__*/Object.assign({}, ${
importVar
}, {"default": ${importVar}});\n`;
content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/Object.assign({}, ${importVar}, {"default": ${importVar}});\n`;
else
content += `${optDeclaration}${
importVar
}_namespace = /*#__PURE__*/{ /* fake namespace object */ "default": ${
importVar
} };\n`;
content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/{ /* fake namespace object */ "default": ${importVar} };\n`;
}
return content;
}
@ -223,13 +197,9 @@ module.exports = class RuntimeTemplate {
return "/* non-default import from non-esm module */undefined";
} else if (!exportName) {
if (asiSafe) {
return `/*#__PURE__*/{ /* fake namespace object */ "default": ${
importVar
} }`;
return `/*#__PURE__*/{ /* fake namespace object */ "default": ${importVar} }`;
} else {
return `/*#__PURE__*/Object({ /* fake namespace object */ "default": ${
importVar
} })`;
return `/*#__PURE__*/Object({ /* fake namespace object */ "default": ${importVar} })`;
}
}
}

View File

@ -81,9 +81,7 @@ const replacePathVariables = (path, data) => {
REGEXP_CONTENTHASH_FOR_TEST.test(path))
) {
throw new Error(
`Cannot use [chunkhash] or [contenthash] for chunk in '${
path
}' (use [hash] instead)`
`Cannot use [chunkhash] or [contenthash] for chunk in '${path}' (use [hash] instead)`
);
}

View File

@ -114,9 +114,7 @@ class UmdMainTemplatePlugin {
)})${accessorToObjectAccess(request.slice(1))}`;
} else expr = `require(${JSON.stringify(request)})`;
if (m.optional) {
expr = `(function webpackLoadOptionalExternalModule() { try { return ${
expr
}; } catch(e) {} }())`;
expr = `(function webpackLoadOptionalExternalModule() { try { return ${expr}; } catch(e) {} }())`;
}
return expr;
})
@ -143,13 +141,11 @@ class UmdMainTemplatePlugin {
const factoryArguments =
requiredExternals.length > 0
? externalsArguments(requiredExternals) +
", " +
externalsRootArray(optionalExternals)
", " +
externalsRootArray(optionalExternals)
: externalsRootArray(optionalExternals);
amdFactory =
`function webpackLoadOptionalExternalModuleAmd(${
wrapperArguments
}) {\n` +
`function webpackLoadOptionalExternalModuleAmd(${wrapperArguments}) {\n` +
` return factory(${factoryArguments});\n` +
" }";
} else {
@ -177,61 +173,61 @@ class UmdMainTemplatePlugin {
(requiredExternals.length > 0
? this.names.amd && this.namedDefine === true
? " define(" +
libraryName(this.names.amd) +
", " +
externalsDepsArray(requiredExternals) +
", " +
amdFactory +
");\n"
libraryName(this.names.amd) +
", " +
externalsDepsArray(requiredExternals) +
", " +
amdFactory +
");\n"
: " define(" +
externalsDepsArray(requiredExternals) +
", " +
amdFactory +
");\n"
externalsDepsArray(requiredExternals) +
", " +
amdFactory +
");\n"
: this.names.amd && this.namedDefine === true
? " define(" +
libraryName(this.names.amd) +
", [], " +
amdFactory +
");\n"
libraryName(this.names.amd) +
", [], " +
amdFactory +
");\n"
: " define([], " + amdFactory + ");\n") +
(this.names.root || this.names.commonjs
? (this.auxiliaryComment &&
typeof this.auxiliaryComment === "string"
typeof this.auxiliaryComment === "string"
? " //" + this.auxiliaryComment + "\n"
: this.auxiliaryComment.commonjs
? " //" + this.auxiliaryComment.commonjs + "\n"
: "") +
" else if(typeof exports === 'object')\n" +
" exports[" +
libraryName(this.names.commonjs || this.names.root) +
"] = factory(" +
externalsRequireArray("commonjs") +
");\n" +
(this.auxiliaryComment &&
typeof this.auxiliaryComment === "string"
" else if(typeof exports === 'object')\n" +
" exports[" +
libraryName(this.names.commonjs || this.names.root) +
"] = factory(" +
externalsRequireArray("commonjs") +
");\n" +
(this.auxiliaryComment &&
typeof this.auxiliaryComment === "string"
? " //" + this.auxiliaryComment + "\n"
: this.auxiliaryComment.root
? " //" + this.auxiliaryComment.root + "\n"
: "") +
" else\n" +
" " +
replaceKeys(
" else\n" +
" " +
replaceKeys(
accessorAccess("root", this.names.root || this.names.commonjs)
) +
" = factory(" +
externalsRootArray(externals) +
");\n"
) +
" = factory(" +
externalsRootArray(externals) +
");\n"
: " else {\n" +
(externals.length > 0
(externals.length > 0
? " var a = typeof exports === 'object' ? factory(" +
externalsRequireArray("commonjs") +
") : factory(" +
externalsRootArray(externals) +
");\n"
externalsRequireArray("commonjs") +
") : factory(" +
externalsRootArray(externals) +
");\n"
: " var a = factory();\n") +
" for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n" +
" }\n") +
" for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n" +
" }\n") +
`})(${
runtimeTemplate.outputOptions.globalObject
}, function(${externalsArguments(externals)}) {\nreturn `,

View File

@ -231,8 +231,8 @@ class WebpackOptionsApply extends OptionsApply {
comment =
legacy && modern
? "\n/*\n//@ source" +
"MappingURL=[url]\n//# source" +
"MappingURL=[url]\n*/"
"MappingURL=[url]\n//# source" +
"MappingURL=[url]\n*/"
: legacy
? "\n/*\n//@ source" + "MappingURL=[url]\n*/"
: modern ? "\n//# source" + "MappingURL=[url]" : null;

View File

@ -266,12 +266,10 @@ class WebpackOptionsValidationError extends WebpackError {
)}`;
} else if (err.keyword === "required") {
const missingProperty = err.params.missingProperty.replace(/^\./, "");
return `${dataPath} misses the property '${
missingProperty
}'.\n${getSchemaPartText(err.parentSchema, [
"properties",
missingProperty
])}`;
return `${dataPath} misses the property '${missingProperty}'.\n${getSchemaPartText(
err.parentSchema,
["properties", missingProperty]
)}`;
} else if (err.keyword === "minimum") {
return `${dataPath} ${err.message}.${getSchemaPartDescription(
err.parentSchema

View File

@ -341,9 +341,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
? `the named export '${this.id}'`
: "the namespace object";
const err = new Error(
`Can't reexport ${
exportName
} from non EcmaScript module (only default export is available)`
`Can't reexport ${exportName} from non EcmaScript module (only default export is available)`
);
err.hideStack = true;
return [err];
@ -363,9 +361,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
// We are sure that it's not provided
const idIsNotNameMessage =
this.id !== this.name ? ` (reexported as '${this.name}')` : "";
const errorMessage = `"export '${this.id}'${
idIsNotNameMessage
} was not found in '${this.userRequest}'`;
const errorMessage = `"export '${
this.id
}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
const err = new Error(errorMessage);
err.hideStack = true;
return [err];
@ -578,11 +576,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
const exportsName = dep.originModule.exportsArgument;
return (
content +
`(function(key) { __webpack_require__.d(${
exportsName
}, key, function() { return ${
importVar
}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`
`(function(key) { __webpack_require__.d(${exportsName}, key, function() { return ${importVar}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`
);
}

View File

@ -44,9 +44,9 @@ HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependen
const exportsName = dep.originModule.exportsArgument;
return `/* harmony export (binding) */ __webpack_require__.d(${
exportsName
}, ${JSON.stringify(used)}, function() { return ${dep.id}; });\n`;
return `/* harmony export (binding) */ __webpack_require__.d(${exportsName}, ${JSON.stringify(
used
)}, function() { return ${dep.id}; });\n`;
}
};

View File

@ -77,9 +77,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
? `the named export '${this.id}'`
: "the namespace object";
const err = new Error(
`Can't import ${
exportName
} from non EcmaScript module (only default export is available)`
`Can't import ${exportName} from non EcmaScript module (only default export is available)`
);
err.hideStack = true;
return [err];
@ -99,9 +97,9 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
// We are sure that it's not provided
const idIsNotNameMessage =
this.id !== this.name ? ` (imported as '${this.name}')` : "";
const errorMessage = `"export '${this.id}'${
idIsNotNameMessage
} was not found in '${this.userRequest}'`;
const errorMessage = `"export '${
this.id
}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
const err = new Error(errorMessage);
err.hideStack = true;
return [err];

View File

@ -97,9 +97,7 @@ class ImportParserPlugin {
parser.state.module.warnings.push(
new UnsupportedFeatureWarning(
parser.state.module,
`\`webpackMode\` expected 'lazy', 'eager' or 'weak', but received: ${
mode
}.`
`\`webpackMode\` expected 'lazy', 'eager' or 'weak', but received: ${mode}.`
)
);
}
@ -140,9 +138,7 @@ class ImportParserPlugin {
parser.state.module.warnings.push(
new UnsupportedFeatureWarning(
parser.state.module,
`\`webpackMode\` expected 'lazy', 'lazy-once', 'eager' or 'weak', but received: ${
mode
}.`
`\`webpackMode\` expected 'lazy', 'lazy-once', 'eager' or 'weak', but received: ${mode}.`
)
);
mode = "lazy";

View File

@ -31,7 +31,7 @@ RequireIncludeDependency.Template = class RequireIncludeDependencyTemplate {
const comment = runtime.outputOptions.pathinfo
? Template.toComment(
`require.include ${runtime.requestShortener.shorten(dep.request)}`
)
)
: "";
source.replace(dep.range[0], dep.range[1] - 1, `undefined${comment}`);
}

View File

@ -11,9 +11,7 @@ exports.module = request =>
exports.promise = request => {
const errorCode = toErrorCode(`Cannot find module "${request}"`);
return `Promise.reject(function webpackMissingModule() { ${
errorCode
} return e; }())`;
return `Promise.reject(function webpackMissingModule() { ${errorCode} return e; }())`;
};
exports.moduleCode = request => {

View File

@ -72,9 +72,7 @@ class ReadFileCompileWasmMainTemplatePlugin {
Template.indent([
"(installedWasmModules[wasmModuleId] = new Promise(function(resolve, reject) {",
Template.indent([
`require('fs').readFile(require('path').resolve(__dirname, ${
wasmModuleSrcPath
}), function(err, buffer) {`,
`require('fs').readFile(require('path').resolve(__dirname, ${wasmModuleSrcPath}), function(err, buffer) {`,
Template.indent([
"if(err) return reject(err);",
"resolve(WebAssembly.compile(buffer));"

View File

@ -146,9 +146,9 @@ const getFinalName = (
}
}
const problem =
`Cannot get final name for export "${
exportName
}" in "${info.module.readableIdentifier(requestShortener)}"` +
`Cannot get final name for export "${exportName}" in "${info.module.readableIdentifier(
requestShortener
)}"` +
` (known exports: ${Array.from(info.exportMap.keys())
.filter(name => name !== true)
.join(" ")}, ` +
@ -1134,14 +1134,14 @@ class HarmonyImportSpecifierDependencyConcatenatedTemplate {
if (dep.id === null) {
content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
} else if (dep.namespaceObjectAsContext) {
content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${
strictFlag
}__[${JSON.stringify(dep.id)}]`;
content = `__WEBPACK_MODULE_REFERENCE__${
info.index
}_ns${strictFlag}__[${JSON.stringify(dep.id)}]`;
} else {
const exportData = Buffer.from(dep.id, "utf-8").toString("hex");
content = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${
callFlag
}${strictFlag}__`;
content = `__WEBPACK_MODULE_REFERENCE__${
info.index
}_${exportData}${callFlag}${strictFlag}__`;
}
if (dep.shorthand) {
content = dep.name + ": " + content;
@ -1328,19 +1328,19 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {
? "_strict"
: "";
if (def.id === true) {
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${
strictFlag
}__`;
finalName = `__WEBPACK_MODULE_REFERENCE__${
info.index
}_ns${strictFlag}__`;
} else {
const exportData = Buffer.from(def.id, "utf-8").toString("hex");
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_${
exportData
}${strictFlag}__`;
finalName = `__WEBPACK_MODULE_REFERENCE__${
info.index
}_${exportData}${strictFlag}__`;
}
const exportsName = this.rootModule.exportsArgument;
const content = `/* concated harmony reexport */__webpack_require__.d(${
exportsName
}, ${JSON.stringify(used)}, function() { return ${finalName}; });\n`;
const content = `/* concated harmony reexport */__webpack_require__.d(${exportsName}, ${JSON.stringify(
used
)}, function() { return ${finalName}; });\n`;
source.insert(-1, content);
}
} else {

View File

@ -308,11 +308,11 @@ module.exports = class SplitChunksPlugin {
cacheGroup.chunks === "initial"
? Array.from(chunkCombination).filter(chunk =>
chunk.canBeInitial()
)
)
: cacheGroup.chunks === "async"
? Array.from(chunkCombination).filter(
chunk => !chunk.canBeInitial()
)
)
: Array.from(chunkCombination);
// Break if minimum number of chunks is not reached
if (selectedChunks.length < cacheGroup.minChunks) continue;
@ -420,7 +420,7 @@ module.exports = class SplitChunksPlugin {
? Math.min(
item.cacheGroup.maxInitialRequests,
item.cacheGroup.maxAsyncRequests
)
)
: item.cacheGroup.maxAsyncRequests;
if (isFinite(maxRequests) && getRequests(chunk) >= maxRequests)
continue;

View File

@ -15,11 +15,11 @@ class JsonpChunkTemplatePlugin {
const globalObject = chunkTemplate.outputOptions.globalObject;
const source = new ConcatSource();
source.add(
`(${globalObject}[${JSON.stringify(jsonpFunction)}] = ${
globalObject
}[${JSON.stringify(jsonpFunction)}] || []).push([${JSON.stringify(
chunk.ids
)},`
`(${globalObject}[${JSON.stringify(
jsonpFunction
)}] = ${globalObject}[${JSON.stringify(
jsonpFunction
)}] || []).push([${JSON.stringify(chunk.ids)},`
);
source.add(modules);
const entries = [chunk.entryModule].filter(Boolean).map(m =>

View File

@ -265,7 +265,7 @@ class JsonpMainTemplatePlugin {
"",
"// run deferred modules when all chunks ready",
"return checkDeferredModules();"
])
])
: ""
]),
"};",
@ -299,7 +299,7 @@ class JsonpMainTemplatePlugin {
"return result;"
]),
"}"
])
])
: ""
]);
}

View File

@ -34,9 +34,10 @@
"coveralls": "^2.11.2",
"css-loader": "^0.28.3",
"es6-promise-polyfill": "^1.1.1",
"eslint": "^4.3.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-prettier": "^2.3.1",
"eslint": "^4.19.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-prettier": "^2.6.0",
"express": "~4.13.1",
"file-loader": "^1.1.6",
"glob": "^7.1.2",
@ -50,7 +51,7 @@
"lodash": "^4.17.4",
"mocha": "^3.2.0",
"mocha-lcov-reporter": "^1.0.0",
"prettier": "^1.8.2",
"prettier": "^1.11.1",
"raw-loader": "~0.5.0",
"react": "^15.2.1",
"react-dom": "^15.2.1",
@ -104,7 +105,7 @@
"lint-files": "npm run lint && npm run schema-lint",
"lint": "eslint lib bin hot buildin \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\"",
"fix": "npm run lint -- --fix",
"pretty-files": "prettier \"lib/**.*\" \"bin/**.*\" \"hot/**.*\" \"buildin/**.*\" \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\" --write",
"pretty-files": "prettier \"lib/**/*.js\" \"bin/*.js\" \"hot/*.js\" \"buildin/*.js\" \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\" --write",
"schema-lint": "mocha test/*.lint.js --opts test/lint-mocha.opts",
"benchmark": "mocha --max-old-space-size=4096 --harmony --trace-deprecation test/*.benchmark.js -R spec",
"cover": "npm run cover:init && npm run cover:all && npm run cover:report",

View File

@ -12,7 +12,7 @@ const getErrorFor = (shouldBeAbsolute, data, schema) => {
? `The provided value ${JSON.stringify(data)} is not an absolute path!`
: `A relative path is expected. However, the provided value ${JSON.stringify(
data
)} is an absolute path!`;
)} is an absolute path!`;
return errorMessage(schema, data, message);
};

View File

@ -273,9 +273,9 @@ describe("BenchmarkTestCases", function() {
const test = new Test(title, fn);
suite.addTest(test);
}
it(`should benchmark ${baseline.name} (${baseline.rev})`, function(
done
) {
it(`should benchmark ${baseline.name} (${
baseline.rev
})`, function(done) {
this.timeout(180000);
const outputDirectory = path.join(
__dirname,

View File

@ -193,9 +193,7 @@ describe("NodeWatchFileSystem", function() {
fs.writeFile(fileDirect, "", function() {});
});
it("should register a context change (change delayed, subdirectory)", function(
done
) {
it("should register a context change (change delayed, subdirectory)", function(done) {
var startTime = new Date().getTime();
var wfs = new NodeWatchFileSystem();
var watcher = wfs.watch(
@ -227,9 +225,7 @@ describe("NodeWatchFileSystem", function() {
fs.writeFile(fileSubdir, "", function() {});
}, 500);
});
it("should register a context change (watch delayed, subdirectory)", function(
done
) {
it("should register a context change (watch delayed, subdirectory)", function(done) {
var startTime = new Date().getTime();
setTimeout(function() {
var wfs = new NodeWatchFileSystem();

View File

@ -177,7 +177,7 @@ describe("TestCases", () => {
{},
config.optimization,
DEFAULT_OPTIMIZATIONS
),
),
performance: {
hints: false
},

View File

@ -36,9 +36,7 @@ describe("WatcherEvents", function() {
this.timeout(10000);
it("should emit 'watch-close' when using single-compiler mode and the compiler is not running", function(
done
) {
it("should emit 'watch-close' when using single-compiler mode and the compiler is not running", function(done) {
let called = false;
const compiler = createSingleCompiler();
@ -56,9 +54,7 @@ describe("WatcherEvents", function() {
});
});
it("should emit 'watch-close' when using multi-compiler mode and the compiler is not running", function(
done
) {
it("should emit 'watch-close' when using multi-compiler mode and the compiler is not running", function(done) {
let called = false;
const compiler = createMultiCompiler();

View File

@ -51,9 +51,9 @@ acorn@^5.0.0:
version "5.4.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.4.1.tgz#fdc58d9d17f4a4e98d102ded826a9b9759125102"
acorn@^5.2.1:
version "5.3.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822"
acorn@^5.5.0:
version "5.5.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.5.3.tgz#f473dd47e0277a08e28e9bec5aeeb04751f0b8c9"
ajv-keywords@^2.1.0:
version "2.1.1"
@ -1155,9 +1155,9 @@ diffie-hellman@^5.0.0:
miller-rabin "^4.0.0"
randombytes "^2.0.0"
doctrine@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.2.tgz#68f96ce8efc56cc42651f1faadb4f175273b0075"
doctrine@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
dependencies:
esutils "^2.0.2"
@ -1265,18 +1265,24 @@ escodegen@1.8.x:
optionalDependencies:
source-map "~0.2.0"
eslint-plugin-node@^5.1.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-5.2.1.tgz#80df3253c4d7901045ec87fa660a284e32bdca29"
eslint-config-prettier@^2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz#5ecd65174d486c22dff389fe036febf502d468a3"
dependencies:
get-stdin "^5.0.1"
eslint-plugin-node@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-6.0.1.tgz#bf19642298064379315d7a4b2a75937376fa05e4"
dependencies:
ignore "^3.3.6"
minimatch "^3.0.4"
resolve "^1.3.3"
semver "5.3.0"
semver "^5.4.1"
eslint-plugin-prettier@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.3.1.tgz#e7a746c67e716f335274b88295a9ead9f544e44d"
eslint-plugin-prettier@^2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.0.tgz#33e4e228bdb06142d03c560ce04ec23f6c767dd7"
dependencies:
fast-diff "^1.1.1"
jest-docblock "^21.0.0"
@ -1292,9 +1298,9 @@ eslint-visitor-keys@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"
eslint@^4.3.0:
version "4.14.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.14.0.tgz#96609768d1dd23304faba2d94b7fefe5a5447a82"
eslint@^4.19.1:
version "4.19.1"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.19.1.tgz#32d1d653e1d90408854bfb296f076ec7e186a300"
dependencies:
ajv "^5.3.0"
babel-code-frame "^6.22.0"
@ -1302,10 +1308,10 @@ eslint@^4.3.0:
concat-stream "^1.6.0"
cross-spawn "^5.1.0"
debug "^3.1.0"
doctrine "^2.0.2"
doctrine "^2.1.0"
eslint-scope "^3.7.1"
eslint-visitor-keys "^1.0.0"
espree "^3.5.2"
espree "^3.5.4"
esquery "^1.0.0"
esutils "^2.0.2"
file-entry-cache "^2.0.0"
@ -1327,18 +1333,19 @@ eslint@^4.3.0:
path-is-inside "^1.0.2"
pluralize "^7.0.0"
progress "^2.0.0"
regexpp "^1.0.1"
require-uncached "^1.0.3"
semver "^5.3.0"
strip-ansi "^4.0.0"
strip-json-comments "~2.0.1"
table "^4.0.1"
table "4.0.2"
text-table "~0.2.0"
espree@^3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca"
espree@^3.5.4:
version "3.5.4"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7"
dependencies:
acorn "^5.2.1"
acorn "^5.5.0"
acorn-jsx "^3.0.0"
esprima@2.7.x, esprima@^2.6.0, esprima@^2.7.1:
@ -1700,6 +1707,10 @@ generate-object-property@^1.1.0:
dependencies:
is-property "^1.0.0"
get-stdin@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-5.0.1.tgz#122e161591e21ff4c52530305693f20e6393a398"
get-value@^2.0.3, get-value@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28"
@ -3418,9 +3429,9 @@ prepend-http@^1.0.0:
version "1.0.4"
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"
prettier@^1.8.2:
version "1.8.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.8.2.tgz#bff83e7fd573933c607875e5ba3abbdffb96aeb8"
prettier@^1.11.1:
version "1.11.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.11.1.tgz#61e43fc4cd44e68f2b0dfc2c38cd4bb0fccdcc75"
process-nextick-args@~1.0.6:
version "1.0.7"
@ -3653,6 +3664,10 @@ regex-not@^1.0.0:
extend-shallow "^3.0.2"
safe-regex "^1.1.0"
regexpp@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.0.1.tgz#d857c3a741dce075c2848dcb019a0a975b190d43"
regexpu-core@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-1.0.0.tgz#86a763f58ee4d7c2f6b102e4764050de7ed90c6b"
@ -3892,14 +3907,14 @@ script-loader@~0.7.0:
dependencies:
raw-loader "~0.5.1"
semver@5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
semver@^5.3.0:
version "5.4.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
semver@^5.4.1:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
send@0.13.1:
version "0.13.1"
resolved "https://registry.yarnpkg.com/send/-/send-0.13.1.tgz#a30d5f4c82c8a9bae9ad00a1d9b1bdbe6f199ed7"
@ -4320,7 +4335,7 @@ svgo@^0.7.0:
sax "~1.2.1"
whet.extend "~0.9.9"
table@^4.0.1:
table@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36"
dependencies: