mirror of https://github.com/webpack/webpack.git
refactor: improve code
This commit is contained in:
parent
1fe55ac7b5
commit
40151be78e
|
@ -80,8 +80,8 @@ const runCli = cli => {
|
||||||
|
|
||||||
if (pkg.type === "module" || /\.mjs/i.test(pkg.bin[cli.binName])) {
|
if (pkg.type === "module" || /\.mjs/i.test(pkg.bin[cli.binName])) {
|
||||||
import(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName])).catch(
|
import(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName])).catch(
|
||||||
error => {
|
err => {
|
||||||
console.error(error);
|
console.error(err);
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -177,8 +177,8 @@ if (!cli.installed) {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
runCli(cli);
|
runCli(cli);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(err => {
|
||||||
console.error(error);
|
console.error(err);
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,6 +6,7 @@ const jsdoc = require("eslint-plugin-jsdoc");
|
||||||
const prettierConfig = require("eslint-config-prettier");
|
const prettierConfig = require("eslint-config-prettier");
|
||||||
const globals = require("globals");
|
const globals = require("globals");
|
||||||
const stylistic = require("@stylistic/eslint-plugin");
|
const stylistic = require("@stylistic/eslint-plugin");
|
||||||
|
const unicorn = require("eslint-plugin-unicorn");
|
||||||
|
|
||||||
const nodeConfig = n.configs["flat/recommended"];
|
const nodeConfig = n.configs["flat/recommended"];
|
||||||
const jsdocConfig = jsdoc.configs["flat/recommended-typescript-flavor-error"];
|
const jsdocConfig = jsdoc.configs["flat/recommended-typescript-flavor-error"];
|
||||||
|
@ -78,7 +79,7 @@ module.exports = [
|
||||||
varsIgnorePattern: "^_",
|
varsIgnorePattern: "^_",
|
||||||
args: "none",
|
args: "none",
|
||||||
argsIgnorePattern: "^_",
|
argsIgnorePattern: "^_",
|
||||||
caughtErrors: "none",
|
caughtErrors: "all",
|
||||||
caughtErrorsIgnorePattern: "^_",
|
caughtErrorsIgnorePattern: "^_",
|
||||||
ignoreRestSiblings: true
|
ignoreRestSiblings: true
|
||||||
}
|
}
|
||||||
|
@ -197,9 +198,42 @@ module.exports = [
|
||||||
"prefer-spread": "error",
|
"prefer-spread": "error",
|
||||||
"no-sequences": "error",
|
"no-sequences": "error",
|
||||||
// TODO Enable
|
// TODO Enable
|
||||||
|
"id-length": "off",
|
||||||
"prefer-destructuring": "off"
|
"prefer-destructuring": "off"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
unicorn
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
"unicorn/catch-error-name": [
|
||||||
|
"error",
|
||||||
|
{ name: "err", ignore: [/(^_|[0-9]+$)/i] }
|
||||||
|
],
|
||||||
|
// TODO Enable
|
||||||
|
"unicorn/prefer-spread": "off",
|
||||||
|
"unicorn/prefer-string-slice": "off",
|
||||||
|
"unicorn/explicit-length-check": "off",
|
||||||
|
"unicorn/no-lonely-if": "off",
|
||||||
|
"unicorn/prefer-ternary": "off",
|
||||||
|
"unicorn/no-useless-undefined": "off",
|
||||||
|
"unicorn/no-hex-escape": "off",
|
||||||
|
"unicorn/escape-case": "off",
|
||||||
|
"unicorn/prefer-negative-index": "off",
|
||||||
|
"unicorn/no-array-for-each": "off",
|
||||||
|
"unicorn/prefer-number-properties": "off",
|
||||||
|
"unicorn/prefer-default-parameters": "off",
|
||||||
|
"unicorn/prefer-regexp-test": "off",
|
||||||
|
"unicorn/prefer-includes": "off",
|
||||||
|
"unicorn/prefer-math-trunc": "off",
|
||||||
|
"unicorn/prefer-array-find": "off",
|
||||||
|
"unicorn/prefer-native-coercion-functions": "off",
|
||||||
|
"unicorn/no-useless-switch-case": "off",
|
||||||
|
"unicorn/prefer-string-starts-ends-with": "off",
|
||||||
|
"unicorn/no-zero-fractions": "off"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
plugins: {
|
plugins: {
|
||||||
"@stylistic": stylistic
|
"@stylistic": stylistic
|
||||||
|
|
|
@ -483,8 +483,8 @@ class Compilation {
|
||||||
fn: (assets, callback) => {
|
fn: (assets, callback) => {
|
||||||
try {
|
try {
|
||||||
fn(assets);
|
fn(assets);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
return callback(e);
|
return callback(err);
|
||||||
}
|
}
|
||||||
if (processedAssets !== undefined)
|
if (processedAssets !== undefined)
|
||||||
processedAssets.add(this.assets);
|
processedAssets.add(this.assets);
|
||||||
|
@ -1644,8 +1644,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
console.error(e);
|
console.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
processDependencyForResolving(dep);
|
processDependencyForResolving(dep);
|
||||||
|
@ -1737,8 +1737,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
for (const b of block.blocks) queue.push(b);
|
for (const b of block.blocks) queue.push(b);
|
||||||
}
|
}
|
||||||
} while (queue.length !== 0);
|
} while (queue.length !== 0);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
return callback(e);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (--inProgressSorting === 0) onDependenciesSorted();
|
if (--inProgressSorting === 0) onDependenciesSorted();
|
||||||
|
@ -5240,14 +5240,14 @@ This prevents using hashes of each other and should be avoided.`);
|
||||||
);
|
);
|
||||||
moduleObject.loaded = true;
|
moduleObject.loaded = true;
|
||||||
return moduleObject.exports;
|
return moduleObject.exports;
|
||||||
} catch (e) {
|
} catch (execErr) {
|
||||||
if (strictModuleExceptionHandling) {
|
if (strictModuleExceptionHandling) {
|
||||||
if (id) delete moduleCache[id];
|
if (id) delete moduleCache[id];
|
||||||
} else if (strictModuleErrorHandling) {
|
} else if (strictModuleErrorHandling) {
|
||||||
moduleObject.error = e;
|
moduleObject.error = execErr;
|
||||||
}
|
}
|
||||||
if (!e.module) e.module = module;
|
if (!execErr.module) execErr.module = module;
|
||||||
throw e;
|
throw execErr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5260,14 +5260,14 @@ This prevents using hashes of each other and should be avoided.`);
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
exports = __webpack_require__(module.identifier());
|
exports = __webpack_require__(module.identifier());
|
||||||
} catch (e) {
|
} catch (execErr) {
|
||||||
const err = new WebpackError(
|
const err = new WebpackError(
|
||||||
`Execution of module code from module graph (${module.readableIdentifier(
|
`Execution of module code from module graph (${module.readableIdentifier(
|
||||||
this.requestShortener
|
this.requestShortener
|
||||||
)}) failed: ${e.message}`
|
)}) failed: ${execErr.message}`
|
||||||
);
|
);
|
||||||
err.stack = e.stack;
|
err.stack = execErr.stack;
|
||||||
err.module = e.module;
|
err.module = execErr.module;
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -619,11 +619,11 @@ class Compiler {
|
||||||
const finalCallback = (err, entries, compilation) => {
|
const finalCallback = (err, entries, compilation) => {
|
||||||
try {
|
try {
|
||||||
callback(err, entries, compilation);
|
callback(err, entries, compilation);
|
||||||
} catch (e) {
|
} catch (runAsChildErr) {
|
||||||
const err = new WebpackError(
|
const err = new WebpackError(
|
||||||
`compiler.runAsChild callback error: ${e}`
|
`compiler.runAsChild callback error: ${runAsChildErr}`
|
||||||
);
|
);
|
||||||
err.details = /** @type {Error} */ (e).stack;
|
err.details = /** @type {Error} */ (runAsChildErr).stack;
|
||||||
/** @type {Compilation} */
|
/** @type {Compilation} */
|
||||||
(this.parentCompilation).errors.push(err);
|
(this.parentCompilation).errors.push(err);
|
||||||
}
|
}
|
||||||
|
@ -1137,10 +1137,10 @@ ${other}`);
|
||||||
this.records = parseJson(
|
this.records = parseJson(
|
||||||
/** @type {Buffer} */ (content).toString("utf-8")
|
/** @type {Buffer} */ (content).toString("utf-8")
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (parseErr) {
|
||||||
return callback(
|
return callback(
|
||||||
new Error(
|
new Error(
|
||||||
`Cannot parse records: ${/** @type {Error} */ (e).message}`
|
`Cannot parse records: ${/** @type {Error} */ (parseErr).message}`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ class DllReferencePlugin {
|
||||||
data.data = parseJson(
|
data.data = parseJson(
|
||||||
/** @type {Buffer} */ (result).toString("utf-8")
|
/** @type {Buffer} */ (result).toString("utf-8")
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (parseErr) {
|
||||||
// Store the error in the params so that it can
|
// Store the error in the params so that it can
|
||||||
// be added as a compilation error later on.
|
// be added as a compilation error later on.
|
||||||
const manifestPath = makePathsRelative(
|
const manifestPath = makePathsRelative(
|
||||||
|
@ -83,7 +83,10 @@ class DllReferencePlugin {
|
||||||
manifest,
|
manifest,
|
||||||
compiler.root
|
compiler.root
|
||||||
);
|
);
|
||||||
data.error = new DllManifestError(manifestPath, e.message);
|
data.error = new DllManifestError(
|
||||||
|
manifestPath,
|
||||||
|
parseErr.message
|
||||||
|
);
|
||||||
}
|
}
|
||||||
this._compilationData.set(params, data);
|
this._compilationData.set(params, data);
|
||||||
return callback();
|
return callback();
|
||||||
|
|
|
@ -1770,7 +1770,7 @@ class FileSystemInfo {
|
||||||
expected: imp.d > -1 ? false : undefined,
|
expected: imp.d > -1 ? false : undefined,
|
||||||
issuer: job
|
issuer: job
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (err1) {
|
||||||
this.logger.warn(
|
this.logger.warn(
|
||||||
`Parsing of ${path} for build dependencies failed at 'import(${source.substring(
|
`Parsing of ${path} for build dependencies failed at 'import(${source.substring(
|
||||||
imp.s,
|
imp.s,
|
||||||
|
@ -1779,15 +1779,15 @@ class FileSystemInfo {
|
||||||
"Build dependencies behind this expression are ignored and might cause incorrect cache invalidation."
|
"Build dependencies behind this expression are ignored and might cause incorrect cache invalidation."
|
||||||
);
|
);
|
||||||
this.logger.debug(pathToString(job));
|
this.logger.debug(pathToString(job));
|
||||||
this.logger.debug(e.stack);
|
this.logger.debug(err1.stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (err2) {
|
||||||
this.logger.warn(
|
this.logger.warn(
|
||||||
`Parsing of ${path} for build dependencies failed and all dependencies of this file are ignored, which might cause incorrect cache invalidation..`
|
`Parsing of ${path} for build dependencies failed and all dependencies of this file are ignored, which might cause incorrect cache invalidation..`
|
||||||
);
|
);
|
||||||
this.logger.debug(pathToString(job));
|
this.logger.debug(pathToString(job));
|
||||||
this.logger.debug(e.stack);
|
this.logger.debug(err2.stack);
|
||||||
}
|
}
|
||||||
process.nextTick(callback);
|
process.nextTick(callback);
|
||||||
});
|
});
|
||||||
|
@ -1830,8 +1830,8 @@ class FileSystemInfo {
|
||||||
let packageData;
|
let packageData;
|
||||||
try {
|
try {
|
||||||
packageData = JSON.parse(content.toString("utf-8"));
|
packageData = JSON.parse(content.toString("utf-8"));
|
||||||
} catch (e) {
|
} catch (parseErr) {
|
||||||
return callback(e);
|
return callback(parseErr);
|
||||||
}
|
}
|
||||||
const depsObject = packageData.dependencies;
|
const depsObject = packageData.dependencies;
|
||||||
const optionalDepsObject = packageData.optionalDependencies;
|
const optionalDepsObject = packageData.optionalDependencies;
|
||||||
|
@ -3616,8 +3616,8 @@ class FileSystemInfo {
|
||||||
let data;
|
let data;
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(/** @type {Buffer} */ (content).toString("utf-8"));
|
data = JSON.parse(/** @type {Buffer} */ (content).toString("utf-8"));
|
||||||
} catch (e) {
|
} catch (parseErr) {
|
||||||
return callback(e);
|
return callback(parseErr);
|
||||||
}
|
}
|
||||||
if (!data.name) {
|
if (!data.name) {
|
||||||
/** @type {Logger} */
|
/** @type {Logger} */
|
||||||
|
|
|
@ -615,8 +615,8 @@ class NormalModule extends Module {
|
||||||
if (options.startsWith("{") && options.endsWith("}")) {
|
if (options.startsWith("{") && options.endsWith("}")) {
|
||||||
try {
|
try {
|
||||||
options = parseJson(options);
|
options = parseJson(options);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
throw new Error(`Cannot parse string options: ${e.message}`);
|
throw new Error(`Cannot parse string options: ${err.message}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options = querystring.parse(options, "&", "=", {
|
options = querystring.parse(options, "&", "=", {
|
||||||
|
@ -1161,7 +1161,7 @@ class NormalModule extends Module {
|
||||||
: deps
|
: deps
|
||||||
).add(absolute);
|
).add(absolute);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1237,8 +1237,8 @@ class NormalModule extends Module {
|
||||||
compilation,
|
compilation,
|
||||||
options
|
options
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (parseErr) {
|
||||||
handleParseError(/** @type {Error} */ (e));
|
handleParseError(/** @type {Error} */ (parseErr));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handleParseResult();
|
handleParseResult();
|
||||||
|
|
|
@ -535,8 +535,8 @@ class NormalModuleFactory extends ModuleFactory {
|
||||||
item.ident = ident;
|
item.ident = ident;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (identErr) {
|
||||||
return callback(/** @type {Error} */ (e));
|
return callback(/** @type {Error} */ (identErr));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resourceData) {
|
if (!resourceData) {
|
||||||
|
@ -685,8 +685,8 @@ class NormalModuleFactory extends ModuleFactory {
|
||||||
generatorOptions: settings.generator,
|
generatorOptions: settings.generator,
|
||||||
resolveOptions
|
resolveOptions
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (createDataErr) {
|
||||||
return callback(/** @type {Error} */ (e));
|
return callback(/** @type {Error} */ (createDataErr));
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
|
|
@ -159,7 +159,7 @@ class RuntimeModule extends Module {
|
||||||
try {
|
try {
|
||||||
const source = this.getGeneratedCode();
|
const source = this.getGeneratedCode();
|
||||||
return source ? source.length : 0;
|
return source ? source.length : 0;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,10 +207,10 @@ class AssetModulesPlugin {
|
||||||
module.buildInfo.fullContentHash ||
|
module.buildInfo.fullContentHash ||
|
||||||
codeGenResult.data.get("fullContentHash")
|
codeGenResult.data.get("fullContentHash")
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
/** @type {Error} */ (e).message +=
|
/** @type {Error} */ (err).message +=
|
||||||
`\nduring rendering of asset ${module.identifier()}`;
|
`\nduring rendering of asset ${module.identifier()}`;
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -676,16 +676,16 @@ class PackContentItems {
|
||||||
logger.log(`Serialization of '${key}': ${duration} ms`);
|
logger.log(`Serialization of '${key}': ${duration} ms`);
|
||||||
else logger.debug(`Serialization of '${key}': ${duration} ms`);
|
else logger.debug(`Serialization of '${key}': ${duration} ms`);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
rollback(s);
|
rollback(s);
|
||||||
if (e === NOT_SERIALIZABLE) continue;
|
if (err === NOT_SERIALIZABLE) continue;
|
||||||
const msg = "Skipped not serializable cache item";
|
const msg = "Skipped not serializable cache item";
|
||||||
if (e.message.includes("ModuleBuildError")) {
|
if (err.message.includes("ModuleBuildError")) {
|
||||||
logger.log(`${msg} (in build error): ${e.message}`);
|
logger.log(`${msg} (in build error): ${err.message}`);
|
||||||
logger.debug(`${msg} '${key}' (in build error): ${e.stack}`);
|
logger.debug(`${msg} '${key}' (in build error): ${err.stack}`);
|
||||||
} else {
|
} else {
|
||||||
logger.warn(`${msg}: ${e.message}`);
|
logger.warn(`${msg}: ${err.message}`);
|
||||||
logger.debug(`${msg} '${key}': ${e.stack}`);
|
logger.debug(`${msg} '${key}': ${err.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -697,7 +697,7 @@ class PackContentItems {
|
||||||
try {
|
try {
|
||||||
write(true);
|
write(true);
|
||||||
write(this.map);
|
write(this.map);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
rollback(s);
|
rollback(s);
|
||||||
|
|
||||||
// Try to serialize each item on it's own
|
// Try to serialize each item on it's own
|
||||||
|
@ -707,13 +707,13 @@ class PackContentItems {
|
||||||
try {
|
try {
|
||||||
write(key);
|
write(key);
|
||||||
write(value);
|
write(value);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
rollback(s);
|
rollback(s);
|
||||||
if (e === NOT_SERIALIZABLE) continue;
|
if (err === NOT_SERIALIZABLE) continue;
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Skipped not serializable cache item '${key}': ${e.message}`
|
`Skipped not serializable cache item '${key}': ${err.message}`
|
||||||
);
|
);
|
||||||
logger.debug(e.stack);
|
logger.debug(err.stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write(null);
|
write(null);
|
||||||
|
|
|
@ -411,7 +411,7 @@ const applyCacheDefaults = (
|
||||||
try {
|
try {
|
||||||
if (fs.statSync(path.join(dir, "package.json")).isFile()) break;
|
if (fs.statSync(path.join(dir, "package.json")).isFile()) break;
|
||||||
// eslint-disable-next-line no-empty
|
// eslint-disable-next-line no-empty
|
||||||
} catch (e) {}
|
} catch (_err) {}
|
||||||
const parent = path.dirname(dir);
|
const parent = path.dirname(dir);
|
||||||
if (dir === parent) {
|
if (dir === parent) {
|
||||||
dir = undefined;
|
dir = undefined;
|
||||||
|
@ -908,12 +908,12 @@ const applyOutputDefaults = (
|
||||||
try {
|
try {
|
||||||
const packageInfo = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
const packageInfo = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
||||||
return packageInfo.name || "";
|
return packageInfo.name || "";
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
if (/** @type {Error & { code: string }} */ (e).code !== "ENOENT") {
|
if (/** @type {Error & { code: string }} */ (err).code !== "ENOENT") {
|
||||||
/** @type {Error & { code: string }} */
|
/** @type {Error & { code: string }} */
|
||||||
(e).message +=
|
(err).message +=
|
||||||
`\nwhile determining default 'output.uniqueName' from 'name' in ${pkgPath}`;
|
`\nwhile determining default 'output.uniqueName' from 'name' in ${pkgPath}`;
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -758,10 +758,10 @@ class CssModulesPlugin {
|
||||||
module
|
module
|
||||||
});
|
});
|
||||||
source.add(moduleSource);
|
source.add(moduleSource);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
/** @type {Error} */
|
/** @type {Error} */
|
||||||
(e).message += `\nduring rendering of css ${module.identifier()}`;
|
(err).message += `\nduring rendering of css ${module.identifier()}`;
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const metaDataStr = metaData.join(",");
|
const metaDataStr = metaData.join(",");
|
||||||
|
|
|
@ -73,7 +73,7 @@ const normalizeUrl = (str, isString) => {
|
||||||
// Convert `url('%2E/img.png')` -> `url('./img.png')`
|
// Convert `url('%2E/img.png')` -> `url('./img.png')`
|
||||||
try {
|
try {
|
||||||
str = decodeURIComponent(str);
|
str = decodeURIComponent(str);
|
||||||
} catch (error) {
|
} catch (_err) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ let inspector;
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||||
inspector = require("inspector");
|
inspector = require("inspector");
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
console.log("Unable to CPU profile in < node 8.0");
|
console.log("Unable to CPU profile in < node 8.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,13 +474,13 @@ const makeNewProfiledTapFn = (hookName, tracer, { name, type, fn }) => {
|
||||||
let r;
|
let r;
|
||||||
try {
|
try {
|
||||||
r = fn(...args);
|
r = fn(...args);
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
tracer.trace.end({
|
tracer.trace.end({
|
||||||
name,
|
name,
|
||||||
id,
|
id,
|
||||||
cat: defaultCategory
|
cat: defaultCategory
|
||||||
});
|
});
|
||||||
throw error;
|
throw err;
|
||||||
}
|
}
|
||||||
tracer.trace.end({
|
tracer.trace.end({
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -376,17 +376,17 @@ module.exports = function () {
|
||||||
moduleId: moduleId,
|
moduleId: moduleId,
|
||||||
module: $moduleCache$[moduleId]
|
module: $moduleCache$[moduleId]
|
||||||
});
|
});
|
||||||
} catch (err2) {
|
} catch (err1) {
|
||||||
if (options.onErrored) {
|
if (options.onErrored) {
|
||||||
options.onErrored({
|
options.onErrored({
|
||||||
type: "self-accept-error-handler-errored",
|
type: "self-accept-error-handler-errored",
|
||||||
moduleId: moduleId,
|
moduleId: moduleId,
|
||||||
error: err2,
|
error: err1,
|
||||||
originalError: err
|
originalError: err
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!options.ignoreErrored) {
|
if (!options.ignoreErrored) {
|
||||||
reportError(err2);
|
reportError(err1);
|
||||||
reportError(err);
|
reportError(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -448,12 +448,12 @@ class JavascriptModulesPlugin {
|
||||||
moduleObject.exports,
|
moduleObject.exports,
|
||||||
context.__webpack_require__
|
context.__webpack_require__
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
e.stack += printGeneratedCodeForStack(
|
err.stack += printGeneratedCodeForStack(
|
||||||
options.module,
|
options.module,
|
||||||
/** @type {string} */ (code)
|
/** @type {string} */ (code)
|
||||||
);
|
);
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compilation.hooks.executeModule.tap(PLUGIN_NAME, (options, context) => {
|
compilation.hooks.executeModule.tap(PLUGIN_NAME, (options, context) => {
|
||||||
|
@ -472,9 +472,9 @@ class JavascriptModulesPlugin {
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line no-useless-call
|
// eslint-disable-next-line no-useless-call
|
||||||
fn.call(null, context.__webpack_require__);
|
fn.call(null, context.__webpack_require__);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
e.stack += printGeneratedCodeForStack(options.module, code);
|
err.stack += printGeneratedCodeForStack(options.module, code);
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -603,9 +603,9 @@ class JavascriptModulesPlugin {
|
||||||
),
|
),
|
||||||
"JavascriptModulesPlugin.getCompilationHooks().renderModulePackage"
|
"JavascriptModulesPlugin.getCompilationHooks().renderModulePackage"
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
e.module = module;
|
err.module = module;
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4056,8 +4056,8 @@ class JavascriptParser extends Parser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
console.warn(e);
|
console.warn(err);
|
||||||
// ignore error
|
// ignore error
|
||||||
}
|
}
|
||||||
return new BasicEvaluatedExpression()
|
return new BasicEvaluatedExpression()
|
||||||
|
@ -4594,9 +4594,9 @@ class JavascriptParser extends Parser {
|
||||||
}
|
}
|
||||||
options[key] = val;
|
options[key] = val;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
const newErr = new Error(String(e.message));
|
const newErr = new Error(String(err.message));
|
||||||
newErr.stack = String(e.stack);
|
newErr.stack = String(err.stack);
|
||||||
Object.assign(newErr, { comment });
|
Object.assign(newErr, { comment });
|
||||||
errors.push(newErr);
|
errors.push(newErr);
|
||||||
}
|
}
|
||||||
|
@ -4749,8 +4749,8 @@ class JavascriptParser extends Parser {
|
||||||
let threw = false;
|
let threw = false;
|
||||||
try {
|
try {
|
||||||
ast = /** @type {AnyNode} */ (parser.parse(code, parserOptions));
|
ast = /** @type {AnyNode} */ (parser.parse(code, parserOptions));
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
error = e;
|
error = err;
|
||||||
threw = true;
|
threw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4765,7 +4765,7 @@ class JavascriptParser extends Parser {
|
||||||
try {
|
try {
|
||||||
ast = /** @type {AnyNode} */ (parser.parse(code, parserOptions));
|
ast = /** @type {AnyNode} */ (parser.parse(code, parserOptions));
|
||||||
threw = false;
|
threw = false;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// we use the error from first parse try
|
// we use the error from first parse try
|
||||||
// so nothing to do here
|
// so nothing to do here
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,10 @@ class JsonParser extends Parser {
|
||||||
typeof source === "object"
|
typeof source === "object"
|
||||||
? source
|
? source
|
||||||
: parseFn(source[0] === "\ufeff" ? source.slice(1) : source);
|
: parseFn(source[0] === "\ufeff" ? source.slice(1) : source);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
throw new Error(`Cannot parse JSON: ${/** @type {Error} */ (e).message}`);
|
throw new Error(
|
||||||
|
`Cannot parse JSON: ${/** @type {Error} */ (err).message}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const jsonData = new JsonData(/** @type {Buffer | RawJsonData} */ (data));
|
const jsonData = new JsonData(/** @type {Buffer | RawJsonData} */ (data));
|
||||||
const buildInfo = /** @type {BuildInfo} */ (state.module.buildInfo);
|
const buildInfo = /** @type {BuildInfo} */ (state.module.buildInfo);
|
||||||
|
|
|
@ -1488,11 +1488,11 @@ class ConcatenatedModule extends Module {
|
||||||
return `/* ${
|
return `/* ${
|
||||||
exportInfo.isReexport() ? "reexport" : "binding"
|
exportInfo.isReexport() ? "reexport" : "binding"
|
||||||
} */ ${finalName}`;
|
} */ ${finalName}`;
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
/** @type {Error} */
|
/** @type {Error} */
|
||||||
(e).message +=
|
(err).message +=
|
||||||
`\nwhile generating the root export '${name}' (used name: '${used}')`;
|
`\nwhile generating the root export '${name}' (used name: '${used}')`;
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,7 +236,7 @@ class RuleSetCompiler {
|
||||||
matchWhenEmpty: condition(""),
|
matchWhenEmpty: condition(""),
|
||||||
fn: condition
|
fn: condition
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (_err) {
|
||||||
throw this.error(
|
throw this.error(
|
||||||
path,
|
path,
|
||||||
condition,
|
condition,
|
||||||
|
|
|
@ -938,7 +938,7 @@ Remove this line from the lockfile to force upgrading.`
|
||||||
contentWithChangedEol,
|
contentWithChangedEol,
|
||||||
entry.integrity
|
entry.integrity
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
if (isEolChanged) {
|
if (isEolChanged) {
|
||||||
|
|
|
@ -383,7 +383,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
||||||
if (request) {
|
if (request) {
|
||||||
return `${request}${name ? `.${name}` : ""}`;
|
return `${request}${name ? `.${name}` : ""}`;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// ignore -> fallback
|
// ignore -> fallback
|
||||||
}
|
}
|
||||||
if (typeof item === "object" && item !== null) {
|
if (typeof item === "object" && item !== null) {
|
||||||
|
@ -406,8 +406,8 @@ class ObjectMiddleware extends SerializerMiddleware {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return `${item}`;
|
return `${item}`;
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
return `(${e.message})`;
|
return `(${err.message})`;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.join(" -> ");
|
.join(" -> ");
|
||||||
|
@ -417,16 +417,16 @@ class ObjectMiddleware extends SerializerMiddleware {
|
||||||
write(value, key) {
|
write(value, key) {
|
||||||
try {
|
try {
|
||||||
process(value);
|
process(value);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
if (e !== NOT_SERIALIZABLE) {
|
if (err !== NOT_SERIALIZABLE) {
|
||||||
if (hasDebugInfoAttached === undefined)
|
if (hasDebugInfoAttached === undefined)
|
||||||
hasDebugInfoAttached = new WeakSet();
|
hasDebugInfoAttached = new WeakSet();
|
||||||
if (!hasDebugInfoAttached.has(e)) {
|
if (!hasDebugInfoAttached.has(err)) {
|
||||||
e.message += `\nwhile serializing ${stackToString(value)}`;
|
err.message += `\nwhile serializing ${stackToString(value)}`;
|
||||||
hasDebugInfoAttached.add(e);
|
hasDebugInfoAttached.add(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setCircularReference(ref) {
|
setCircularReference(ref) {
|
||||||
|
@ -571,10 +571,10 @@ class ObjectMiddleware extends SerializerMiddleware {
|
||||||
process(item);
|
process(item);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
if (e === NOT_SERIALIZABLE) return null;
|
if (err === NOT_SERIALIZABLE) return null;
|
||||||
|
|
||||||
throw e;
|
throw err;
|
||||||
} finally {
|
} finally {
|
||||||
// Get rid of these references to avoid leaking memory
|
// Get rid of these references to avoid leaking memory
|
||||||
// This happens because the optimized code v8 generates
|
// This happens because the optimized code v8 generates
|
||||||
|
|
|
@ -166,7 +166,7 @@ function getCommithash(urlParsed) {
|
||||||
try {
|
try {
|
||||||
hash = decodeURIComponent(hash);
|
hash = decodeURIComponent(hash);
|
||||||
// eslint-disable-next-line no-empty
|
// eslint-disable-next-line no-empty
|
||||||
} catch (e) {}
|
} catch (_err) {}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
extractCommithashByDomain[
|
extractCommithashByDomain[
|
||||||
|
@ -236,7 +236,7 @@ function getVersionFromHash(hash) {
|
||||||
function canBeDecoded(str) {
|
function canBeDecoded(str) {
|
||||||
try {
|
try {
|
||||||
decodeURIComponent(str);
|
decodeURIComponent(str);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ function getGitUrlVersion(gitUrl) {
|
||||||
try {
|
try {
|
||||||
parsed = new URL(gitUrl);
|
parsed = new URL(gitUrl);
|
||||||
// eslint-disable-next-line no-empty
|
// eslint-disable-next-line no-empty
|
||||||
} catch (e) {}
|
} catch (_err) {}
|
||||||
|
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -597,8 +597,8 @@ const readJson = (fs, p, callback) => {
|
||||||
let data;
|
let data;
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(/** @type {Buffer} */ (buf).toString("utf-8"));
|
data = JSON.parse(/** @type {Buffer} */ (buf).toString("utf-8"));
|
||||||
} catch (e) {
|
} catch (err1) {
|
||||||
return callback(/** @type {Error} */ (e));
|
return callback(/** @type {Error} */ (err1));
|
||||||
}
|
}
|
||||||
return callback(null, data);
|
return callback(null, data);
|
||||||
});
|
});
|
||||||
|
|
|
@ -208,9 +208,9 @@ class AsyncWebAssemblyModulesPlugin {
|
||||||
hooks.renderModuleContent.call(moduleSource, module, renderContext),
|
hooks.renderModuleContent.call(moduleSource, module, renderContext),
|
||||||
"AsyncWebAssemblyModulesPlugin.getCompilationHooks().renderModuleContent"
|
"AsyncWebAssemblyModulesPlugin.getCompilationHooks().renderModuleContent"
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
/** @type {WebpackError} */ (e).module = module;
|
/** @type {WebpackError} */ (err).module = module;
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
"eslint-plugin-jsdoc": "^48.10.1",
|
"eslint-plugin-jsdoc": "^48.10.1",
|
||||||
"eslint-plugin-n": "^17.8.1",
|
"eslint-plugin-n": "^17.8.1",
|
||||||
"eslint-plugin-prettier": "^5.1.3",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
|
"eslint-plugin-unicorn": "^55.0.0",
|
||||||
"file-loader": "^6.0.0",
|
"file-loader": "^6.0.0",
|
||||||
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
||||||
"globals": "^15.4.0",
|
"globals": "^15.4.0",
|
||||||
|
|
|
@ -21,8 +21,8 @@ function setup() {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
process.exitCode = 0;
|
process.exitCode = 0;
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(err => {
|
||||||
console.error(e);
|
console.error(err);
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ async function ensureYarnInstalledAsync() {
|
||||||
try {
|
try {
|
||||||
const stdout = await execGetOutput("yarn", ["-v"], "Check yarn version");
|
const stdout = await execGetOutput("yarn", ["-v"], "Check yarn version");
|
||||||
hasYarn = semverPattern.test(stdout);
|
hasYarn = semverPattern.test(stdout);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
hasYarn = false;
|
hasYarn = false;
|
||||||
}
|
}
|
||||||
if (!hasYarn) await installYarnAsync();
|
if (!hasYarn) await installYarnAsync();
|
||||||
|
|
|
@ -16,7 +16,7 @@ it("should cache assets", done => {
|
||||||
fs.mkdirSync(path.join(pluginDir), {
|
fs.mkdirSync(path.join(pluginDir), {
|
||||||
recursive: true
|
recursive: true
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
const compiler = webpack({
|
const compiler = webpack({
|
||||||
|
@ -53,7 +53,7 @@ it("can place banner as footer", done => {
|
||||||
fs.mkdirSync(path.join(pluginDir), {
|
fs.mkdirSync(path.join(pluginDir), {
|
||||||
recursive: true
|
recursive: true
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
const compiler = webpack({
|
const compiler = webpack({
|
||||||
|
@ -87,7 +87,7 @@ it("should allow to change stage", done => {
|
||||||
fs.mkdirSync(path.join(pluginDir), {
|
fs.mkdirSync(path.join(pluginDir), {
|
||||||
recursive: true
|
recursive: true
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
const compiler = webpack({
|
const compiler = webpack({
|
||||||
|
|
|
@ -20,10 +20,10 @@ describe("BenchmarkTestCases", function () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(path.join(__dirname, "js"));
|
fs.mkdirSync(path.join(__dirname, "js"));
|
||||||
} catch (e) {} // eslint-disable-line no-empty
|
} catch (_err) {} // eslint-disable-line no-empty
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(baselinesPath);
|
fs.mkdirSync(baselinesPath);
|
||||||
} catch (e) {} // eslint-disable-line no-empty
|
} catch (_err) {} // eslint-disable-line no-empty
|
||||||
|
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
const git = require("simple-git");
|
const git = require("simple-git");
|
||||||
|
@ -40,7 +40,7 @@ describe("BenchmarkTestCases", function () {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(baselinePath);
|
fs.mkdirSync(baselinePath);
|
||||||
} catch (e) {} // eslint-disable-line no-empty
|
} catch (_err) {} // eslint-disable-line no-empty
|
||||||
const gitIndex = path.resolve(rootPath, ".git/index");
|
const gitIndex = path.resolve(rootPath, ".git/index");
|
||||||
const index = fs.readFileSync(gitIndex);
|
const index = fs.readFileSync(gitIndex);
|
||||||
git(rootPath).raw(
|
git(rootPath).raw(
|
||||||
|
|
|
@ -154,7 +154,7 @@ const describeCases = config => {
|
||||||
testConfig,
|
testConfig,
|
||||||
require(path.join(testDirectory, "test.config.js"))
|
require(path.join(testDirectory, "test.config.js"))
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
if (testConfig.timeout) setDefaultTimeout(testConfig.timeout);
|
if (testConfig.timeout) setDefaultTimeout(testConfig.timeout);
|
||||||
|
@ -712,8 +712,8 @@ const describeCases = config => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
handleFatalError(e, done);
|
handleFatalError(err, done);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
require("..")(options, onCompiled);
|
require("..")(options, onCompiled);
|
||||||
|
|
|
@ -36,12 +36,12 @@ describe("HotModuleReplacementPlugin", () => {
|
||||||
fs.mkdirSync(path.join(__dirname, "js", "HotModuleReplacementPlugin"), {
|
fs.mkdirSync(path.join(__dirname, "js", "HotModuleReplacementPlugin"), {
|
||||||
recursive: true
|
recursive: true
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(recordsFile);
|
fs.unlinkSync(recordsFile);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
const compiler = webpack({
|
const compiler = webpack({
|
||||||
|
@ -107,7 +107,7 @@ describe("HotModuleReplacementPlugin", () => {
|
||||||
let firstUpdate;
|
let firstUpdate;
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(outputPath, { recursive: true });
|
fs.mkdirSync(outputPath, { recursive: true });
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
fs.writeFileSync(entryFile, `${++step}`, "utf-8");
|
fs.writeFileSync(entryFile, `${++step}`, "utf-8");
|
||||||
|
@ -116,7 +116,7 @@ describe("HotModuleReplacementPlugin", () => {
|
||||||
try {
|
try {
|
||||||
fs.statSync(path.join(outputPath, file));
|
fs.statSync(path.join(outputPath, file));
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -188,12 +188,12 @@ describe("HotModuleReplacementPlugin", () => {
|
||||||
const recordsFile = path.join(outputPath, "records.json");
|
const recordsFile = path.join(outputPath, "records.json");
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(outputPath, { recursive: true });
|
fs.mkdirSync(outputPath, { recursive: true });
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(recordsFile);
|
fs.unlinkSync(recordsFile);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
const compiler = webpack({
|
const compiler = webpack({
|
||||||
|
@ -271,12 +271,12 @@ describe("HotModuleReplacementPlugin", () => {
|
||||||
recursive: true
|
recursive: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(recordsFile);
|
fs.unlinkSync(recordsFile);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
const compiler = webpack({
|
const compiler = webpack({
|
||||||
|
|
|
@ -155,7 +155,7 @@ describe("JavascriptParser", () => {
|
||||||
fgh.sub;
|
fgh.sub;
|
||||||
fgh;
|
fgh;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
fgh.sub;
|
fgh.sub;
|
||||||
fgh;
|
fgh;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ describe("MemoryLimitTestCases", () => {
|
||||||
testConfig,
|
testConfig,
|
||||||
require(path.join(base, testName, "test.config.js"))
|
require(path.join(base, testName, "test.config.js"))
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
it(`should build ${JSON.stringify(testName)} with heap limit of ${toMiB(
|
it(`should build ${JSON.stringify(testName)} with heap limit of ${toMiB(
|
||||||
|
|
|
@ -451,9 +451,9 @@ describe("MultiCompiler", function () {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
console.error(e);
|
console.error(err);
|
||||||
done(e);
|
done(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -530,9 +530,9 @@ describe("MultiCompiler", function () {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
console.error(e);
|
console.error(err);
|
||||||
done(e);
|
done(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,8 +27,8 @@ describe("MultiStats", () => {
|
||||||
);
|
);
|
||||||
expect(statsObject.children).toHaveLength(2);
|
expect(statsObject.children).toHaveLength(2);
|
||||||
done();
|
done();
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
done(e);
|
done(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,7 +65,7 @@ describe("StatsTestCases", () => {
|
||||||
testConfig,
|
testConfig,
|
||||||
require(path.join(base, testName, "test.config.js"))
|
require(path.join(base, testName, "test.config.js"))
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -447,10 +447,10 @@ const describeCases = config => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cleanups.push(() => (esmContext.it = undefined));
|
cleanups.push(() => (esmContext.it = undefined));
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
console.log(e);
|
console.log(err);
|
||||||
e.message += `\nwhile parsing ${p}`;
|
err.message += `\nwhile parsing ${p}`;
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
if (esmMode === "unlinked") return esm;
|
if (esmMode === "unlinked") return esm;
|
||||||
return (async () => {
|
return (async () => {
|
||||||
|
|
|
@ -41,7 +41,7 @@ describe("WatchDetection", () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(fixturePath);
|
fs.mkdirSync(fixturePath);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
fs.writeFileSync(filePath, "require('./file2')", "utf-8");
|
fs.writeFileSync(filePath, "require('./file2')", "utf-8");
|
||||||
|
@ -52,17 +52,17 @@ describe("WatchDetection", () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(filePath);
|
fs.unlinkSync(filePath);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(file2Path);
|
fs.unlinkSync(file2Path);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(fixturePath);
|
fs.rmdirSync(fixturePath);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
|
|
|
@ -32,14 +32,14 @@ describe("WatchSuspend", () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(fixturePath);
|
fs.mkdirSync(fixturePath);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// skip
|
// skip
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(filePath, "'foo'", "utf-8");
|
fs.writeFileSync(filePath, "'foo'", "utf-8");
|
||||||
fs.writeFileSync(file2Path, "'file2'", "utf-8");
|
fs.writeFileSync(file2Path, "'file2'", "utf-8");
|
||||||
fs.writeFileSync(file3Path, "'file3'", "utf-8");
|
fs.writeFileSync(file3Path, "'file3'", "utf-8");
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// skip
|
// skip
|
||||||
}
|
}
|
||||||
const webpack = require("../");
|
const webpack = require("../");
|
||||||
|
@ -63,12 +63,12 @@ describe("WatchSuspend", () => {
|
||||||
compiler = null;
|
compiler = null;
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(filePath);
|
fs.unlinkSync(filePath);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// skip
|
// skip
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fs.rmdirSync(fixturePath);
|
fs.rmdirSync(fixturePath);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// skip
|
// skip
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -335,7 +335,7 @@ const describeCases = config => {
|
||||||
testConfig = require(
|
testConfig = require(
|
||||||
path.join(testDirectory, "test.config.js")
|
path.join(testDirectory, "test.config.js")
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,14 @@ module.exports = {
|
||||||
beforeExecute() {
|
beforeExecute() {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(path.join(__dirname, "dev-defaults.webpack.lock"));
|
fs.unlinkSync(path.join(__dirname, "dev-defaults.webpack.lock"));
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
afterExecute() {
|
afterExecute() {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(path.join(__dirname, "dev-defaults.webpack.lock"));
|
fs.unlinkSync(path.join(__dirname, "dev-defaults.webpack.lock"));
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ module.exports = () => {
|
||||||
);
|
);
|
||||||
fs.unlinkSync(path.join(__dirname, ".testlink"));
|
fs.unlinkSync(path.join(__dirname, ".testlink"));
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -60,9 +60,9 @@ module.exports = {
|
||||||
expect(auxiliaryFiles).toContain("assets/file.png");
|
expect(auxiliaryFiles).toContain("assets/file.png");
|
||||||
expect(auxiliaryFiles).toContain("assets/file.png?1");
|
expect(auxiliaryFiles).toContain("assets/file.png?1");
|
||||||
expect(auxiliaryFiles).toContain("assets/file.jpg");
|
expect(auxiliaryFiles).toContain("assets/file.jpg");
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
console.log(stats.toString({ colors: true, orphanModules: true }));
|
console.log(stats.toString({ colors: true, orphanModules: true }));
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
|
|
@ -5,9 +5,9 @@ const plugins = [
|
||||||
const result = asset.source.sourceAndMap();
|
const result = asset.source.sourceAndMap();
|
||||||
try {
|
try {
|
||||||
expect(result.map).toBe(null);
|
expect(result.map).toBe(null);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
e.message += `\nfor asset ${asset.name}`;
|
err.message += `\nfor asset ${asset.name}`;
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -60,10 +60,10 @@ module.exports = (globalTimeout = 2000, nameSuffix = "") => {
|
||||||
state.hasStarted = false;
|
state.hasStarted = false;
|
||||||
try {
|
try {
|
||||||
fn();
|
fn();
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
// avoid leaking memory
|
// avoid leaking memory
|
||||||
e.stack;
|
err.stack;
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
state.currentDescribeBlock = oldCurrentDescribeBlock;
|
state.currentDescribeBlock = oldCurrentDescribeBlock;
|
||||||
state.currentlyRunningTest = oldCurrentlyRunningTest;
|
state.currentlyRunningTest = oldCurrentlyRunningTest;
|
||||||
|
|
|
@ -4,7 +4,7 @@ module.exports = function supportDefaultAssignment() {
|
||||||
var E = eval("class E { toString() { return 'default' } }");
|
var E = eval("class E { toString() { return 'default' } }");
|
||||||
var f1 = eval("(function f1({a, b = E}) {return new b().toString();})");
|
var f1 = eval("(function f1({a, b = E}) {return new b().toString();})");
|
||||||
return f1({ a: "test" }) === "default";
|
return f1({ a: "test" }) === "default";
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ module.exports = function supportArrowFunctionExpression() {
|
||||||
"var foo = function(fn) {return fn.toString()}; foo(() => {return 'a'})"
|
"var foo = function(fn) {return fn.toString()}; foo(() => {return 'a'})"
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ module.exports = function supportsBlockScoping() {
|
||||||
"(function f() { const x = 1; if (true) { const x = 2; } return x; })"
|
"(function f() { const x = 1; if (true) { const x = 2; } return x; })"
|
||||||
);
|
);
|
||||||
return f() === 1;
|
return f() === 1;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportsES6() {
|
||||||
try {
|
try {
|
||||||
eval("class A { #field = 1 }");
|
eval("class A { #field = 1 }");
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportsClassStaticBLock() {
|
||||||
try {
|
try {
|
||||||
eval("(function f({x, y}) { class Foo { static {} } })");
|
eval("(function f({x, y}) { class Foo { static {} } })");
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportsDefaultArgs() {
|
||||||
try {
|
try {
|
||||||
var f = eval("(function f(a = 123) { return a; })");
|
var f = eval("(function f(a = 123) { return a; })");
|
||||||
return f() === 123;
|
return f() === 123;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportsES6() {
|
||||||
try {
|
try {
|
||||||
eval("class A {}");
|
eval("class A {}");
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportDefaultAssignment() {
|
||||||
try {
|
try {
|
||||||
var f = eval("(function f() { for(var x of ['ok', 'fail']) return x; })");
|
var f = eval("(function f() { for(var x of ['ok', 'fail']) return x; })");
|
||||||
return f() === "ok";
|
return f() === "ok";
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportsIteratorDestructuring() {
|
||||||
try {
|
try {
|
||||||
var f = eval("(function f([, x, ...y]) { return x; })");
|
var f = eval("(function f([, x, ...y]) { return x; })");
|
||||||
return f([1, 2]) === 2;
|
return f([1, 2]) === 2;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ module.exports = function supportsLogicalAssignment() {
|
||||||
"(function f() { var x = null; x ??= true; x &&= true; return x ||= false; })"
|
"(function f() { var x = null; x ??= true; x &&= true; return x ||= false; })"
|
||||||
);
|
);
|
||||||
return f();
|
return f();
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportsNullishCoalescing() {
|
||||||
try {
|
try {
|
||||||
var f = eval("(function f() { return null ?? true; })");
|
var f = eval("(function f() { return null ?? true; })");
|
||||||
return f();
|
return f();
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportsObjectDestructuring() {
|
||||||
try {
|
try {
|
||||||
var f = eval("(function f({x, y}) { return x + y; })");
|
var f = eval("(function f({x, y}) { return x + y; })");
|
||||||
return f({ x: 1, y: 2 }) === 3;
|
return f({ x: 1, y: 2 }) === 3;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportsOptionalCatchBinding() {
|
||||||
try {
|
try {
|
||||||
eval("try {} catch {}");
|
eval("try {} catch {}");
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportsOptionalChaining() {
|
||||||
try {
|
try {
|
||||||
var f = eval("(function f() { return ({a: true}) ?.a })");
|
var f = eval("(function f() { return ({a: true}) ?.a })");
|
||||||
return f();
|
return f();
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ module.exports = function supportsSpread() {
|
||||||
var y;
|
var y;
|
||||||
eval("y = { ...x }");
|
eval("y = { ...x }");
|
||||||
return y !== x && y.a;
|
return y !== x && y.a;
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ module.exports = function supportsTemplateStrings() {
|
||||||
try {
|
try {
|
||||||
var f = eval("(function f() { return String.raw`a\\b`; })");
|
var f = eval("(function f() { return String.raw`a\\b`; })");
|
||||||
return f() === "a\\b";
|
return f() === "a\\b";
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module.exports = function supportsWebAssembly() {
|
module.exports = function supportsWebAssembly() {
|
||||||
try {
|
try {
|
||||||
return typeof WebAssembly !== "undefined";
|
return typeof WebAssembly !== "undefined";
|
||||||
} catch (e) {
|
} catch (_err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,8 +17,8 @@ describe("warmup", () => {
|
||||||
try {
|
try {
|
||||||
expect(err).toBe(END);
|
expect(err).toBe(END);
|
||||||
done();
|
done();
|
||||||
} catch (e) {
|
} catch (doneErr) {
|
||||||
done(e);
|
done(doneErr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -83,17 +83,17 @@ if (process.env.DEBUG_INFO) {
|
||||||
process.stdout.write(`DONE OK ${name}\n`);
|
process.stdout.write(`DONE OK ${name}\n`);
|
||||||
return r;
|
return r;
|
||||||
},
|
},
|
||||||
e => {
|
err => {
|
||||||
process.stdout.write(`DONE FAIL ${name}\n`);
|
process.stdout.write(`DONE FAIL ${name}\n`);
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.stdout.write(`DONE OK ${name}\n`);
|
process.stdout.write(`DONE OK ${name}\n`);
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
process.stdout.write(`DONE FAIL ${name}\n`);
|
process.stdout.write(`DONE FAIL ${name}\n`);
|
||||||
throw e;
|
throw err;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeout
|
timeout
|
||||||
|
|
Loading…
Reference in New Issue