mirror of https://github.com/webpack/webpack.git
chore: more eslint rules (#19667)
Github Actions / lint (push) Waiting to run
Details
Github Actions / validate-legacy-node (push) Waiting to run
Details
Github Actions / benchmark (1/4) (push) Waiting to run
Details
Github Actions / benchmark (2/4) (push) Waiting to run
Details
Github Actions / benchmark (3/4) (push) Waiting to run
Details
Github Actions / benchmark (4/4) (push) Waiting to run
Details
Github Actions / basic (push) Waiting to run
Details
Github Actions / unit (push) Waiting to run
Details
Github Actions / integration (10.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Blocked by required conditions
Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Blocked by required conditions
Details
Github Actions / lint (push) Waiting to run
Details
Github Actions / validate-legacy-node (push) Waiting to run
Details
Github Actions / benchmark (1/4) (push) Waiting to run
Details
Github Actions / benchmark (2/4) (push) Waiting to run
Details
Github Actions / benchmark (3/4) (push) Waiting to run
Details
Github Actions / benchmark (4/4) (push) Waiting to run
Details
Github Actions / basic (push) Waiting to run
Details
Github Actions / unit (push) Waiting to run
Details
Github Actions / integration (10.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (24.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Blocked by required conditions
Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Blocked by required conditions
Details
This commit is contained in:
parent
260f85e466
commit
5a204dc8cd
|
@ -84,12 +84,6 @@ export default defineConfig([
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
// TODO enable me in future
|
// TODO enable me in future
|
||||||
"unicorn/prefer-regexp-test": "off",
|
|
||||||
"unicorn/prefer-string-slice": "off",
|
|
||||||
// TODO false positive, need to fix in upstream
|
|
||||||
"n/prefer-node-protocol": "off",
|
|
||||||
"n/prefer-global/url": "off",
|
|
||||||
// TODO enable me in future
|
|
||||||
"prefer-destructuring": "off"
|
"prefer-destructuring": "off"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -160,6 +154,9 @@ export default defineConfig([
|
||||||
// TODO enable me
|
// TODO enable me
|
||||||
strict: "off",
|
strict: "off",
|
||||||
|
|
||||||
|
// Some our tests contain `package.json` without `engines`, but tests should work on Node.js@10, so let's disable it
|
||||||
|
"n/prefer-node-protocol": "off",
|
||||||
|
|
||||||
// No need here, we have custom test logic, so except can be placed in different places
|
// No need here, we have custom test logic, so except can be placed in different places
|
||||||
"jest/no-standalone-expect": "off",
|
"jest/no-standalone-expect": "off",
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ class APIPlugin {
|
||||||
|
|
||||||
compilation.hooks.runtimeRequirementInTree
|
compilation.hooks.runtimeRequirementInTree
|
||||||
.for(RuntimeGlobals.getFullHash)
|
.for(RuntimeGlobals.getFullHash)
|
||||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
.tap(PLUGIN_NAME, (chunk, _set) => {
|
||||||
compilation.addRuntimeModule(chunk, new GetFullHashRuntimeModule());
|
compilation.addRuntimeModule(chunk, new GetFullHashRuntimeModule());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -683,7 +683,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
{
|
{
|
||||||
name,
|
name,
|
||||||
/** @type {AsyncSeriesHook<T>["intercept"]} */
|
/** @type {AsyncSeriesHook<T>["intercept"]} */
|
||||||
intercept(interceptor) {
|
intercept(_interceptor) {
|
||||||
throw new Error(errorMessage("it's using 'intercept'"));
|
throw new Error(errorMessage("it's using 'intercept'"));
|
||||||
},
|
},
|
||||||
/** @type {AsyncSeriesHook<T>["tap"]} */
|
/** @type {AsyncSeriesHook<T>["tap"]} */
|
||||||
|
@ -5279,7 +5279,7 @@ This prevents using hashes of each other and should be avoided.`);
|
||||||
runtimeTemplate,
|
runtimeTemplate,
|
||||||
errors,
|
errors,
|
||||||
codeGenerationResults,
|
codeGenerationResults,
|
||||||
(err, codeGenerated) => {
|
(err, _codeGenerated) => {
|
||||||
callback(err);
|
callback(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -5654,9 +5654,9 @@ Object.defineProperty(compilationPrototype, "cache", {
|
||||||
),
|
),
|
||||||
set: util.deprecate(
|
set: util.deprecate(
|
||||||
/**
|
/**
|
||||||
* @param {EXPECTED_ANY} v value
|
* @param {EXPECTED_ANY} _v value
|
||||||
*/
|
*/
|
||||||
v => {},
|
_v => {},
|
||||||
"Compilation.cache was removed in favor of Compilation.getCache()",
|
"Compilation.cache was removed in favor of Compilation.getCache()",
|
||||||
"DEP_WEBPACK_COMPILATION_CACHE"
|
"DEP_WEBPACK_COMPILATION_CACHE"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1391,7 +1391,7 @@ ${other}`);
|
||||||
close(callback) {
|
close(callback) {
|
||||||
if (this.watching) {
|
if (this.watching) {
|
||||||
// When there is still an active watching, close this first
|
// When there is still an active watching, close this first
|
||||||
this.watching.close(err => {
|
this.watching.close(_err => {
|
||||||
this.close(callback);
|
this.close(callback);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -160,7 +160,7 @@ class ConstPlugin {
|
||||||
* @param {JavascriptParser} parser the parser
|
* @param {JavascriptParser} parser the parser
|
||||||
*/
|
*/
|
||||||
const handler = parser => {
|
const handler = parser => {
|
||||||
parser.hooks.terminate.tap(PLUGIN_NAME, statement => true);
|
parser.hooks.terminate.tap(PLUGIN_NAME, _statement => true);
|
||||||
parser.hooks.statementIf.tap(PLUGIN_NAME, statement => {
|
parser.hooks.statementIf.tap(PLUGIN_NAME, statement => {
|
||||||
if (parser.scope.isAsmJs) return;
|
if (parser.scope.isAsmJs) return;
|
||||||
const param = parser.evaluateExpression(statement.test);
|
const param = parser.evaluateExpression(statement.test);
|
||||||
|
|
|
@ -352,7 +352,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
||||||
(segment, callback) => {
|
(segment, callback) => {
|
||||||
const subResource = join(fs, directory, segment);
|
const subResource = join(fs, directory, segment);
|
||||||
|
|
||||||
if (!exclude || !subResource.match(exclude)) {
|
if (!exclude || !exclude.test(subResource)) {
|
||||||
fs.stat(subResource, (err, _stat) => {
|
fs.stat(subResource, (err, _stat) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.code === "ENOENT") {
|
if (err.code === "ENOENT") {
|
||||||
|
@ -370,7 +370,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
||||||
addSubDirectory(ctx, subResource, callback);
|
addSubDirectory(ctx, subResource, callback);
|
||||||
} else if (
|
} else if (
|
||||||
stat.isFile() &&
|
stat.isFile() &&
|
||||||
(!include || subResource.match(include))
|
(!include || include.test(subResource))
|
||||||
) {
|
) {
|
||||||
/** @type {{ context: string, request: string }} */
|
/** @type {{ context: string, request: string }} */
|
||||||
const obj = {
|
const obj = {
|
||||||
|
|
|
@ -80,7 +80,7 @@ class DynamicEntryPlugin {
|
||||||
}
|
}
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
})
|
})
|
||||||
.then(x => {})
|
.then(() => {})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ class EvalDevToolModulePlugin {
|
||||||
if (compilation.outputOptions.trustedTypes) {
|
if (compilation.outputOptions.trustedTypes) {
|
||||||
compilation.hooks.additionalModuleRuntimeRequirements.tap(
|
compilation.hooks.additionalModuleRuntimeRequirements.tap(
|
||||||
PLUGIN_NAME,
|
PLUGIN_NAME,
|
||||||
(module, set, context) => {
|
(module, set, _context) => {
|
||||||
set.add(RuntimeGlobals.createScript);
|
set.add(RuntimeGlobals.createScript);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -669,7 +669,7 @@ class ExternalModule extends Module {
|
||||||
* @param {ConcatenationBailoutReasonContext} context context
|
* @param {ConcatenationBailoutReasonContext} context context
|
||||||
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
|
* @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated
|
||||||
*/
|
*/
|
||||||
getConcatenationBailoutReason({ moduleGraph }) {
|
getConcatenationBailoutReason(context) {
|
||||||
switch (this.externalType) {
|
switch (this.externalType) {
|
||||||
case "amd":
|
case "amd":
|
||||||
case "amd-require":
|
case "amd-require":
|
||||||
|
|
|
@ -1950,11 +1950,11 @@ class FileSystemInfo {
|
||||||
if (imp.d === -1) {
|
if (imp.d === -1) {
|
||||||
// import ... from "..."
|
// import ... from "..."
|
||||||
dependency = parseString(
|
dependency = parseString(
|
||||||
source.substring(imp.s - 1, imp.e + 1)
|
source.slice(imp.s - 1, imp.e + 1)
|
||||||
);
|
);
|
||||||
} else if (imp.d > -1) {
|
} else if (imp.d > -1) {
|
||||||
// import()
|
// import()
|
||||||
const expr = source.substring(imp.s, imp.e).trim();
|
const expr = source.slice(imp.s, imp.e).trim();
|
||||||
dependency = parseString(expr);
|
dependency = parseString(expr);
|
||||||
} else {
|
} else {
|
||||||
// e.g. import.meta
|
// e.g. import.meta
|
||||||
|
@ -1974,7 +1974,7 @@ class FileSystemInfo {
|
||||||
});
|
});
|
||||||
} catch (err1) {
|
} catch (err1) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Parsing of ${path} for build dependencies failed at 'import(${source.substring(
|
`Parsing of ${path} for build dependencies failed at 'import(${source.slice(
|
||||||
imp.s,
|
imp.s,
|
||||||
imp.e
|
imp.e
|
||||||
)})'.\n` +
|
)})'.\n` +
|
||||||
|
|
|
@ -598,7 +598,7 @@ module.exports = class MultiCompiler {
|
||||||
}
|
}
|
||||||
return watching;
|
return watching;
|
||||||
},
|
},
|
||||||
(compiler, watching, callback) => {
|
(compiler, watching, _callback) => {
|
||||||
if (compiler.watching !== watching) return;
|
if (compiler.watching !== watching) return;
|
||||||
if (!watching.running) watching.invalidate();
|
if (!watching.running) watching.invalidate();
|
||||||
},
|
},
|
||||||
|
|
|
@ -415,7 +415,7 @@ class ProgressPlugin {
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
err => {
|
_err => {
|
||||||
// Ignore error
|
// Ignore error
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -363,7 +363,7 @@ class RuntimePlugin {
|
||||||
"javascript",
|
"javascript",
|
||||||
"javascript update",
|
"javascript update",
|
||||||
RuntimeGlobals.getChunkUpdateScriptFilename,
|
RuntimeGlobals.getChunkUpdateScriptFilename,
|
||||||
c =>
|
_chunk =>
|
||||||
/** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */
|
/** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */
|
||||||
(compilation.outputOptions.hotUpdateChunkFilename),
|
(compilation.outputOptions.hotUpdateChunkFilename),
|
||||||
true
|
true
|
||||||
|
@ -465,13 +465,13 @@ class RuntimePlugin {
|
||||||
});
|
});
|
||||||
compilation.hooks.runtimeRequirementInTree
|
compilation.hooks.runtimeRequirementInTree
|
||||||
.for(RuntimeGlobals.relativeUrl)
|
.for(RuntimeGlobals.relativeUrl)
|
||||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
.tap(PLUGIN_NAME, (chunk, _set) => {
|
||||||
compilation.addRuntimeModule(chunk, new RelativeUrlRuntimeModule());
|
compilation.addRuntimeModule(chunk, new RelativeUrlRuntimeModule());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
compilation.hooks.runtimeRequirementInTree
|
compilation.hooks.runtimeRequirementInTree
|
||||||
.for(RuntimeGlobals.onChunksLoaded)
|
.for(RuntimeGlobals.onChunksLoaded)
|
||||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
.tap(PLUGIN_NAME, (chunk, _set) => {
|
||||||
compilation.addRuntimeModule(
|
compilation.addRuntimeModule(
|
||||||
chunk,
|
chunk,
|
||||||
new OnChunksLoadedRuntimeModule()
|
new OnChunksLoadedRuntimeModule()
|
||||||
|
@ -495,7 +495,7 @@ class RuntimePlugin {
|
||||||
// TODO webpack 6: remove CompatRuntimeModule
|
// TODO webpack 6: remove CompatRuntimeModule
|
||||||
compilation.hooks.additionalTreeRuntimeRequirements.tap(
|
compilation.hooks.additionalTreeRuntimeRequirements.tap(
|
||||||
PLUGIN_NAME,
|
PLUGIN_NAME,
|
||||||
(chunk, set) => {
|
(chunk, _set) => {
|
||||||
const { mainTemplate } = compilation;
|
const { mainTemplate } = compilation;
|
||||||
if (
|
if (
|
||||||
mainTemplate.hooks.bootstrap.isUsed() ||
|
mainTemplate.hooks.bootstrap.isUsed() ||
|
||||||
|
|
|
@ -1209,7 +1209,7 @@ class PackFileCacheStrategy {
|
||||||
}
|
}
|
||||||
logger.time("check build dependencies");
|
logger.time("check build dependencies");
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, _reject) => {
|
||||||
this.fileSystemInfo.checkSnapshotValid(
|
this.fileSystemInfo.checkSnapshotValid(
|
||||||
packContainer.buildSnapshot,
|
packContainer.buildSnapshot,
|
||||||
(err, valid) => {
|
(err, valid) => {
|
||||||
|
@ -1231,7 +1231,7 @@ class PackFileCacheStrategy {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, _reject) => {
|
||||||
this.fileSystemInfo.checkSnapshotValid(
|
this.fileSystemInfo.checkSnapshotValid(
|
||||||
packContainer.resolveBuildDependenciesSnapshot,
|
packContainer.resolveBuildDependenciesSnapshot,
|
||||||
(err, valid) => {
|
(err, valid) => {
|
||||||
|
|
|
@ -56,7 +56,7 @@ class HoistContainerReferences {
|
||||||
// advanced stage is where SplitChunksPlugin runs.
|
// advanced stage is where SplitChunksPlugin runs.
|
||||||
stage: STAGE_ADVANCED + 1
|
stage: STAGE_ADVANCED + 1
|
||||||
},
|
},
|
||||||
chunks => {
|
_chunks => {
|
||||||
this.hoistModulesInChunks(
|
this.hoistModulesInChunks(
|
||||||
compilation,
|
compilation,
|
||||||
depsToTrace,
|
depsToTrace,
|
||||||
|
|
|
@ -141,7 +141,7 @@ class RemoteModule extends Module {
|
||||||
* @param {CodeGenerationContext} context context for code generation
|
* @param {CodeGenerationContext} context context for code generation
|
||||||
* @returns {CodeGenerationResult} result
|
* @returns {CodeGenerationResult} result
|
||||||
*/
|
*/
|
||||||
codeGeneration({ runtimeTemplate, moduleGraph, chunkGraph }) {
|
codeGeneration({ moduleGraph, chunkGraph }) {
|
||||||
const module = moduleGraph.getModule(this.dependencies[0]);
|
const module = moduleGraph.getModule(this.dependencies[0]);
|
||||||
const id = module && chunkGraph.getModuleId(module);
|
const id = module && chunkGraph.getModuleId(module);
|
||||||
const sources = new Map();
|
const sources = new Map();
|
||||||
|
|
|
@ -320,6 +320,7 @@ const consumeAStringToken = (input, pos, callbacks) => {
|
||||||
const isNonASCIICodePoint = (cc, q) =>
|
const isNonASCIICodePoint = (cc, q) =>
|
||||||
// Simplify
|
// Simplify
|
||||||
cc > 0x80;
|
cc > 0x80;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} cc char code
|
* @param {number} cc char code
|
||||||
* @returns {boolean} is letter
|
* @returns {boolean} is letter
|
||||||
|
@ -716,12 +717,12 @@ const consumeRightParenthesis = (input, pos, callbacks) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {CharHandler} */
|
/** @type {CharHandler} */
|
||||||
const consumeLeftSquareBracket = (input, pos, callbacks) =>
|
const consumeLeftSquareBracket = (input, pos, _callbacks) =>
|
||||||
// Return a <]-token>.
|
// Return a <]-token>.
|
||||||
pos;
|
pos;
|
||||||
|
|
||||||
/** @type {CharHandler} */
|
/** @type {CharHandler} */
|
||||||
const consumeRightSquareBracket = (input, pos, callbacks) =>
|
const consumeRightSquareBracket = (input, pos, _callbacks) =>
|
||||||
// Return a <]-token>.
|
// Return a <]-token>.
|
||||||
pos;
|
pos;
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ const interceptAllParserHooks = (moduleFactory, tracer) => {
|
||||||
for (const moduleType of moduleTypes) {
|
for (const moduleType of moduleTypes) {
|
||||||
moduleFactory.hooks.parser
|
moduleFactory.hooks.parser
|
||||||
.for(moduleType)
|
.for(moduleType)
|
||||||
.tap(PLUGIN_NAME, (parser, parserOpts) => {
|
.tap(PLUGIN_NAME, (parser, _parserOpts) => {
|
||||||
interceptAllHooksFor(parser, tracer, "Parser");
|
interceptAllHooksFor(parser, tracer, "Parser");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -399,7 +399,7 @@ const interceptAllGeneratorHooks = (moduleFactory, tracer) => {
|
||||||
for (const moduleType of moduleTypes) {
|
for (const moduleType of moduleTypes) {
|
||||||
moduleFactory.hooks.generator
|
moduleFactory.hooks.generator
|
||||||
.for(moduleType)
|
.for(moduleType)
|
||||||
.tap(PLUGIN_NAME, (parser, parserOpts) => {
|
.tap(PLUGIN_NAME, (parser, _parserOpts) => {
|
||||||
interceptAllHooksFor(parser, tracer, "Generator");
|
interceptAllHooksFor(parser, tracer, "Generator");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,13 +119,13 @@ class AMDPlugin {
|
||||||
|
|
||||||
compilation.hooks.runtimeRequirementInTree
|
compilation.hooks.runtimeRequirementInTree
|
||||||
.for(RuntimeGlobals.amdDefine)
|
.for(RuntimeGlobals.amdDefine)
|
||||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
.tap(PLUGIN_NAME, (chunk, _set) => {
|
||||||
compilation.addRuntimeModule(chunk, new AMDDefineRuntimeModule());
|
compilation.addRuntimeModule(chunk, new AMDDefineRuntimeModule());
|
||||||
});
|
});
|
||||||
|
|
||||||
compilation.hooks.runtimeRequirementInTree
|
compilation.hooks.runtimeRequirementInTree
|
||||||
.for(RuntimeGlobals.amdOptions)
|
.for(RuntimeGlobals.amdOptions)
|
||||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
.tap(PLUGIN_NAME, (chunk, _set) => {
|
||||||
compilation.addRuntimeModule(
|
compilation.addRuntimeModule(
|
||||||
chunk,
|
chunk,
|
||||||
new AMDOptionsRuntimeModule(amdOptions)
|
new AMDOptionsRuntimeModule(amdOptions)
|
||||||
|
|
|
@ -99,11 +99,7 @@ CachedConstDependency.Template = class CachedConstDependencyTemplate extends (
|
||||||
* @param {DependencyTemplateContext} templateContext the context object
|
* @param {DependencyTemplateContext} templateContext the context object
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
apply(
|
apply(dependency, source, { initFragments }) {
|
||||||
dependency,
|
|
||||||
source,
|
|
||||||
{ runtimeTemplate, dependencyTemplates, initFragments }
|
|
||||||
) {
|
|
||||||
const dep = /** @type {CachedConstDependency} */ (dependency);
|
const dep = /** @type {CachedConstDependency} */ (dependency);
|
||||||
|
|
||||||
initFragments.push(
|
initFragments.push(
|
||||||
|
|
|
@ -107,15 +107,7 @@ CommonJsFullRequireDependency.Template = class CommonJsFullRequireDependencyTemp
|
||||||
apply(
|
apply(
|
||||||
dependency,
|
dependency,
|
||||||
source,
|
source,
|
||||||
{
|
{ runtimeTemplate, moduleGraph, chunkGraph, runtimeRequirements, runtime }
|
||||||
module,
|
|
||||||
runtimeTemplate,
|
|
||||||
moduleGraph,
|
|
||||||
chunkGraph,
|
|
||||||
runtimeRequirements,
|
|
||||||
runtime,
|
|
||||||
initFragments
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
const dep = /** @type {CommonJsFullRequireDependency} */ (dependency);
|
const dep = /** @type {CommonJsFullRequireDependency} */ (dependency);
|
||||||
if (!dep.range) return;
|
if (!dep.range) return;
|
||||||
|
|
|
@ -156,7 +156,7 @@ class CommonJsPlugin {
|
||||||
|
|
||||||
compilation.hooks.runtimeRequirementInTree
|
compilation.hooks.runtimeRequirementInTree
|
||||||
.for(RuntimeGlobals.harmonyModuleDecorator)
|
.for(RuntimeGlobals.harmonyModuleDecorator)
|
||||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
.tap(PLUGIN_NAME, (chunk, _set) => {
|
||||||
compilation.addRuntimeModule(
|
compilation.addRuntimeModule(
|
||||||
chunk,
|
chunk,
|
||||||
new HarmonyModuleDecoratorRuntimeModule()
|
new HarmonyModuleDecoratorRuntimeModule()
|
||||||
|
@ -165,7 +165,7 @@ class CommonJsPlugin {
|
||||||
|
|
||||||
compilation.hooks.runtimeRequirementInTree
|
compilation.hooks.runtimeRequirementInTree
|
||||||
.for(RuntimeGlobals.nodeModuleDecorator)
|
.for(RuntimeGlobals.nodeModuleDecorator)
|
||||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
.tap(PLUGIN_NAME, (chunk, _set) => {
|
||||||
compilation.addRuntimeModule(
|
compilation.addRuntimeModule(
|
||||||
chunk,
|
chunk,
|
||||||
new NodeModuleDecoratorRuntimeModule()
|
new NodeModuleDecoratorRuntimeModule()
|
||||||
|
|
|
@ -346,9 +346,9 @@ class ImportParserPlugin {
|
||||||
include,
|
include,
|
||||||
exclude,
|
exclude,
|
||||||
mode,
|
mode,
|
||||||
namespaceObject: /** @type {BuildMeta} */ (
|
namespaceObject:
|
||||||
parser.state.module.buildMeta
|
/** @type {BuildMeta} */
|
||||||
).strictHarmonyModule
|
(parser.state.module.buildMeta).strictHarmonyModule
|
||||||
? "strict"
|
? "strict"
|
||||||
: true,
|
: true,
|
||||||
typePrefix: "import()",
|
typePrefix: "import()",
|
||||||
|
|
|
@ -46,7 +46,7 @@ class SystemPlugin {
|
||||||
|
|
||||||
compilation.hooks.runtimeRequirementInTree
|
compilation.hooks.runtimeRequirementInTree
|
||||||
.for(RuntimeGlobals.system)
|
.for(RuntimeGlobals.system)
|
||||||
.tap(PLUGIN_NAME, (chunk, set) => {
|
.tap(PLUGIN_NAME, (chunk, _set) => {
|
||||||
compilation.addRuntimeModule(chunk, new SystemRuntimeModule());
|
compilation.addRuntimeModule(chunk, new SystemRuntimeModule());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -493,12 +493,18 @@ class WorkerPlugin {
|
||||||
const pattern = item.slice(1, firstDot);
|
const pattern = item.slice(1, firstDot);
|
||||||
const itemMembers = item.slice(firstDot + 1, -2);
|
const itemMembers = item.slice(firstDot + 1, -2);
|
||||||
|
|
||||||
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, statement) => {
|
parser.hooks.preDeclarator.tap(
|
||||||
if (decl.id.type === "Identifier" && decl.id.name === pattern) {
|
PLUGIN_NAME,
|
||||||
|
(decl, _statement) => {
|
||||||
|
if (
|
||||||
|
decl.id.type === "Identifier" &&
|
||||||
|
decl.id.name === pattern
|
||||||
|
) {
|
||||||
parser.tagVariable(decl.id.name, WorkerSpecifierTag);
|
parser.tagVariable(decl.id.name, WorkerSpecifierTag);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
parser.hooks.pattern.for(pattern).tap(PLUGIN_NAME, pattern => {
|
parser.hooks.pattern.for(pattern).tap(PLUGIN_NAME, pattern => {
|
||||||
parser.tagVariable(pattern.name, WorkerSpecifierTag);
|
parser.tagVariable(pattern.name, WorkerSpecifierTag);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -287,9 +287,7 @@ class ModuleChunkFormatPlugin {
|
||||||
}
|
}
|
||||||
return source;
|
return source;
|
||||||
});
|
});
|
||||||
hooks.chunkHash.tap(
|
hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash, { chunkGraph }) => {
|
||||||
PLUGIN_NAME,
|
|
||||||
(chunk, hash, { chunkGraph, runtimeTemplate }) => {
|
|
||||||
if (chunk.hasRuntime()) return;
|
if (chunk.hasRuntime()) return;
|
||||||
const { entries, runtimeChunk } = getChunkInfo(chunk, chunkGraph);
|
const { entries, runtimeChunk } = getChunkInfo(chunk, chunkGraph);
|
||||||
hash.update(PLUGIN_NAME);
|
hash.update(PLUGIN_NAME);
|
||||||
|
@ -301,8 +299,7 @@ class ModuleChunkFormatPlugin {
|
||||||
hash.update(runtimeChunk.hash);
|
hash.update(runtimeChunk.hash);
|
||||||
}
|
}
|
||||||
updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
|
updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class NaturalModuleIdsPlugin {
|
||||||
*/
|
*/
|
||||||
apply(compiler) {
|
apply(compiler) {
|
||||||
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
||||||
compilation.hooks.moduleIds.tap(PLUGIN_NAME, modules => {
|
compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
|
||||||
const [usedIds, modulesInNaturalOrder] =
|
const [usedIds, modulesInNaturalOrder] =
|
||||||
getUsedModuleIdsAndModules(compilation);
|
getUsedModuleIdsAndModules(compilation);
|
||||||
modulesInNaturalOrder.sort(
|
modulesInNaturalOrder.sort(
|
||||||
|
|
|
@ -117,10 +117,10 @@ const printGeneratedCodeForStack = (module, code) => {
|
||||||
/**
|
/**
|
||||||
* @param {string} line the line
|
* @param {string} line the line
|
||||||
* @param {number} i the index
|
* @param {number} i the index
|
||||||
* @param {string[]} lines the lines
|
* @param {string[]} _lines the lines
|
||||||
* @returns {string} the line with line number
|
* @returns {string} the line with line number
|
||||||
*/
|
*/
|
||||||
(line, i, lines) => {
|
(line, i, _lines) => {
|
||||||
const iStr = `${i + 1}`;
|
const iStr = `${i + 1}`;
|
||||||
return `${" ".repeat(n - iStr.length)}${iStr} | ${line}`;
|
return `${" ".repeat(n - iStr.length)}${iStr} | ${line}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1386,7 +1386,7 @@ class JavascriptParser extends Parser {
|
||||||
return this.callHooksForInfoWithFallback(
|
return this.callHooksForInfoWithFallback(
|
||||||
this.hooks.evaluateIdentifier,
|
this.hooks.evaluateIdentifier,
|
||||||
info.name,
|
info.name,
|
||||||
name => {
|
_name => {
|
||||||
cachedExpression = expression;
|
cachedExpression = expression;
|
||||||
cachedInfo = info;
|
cachedInfo = info;
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -1441,7 +1441,7 @@ class JavascriptParser extends Parser {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tapEvaluateWithVariableInfo("ThisExpression", expr => {
|
tapEvaluateWithVariableInfo("ThisExpression", _expr => {
|
||||||
const info = this.getVariableInfo("this");
|
const info = this.getVariableInfo("this");
|
||||||
if (
|
if (
|
||||||
typeof info === "string" ||
|
typeof info === "string" ||
|
||||||
|
@ -3481,7 +3481,7 @@ class JavascriptParser extends Parser {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.walkExpression(expression.right);
|
this.walkExpression(expression.right);
|
||||||
this.enterPattern(expression.left, (name, decl) => {
|
this.enterPattern(expression.left, (name, _decl) => {
|
||||||
if (!this.callHooksForName(this.hooks.assign, name, expression)) {
|
if (!this.callHooksForName(this.hooks.assign, name, expression)) {
|
||||||
this.walkExpression(
|
this.walkExpression(
|
||||||
/** @type {MemberExpression} */
|
/** @type {MemberExpression} */
|
||||||
|
@ -3491,7 +3491,7 @@ class JavascriptParser extends Parser {
|
||||||
});
|
});
|
||||||
} else if (expression.left.type.endsWith("Pattern")) {
|
} else if (expression.left.type.endsWith("Pattern")) {
|
||||||
this.walkExpression(expression.right);
|
this.walkExpression(expression.right);
|
||||||
this.enterPattern(expression.left, (name, decl) => {
|
this.enterPattern(expression.left, (name, _decl) => {
|
||||||
if (!this.callHooksForName(this.hooks.assign, name, expression)) {
|
if (!this.callHooksForName(this.hooks.assign, name, expression)) {
|
||||||
this.defineVariable(name);
|
this.defineVariable(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ class InnerGraphPlugin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, statement) => {
|
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, _statement) => {
|
||||||
if (!InnerGraph.isEnabled(parser.state)) return;
|
if (!InnerGraph.isEnabled(parser.state)) return;
|
||||||
if (
|
if (
|
||||||
parser.scope.topLevelScope === true &&
|
parser.scope.topLevelScope === true &&
|
||||||
|
@ -363,7 +363,7 @@ class InnerGraphPlugin {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
parser.hooks.declarator.tap(PLUGIN_NAME, (decl, statement) => {
|
parser.hooks.declarator.tap(PLUGIN_NAME, (decl, _statement) => {
|
||||||
if (!InnerGraph.isEnabled(parser.state)) return;
|
if (!InnerGraph.isEnabled(parser.state)) return;
|
||||||
const fn = declWithTopLevelSymbol.get(decl);
|
const fn = declWithTopLevelSymbol.get(decl);
|
||||||
|
|
||||||
|
|
|
@ -279,10 +279,10 @@ const INITIAL_CHUNK_FILTER = chunk => chunk.canBeInitial();
|
||||||
*/
|
*/
|
||||||
const ASYNC_CHUNK_FILTER = chunk => !chunk.canBeInitial();
|
const ASYNC_CHUNK_FILTER = chunk => !chunk.canBeInitial();
|
||||||
/**
|
/**
|
||||||
* @param {Chunk} chunk the chunk
|
* @param {Chunk} _chunk the chunk
|
||||||
* @returns {boolean} always true
|
* @returns {boolean} always true
|
||||||
*/
|
*/
|
||||||
const ALL_CHUNK_FILTER = chunk => true;
|
const ALL_CHUNK_FILTER = _chunk => true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {OptimizationSplitChunksSizes | undefined} value the sizes
|
* @param {OptimizationSplitChunksSizes | undefined} value the sizes
|
||||||
|
|
|
@ -35,7 +35,7 @@ class BasicEffectRulePlugin {
|
||||||
apply(ruleSetCompiler) {
|
apply(ruleSetCompiler) {
|
||||||
ruleSetCompiler.hooks.rule.tap(
|
ruleSetCompiler.hooks.rule.tap(
|
||||||
PLUGIN_NAME,
|
PLUGIN_NAME,
|
||||||
(path, rule, unhandledProperties, result, references) => {
|
(path, rule, unhandledProperties, result) => {
|
||||||
if (unhandledProperties.has(this.ruleProperty)) {
|
if (unhandledProperties.has(this.ruleProperty)) {
|
||||||
unhandledProperties.delete(this.ruleProperty);
|
unhandledProperties.delete(this.ruleProperty);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const { URL, fileURLToPath } = require("url");
|
const { fileURLToPath } = require("url");
|
||||||
const { NormalModule } = require("..");
|
const { NormalModule } = require("..");
|
||||||
|
|
||||||
/** @typedef {import("../Compiler")} Compiler */
|
/** @typedef {import("../Compiler")} Compiler */
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
const EventEmitter = require("events");
|
const EventEmitter = require("events");
|
||||||
const { basename, extname } = require("path");
|
const { basename, extname } = require("path");
|
||||||
const { URL } = require("url");
|
|
||||||
const {
|
const {
|
||||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||||
createBrotliDecompress,
|
createBrotliDecompress,
|
||||||
|
@ -37,7 +36,7 @@ const getHttps = memoize(() => require("https"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {typeof import("http") | typeof import("https")} request request
|
* @param {typeof import("http") | typeof import("https")} request request
|
||||||
* @param {string | { toString: () => string } | undefined} proxy proxy
|
* @param {string | URL | undefined} proxy proxy
|
||||||
* @returns {(url: URL, requestOptions: RequestOptions, callback: (incomingMessage: IncomingMessage) => void) => EventEmitter} fn
|
* @returns {(url: URL, requestOptions: RequestOptions, callback: (incomingMessage: IncomingMessage) => void) => EventEmitter} fn
|
||||||
*/
|
*/
|
||||||
const proxyFetch = (request, proxy) => (url, options, callback) => {
|
const proxyFetch = (request, proxy) => (url, options, callback) => {
|
||||||
|
|
|
@ -554,7 +554,7 @@ class FileMiddleware extends SerializerMiddleware {
|
||||||
* @param {(value?: undefined) => void} resolve resolve
|
* @param {(value?: undefined) => void} resolve resolve
|
||||||
*/
|
*/
|
||||||
resolve => {
|
resolve => {
|
||||||
this.fs.rename(filename, `${filename}.old`, err => {
|
this.fs.rename(filename, `${filename}.old`, _err => {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ class ConsumeSharedModule extends Module {
|
||||||
* @param {CodeGenerationContext} context context for code generation
|
* @param {CodeGenerationContext} context context for code generation
|
||||||
* @returns {CodeGenerationResult} result
|
* @returns {CodeGenerationResult} result
|
||||||
*/
|
*/
|
||||||
codeGeneration({ chunkGraph, moduleGraph, runtimeTemplate }) {
|
codeGeneration({ chunkGraph, runtimeTemplate }) {
|
||||||
const runtimeRequirements = new Set([RuntimeGlobals.shareScopeMap]);
|
const runtimeRequirements = new Set([RuntimeGlobals.shareScopeMap]);
|
||||||
const {
|
const {
|
||||||
shareScope,
|
shareScope,
|
||||||
|
|
|
@ -132,7 +132,7 @@ class ProvideSharedModule extends Module {
|
||||||
* @param {CodeGenerationContext} context context for code generation
|
* @param {CodeGenerationContext} context context for code generation
|
||||||
* @returns {CodeGenerationResult} result
|
* @returns {CodeGenerationResult} result
|
||||||
*/
|
*/
|
||||||
codeGeneration({ runtimeTemplate, moduleGraph, chunkGraph }) {
|
codeGeneration({ runtimeTemplate, chunkGraph }) {
|
||||||
const runtimeRequirements = new Set([RuntimeGlobals.initializeSharing]);
|
const runtimeRequirements = new Set([RuntimeGlobals.initializeSharing]);
|
||||||
const code = `register(${JSON.stringify(this._name)}, ${JSON.stringify(
|
const code = `register(${JSON.stringify(this._name)}, ${JSON.stringify(
|
||||||
this._version || "0"
|
this._version || "0"
|
||||||
|
|
|
@ -495,7 +495,7 @@ const EXTRACT_ERROR = {
|
||||||
errorDetails: (
|
errorDetails: (
|
||||||
object,
|
object,
|
||||||
error,
|
error,
|
||||||
{ type, compilation, cachedGetErrors, cachedGetWarnings },
|
{ type, compilation, cachedGetErrors },
|
||||||
{ errorDetails }
|
{ errorDetails }
|
||||||
) => {
|
) => {
|
||||||
if (
|
if (
|
||||||
|
@ -1037,7 +1037,7 @@ const SIMPLE_EXTRACTORS = {
|
||||||
_: (
|
_: (
|
||||||
object,
|
object,
|
||||||
asset,
|
asset,
|
||||||
{ compilation, compilationFileToChunks, compilationAuxiliaryFileToChunks }
|
{ compilationFileToChunks, compilationAuxiliaryFileToChunks }
|
||||||
) => {
|
) => {
|
||||||
const chunks = compilationFileToChunks.get(asset.name) || [];
|
const chunks = compilationFileToChunks.get(asset.name) || [];
|
||||||
const auxiliaryChunks =
|
const auxiliaryChunks =
|
||||||
|
@ -1522,7 +1522,7 @@ const SIMPLE_EXTRACTORS = {
|
||||||
ids: (object, chunk) => {
|
ids: (object, chunk) => {
|
||||||
object.id = /** @type {ChunkId} */ (chunk.id);
|
object.id = /** @type {ChunkId} */ (chunk.id);
|
||||||
},
|
},
|
||||||
chunkRelations: (object, chunk, { compilation: { chunkGraph } }) => {
|
chunkRelations: (object, chunk, _context) => {
|
||||||
/** @type {Set<string|number>} */
|
/** @type {Set<string|number>} */
|
||||||
const parents = new Set();
|
const parents = new Set();
|
||||||
/** @type {Set<string|number>} */
|
/** @type {Set<string|number>} */
|
||||||
|
@ -1703,7 +1703,7 @@ const SORTERS = {
|
||||||
"chunk.modules": MODULES_SORTER,
|
"chunk.modules": MODULES_SORTER,
|
||||||
"module.modules": MODULES_SORTER,
|
"module.modules": MODULES_SORTER,
|
||||||
"module.reasons": {
|
"module.reasons": {
|
||||||
_: (comparators, { compilation: { chunkGraph } }) => {
|
_: (comparators, _context) => {
|
||||||
comparators.push(
|
comparators.push(
|
||||||
compareSelect(x => x.originModule, compareModulesByIdentifier)
|
compareSelect(x => x.originModule, compareModulesByIdentifier)
|
||||||
);
|
);
|
||||||
|
@ -2147,7 +2147,7 @@ const ASSETS_GROUPERS = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
groupAssetsByInfo: (groupConfigs, context, options) => {
|
groupAssetsByInfo: (groupConfigs, _context, _options) => {
|
||||||
/**
|
/**
|
||||||
* @param {string} name name
|
* @param {string} name name
|
||||||
*/
|
*/
|
||||||
|
@ -2168,7 +2168,7 @@ const ASSETS_GROUPERS = {
|
||||||
groupByAssetInfoFlag("development");
|
groupByAssetInfoFlag("development");
|
||||||
groupByAssetInfoFlag("hotModuleReplacement");
|
groupByAssetInfoFlag("hotModuleReplacement");
|
||||||
},
|
},
|
||||||
groupAssetsByChunk: (groupConfigs, context, options) => {
|
groupAssetsByChunk: (groupConfigs, _context, _options) => {
|
||||||
/**
|
/**
|
||||||
* @param {keyof KnownStatsAsset} name name
|
* @param {keyof KnownStatsAsset} name name
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -384,7 +384,7 @@ class DefaultStatsPresetPlugin {
|
||||||
const defaults = NAMED_PRESETS[/** @type {keyof NamedPresets} */ (key)];
|
const defaults = NAMED_PRESETS[/** @type {keyof NamedPresets} */ (key)];
|
||||||
compilation.hooks.statsPreset
|
compilation.hooks.statsPreset
|
||||||
.for(key)
|
.for(key)
|
||||||
.tap(PLUGIN_NAME, (options, context) => {
|
.tap(PLUGIN_NAME, (options, _context) => {
|
||||||
applyDefaults(options, defaults);
|
applyDefaults(options, defaults);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,7 +494,7 @@ const MODULE_SIMPLE_PRINTERS = {
|
||||||
const [prefix, resource] = getModuleName(name);
|
const [prefix, resource] = getModuleName(name);
|
||||||
return `${prefix || ""}${bold(resource || "")}`;
|
return `${prefix || ""}${bold(resource || "")}`;
|
||||||
},
|
},
|
||||||
"module.identifier": identifier => undefined,
|
"module.identifier": _identifier => undefined,
|
||||||
"module.layer": (layer, { formatLayer }) =>
|
"module.layer": (layer, { formatLayer }) =>
|
||||||
layer ? formatLayer(layer) : undefined,
|
layer ? formatLayer(layer) : undefined,
|
||||||
"module.sizes": printSizes,
|
"module.sizes": printSizes,
|
||||||
|
@ -571,7 +571,7 @@ const MODULE_SIMPLE_PRINTERS = {
|
||||||
yellow(optimizationBailout),
|
yellow(optimizationBailout),
|
||||||
"module.issuerPath": (issuerPath, { module }) =>
|
"module.issuerPath": (issuerPath, { module }) =>
|
||||||
module.profile ? undefined : "",
|
module.profile ? undefined : "",
|
||||||
"module.profile": profile => undefined,
|
"module.profile": _profile => undefined,
|
||||||
"module.filteredModules": (filteredModules, { module: { modules } }) =>
|
"module.filteredModules": (filteredModules, { module: { modules } }) =>
|
||||||
filteredModules > 0
|
filteredModules > 0
|
||||||
? `${moreCount(modules, filteredModules)} nested ${plural(
|
? `${moreCount(modules, filteredModules)} nested ${plural(
|
||||||
|
@ -831,7 +831,7 @@ const ERROR_PRINTERS = {
|
||||||
" "
|
" "
|
||||||
)
|
)
|
||||||
: undefined,
|
: undefined,
|
||||||
"error.moduleTrace": moduleTrace => undefined,
|
"error.moduleTrace": _moduleTrace => undefined,
|
||||||
"error.separator!": () => "\n"
|
"error.separator!": () => "\n"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1856,7 +1856,7 @@ class DefaultStatsPrinterPlugin {
|
||||||
const preferredOrder = PREFERRED_ORDERS[key];
|
const preferredOrder = PREFERRED_ORDERS[key];
|
||||||
stats.hooks.sortElements
|
stats.hooks.sortElements
|
||||||
.for(key)
|
.for(key)
|
||||||
.tap(PLUGIN_NAME, (elements, context) => {
|
.tap(PLUGIN_NAME, (elements, _context) => {
|
||||||
createOrder(elements, preferredOrder);
|
createOrder(elements, preferredOrder);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
"eslint-plugin-import": "^2.32.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-jest": "^29.0.1",
|
"eslint-plugin-jest": "^29.0.1",
|
||||||
"eslint-plugin-jsdoc": "^51.2.3",
|
"eslint-plugin-jsdoc": "^51.2.3",
|
||||||
"eslint-plugin-n": "^17.20.0",
|
"eslint-plugin-n": "^17.21.0",
|
||||||
"eslint-plugin-prettier": "^5.5.0",
|
"eslint-plugin-prettier": "^5.5.0",
|
||||||
"eslint-plugin-unicorn": "^59.0.1",
|
"eslint-plugin-unicorn": "^59.0.1",
|
||||||
"file-loader": "^6.0.0",
|
"file-loader": "^6.0.0",
|
||||||
|
|
|
@ -43,7 +43,7 @@ async function runSetupSymlinkAsync() {
|
||||||
* @returns {Promise<boolean>} result
|
* @returns {Promise<boolean>} result
|
||||||
*/
|
*/
|
||||||
function checkSymlinkExistsAsync() {
|
function checkSymlinkExistsAsync() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise(resolve => {
|
||||||
if (
|
if (
|
||||||
fs.existsSync(nodeModulesFolder) &&
|
fs.existsSync(nodeModulesFolder) &&
|
||||||
fs.existsSync(webpackDependencyFolder) &&
|
fs.existsSync(webpackDependencyFolder) &&
|
||||||
|
|
|
@ -133,12 +133,12 @@ describe("Compiler (caching)", () => {
|
||||||
const options = {};
|
const options = {};
|
||||||
const tempFixture = createTempFixture();
|
const tempFixture = createTempFixture();
|
||||||
|
|
||||||
const helper = compile(tempFixture.cFilepath, options, (stats, files) => {
|
const helper = compile(tempFixture.cFilepath, options, (stats, _files) => {
|
||||||
// Not cached the first time
|
// Not cached the first time
|
||||||
expect(stats.assets[0].name).toBe("bundle.js");
|
expect(stats.assets[0].name).toBe("bundle.js");
|
||||||
expect(stats.assets[0].emitted).toBe(true);
|
expect(stats.assets[0].emitted).toBe(true);
|
||||||
|
|
||||||
helper.runAgain((stats, files, iteration) => {
|
helper.runAgain((stats, _files, _iteration) => {
|
||||||
// Cached the second run
|
// Cached the second run
|
||||||
expect(stats.assets[0].name).toBe("bundle.js");
|
expect(stats.assets[0].name).toBe("bundle.js");
|
||||||
expect(stats.assets[0].emitted).toBe(false);
|
expect(stats.assets[0].emitted).toBe(false);
|
||||||
|
@ -151,7 +151,7 @@ describe("Compiler (caching)", () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
fs.writeFileSync(tempFixture.aFilepath, aContent);
|
fs.writeFileSync(tempFixture.aFilepath, aContent);
|
||||||
|
|
||||||
helper.runAgain((stats, files, iteration) => {
|
helper.runAgain((stats, _files, _iteration) => {
|
||||||
// Cached the third run
|
// Cached the third run
|
||||||
expect(stats.assets[0].name).toBe("bundle.js");
|
expect(stats.assets[0].name).toBe("bundle.js");
|
||||||
expect(stats.assets[0].emitted).toBe(true);
|
expect(stats.assets[0].emitted).toBe(true);
|
||||||
|
@ -167,12 +167,12 @@ describe("Compiler (caching)", () => {
|
||||||
const options = {};
|
const options = {};
|
||||||
const tempFixture = createTempFixture();
|
const tempFixture = createTempFixture();
|
||||||
|
|
||||||
const helper = compile(tempFixture.cFilepath, options, (stats, files) => {
|
const helper = compile(tempFixture.cFilepath, options, (stats, _files) => {
|
||||||
// Not cached the first time
|
// Not cached the first time
|
||||||
expect(stats.assets[0].name).toBe("bundle.js");
|
expect(stats.assets[0].name).toBe("bundle.js");
|
||||||
expect(stats.assets[0].emitted).toBe(true);
|
expect(stats.assets[0].emitted).toBe(true);
|
||||||
|
|
||||||
helper.runAgain((stats, files, iteration) => {
|
helper.runAgain((stats, files, _iteration) => {
|
||||||
// Cached the second run
|
// Cached the second run
|
||||||
expect(stats.assets[0].name).toBe("bundle.js");
|
expect(stats.assets[0].name).toBe("bundle.js");
|
||||||
expect(stats.assets[0].emitted).toBe(false);
|
expect(stats.assets[0].emitted).toBe(false);
|
||||||
|
@ -186,7 +186,7 @@ describe("Compiler (caching)", () => {
|
||||||
|
|
||||||
fs.writeFileSync(tempFixture.aFilepath, aContent);
|
fs.writeFileSync(tempFixture.aFilepath, aContent);
|
||||||
|
|
||||||
helper.runAgain((stats, files, iteration) => {
|
helper.runAgain((stats, files, _iteration) => {
|
||||||
// Cached the third run
|
// Cached the third run
|
||||||
expect(stats.assets[0].name).toBe("bundle.js");
|
expect(stats.assets[0].name).toBe("bundle.js");
|
||||||
expect(stats.assets[0].emitted).toBe(true);
|
expect(stats.assets[0].emitted).toBe(true);
|
||||||
|
@ -203,7 +203,7 @@ describe("Compiler (caching)", () => {
|
||||||
const options = {};
|
const options = {};
|
||||||
const tempFixture = createTempFixture();
|
const tempFixture = createTempFixture();
|
||||||
|
|
||||||
const helper = compile(tempFixture.cFilepath, options, (stats, files) => {
|
const helper = compile(tempFixture.cFilepath, options, (stats, _files) => {
|
||||||
// Built the first time
|
// Built the first time
|
||||||
expect(stats.modules[0].name).toMatch("c.js");
|
expect(stats.modules[0].name).toMatch("c.js");
|
||||||
expect(stats.modules[0].built).toBe(true);
|
expect(stats.modules[0].built).toBe(true);
|
||||||
|
@ -212,7 +212,7 @@ describe("Compiler (caching)", () => {
|
||||||
expect(stats.modules[1].built).toBe(true);
|
expect(stats.modules[1].built).toBe(true);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
helper.runAgain((stats, files, iteration) => {
|
helper.runAgain((stats, _files, _iteration) => {
|
||||||
// Not built when cached the second run
|
// Not built when cached the second run
|
||||||
expect(stats.modules[0].name).toMatch("c.js");
|
expect(stats.modules[0].name).toMatch("c.js");
|
||||||
// expect(stats.modules[0].built).toBe(false);
|
// expect(stats.modules[0].built).toBe(false);
|
||||||
|
@ -228,7 +228,7 @@ describe("Compiler (caching)", () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
fs.writeFileSync(tempFixture.aFilepath, aContent);
|
fs.writeFileSync(tempFixture.aFilepath, aContent);
|
||||||
|
|
||||||
helper.runAgain((stats, files, iteration) => {
|
helper.runAgain((stats, _files, _iteration) => {
|
||||||
// And only a.js built after it was modified
|
// And only a.js built after it was modified
|
||||||
expect(stats.modules[0].name).toMatch("c.js");
|
expect(stats.modules[0].name).toMatch("c.js");
|
||||||
expect(stats.modules[0].built).toBe(false);
|
expect(stats.modules[0].built).toBe(false);
|
||||||
|
@ -248,7 +248,7 @@ describe("Compiler (caching)", () => {
|
||||||
const options = {};
|
const options = {};
|
||||||
const tempFixture = createTempFixture();
|
const tempFixture = createTempFixture();
|
||||||
|
|
||||||
const helper = compile(tempFixture.cFilepath, options, (stats, files) => {
|
const helper = compile(tempFixture.cFilepath, options, (stats, _files) => {
|
||||||
// Built the first time
|
// Built the first time
|
||||||
expect(stats.modules[0].name).toMatch("c.js");
|
expect(stats.modules[0].name).toMatch("c.js");
|
||||||
expect(stats.modules[0].built).toBe(true);
|
expect(stats.modules[0].built).toBe(true);
|
||||||
|
@ -256,7 +256,7 @@ describe("Compiler (caching)", () => {
|
||||||
expect(stats.modules[1].name).toMatch("a.js");
|
expect(stats.modules[1].name).toMatch("a.js");
|
||||||
expect(stats.modules[1].built).toBe(true);
|
expect(stats.modules[1].built).toBe(true);
|
||||||
|
|
||||||
helper.runAgain((stats, files, iteration) => {
|
helper.runAgain((stats, _files, _iteration) => {
|
||||||
// Not built when cached the second run
|
// Not built when cached the second run
|
||||||
expect(stats.modules[0].name).toMatch("c.js");
|
expect(stats.modules[0].name).toMatch("c.js");
|
||||||
// expect(stats.modules[0].built).toBe(false);
|
// expect(stats.modules[0].built).toBe(false);
|
||||||
|
@ -271,7 +271,7 @@ describe("Compiler (caching)", () => {
|
||||||
|
|
||||||
fs.writeFileSync(tempFixture.aFilepath, aContent);
|
fs.writeFileSync(tempFixture.aFilepath, aContent);
|
||||||
|
|
||||||
helper.runAgain((stats, files, iteration) => {
|
helper.runAgain((stats, _files, _iteration) => {
|
||||||
// And only a.js built after it was modified
|
// And only a.js built after it was modified
|
||||||
expect(stats.modules[0].name).toMatch("c.js");
|
expect(stats.modules[0].name).toMatch("c.js");
|
||||||
// expect(stats.modules[0].built).toBe(false);
|
// expect(stats.modules[0].built).toBe(false);
|
||||||
|
|
|
@ -94,7 +94,7 @@ describe("Compiler", () => {
|
||||||
filename: "the/hell.js"
|
filename: "the/hell.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(stats, files) => {
|
(stats, _files) => {
|
||||||
expect(stats.logs.mkdir).toEqual(["/what", "/what/the"]);
|
expect(stats.logs.mkdir).toEqual(["/what", "/what/the"]);
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ describe("Compiler", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
if (compiler.outputFileSystem.existsSync("/bundle.js")) {
|
if (compiler.outputFileSystem.existsSync("/bundle.js")) {
|
||||||
return done(new Error("Bundle should not be created on error"));
|
return done(new Error("Bundle should not be created on error"));
|
||||||
|
@ -430,7 +430,7 @@ describe("Compiler", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
const watching = compiler.watch({}, (err, stats) => {
|
const watching = compiler.watch({}, (err, _stats) => {
|
||||||
watching.close();
|
watching.close();
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
if (compiler.outputFileSystem.existsSync("/bundle.js")) {
|
if (compiler.outputFileSystem.existsSync("/bundle.js")) {
|
||||||
|
@ -453,10 +453,10 @@ describe("Compiler", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done();
|
if (err) return done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -474,10 +474,10 @@ describe("Compiler", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done();
|
if (err) return done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -495,10 +495,10 @@ describe("Compiler", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done();
|
if (err) return done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -516,10 +516,10 @@ describe("Compiler", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done();
|
if (err) return done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -540,7 +540,7 @@ describe("Compiler", () => {
|
||||||
() => {}
|
() => {}
|
||||||
);
|
);
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done();
|
if (err) return done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -561,7 +561,7 @@ describe("Compiler", () => {
|
||||||
compiler.run((err, stats1) => {
|
compiler.run((err, stats1) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
|
||||||
compiler.run((err, stats2) => {
|
compiler.run((err, _stats2) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
expect(stats1.toString({ all: true })).toBeTypeOf("string");
|
expect(stats1.toString({ all: true })).toBeTypeOf("string");
|
||||||
done();
|
done();
|
||||||
|
@ -582,10 +582,10 @@ describe("Compiler", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
|
||||||
const watching = compiler.watch({}, (err, stats) => {
|
const watching = compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
watching.close(done);
|
watching.close(done);
|
||||||
});
|
});
|
||||||
|
@ -605,11 +605,11 @@ describe("Compiler", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
const watching = compiler.watch({}, (err, stats) => {
|
const watching = compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
watching.close(() => {
|
watching.close(() => {
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -629,7 +629,7 @@ describe("Compiler", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
const watching = compiler.watch({}, (err, stats) => {
|
const watching = compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
watching.close(done);
|
watching.close(done);
|
||||||
});
|
});
|
||||||
|
@ -649,11 +649,11 @@ describe("Compiler", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
const watching = compiler.watch({}, (err, stats) => {
|
const watching = compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
watching.close(() => {
|
watching.close(() => {
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -677,12 +677,12 @@ describe("Compiler", () => {
|
||||||
compiler.hooks.afterDone.tap("RunAgainTest", () => {
|
compiler.hooks.afterDone.tap("RunAgainTest", () => {
|
||||||
if (!once) return;
|
if (!once) return;
|
||||||
once = false;
|
once = false;
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -708,7 +708,7 @@ describe("Compiler", () => {
|
||||||
expect(doneHookCb).toHaveBeenCalled();
|
expect(doneHookCb).toHaveBeenCalled();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
runCb();
|
runCb();
|
||||||
});
|
});
|
||||||
|
@ -729,7 +729,7 @@ describe("Compiler", () => {
|
||||||
filename: "bundle.js"
|
filename: "bundle.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(err, stats) => {
|
(err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
instanceCb();
|
instanceCb();
|
||||||
}
|
}
|
||||||
|
@ -770,7 +770,7 @@ describe("Compiler", () => {
|
||||||
expect(invalidateCb).toHaveBeenCalled();
|
expect(invalidateCb).toHaveBeenCalled();
|
||||||
watching.close(done);
|
watching.close(done);
|
||||||
});
|
});
|
||||||
const watching = compiler.watch({}, (err, stats) => {
|
const watching = compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
watchCb();
|
watchCb();
|
||||||
});
|
});
|
||||||
|
@ -805,7 +805,7 @@ describe("Compiler", () => {
|
||||||
expect(invalidateCb).toHaveBeenCalled();
|
expect(invalidateCb).toHaveBeenCalled();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
const watch = compiler.watch({}, (err, stats) => {
|
const watch = compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
watch.close(watchCloseCb);
|
watch.close(watchCloseCb);
|
||||||
});
|
});
|
||||||
|
@ -881,7 +881,7 @@ describe("Compiler", () => {
|
||||||
});
|
});
|
||||||
compiler.hooks.failed.tap("CompilerTest", failedSpy);
|
compiler.hooks.failed.tap("CompilerTest", failedSpy);
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
expect(err).toBeTruthy();
|
expect(err).toBeTruthy();
|
||||||
expect(failedSpy).toHaveBeenCalledTimes(1);
|
expect(failedSpy).toHaveBeenCalledTimes(1);
|
||||||
expect(failedSpy).toHaveBeenCalledWith(err);
|
expect(failedSpy).toHaveBeenCalledWith(err);
|
||||||
|
@ -956,7 +956,7 @@ describe("Compiler", () => {
|
||||||
plugins: [new MyPlugin()]
|
plugins: [new MyPlugin()]
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((_err, _stats) => {
|
||||||
expect(capture.toString().replace(/[\d.]+ ms/, "X ms"))
|
expect(capture.toString().replace(/[\d.]+ ms/, "X ms"))
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"<-> [MyPlugin] Group
|
"<-> [MyPlugin] Group
|
||||||
|
@ -990,7 +990,7 @@ describe("Compiler", () => {
|
||||||
plugins: [new MyPlugin()]
|
plugins: [new MyPlugin()]
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((_err, _stats) => {
|
||||||
expect(capture.toString().replace(/[\d.]+ ms/, "X ms"))
|
expect(capture.toString().replace(/[\d.]+ ms/, "X ms"))
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"<-> [MyPlugin] Group
|
"<-> [MyPlugin] Group
|
||||||
|
@ -1024,7 +1024,7 @@ describe("Compiler", () => {
|
||||||
plugins: [new MyPlugin()]
|
plugins: [new MyPlugin()]
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((_err, _stats) => {
|
||||||
expect(capture.toString()).toMatchInlineSnapshot('""');
|
expect(capture.toString()).toMatchInlineSnapshot('""');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -1047,7 +1047,7 @@ describe("Compiler", () => {
|
||||||
plugins: [new MyPlugin()]
|
plugins: [new MyPlugin()]
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((_err, _stats) => {
|
||||||
expect(escapeAnsi(capture.toStringRaw()).replace(/[\d.]+ ms/, "X ms"))
|
expect(escapeAnsi(capture.toStringRaw()).replace(/[\d.]+ ms/, "X ms"))
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"<-> <CLR=36,BOLD>[MyPlugin] Group</CLR>
|
"<-> <CLR=36,BOLD>[MyPlugin] Group</CLR>
|
||||||
|
@ -1082,7 +1082,7 @@ describe("Compiler", () => {
|
||||||
plugins: [new MyPlugin()]
|
plugins: [new MyPlugin()]
|
||||||
});
|
});
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((_err, _stats) => {
|
||||||
expect(escapeAnsi(capture.toStringRaw()).replace(/[\d.]+ ms/, "X ms"))
|
expect(escapeAnsi(capture.toStringRaw()).replace(/[\d.]+ ms/, "X ms"))
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"<-> <CLR=36,BOLD>[MyPlugin] Group</CLR>
|
"<-> <CLR=36,BOLD>[MyPlugin] Group</CLR>
|
||||||
|
|
|
@ -270,10 +270,10 @@ describe("JavascriptParser", () => {
|
||||||
const testParser = new JavascriptParser({});
|
const testParser = new JavascriptParser({});
|
||||||
testParser.hooks.canRename
|
testParser.hooks.canRename
|
||||||
.for("abc")
|
.for("abc")
|
||||||
.tap("JavascriptParserTest", expr => true);
|
.tap("JavascriptParserTest", _expr => true);
|
||||||
testParser.hooks.canRename
|
testParser.hooks.canRename
|
||||||
.for("ijk")
|
.for("ijk")
|
||||||
.tap("JavascriptParserTest", expr => true);
|
.tap("JavascriptParserTest", _expr => true);
|
||||||
testParser.hooks.call.for("abc").tap("JavascriptParserTest", expr => {
|
testParser.hooks.call.for("abc").tap("JavascriptParserTest", expr => {
|
||||||
if (!testParser.state.abc) testParser.state.abc = [];
|
if (!testParser.state.abc) testParser.state.abc = [];
|
||||||
testParser.state.abc.push(testParser.parseString(expr.arguments[0]));
|
testParser.state.abc.push(testParser.parseString(expr.arguments[0]));
|
||||||
|
@ -295,7 +295,7 @@ describe("JavascriptParser", () => {
|
||||||
});
|
});
|
||||||
testParser.hooks.expression
|
testParser.hooks.expression
|
||||||
.for("fgh")
|
.for("fgh")
|
||||||
.tap("JavascriptParserTest", expr => {
|
.tap("JavascriptParserTest", _expr => {
|
||||||
if (!testParser.state.fgh) testParser.state.fgh = [];
|
if (!testParser.state.fgh) testParser.state.fgh = [];
|
||||||
testParser.state.fgh.push(
|
testParser.state.fgh.push(
|
||||||
[...testParser.scope.definitions.asSet()].join(" ")
|
[...testParser.scope.definitions.asSet()].join(" ")
|
||||||
|
@ -304,7 +304,7 @@ describe("JavascriptParser", () => {
|
||||||
});
|
});
|
||||||
testParser.hooks.expression
|
testParser.hooks.expression
|
||||||
.for("fgh.sub")
|
.for("fgh.sub")
|
||||||
.tap("JavascriptParserTest", expr => {
|
.tap("JavascriptParserTest", _expr => {
|
||||||
if (!testParser.state.fghsub) testParser.state.fghsub = [];
|
if (!testParser.state.fghsub) testParser.state.fghsub = [];
|
||||||
testParser.state.fghsub.push(
|
testParser.state.fghsub.push(
|
||||||
testParser.scope.inTry ? "try" : "notry"
|
testParser.scope.inTry ? "try" : "notry"
|
||||||
|
@ -313,7 +313,7 @@ describe("JavascriptParser", () => {
|
||||||
});
|
});
|
||||||
testParser.hooks.expression
|
testParser.hooks.expression
|
||||||
.for("ijk.sub")
|
.for("ijk.sub")
|
||||||
.tap("JavascriptParserTest", expr => {
|
.tap("JavascriptParserTest", _expr => {
|
||||||
if (!testParser.state.ijksub) testParser.state.ijksub = [];
|
if (!testParser.state.ijksub) testParser.state.ijksub = [];
|
||||||
testParser.state.ijksub.push("test");
|
testParser.state.ijksub.push("test");
|
||||||
return true;
|
return true;
|
||||||
|
@ -710,7 +710,7 @@ describe("JavascriptParser", () => {
|
||||||
|
|
||||||
const parser = new JavascriptParser();
|
const parser = new JavascriptParser();
|
||||||
|
|
||||||
parser.hooks.statement.tap("JavascriptParserTest", expr => {
|
parser.hooks.statement.tap("JavascriptParserTest", _expr => {
|
||||||
definitions = parser.scope.definitions;
|
definitions = parser.scope.definitions;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,7 +26,7 @@ const createMultiCompiler = options => {
|
||||||
);
|
);
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.watchFileSystem = {
|
compiler.watchFileSystem = {
|
||||||
watch(a, b, c, d, e, f, g) {}
|
watch(_a, _b, _c, _d, _e, _f, _g) {}
|
||||||
};
|
};
|
||||||
return compiler;
|
return compiler;
|
||||||
};
|
};
|
||||||
|
@ -64,10 +64,10 @@ describe("MultiCompiler", () => {
|
||||||
|
|
||||||
it("should not be running twice at a time (run)", done => {
|
it("should not be running twice at a time (run)", done => {
|
||||||
const compiler = createMultiCompiler();
|
const compiler = createMultiCompiler();
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,10 @@ describe("MultiCompiler", () => {
|
||||||
|
|
||||||
it("should not be running twice at a time (watch)", done => {
|
it("should not be running twice at a time (watch)", done => {
|
||||||
const compiler = createMultiCompiler();
|
const compiler = createMultiCompiler();
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
}
|
}
|
||||||
|
@ -88,10 +88,10 @@ describe("MultiCompiler", () => {
|
||||||
|
|
||||||
it("should not be running twice at a time (run - watch)", done => {
|
it("should not be running twice at a time (run - watch)", done => {
|
||||||
const compiler = createMultiCompiler();
|
const compiler = createMultiCompiler();
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
}
|
}
|
||||||
|
@ -100,10 +100,10 @@ describe("MultiCompiler", () => {
|
||||||
|
|
||||||
it("should not be running twice at a time (watch - run)", done => {
|
it("should not be running twice at a time (watch - run)", done => {
|
||||||
const compiler = createMultiCompiler();
|
const compiler = createMultiCompiler();
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ describe("MultiCompiler", () => {
|
||||||
() => {}
|
() => {}
|
||||||
);
|
);
|
||||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
}
|
}
|
||||||
|
@ -133,10 +133,10 @@ describe("MultiCompiler", () => {
|
||||||
|
|
||||||
it("should run again correctly after first compilation", done => {
|
it("should run again correctly after first compilation", done => {
|
||||||
const compiler = createMultiCompiler();
|
const compiler = createMultiCompiler();
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
});
|
});
|
||||||
|
@ -145,10 +145,10 @@ describe("MultiCompiler", () => {
|
||||||
|
|
||||||
it("should watch again correctly after first compilation", done => {
|
it("should watch again correctly after first compilation", done => {
|
||||||
const compiler = createMultiCompiler();
|
const compiler = createMultiCompiler();
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
});
|
});
|
||||||
|
@ -157,11 +157,11 @@ describe("MultiCompiler", () => {
|
||||||
|
|
||||||
it("should run again correctly after first closed watch", done => {
|
it("should run again correctly after first closed watch", done => {
|
||||||
const compiler = createMultiCompiler();
|
const compiler = createMultiCompiler();
|
||||||
const watching = compiler.watch({}, (err, stats) => {
|
const watching = compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
watching.close(() => {
|
watching.close(() => {
|
||||||
compiler.run((err, stats) => {
|
compiler.run((err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
});
|
});
|
||||||
|
@ -170,11 +170,11 @@ describe("MultiCompiler", () => {
|
||||||
|
|
||||||
it("should watch again correctly after first closed watch", done => {
|
it("should watch again correctly after first closed watch", done => {
|
||||||
const compiler = createMultiCompiler();
|
const compiler = createMultiCompiler();
|
||||||
const watching = compiler.watch({}, (err, stats) => {
|
const watching = compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
});
|
});
|
||||||
watching.close(() => {
|
watching.close(() => {
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
});
|
});
|
||||||
|
@ -210,7 +210,7 @@ describe("MultiCompiler", () => {
|
||||||
events.push(`${c.name} done`);
|
events.push(`${c.name} done`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
compiler.run((err, stats) => {
|
compiler.run((_err, _stats) => {
|
||||||
expect(events.join(" ")).toBe(
|
expect(events.join(" ")).toBe(
|
||||||
"a run a done b run b done d run d done e run e done c run c done"
|
"a run a done b run b done d run d done e run e done c run c done"
|
||||||
);
|
);
|
||||||
|
@ -628,7 +628,7 @@ describe("MultiCompiler", () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
compiler.watch({}, (err, stats) => {
|
compiler.watch({}, (err, _stats) => {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
compiler.close(done);
|
compiler.close(done);
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,7 @@ const captureStdio = require("./helpers/captureStdio");
|
||||||
const createLazyTestEnv = require("./helpers/createLazyTestEnv");
|
const createLazyTestEnv = require("./helpers/createLazyTestEnv");
|
||||||
const deprecationTracking = require("./helpers/deprecationTracking");
|
const deprecationTracking = require("./helpers/deprecationTracking");
|
||||||
const filterInfraStructureErrors = require("./helpers/infrastructureLogErrors");
|
const filterInfraStructureErrors = require("./helpers/infrastructureLogErrors");
|
||||||
const { TestRunner } = require("./runner");
|
const { TestRunner } = require("./runner/index");
|
||||||
|
|
||||||
const casesPath = path.join(__dirname, "cases");
|
const casesPath = path.join(__dirname, "cases");
|
||||||
let categories = fs.readdirSync(casesPath);
|
let categories = fs.readdirSync(casesPath);
|
||||||
|
|
|
@ -212,7 +212,7 @@ const describeCases = config => {
|
||||||
const compiler = webpack(options);
|
const compiler = webpack(options);
|
||||||
compiler.hooks.invalid.tap(
|
compiler.hooks.invalid.tap(
|
||||||
"WatchTestCasesTest",
|
"WatchTestCasesTest",
|
||||||
(filename, mtime) => {
|
(filename, _mtime) => {
|
||||||
triggeringFilename = filename;
|
triggeringFilename = filename;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -38,7 +38,7 @@ describe("WatcherEvents", () => {
|
||||||
let called = false;
|
let called = false;
|
||||||
|
|
||||||
const compiler = createSingleCompiler();
|
const compiler = createSingleCompiler();
|
||||||
const watcher = compiler.watch({}, (err, stats) => {
|
const watcher = compiler.watch({}, (err, _stats) => {
|
||||||
expect(called).toBe(true);
|
expect(called).toBe(true);
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
|
@ -56,7 +56,7 @@ describe("WatcherEvents", () => {
|
||||||
let called = false;
|
let called = false;
|
||||||
|
|
||||||
const compiler = createMultiCompiler();
|
const compiler = createMultiCompiler();
|
||||||
const watcher = compiler.watch({}, (err, stats) => {
|
const watcher = compiler.watch({}, (err, _stats) => {
|
||||||
expect(called).toBe(true);
|
expect(called).toBe(true);
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ const WebpackError = require("../lib/WebpackError");
|
||||||
|
|
||||||
describe("WebpackError", () => {
|
describe("WebpackError", () => {
|
||||||
class CustomError extends WebpackError {
|
class CustomError extends WebpackError {
|
||||||
constructor(message) {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.name = "CustomError";
|
this.name = "CustomError";
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
const supportsOptionalChaining = require("../../../helpers/supportsOptionalChaining");
|
const supportsOptionalChaining = require("../../../helpers/supportsOptionalChaining");
|
||||||
|
|
||||||
module.exports = config => supportsOptionalChaining();
|
module.exports = () => supportsOptionalChaining();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle() {
|
||||||
return ["test.js"];
|
return ["test.js"];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,7 @@ module.exports = {
|
||||||
type: "asset",
|
type: "asset",
|
||||||
/** @type {ParserOptionsByModuleTypeKnown['asset']} */
|
/** @type {ParserOptionsByModuleTypeKnown['asset']} */
|
||||||
parser: {
|
parser: {
|
||||||
dataUrlCondition: (source, { filename, module }) =>
|
dataUrlCondition: (source, { filename }) =>
|
||||||
filename.includes("?foo=bar")
|
filename.includes("?foo=bar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle() {
|
||||||
return ["a.js", "b.js"];
|
return ["a.js", "b.js"];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle() {
|
||||||
return ["a.js", "b.js"];
|
return ["a.js", "b.js"];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle() {
|
||||||
return ["main.js"];
|
return ["main.js"];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle() {
|
||||||
return ["main.js", "A.js", "shared.js", "B.js", "B-2.js"];
|
return ["main.js", "A.js", "shared.js", "B.js", "B-2.js"];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle() {
|
||||||
return ["entry1.js", "entry2.js"];
|
return ["entry1.js", "entry2.js"];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle() {
|
||||||
return ["entry1.js", "entry2.js"];
|
return ["entry1.js", "entry2.js"];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle() {
|
||||||
return ["runtime.js", "common-index_js.js", "main.js"];
|
return ["runtime.js", "common-index_js.js", "main.js"];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle(i) {
|
||||||
return i === 0 ? "./main.js" : "./module/main.mjs";
|
return i === 0 ? "./main.js" : "./module/main.mjs";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle(i) {
|
||||||
return i === 0 ? "./main.js" : "./module/main.mjs";
|
return i === 0 ? "./main.js" : "./module/main.mjs";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle(i) {
|
||||||
return i === 0 ? "./main.js" : "./module/main.mjs";
|
return i === 0 ? "./main.js" : "./module/main.mjs";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle(i) {
|
||||||
return i === 0 ? "./main.js" : "./module/main.mjs";
|
return i === 0 ? "./main.js" : "./module/main.mjs";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findBundle(i, options) {
|
findBundle(i) {
|
||||||
return i === 0 ? "./main.js" : "./module/main.mjs";
|
return i === 0 ? "./main.js" : "./module/main.mjs";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export default "a";
|
|
@ -0,0 +1 @@
|
||||||
|
export default "b";
|
|
@ -0,0 +1 @@
|
||||||
|
export default "c";
|
|
@ -0,0 +1,39 @@
|
||||||
|
async function loadModule(name) {
|
||||||
|
return import("./dir/" + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadModuleWithExclude(name) {
|
||||||
|
return import(/* webpackExclude: /module-b\.js$/ */ "./dir/" + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadModuleWithInclude(name) {
|
||||||
|
return import(/* webpackInclude: /module-b\.js$/ */ "./dir/" + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadModuleWithMode(name) {
|
||||||
|
return import(/* webpackMode: "eager" */ "./dir/" + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
it("should work when no options", async () => {
|
||||||
|
expect((await loadModule("module-a.js")).default).toBe("a");
|
||||||
|
expect((await loadModule("module-b.js")).default).toBe("b");
|
||||||
|
expect((await loadModule("module-c.js")).default).toBe("c");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should work with exclude", async () => {
|
||||||
|
expect((await loadModuleWithExclude("module-a.js")).default).toBe("a");
|
||||||
|
await expect(loadModuleWithExclude("module-b.js")).rejects.toThrow("Cannot find module './module-b.js'");
|
||||||
|
expect((await loadModuleWithExclude("module-c.js")).default).toBe("c");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should work with include", async () => {
|
||||||
|
await expect(loadModuleWithInclude("module-a.js")).rejects.toThrow("Cannot find module './module-a.js'");
|
||||||
|
expect((await loadModuleWithInclude("module-b.js")).default).toBe("b");
|
||||||
|
await expect(loadModuleWithInclude("module-c.js")).rejects.toThrow("Cannot find module './module-c.js'");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should work with mode", async () => {
|
||||||
|
expect((await loadModuleWithMode("module-a.js")).default).toBe("a");
|
||||||
|
expect((await loadModuleWithMode("module-b.js")).default).toBe("b");
|
||||||
|
expect((await loadModuleWithMode("module-c.js")).default).toBe("c");
|
||||||
|
});
|
|
@ -0,0 +1,2 @@
|
||||||
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
module.exports = {};
|
|
@ -5,7 +5,7 @@ var webpack = require("../../../../");
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.ContextReplacementPlugin(
|
new webpack.ContextReplacementPlugin(
|
||||||
/context-replacement/,
|
/replacement/,
|
||||||
path.resolve(__dirname, "modules"),
|
path.resolve(__dirname, "modules"),
|
||||||
{
|
{
|
||||||
a: "./module-b"
|
a: "./module-b"
|
|
@ -4,7 +4,7 @@ const webpack = require("../../../../");
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.ContextReplacementPlugin(
|
new webpack.ContextReplacementPlugin(
|
||||||
/context-replacement.a$/,
|
/replacement.a$/,
|
||||||
"new-context",
|
"new-context",
|
||||||
true,
|
true,
|
||||||
/^replaced$/
|
/^replaced$/
|
|
@ -2,7 +2,5 @@ const webpack = require("../../../../");
|
||||||
|
|
||||||
/** @type {import("../../../../").Configuration} */
|
/** @type {import("../../../../").Configuration} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: [
|
plugins: [new webpack.ContextReplacementPlugin(/replacement.b$/, /^\.\/only/)]
|
||||||
new webpack.ContextReplacementPlugin(/context-replacement.b$/, /^\.\/only/)
|
|
||||||
]
|
|
||||||
};
|
};
|
|
@ -5,7 +5,7 @@ const webpack = require("../../../../");
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.ContextReplacementPlugin(
|
new webpack.ContextReplacementPlugin(
|
||||||
/context-replacement.c$/,
|
/replacement.c$/,
|
||||||
path.resolve(__dirname, "modules"),
|
path.resolve(__dirname, "modules"),
|
||||||
{
|
{
|
||||||
a: "./a",
|
a: "./a",
|
|
@ -13,7 +13,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.ContextReplacementPlugin(
|
new webpack.ContextReplacementPlugin(
|
||||||
/context-replacement.d$/,
|
/replacement.d$/,
|
||||||
path.resolve(__dirname, "modules?cats=meow"),
|
path.resolve(__dirname, "modules?cats=meow"),
|
||||||
{
|
{
|
||||||
a: "./a"
|
a: "./a"
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue