mirror of https://github.com/webpack/webpack.git
chore: eslint more rules (#19648)
This commit is contained in:
parent
02a1d22db8
commit
87f648ebf0
|
|
@ -176,8 +176,9 @@ if (!cli.installed) {
|
|||
);
|
||||
|
||||
runCommand(
|
||||
/** @type {string} */ (packageManager),
|
||||
installOptions.concat(cli.package)
|
||||
/** @type {string} */
|
||||
(packageManager),
|
||||
[...installOptions, cli.package]
|
||||
)
|
||||
.then(() => {
|
||||
runCli(cli);
|
||||
|
|
|
|||
|
|
@ -51,10 +51,8 @@ export default defineConfig([
|
|||
ignores: ["lib/**/*.runtime.js", "hot/*.js"],
|
||||
extends: [config],
|
||||
rules: {
|
||||
// Revisit it in future
|
||||
"id-length": "off",
|
||||
// Revisit it in future
|
||||
"no-use-before-define": "off",
|
||||
// Too noise
|
||||
"jsdoc/require-property-description": "off",
|
||||
// We have helpers for the default configuration
|
||||
"new-cap": [
|
||||
"error",
|
||||
|
|
@ -63,15 +61,11 @@ export default defineConfig([
|
|||
capIsNewExceptions: ["A", "F", "D", "MODULES_GROUPERS"]
|
||||
}
|
||||
],
|
||||
// Revisit it in future
|
||||
"id-length": "off",
|
||||
// Revisit it in future
|
||||
"no-use-before-define": "off",
|
||||
|
||||
// TODO enable me in future
|
||||
"prefer-destructuring": "off",
|
||||
// TODO enable me in future, we need to ignore Object.define
|
||||
"func-names": "off",
|
||||
// TODO enable me in future
|
||||
"unicorn/prefer-spread": "off",
|
||||
// TODO need patch in tooling, now we are doing weird order for destructuring in cjs import
|
||||
"import/order": "off",
|
||||
// TODO We need allow to have `_arg` in tooling and use `after-used` value for `args`
|
||||
"no-unused-vars": [
|
||||
"error",
|
||||
|
|
@ -88,17 +82,14 @@ export default defineConfig([
|
|||
reportUsedIgnorePattern: false
|
||||
}
|
||||
],
|
||||
|
||||
// Too noise
|
||||
"jsdoc/require-property-description": "off",
|
||||
|
||||
// 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"
|
||||
"n/prefer-global/url": "off",
|
||||
// TODO enable me in future
|
||||
"prefer-destructuring": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
const toml = require("toml");
|
||||
const json5 = require("json5");
|
||||
const toml = require("toml");
|
||||
const yaml = require("yamljs");
|
||||
|
||||
module.exports = {
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ const ConstDependency = require("./dependencies/ConstDependency");
|
|||
const BasicEvaluatedExpression = require("./javascript/BasicEvaluatedExpression");
|
||||
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
||||
const {
|
||||
toConstantDependency,
|
||||
evaluateToString
|
||||
evaluateToString,
|
||||
toConstantDependency
|
||||
} = require("./javascript/JavascriptParserHelpers");
|
||||
const ChunkNameRuntimeModule = require("./runtime/ChunkNameRuntimeModule");
|
||||
const GetFullHashRuntimeModule = require("./runtime/GetFullHashRuntimeModule");
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ const createModulesListMessage = (modules, moduleGraph) =>
|
|||
modules
|
||||
.map(m => {
|
||||
let message = `* ${m.identifier()}`;
|
||||
const validReasons = Array.from(
|
||||
moduleGraph.getIncomingConnectionsByOriginModule(m).keys()
|
||||
).filter(Boolean);
|
||||
const validReasons = [
|
||||
...moduleGraph.getIncomingConnectionsByOriginModule(m).keys()
|
||||
].filter(Boolean);
|
||||
|
||||
if (validReasons.length > 0) {
|
||||
message += `\n Used by ${validReasons.length} module(s), i. e.`;
|
||||
|
|
@ -56,7 +56,7 @@ class CaseSensitiveModulesWarning extends WebpackError {
|
|||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
*/
|
||||
constructor(modules, moduleGraph) {
|
||||
const sortedModules = sortModules(Array.from(modules));
|
||||
const sortedModules = sortModules([...modules]);
|
||||
const modulesList = createModulesListMessage(sortedModules, moduleGraph);
|
||||
super(`There are multiple modules with names that only differ in casing.
|
||||
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
|
||||
|
|
|
|||
12
lib/Chunk.js
12
lib/Chunk.js
|
|
@ -11,9 +11,9 @@ const { intersect } = require("./util/SetHelpers");
|
|||
const SortableSet = require("./util/SortableSet");
|
||||
const StringXor = require("./util/StringXor");
|
||||
const {
|
||||
compareModulesByIdentifier,
|
||||
compareChunkGroupsByIndex,
|
||||
compareModulesById
|
||||
compareModulesById,
|
||||
compareModulesByIdentifier
|
||||
} = require("./util/comparators");
|
||||
const { createArrayToSetDeprecationSet } = require("./util/deprecation");
|
||||
const { mergeRuntime } = require("./util/runtime");
|
||||
|
|
@ -116,13 +116,13 @@ class Chunk {
|
|||
// TODO remove in webpack 6
|
||||
// BACKWARD-COMPAT START
|
||||
get entryModule() {
|
||||
const entryModules = Array.from(
|
||||
ChunkGraph.getChunkGraphForChunk(
|
||||
const entryModules = [
|
||||
...ChunkGraph.getChunkGraphForChunk(
|
||||
this,
|
||||
"Chunk.entryModule",
|
||||
"DEP_WEBPACK_CHUNK_ENTRY_MODULE"
|
||||
).getChunkEntryModulesIterable(this)
|
||||
);
|
||||
];
|
||||
if (entryModules.length === 0) {
|
||||
return undefined;
|
||||
} else if (entryModules.length === 1) {
|
||||
|
|
@ -747,7 +747,7 @@ class Chunk {
|
|||
}
|
||||
}
|
||||
if (chunkIdSet.size > 0) {
|
||||
result[name] = Array.from(chunkIdSet);
|
||||
result[name] = [...chunkIdSet];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -12,21 +12,21 @@ const { DEFAULTS } = require("./config/defaults");
|
|||
const { first } = require("./util/SetHelpers");
|
||||
const SortableSet = require("./util/SortableSet");
|
||||
const {
|
||||
compareModulesById,
|
||||
compareIds,
|
||||
compareIterables,
|
||||
compareModulesById,
|
||||
compareModulesByIdentifier,
|
||||
concatComparators,
|
||||
compareSelect,
|
||||
compareIds
|
||||
concatComparators
|
||||
} = require("./util/comparators");
|
||||
const createHash = require("./util/createHash");
|
||||
const findGraphRoots = require("./util/findGraphRoots");
|
||||
const {
|
||||
RuntimeSpecMap,
|
||||
RuntimeSpecSet,
|
||||
runtimeToString,
|
||||
forEachRuntime,
|
||||
mergeRuntime,
|
||||
forEachRuntime
|
||||
runtimeToString
|
||||
} = require("./util/runtime");
|
||||
|
||||
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
||||
|
|
@ -76,7 +76,7 @@ class ModuleHashInfo {
|
|||
* @param {SortableSet<T>} set the set
|
||||
* @returns {T[]} set as array
|
||||
*/
|
||||
const getArray = set => Array.from(set);
|
||||
const getArray = set => [...set];
|
||||
|
||||
/**
|
||||
* @param {SortableSet<Chunk>} chunks the chunks
|
||||
|
|
@ -141,7 +141,7 @@ const createOrderedArrayFunction = comparator => {
|
|||
if (fn !== undefined) return fn;
|
||||
fn = set => {
|
||||
set.sortWith(comparator);
|
||||
return Array.from(set);
|
||||
return [...set];
|
||||
};
|
||||
createOrderedArrayFunctionMap.set(comparator, fn);
|
||||
return fn;
|
||||
|
|
@ -310,8 +310,8 @@ class ChunkGraph {
|
|||
*/
|
||||
_getGraphRoots(set) {
|
||||
const { moduleGraph } = this;
|
||||
return Array.from(
|
||||
findGraphRoots(set, module => {
|
||||
return [
|
||||
...findGraphRoots(set, module => {
|
||||
/** @type {Set<Module>} */
|
||||
const set = new Set();
|
||||
/**
|
||||
|
|
@ -332,7 +332,7 @@ class ChunkGraph {
|
|||
addDependencies(module);
|
||||
return set;
|
||||
})
|
||||
).sort(compareModulesByIdentifier);
|
||||
].sort(compareModulesByIdentifier);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1022,9 +1022,10 @@ class ChunkGraph {
|
|||
this.connectChunkAndModule(chunkA, module);
|
||||
}
|
||||
|
||||
for (const [module, chunkGroup] of Array.from(
|
||||
this.getChunkEntryModulesWithChunkGroupIterable(chunkB)
|
||||
)) {
|
||||
for (const [
|
||||
module,
|
||||
chunkGroup
|
||||
] of this.getChunkEntryModulesWithChunkGroupIterable(chunkB)) {
|
||||
this.disconnectChunkAndEntryModule(chunkB, module);
|
||||
this.connectChunkAndEntryModule(
|
||||
chunkA,
|
||||
|
|
@ -1268,7 +1269,7 @@ class ChunkGraph {
|
|||
*/
|
||||
getChunkRuntimeModulesInOrder(chunk) {
|
||||
const cgc = this._getChunkGraphChunk(chunk);
|
||||
const array = Array.from(cgc.runtimeModules);
|
||||
const array = [...cgc.runtimeModules];
|
||||
array.sort(
|
||||
concatComparators(
|
||||
compareSelect(r => /** @type {RuntimeModule} */ (r).stage, compareIds),
|
||||
|
|
@ -1695,7 +1696,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|||
}
|
||||
const connectedModulesInOrder =
|
||||
connectedModules.size > 1
|
||||
? Array.from(connectedModules).sort(([a], [b]) => (a < b ? -1 : 1))
|
||||
? [...connectedModules].sort(([a], [b]) => (a < b ? -1 : 1))
|
||||
: connectedModules;
|
||||
const hash = createHash(this._hashFunction);
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
const util = require("util");
|
||||
const SortableSet = require("./util/SortableSet");
|
||||
const {
|
||||
compareLocations,
|
||||
compareChunks,
|
||||
compareIterables
|
||||
compareIterables,
|
||||
compareLocations
|
||||
} = require("./util/comparators");
|
||||
|
||||
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
||||
|
|
@ -40,7 +40,7 @@ let debugId = 5000;
|
|||
* @param {SortableSet<T>} set set to convert to array.
|
||||
* @returns {T[]} the array format of existing set
|
||||
*/
|
||||
const getArray = set => Array.from(set);
|
||||
const getArray = set => [...set];
|
||||
|
||||
/**
|
||||
* A convenience method used to sort chunks based on their id's
|
||||
|
|
@ -436,7 +436,7 @@ class ChunkGroup {
|
|||
}
|
||||
}
|
||||
|
||||
return Array.from(files);
|
||||
return [...files];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ Object.defineProperty(ChunkTemplate.prototype, "outputOptions", {
|
|||
* @this {ChunkTemplate}
|
||||
* @returns {OutputOptions} output options
|
||||
*/
|
||||
function () {
|
||||
function outputOptions() {
|
||||
return this._outputOptions;
|
||||
},
|
||||
"ChunkTemplate.outputOptions is deprecated (use Compilation.outputOptions instead)",
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const asyncLib = require("neo-async");
|
||||
const path = require("path");
|
||||
const asyncLib = require("neo-async");
|
||||
const { SyncBailHook } = require("tapable");
|
||||
const Compilation = require("./Compilation");
|
||||
const createSchemaValidation = require("./util/create-schema-validation");
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const { DEFAULTS } = require("./config/defaults");
|
|||
const { getOrInsert } = require("./util/MapHelpers");
|
||||
const { first } = require("./util/SetHelpers");
|
||||
const createHash = require("./util/createHash");
|
||||
const { runtimeToString, RuntimeSpecMap } = require("./util/runtime");
|
||||
const { RuntimeSpecMap, runtimeToString } = require("./util/runtime");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
|
|
|
|||
|
|
@ -5,17 +5,17 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const util = require("util");
|
||||
const asyncLib = require("neo-async");
|
||||
const {
|
||||
HookMap,
|
||||
SyncHook,
|
||||
SyncBailHook,
|
||||
SyncWaterfallHook,
|
||||
AsyncSeriesHook,
|
||||
AsyncParallelHook,
|
||||
AsyncSeriesBailHook,
|
||||
AsyncParallelHook
|
||||
AsyncSeriesHook,
|
||||
HookMap,
|
||||
SyncBailHook,
|
||||
SyncHook,
|
||||
SyncWaterfallHook
|
||||
} = require("tapable");
|
||||
const util = require("util");
|
||||
const { CachedSource } = require("webpack-sources");
|
||||
const { MultiItemCache } = require("./CacheFacade");
|
||||
const Chunk = require("./Chunk");
|
||||
|
|
@ -56,7 +56,7 @@ const Stats = require("./Stats");
|
|||
const WebpackError = require("./WebpackError");
|
||||
const buildChunkGraph = require("./buildChunkGraph");
|
||||
const BuildCycleError = require("./errors/BuildCycleError");
|
||||
const { Logger, LogType } = require("./logging/Logger");
|
||||
const { LogType, Logger } = require("./logging/Logger");
|
||||
const StatsFactory = require("./stats/StatsFactory");
|
||||
const StatsPrinter = require("./stats/StatsPrinter");
|
||||
const { equals: arrayEquals } = require("./util/ArrayHelpers");
|
||||
|
|
@ -66,18 +66,18 @@ const { getOrInsert } = require("./util/MapHelpers");
|
|||
const WeakTupleMap = require("./util/WeakTupleMap");
|
||||
const { cachedCleverMerge } = require("./util/cleverMerge");
|
||||
const {
|
||||
compareLocations,
|
||||
concatComparators,
|
||||
compareSelect,
|
||||
compareIds,
|
||||
compareLocations,
|
||||
compareModulesByIdentifier,
|
||||
compareSelect,
|
||||
compareStringsNumeric,
|
||||
compareModulesByIdentifier
|
||||
concatComparators
|
||||
} = require("./util/comparators");
|
||||
const createHash = require("./util/createHash");
|
||||
const {
|
||||
arrayToSetDeprecation,
|
||||
soonFrozenObjectDeprecation,
|
||||
createFakeHook
|
||||
createFakeHook,
|
||||
soonFrozenObjectDeprecation
|
||||
} = require("./util/deprecation");
|
||||
const processAsyncTree = require("./util/processAsyncTree");
|
||||
const { getRuntimeKey } = require("./util/runtime");
|
||||
|
|
@ -2449,8 +2449,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
*/
|
||||
_rebuildModule(module, callback) {
|
||||
this.hooks.rebuildModule.call(module);
|
||||
const oldDependencies = module.dependencies.slice();
|
||||
const oldBlocks = module.blocks.slice();
|
||||
const oldDependencies = [...module.dependencies];
|
||||
const oldBlocks = [...module.blocks];
|
||||
module.invalidateBuild();
|
||||
this.buildQueue.invalidate(module);
|
||||
this.buildModule(module, err => {
|
||||
|
|
@ -2700,7 +2700,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
}
|
||||
if (module.blocks.length > 0) {
|
||||
blocks = [];
|
||||
const queue = Array.from(module.blocks);
|
||||
const queue = [...module.blocks];
|
||||
for (const block of queue) {
|
||||
const chunkGroup = chunkGraph.getBlockChunkGroup(block);
|
||||
if (chunkGroup) {
|
||||
|
|
@ -2732,7 +2732,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
}
|
||||
}
|
||||
if (blocks !== undefined) {
|
||||
const queue = Array.from(module.blocks);
|
||||
const queue = [...module.blocks];
|
||||
let i = 0;
|
||||
for (const block of queue) {
|
||||
const chunkGroup = chunkGraph.getBlockChunkGroup(block);
|
||||
|
|
@ -4409,7 +4409,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|||
let remaining = 0;
|
||||
for (const info of runtimeChunksMap.values()) {
|
||||
for (const other of new Set(
|
||||
Array.from(info.chunk.getAllReferencedAsyncEntrypoints()).map(
|
||||
[...info.chunk.getAllReferencedAsyncEntrypoints()].map(
|
||||
e => e.chunks[e.chunks.length - 1]
|
||||
)
|
||||
)) {
|
||||
|
|
@ -5616,7 +5616,7 @@ Compilation.prototype.factorizeModule = /**
|
|||
(options: FactorizeModuleOptions & { factoryResult?: false }, callback: ModuleCallback): void;
|
||||
(options: FactorizeModuleOptions & { factoryResult: true }, callback: ModuleFactoryResultCallback): void;
|
||||
}} */ (
|
||||
function (options, callback) {
|
||||
function factorizeModule(options, callback) {
|
||||
this.factorizeQueue.add(options, /** @type {TODO} */ (callback));
|
||||
}
|
||||
);
|
||||
|
|
@ -5646,7 +5646,7 @@ Object.defineProperty(compilationPrototype, "cache", {
|
|||
* @this {Compilation} the compilation
|
||||
* @returns {Cache} the cache
|
||||
*/
|
||||
function () {
|
||||
function cache() {
|
||||
return this.compiler.cache;
|
||||
},
|
||||
"Compilation.cache was removed in favor of Compilation.getCache()",
|
||||
|
|
|
|||
|
|
@ -8,13 +8,12 @@
|
|||
const parseJson = require("json-parse-even-better-errors");
|
||||
const asyncLib = require("neo-async");
|
||||
const {
|
||||
SyncHook,
|
||||
SyncBailHook,
|
||||
AsyncParallelHook,
|
||||
AsyncSeriesHook
|
||||
AsyncSeriesHook,
|
||||
SyncBailHook,
|
||||
SyncHook
|
||||
} = require("tapable");
|
||||
const { SizeOnlySource } = require("webpack-sources");
|
||||
const webpack = require(".");
|
||||
const Cache = require("./Cache");
|
||||
const CacheFacade = require("./CacheFacade");
|
||||
const ChunkGraph = require("./ChunkGraph");
|
||||
|
|
@ -29,9 +28,10 @@ const Stats = require("./Stats");
|
|||
const Watching = require("./Watching");
|
||||
const WebpackError = require("./WebpackError");
|
||||
const { Logger } = require("./logging/Logger");
|
||||
const { join, dirname, mkdirp } = require("./util/fs");
|
||||
const { dirname, join, mkdirp } = require("./util/fs");
|
||||
const { makePathsRelative } = require("./util/identifier");
|
||||
const { isSourceEqual } = require("./util/source");
|
||||
const webpack = require(".");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../declarations/WebpackOptions").EntryNormalized} Entry */
|
||||
|
|
@ -1260,11 +1260,12 @@ ${other}`);
|
|||
childCompiler.hooks[
|
||||
/** @type {keyof Compiler["hooks"]} */
|
||||
(name)
|
||||
].taps =
|
||||
this.hooks[
|
||||
].taps = [
|
||||
...this.hooks[
|
||||
/** @type {keyof Compiler["hooks"]} */
|
||||
(name)
|
||||
].taps.slice();
|
||||
].taps
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ const collectDeclaration = (declarations, pattern) => {
|
|||
* @returns {Array<string>} hoisted declarations
|
||||
*/
|
||||
const getHoistedDeclarations = (branch, includeFunctionDeclarations) => {
|
||||
/** @type {Set<string>} */
|
||||
const declarations = new Set();
|
||||
/** @type {Array<Statement | null | undefined>} */
|
||||
const stack = [branch];
|
||||
|
|
@ -129,7 +130,7 @@ const getHoistedDeclarations = (branch, includeFunctionDeclarations) => {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return Array.from(declarations);
|
||||
return [...declarations];
|
||||
};
|
||||
|
||||
const PLUGIN_NAME = "ConstPlugin";
|
||||
|
|
|
|||
|
|
@ -16,15 +16,15 @@ const Template = require("./Template");
|
|||
const WebpackError = require("./WebpackError");
|
||||
const {
|
||||
compareLocations,
|
||||
concatComparators,
|
||||
compareModulesById,
|
||||
compareSelect,
|
||||
keepOriginalOrder,
|
||||
compareModulesById
|
||||
concatComparators,
|
||||
keepOriginalOrder
|
||||
} = require("./util/comparators");
|
||||
const {
|
||||
contextify,
|
||||
parseResource,
|
||||
makePathsRelative
|
||||
makePathsRelative,
|
||||
parseResource
|
||||
} = require("./util/identifier");
|
||||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
||||
|
|
@ -997,10 +997,11 @@ module.exports = webpackAsyncContext;`;
|
|||
if (hasFakeMap) {
|
||||
arrayStart.push(fakeMap[moduleId]);
|
||||
}
|
||||
map[item.userRequest] = arrayStart.concat(
|
||||
/** @type {Chunk[]} */
|
||||
map[item.userRequest] = [
|
||||
...arrayStart,
|
||||
.../** @type {Chunk[]} */
|
||||
(item.chunks).map(chunk => /** @type {ChunkId} */ (chunk.id))
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1187,7 +1188,7 @@ module.exports = webpackEmptyAsyncContext;`;
|
|||
const set = new Set();
|
||||
const allDeps =
|
||||
this.dependencies.length > 0
|
||||
? /** @type {ContextElementDependency[]} */ (this.dependencies).slice()
|
||||
? /** @type {ContextElementDependency[]} */ [...this.dependencies]
|
||||
: [];
|
||||
for (const block of this.blocks) {
|
||||
for (const dep of block.dependencies) {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
const {
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_ESM,
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
||||
JAVASCRIPT_MODULE_TYPE_ESM
|
||||
} = require("./ModuleTypeConstants");
|
||||
const RuntimeGlobals = require("./RuntimeGlobals");
|
||||
const WebpackError = require("./WebpackError");
|
||||
|
|
|
|||
|
|
@ -91,10 +91,10 @@ const cleanUpWebpackOptions = (stack, message) => {
|
|||
return stack;
|
||||
};
|
||||
|
||||
module.exports.cutOffByFlag = cutOffByFlag;
|
||||
module.exports.cutOffLoaderExecution = cutOffLoaderExecution;
|
||||
module.exports.cutOffWebpackOptions = cutOffWebpackOptions;
|
||||
module.exports.cutOffMultilineMessage = cutOffMultilineMessage;
|
||||
module.exports.cutOffMessage = cutOffMessage;
|
||||
module.exports.cleanUp = cleanUp;
|
||||
module.exports.cleanUpWebpackOptions = cleanUpWebpackOptions;
|
||||
module.exports.cutOffByFlag = cutOffByFlag;
|
||||
module.exports.cutOffLoaderExecution = cutOffLoaderExecution;
|
||||
module.exports.cutOffMessage = cutOffMessage;
|
||||
module.exports.cutOffMultilineMessage = cutOffMultilineMessage;
|
||||
module.exports.cutOffWebpackOptions = cutOffWebpackOptions;
|
||||
|
|
|
|||
|
|
@ -727,9 +727,9 @@ class ExportsInfo {
|
|||
) {
|
||||
const nested = info.exportsInfo.getUsedName(name.slice(1), runtime);
|
||||
if (!nested) return false;
|
||||
return arr.concat(nested);
|
||||
return [...arr, ...(Array.isArray(nested) ? nested : [nested])];
|
||||
}
|
||||
return arr.concat(name.slice(1));
|
||||
return [...arr, ...name.slice(1)];
|
||||
}
|
||||
const info = this.getReadOnlyExportInfo(name);
|
||||
const usedName = info.getUsedName(name, runtime);
|
||||
|
|
@ -1250,7 +1250,7 @@ class ExportInfo {
|
|||
}
|
||||
} else if (
|
||||
runtime !== undefined &&
|
||||
Array.from(runtime).every(
|
||||
[...runtime].every(
|
||||
runtime =>
|
||||
!(/** @type {UsedInRuntime} */ (this._usedInRuntime).has(runtime))
|
||||
)
|
||||
|
|
@ -1369,7 +1369,7 @@ class ExportInfo {
|
|||
target = {
|
||||
module: newTarget.module,
|
||||
export: newTarget.export
|
||||
? newTarget.export.concat(target.export.slice(1))
|
||||
? [...newTarget.export, ...target.export.slice(1)]
|
||||
: target.export.slice(1),
|
||||
deferred: newTarget.deferred
|
||||
};
|
||||
|
|
@ -1443,10 +1443,11 @@ class ExportInfo {
|
|||
module: newTarget.module,
|
||||
connection: newTarget.connection,
|
||||
export: newTarget.export
|
||||
? newTarget.export.concat(
|
||||
/** @type {NonNullable<TargetItemWithConnection["export"]>} */
|
||||
? [
|
||||
...newTarget.export,
|
||||
.../** @type {NonNullable<TargetItemWithConnection["export"]>} */
|
||||
(target.export).slice(1)
|
||||
)
|
||||
]
|
||||
: /** @type {NonNullable<TargetItemWithConnection["export"]>} */
|
||||
(target.export).slice(1)
|
||||
};
|
||||
|
|
@ -1683,5 +1684,5 @@ class ExportInfo {
|
|||
|
||||
module.exports = ExportsInfo;
|
||||
module.exports.ExportInfo = ExportInfo;
|
||||
module.exports.UsageState = UsageState;
|
||||
module.exports.RestoreProvidedData = RestoreProvidedData;
|
||||
module.exports.UsageState = UsageState;
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ const { UsageState } = require("./ExportsInfo");
|
|||
const InitFragment = require("./InitFragment");
|
||||
const Module = require("./Module");
|
||||
const {
|
||||
JS_TYPES,
|
||||
CSS_IMPORT_TYPES,
|
||||
CSS_URL_TYPES,
|
||||
CSS_IMPORT_TYPES
|
||||
JS_TYPES
|
||||
} = require("./ModuleSourceTypesConstants");
|
||||
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
||||
const RuntimeGlobals = require("./RuntimeGlobals");
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const CssImportDependency = require("./dependencies/CssImportDependency");
|
|||
const CssUrlDependency = require("./dependencies/CssUrlDependency");
|
||||
const HarmonyImportDependency = require("./dependencies/HarmonyImportDependency");
|
||||
const ImportDependency = require("./dependencies/ImportDependency");
|
||||
const { resolveByProperty, cachedSetProperty } = require("./util/cleverMerge");
|
||||
const { cachedSetProperty, resolveByProperty } = require("./util/cleverMerge");
|
||||
|
||||
/** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionData} ExternalItemFunctionData */
|
||||
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { create: createResolver } = require("enhanced-resolve");
|
||||
const nodeModule = require("module");
|
||||
const asyncLib = require("neo-async");
|
||||
const { isAbsolute } = require("path");
|
||||
const { create: createResolver } = require("enhanced-resolve");
|
||||
const asyncLib = require("neo-async");
|
||||
const { DEFAULTS } = require("./config/defaults");
|
||||
const AsyncQueue = require("./util/AsyncQueue");
|
||||
const StackedCacheMap = require("./util/StackedCacheMap");
|
||||
const createHash = require("./util/createHash");
|
||||
const { join, dirname, relative, lstatReadlinkAbsolute } = require("./util/fs");
|
||||
const { dirname, join, lstatReadlinkAbsolute, relative } = require("./util/fs");
|
||||
const makeSerializable = require("./util/makeSerializable");
|
||||
const processAsyncTree = require("./util/processAsyncTree");
|
||||
|
||||
|
|
@ -1199,7 +1199,7 @@ class FileSystemInfo {
|
|||
parallelism: 10,
|
||||
processor: this._getManagedItemDirectoryInfo.bind(this)
|
||||
});
|
||||
const _unmanagedPaths = Array.from(unmanagedPaths);
|
||||
const _unmanagedPaths = [...unmanagedPaths];
|
||||
this.unmanagedPathsWithSlash =
|
||||
/** @type {string[]} */
|
||||
(_unmanagedPaths.filter(p => typeof p === "string")).map(p =>
|
||||
|
|
@ -1209,7 +1209,7 @@ class FileSystemInfo {
|
|||
/** @type {RegExp[]} */
|
||||
(_unmanagedPaths.filter(p => typeof p !== "string"));
|
||||
|
||||
this.managedPaths = Array.from(managedPaths);
|
||||
this.managedPaths = [...managedPaths];
|
||||
this.managedPathsWithSlash =
|
||||
/** @type {string[]} */
|
||||
(this.managedPaths.filter(p => typeof p === "string")).map(p =>
|
||||
|
|
@ -1219,7 +1219,7 @@ class FileSystemInfo {
|
|||
this.managedPathsRegExps =
|
||||
/** @type {RegExp[]} */
|
||||
(this.managedPaths.filter(p => typeof p !== "string"));
|
||||
this.immutablePaths = Array.from(immutablePaths);
|
||||
this.immutablePaths = [...immutablePaths];
|
||||
this.immutablePathsWithSlash =
|
||||
/** @type {string[]} */
|
||||
(this.immutablePaths.filter(p => typeof p === "string")).map(p =>
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ class FlagDependencyUsagePlugin {
|
|||
} else {
|
||||
processReferencedModule(
|
||||
module,
|
||||
Array.from(referencedExports.values()),
|
||||
[...referencedExports.values()],
|
||||
runtime,
|
||||
forceSideEffects
|
||||
);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@ const { RawSource } = require("webpack-sources");
|
|||
const ChunkGraph = require("./ChunkGraph");
|
||||
const Compilation = require("./Compilation");
|
||||
const HotUpdateChunk = require("./HotUpdateChunk");
|
||||
const {
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
||||
JAVASCRIPT_MODULE_TYPE_ESM,
|
||||
WEBPACK_MODULE_TYPE_RUNTIME
|
||||
} = require("./ModuleTypeConstants");
|
||||
const NormalModule = require("./NormalModule");
|
||||
const RuntimeGlobals = require("./RuntimeGlobals");
|
||||
const WebpackError = require("./WebpackError");
|
||||
|
|
@ -27,21 +33,14 @@ const { find, isSubset } = require("./util/SetHelpers");
|
|||
const TupleSet = require("./util/TupleSet");
|
||||
const { compareModulesById } = require("./util/comparators");
|
||||
const {
|
||||
getRuntimeKey,
|
||||
keyToRuntime,
|
||||
forEachRuntime,
|
||||
getRuntimeKey,
|
||||
intersectRuntime,
|
||||
keyToRuntime,
|
||||
mergeRuntimeOwned,
|
||||
subtractRuntime,
|
||||
intersectRuntime
|
||||
subtractRuntime
|
||||
} = require("./util/runtime");
|
||||
|
||||
const {
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
||||
JAVASCRIPT_MODULE_TYPE_ESM,
|
||||
WEBPACK_MODULE_TYPE_RUNTIME
|
||||
} = require("./ModuleTypeConstants");
|
||||
|
||||
/** @typedef {import("estree").CallExpression} CallExpression */
|
||||
/** @typedef {import("estree").Expression} Expression */
|
||||
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
||||
|
|
@ -601,21 +600,21 @@ class HotModuleReplacementPlugin {
|
|||
newModules = chunkGraph
|
||||
.getChunkModules(currentChunk)
|
||||
.filter(module => updatedModules.has(module, currentChunk));
|
||||
newRuntimeModules = Array.from(
|
||||
chunkGraph.getChunkRuntimeModulesIterable(currentChunk)
|
||||
).filter(module => updatedModules.has(module, currentChunk));
|
||||
newRuntimeModules = [
|
||||
...chunkGraph.getChunkRuntimeModulesIterable(currentChunk)
|
||||
].filter(module => updatedModules.has(module, currentChunk));
|
||||
const fullHashModules =
|
||||
chunkGraph.getChunkFullHashModulesIterable(currentChunk);
|
||||
newFullHashModules =
|
||||
fullHashModules &&
|
||||
Array.from(fullHashModules).filter(module =>
|
||||
[...fullHashModules].filter(module =>
|
||||
updatedModules.has(module, currentChunk)
|
||||
);
|
||||
const dependentHashModules =
|
||||
chunkGraph.getChunkDependentHashModulesIterable(currentChunk);
|
||||
newDependentHashModules =
|
||||
dependentHashModules &&
|
||||
Array.from(dependentHashModules).filter(module =>
|
||||
[...dependentHashModules].filter(module =>
|
||||
updatedModules.has(module, currentChunk)
|
||||
);
|
||||
removedFromRuntime = subtractRuntime(oldRuntime, newRuntime);
|
||||
|
|
@ -776,9 +775,7 @@ class HotModuleReplacementPlugin {
|
|||
});
|
||||
}
|
||||
}
|
||||
const completelyRemovedModulesArray = Array.from(
|
||||
completelyRemovedModules
|
||||
);
|
||||
const completelyRemovedModulesArray = [...completelyRemovedModules];
|
||||
const hotUpdateMainContentByFilename = new Map();
|
||||
for (const {
|
||||
removedChunkIds,
|
||||
|
|
@ -823,18 +820,19 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename
|
|||
{ removedChunkIds, removedModules, updatedChunkIds, assetInfo }
|
||||
] of hotUpdateMainContentByFilename) {
|
||||
const hotUpdateMainJson = {
|
||||
c: Array.from(updatedChunkIds),
|
||||
r: Array.from(removedChunkIds),
|
||||
c: [...updatedChunkIds],
|
||||
r: [...removedChunkIds],
|
||||
m:
|
||||
removedModules.size === 0
|
||||
? completelyRemovedModulesArray
|
||||
: completelyRemovedModulesArray.concat(
|
||||
Array.from(
|
||||
: [
|
||||
...completelyRemovedModulesArray,
|
||||
...Array.from(
|
||||
removedModules,
|
||||
m =>
|
||||
/** @type {ModuleId} */ (chunkGraph.getModuleId(m))
|
||||
)
|
||||
)
|
||||
]
|
||||
};
|
||||
|
||||
const source = new RawSource(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class InvalidDependenciesModuleWarning extends WebpackError {
|
|||
* @param {Iterable<string>} deps invalid dependencies
|
||||
*/
|
||||
constructor(module, deps) {
|
||||
const orderedDeps = deps ? Array.from(deps).sort() : [];
|
||||
const orderedDeps = deps ? [...deps].sort() : [];
|
||||
const depsList = orderedDeps.map(dep => ` * ${JSON.stringify(dep)}`);
|
||||
super(`Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
|
||||
Invalid dependencies may lead to broken watching and caching.
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class LibManifestPlugin {
|
|||
// store used paths to detect issue and output an error. #18200
|
||||
const usedPaths = new Set();
|
||||
asyncLib.each(
|
||||
Array.from(compilation.chunks),
|
||||
[...compilation.chunks],
|
||||
(chunk, callback) => {
|
||||
if (!chunk.canBeInitial()) {
|
||||
callback();
|
||||
|
|
@ -94,7 +94,8 @@ class LibManifestPlugin {
|
|||
const ident = module.libIdent({
|
||||
context:
|
||||
this.options.context ||
|
||||
/** @type {string} */ (compiler.options.context),
|
||||
/** @type {string} */
|
||||
(compiler.options.context),
|
||||
associatedObjectForCache: compiler.root
|
||||
});
|
||||
if (ident) {
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { SyncWaterfallHook } = require("tapable");
|
||||
const util = require("util");
|
||||
const { SyncWaterfallHook } = require("tapable");
|
||||
const RuntimeGlobals = require("./RuntimeGlobals");
|
||||
const memoize = require("./util/memoize");
|
||||
|
||||
|
|
@ -371,7 +371,7 @@ Object.defineProperty(MainTemplate.prototype, "outputOptions", {
|
|||
* @this {MainTemplate}
|
||||
* @returns {OutputOptions} output options
|
||||
*/
|
||||
function () {
|
||||
function outputOptions() {
|
||||
return this._outputOptions;
|
||||
},
|
||||
"MainTemplate.outputOptions is deprecated (use Compilation.outputOptions instead)",
|
||||
|
|
|
|||
|
|
@ -1188,7 +1188,7 @@ Object.defineProperty(Module.prototype, "errors", {
|
|||
* @this {Module}
|
||||
* @returns {WebpackError[]} errors
|
||||
*/
|
||||
function () {
|
||||
function errors() {
|
||||
if (this._errors === undefined) {
|
||||
this._errors = [];
|
||||
}
|
||||
|
|
@ -1210,7 +1210,7 @@ Object.defineProperty(Module.prototype, "warnings", {
|
|||
* @this {Module}
|
||||
* @returns {WebpackError[]} warnings
|
||||
*/
|
||||
function () {
|
||||
function warnings() {
|
||||
if (this._warnings === undefined) {
|
||||
this._warnings = [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -765,8 +765,9 @@ class ModuleGraph {
|
|||
!connection.dependency ||
|
||||
connection.dependency instanceof
|
||||
require("./dependencies/CommonJsSelfReferenceDependency")
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (connection.dependency.defer) return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class ModuleGraphConnection {
|
|||
|
||||
get explanation() {
|
||||
if (this.explanations === undefined) return "";
|
||||
return Array.from(this.explanations).join(" ");
|
||||
return [...this.explanations].join(" ");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -190,10 +190,10 @@ class ModuleGraphConnection {
|
|||
/** @typedef {typeof CIRCULAR_CONNECTION} CIRCULAR_CONNECTION */
|
||||
|
||||
module.exports = ModuleGraphConnection;
|
||||
module.exports.addConnectionStates = addConnectionStates;
|
||||
module.exports.TRANSITIVE_ONLY = /** @type {typeof TRANSITIVE_ONLY} */ (
|
||||
TRANSITIVE_ONLY
|
||||
);
|
||||
module.exports.CIRCULAR_CONNECTION = /** @type {typeof CIRCULAR_CONNECTION} */ (
|
||||
CIRCULAR_CONNECTION
|
||||
);
|
||||
module.exports.TRANSITIVE_ONLY = /** @type {typeof TRANSITIVE_ONLY} */ (
|
||||
TRANSITIVE_ONLY
|
||||
);
|
||||
module.exports.addConnectionStates = addConnectionStates;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { ConcatSource, RawSource, CachedSource } = require("webpack-sources");
|
||||
const { CachedSource, ConcatSource, RawSource } = require("webpack-sources");
|
||||
const { UsageState } = require("./ExportsInfo");
|
||||
const Template = require("./Template");
|
||||
const CssModulesPlugin = require("./css/CssModulesPlugin");
|
||||
|
|
|
|||
|
|
@ -102,22 +102,22 @@ const CONSUME_SHARED_TYPES = new Set(["consume-shared"]);
|
|||
*/
|
||||
const SHARED_INIT_TYPES = new Set(["share-init"]);
|
||||
|
||||
module.exports.NO_TYPES = NO_TYPES;
|
||||
module.exports.JS_TYPE = JS_TYPE;
|
||||
module.exports.JS_TYPES = JS_TYPES;
|
||||
module.exports.JS_AND_CSS_TYPES = JS_AND_CSS_TYPES;
|
||||
module.exports.JS_AND_CSS_URL_TYPES = JS_AND_CSS_URL_TYPES;
|
||||
module.exports.JS_AND_CSS_EXPORT_TYPES = JS_AND_CSS_EXPORT_TYPES;
|
||||
module.exports.ASSET_TYPES = ASSET_TYPES;
|
||||
module.exports.ASSET_AND_JS_TYPES = ASSET_AND_JS_TYPES;
|
||||
module.exports.ASSET_AND_CSS_URL_TYPES = ASSET_AND_CSS_URL_TYPES;
|
||||
module.exports.ASSET_AND_JS_AND_CSS_URL_TYPES = ASSET_AND_JS_AND_CSS_URL_TYPES;
|
||||
module.exports.ASSET_AND_JS_TYPES = ASSET_AND_JS_TYPES;
|
||||
module.exports.ASSET_TYPES = ASSET_TYPES;
|
||||
module.exports.CONSUME_SHARED_TYPES = CONSUME_SHARED_TYPES;
|
||||
module.exports.CSS_IMPORT_TYPES = CSS_IMPORT_TYPES;
|
||||
module.exports.CSS_TYPE = CSS_TYPE;
|
||||
module.exports.CSS_TYPES = CSS_TYPES;
|
||||
module.exports.CSS_URL_TYPES = CSS_URL_TYPES;
|
||||
module.exports.CSS_IMPORT_TYPES = CSS_IMPORT_TYPES;
|
||||
module.exports.WEBASSEMBLY_TYPES = WEBASSEMBLY_TYPES;
|
||||
module.exports.RUNTIME_TYPES = RUNTIME_TYPES;
|
||||
module.exports.JS_AND_CSS_EXPORT_TYPES = JS_AND_CSS_EXPORT_TYPES;
|
||||
module.exports.JS_AND_CSS_TYPES = JS_AND_CSS_TYPES;
|
||||
module.exports.JS_AND_CSS_URL_TYPES = JS_AND_CSS_URL_TYPES;
|
||||
module.exports.JS_TYPE = JS_TYPE;
|
||||
module.exports.JS_TYPES = JS_TYPES;
|
||||
module.exports.NO_TYPES = NO_TYPES;
|
||||
module.exports.REMOTE_AND_SHARE_INIT_TYPES = REMOTE_AND_SHARE_INIT_TYPES;
|
||||
module.exports.CONSUME_SHARED_TYPES = CONSUME_SHARED_TYPES;
|
||||
module.exports.RUNTIME_TYPES = RUNTIME_TYPES;
|
||||
module.exports.SHARED_INIT_TYPES = SHARED_INIT_TYPES;
|
||||
module.exports.WEBASSEMBLY_TYPES = WEBASSEMBLY_TYPES;
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ Object.defineProperty(ModuleTemplate.prototype, "runtimeTemplate", {
|
|||
* @this {ModuleTemplate}
|
||||
* @returns {RuntimeTemplate} output options
|
||||
*/
|
||||
function () {
|
||||
function runtimeTemplate() {
|
||||
return this._runtimeTemplate;
|
||||
},
|
||||
"ModuleTemplate.runtimeTemplate is deprecated (use Compilation.runtimeTemplate instead)",
|
||||
|
|
|
|||
|
|
@ -144,40 +144,40 @@ const WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY = "lazy-compilation-proxy";
|
|||
/** @typedef {JavaScriptModuleTypes | JSONModuleType | WebAssemblyModuleTypes | CSSModuleTypes | AssetModuleTypes | WebpackModuleTypes | UnknownModuleTypes} ModuleTypes */
|
||||
|
||||
module.exports.ASSET_MODULE_TYPE = ASSET_MODULE_TYPE;
|
||||
module.exports.ASSET_MODULE_TYPE_RAW_DATA_URL = ASSET_MODULE_TYPE_RAW_DATA_URL;
|
||||
module.exports.ASSET_MODULE_TYPE_SOURCE = ASSET_MODULE_TYPE_SOURCE;
|
||||
module.exports.ASSET_MODULE_TYPE_RESOURCE = ASSET_MODULE_TYPE_RESOURCE;
|
||||
module.exports.ASSET_MODULE_TYPE_INLINE = ASSET_MODULE_TYPE_INLINE;
|
||||
module.exports.JAVASCRIPT_MODULE_TYPE_AUTO = JAVASCRIPT_MODULE_TYPE_AUTO;
|
||||
module.exports.JAVASCRIPT_MODULE_TYPE_DYNAMIC = JAVASCRIPT_MODULE_TYPE_DYNAMIC;
|
||||
module.exports.JAVASCRIPT_MODULE_TYPE_ESM = JAVASCRIPT_MODULE_TYPE_ESM;
|
||||
module.exports.JAVASCRIPT_MODULES = [
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
||||
JAVASCRIPT_MODULE_TYPE_ESM
|
||||
];
|
||||
module.exports.JSON_MODULE_TYPE = JSON_MODULE_TYPE;
|
||||
module.exports.WEBASSEMBLY_MODULE_TYPE_ASYNC = WEBASSEMBLY_MODULE_TYPE_ASYNC;
|
||||
module.exports.WEBASSEMBLY_MODULE_TYPE_SYNC = WEBASSEMBLY_MODULE_TYPE_SYNC;
|
||||
module.exports.WEBASSEMBLY_MODULES = [
|
||||
WEBASSEMBLY_MODULE_TYPE_SYNC,
|
||||
WEBASSEMBLY_MODULE_TYPE_SYNC
|
||||
];
|
||||
module.exports.CSS_MODULE_TYPE = CSS_MODULE_TYPE;
|
||||
module.exports.CSS_MODULE_TYPE_GLOBAL = CSS_MODULE_TYPE_GLOBAL;
|
||||
module.exports.CSS_MODULE_TYPE_MODULE = CSS_MODULE_TYPE_MODULE;
|
||||
module.exports.CSS_MODULE_TYPE_AUTO = CSS_MODULE_TYPE_AUTO;
|
||||
module.exports.ASSET_MODULE_TYPE_RAW_DATA_URL = ASSET_MODULE_TYPE_RAW_DATA_URL;
|
||||
module.exports.ASSET_MODULE_TYPE_RESOURCE = ASSET_MODULE_TYPE_RESOURCE;
|
||||
module.exports.ASSET_MODULE_TYPE_SOURCE = ASSET_MODULE_TYPE_SOURCE;
|
||||
module.exports.CSS_MODULES = [
|
||||
CSS_MODULE_TYPE,
|
||||
CSS_MODULE_TYPE_GLOBAL,
|
||||
CSS_MODULE_TYPE_MODULE,
|
||||
CSS_MODULE_TYPE_AUTO
|
||||
];
|
||||
module.exports.WEBPACK_MODULE_TYPE_RUNTIME = WEBPACK_MODULE_TYPE_RUNTIME;
|
||||
module.exports.WEBPACK_MODULE_TYPE_FALLBACK = WEBPACK_MODULE_TYPE_FALLBACK;
|
||||
module.exports.WEBPACK_MODULE_TYPE_REMOTE = WEBPACK_MODULE_TYPE_REMOTE;
|
||||
module.exports.WEBPACK_MODULE_TYPE_PROVIDE = WEBPACK_MODULE_TYPE_PROVIDE;
|
||||
module.exports.CSS_MODULE_TYPE = CSS_MODULE_TYPE;
|
||||
module.exports.CSS_MODULE_TYPE_AUTO = CSS_MODULE_TYPE_AUTO;
|
||||
module.exports.CSS_MODULE_TYPE_GLOBAL = CSS_MODULE_TYPE_GLOBAL;
|
||||
module.exports.CSS_MODULE_TYPE_MODULE = CSS_MODULE_TYPE_MODULE;
|
||||
module.exports.JAVASCRIPT_MODULES = [
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
||||
JAVASCRIPT_MODULE_TYPE_ESM
|
||||
];
|
||||
module.exports.JAVASCRIPT_MODULE_TYPE_AUTO = JAVASCRIPT_MODULE_TYPE_AUTO;
|
||||
module.exports.JAVASCRIPT_MODULE_TYPE_DYNAMIC = JAVASCRIPT_MODULE_TYPE_DYNAMIC;
|
||||
module.exports.JAVASCRIPT_MODULE_TYPE_ESM = JAVASCRIPT_MODULE_TYPE_ESM;
|
||||
module.exports.JSON_MODULE_TYPE = JSON_MODULE_TYPE;
|
||||
module.exports.WEBASSEMBLY_MODULES = [
|
||||
WEBASSEMBLY_MODULE_TYPE_SYNC,
|
||||
WEBASSEMBLY_MODULE_TYPE_SYNC
|
||||
];
|
||||
module.exports.WEBASSEMBLY_MODULE_TYPE_ASYNC = WEBASSEMBLY_MODULE_TYPE_ASYNC;
|
||||
module.exports.WEBASSEMBLY_MODULE_TYPE_SYNC = WEBASSEMBLY_MODULE_TYPE_SYNC;
|
||||
module.exports.WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE =
|
||||
WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE;
|
||||
module.exports.WEBPACK_MODULE_TYPE_FALLBACK = WEBPACK_MODULE_TYPE_FALLBACK;
|
||||
module.exports.WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY =
|
||||
WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY;
|
||||
module.exports.WEBPACK_MODULE_TYPE_PROVIDE = WEBPACK_MODULE_TYPE_PROVIDE;
|
||||
module.exports.WEBPACK_MODULE_TYPE_REMOTE = WEBPACK_MODULE_TYPE_REMOTE;
|
||||
module.exports.WEBPACK_MODULE_TYPE_RUNTIME = WEBPACK_MODULE_TYPE_RUNTIME;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
"use strict";
|
||||
|
||||
const asyncLib = require("neo-async");
|
||||
const { SyncHook, MultiHook } = require("tapable");
|
||||
const { MultiHook, SyncHook } = require("tapable");
|
||||
|
||||
const ConcurrentCompilationError = require("./ConcurrentCompilationError");
|
||||
const MultiStats = require("./MultiStats");
|
||||
|
|
@ -305,7 +305,7 @@ module.exports = class MultiCompiler {
|
|||
}
|
||||
if (edges.size > 0) {
|
||||
/** @type {string[]} */
|
||||
const lines = Array.from(edges)
|
||||
const lines = [...edges]
|
||||
.sort(sortEdges)
|
||||
.map(edge => `${edge.source.name} -> ${edge.target.name}`);
|
||||
lines.unshift("Circular dependency found in compiler dependencies.");
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const querystring = require("querystring");
|
||||
const parseJson = require("json-parse-even-better-errors");
|
||||
const { getContext, runLoaders } = require("loader-runner");
|
||||
const querystring = require("querystring");
|
||||
const {
|
||||
AsyncSeriesBailHook,
|
||||
HookMap,
|
||||
SyncHook,
|
||||
SyncWaterfallHook,
|
||||
AsyncSeriesBailHook
|
||||
SyncWaterfallHook
|
||||
} = require("tapable");
|
||||
const {
|
||||
CachedSource,
|
||||
|
|
@ -38,16 +38,16 @@ const { isSubset } = require("./util/SetHelpers");
|
|||
const { getScheme } = require("./util/URLAbsoluteSpecifier");
|
||||
const {
|
||||
compareLocations,
|
||||
concatComparators,
|
||||
compareSelect,
|
||||
concatComparators,
|
||||
keepOriginalOrder
|
||||
} = require("./util/comparators");
|
||||
const createHash = require("./util/createHash");
|
||||
const { createFakeHook } = require("./util/deprecation");
|
||||
const { join } = require("./util/fs");
|
||||
const {
|
||||
contextify,
|
||||
absolutify,
|
||||
contextify,
|
||||
makePathsRelative
|
||||
} = require("./util/identifier");
|
||||
const makeSerializable = require("./util/makeSerializable");
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ const { getContext } = require("loader-runner");
|
|||
const asyncLib = require("neo-async");
|
||||
const {
|
||||
AsyncSeriesBailHook,
|
||||
SyncWaterfallHook,
|
||||
HookMap,
|
||||
SyncBailHook,
|
||||
SyncHook,
|
||||
HookMap
|
||||
SyncWaterfallHook
|
||||
} = require("tapable");
|
||||
const ChunkGraph = require("./ChunkGraph");
|
||||
const Module = require("./Module");
|
||||
|
|
@ -1011,9 +1011,7 @@ ${hints.join("\n\n")}`;
|
|||
|
||||
// Check if the extension is missing a leading dot (e.g. "js" instead of ".js")
|
||||
let appendResolveExtensionsHint = false;
|
||||
const specifiedExtensions = Array.from(
|
||||
resolver.options.extensions
|
||||
);
|
||||
const specifiedExtensions = [...resolver.options.extensions];
|
||||
const expectedExtensions = specifiedExtensions.map(extension => {
|
||||
if (LEADING_DOT_EXTENSION_REGEX.test(extension)) {
|
||||
appendResolveExtensionsHint = true;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { join, dirname } = require("./util/fs");
|
||||
const { dirname, join } = require("./util/fs");
|
||||
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
/** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
module.exports.STAGE_ADVANCED = 10;
|
||||
module.exports.STAGE_BASIC = -10;
|
||||
module.exports.STAGE_DEFAULT = 0;
|
||||
module.exports.STAGE_ADVANCED = 10;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,11 @@ class ProvidePlugin {
|
|||
for (const name of Object.keys(definitions)) {
|
||||
const request =
|
||||
/** @type {string[]} */
|
||||
([]).concat(definitions[name]);
|
||||
([
|
||||
...(Array.isArray(definitions[name])
|
||||
? definitions[name]
|
||||
: [definitions[name]])
|
||||
]);
|
||||
const splittedName = name.split(".");
|
||||
if (splittedName.length > 0) {
|
||||
for (const [i, _] of splittedName.slice(1).entries()) {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class RecordIdsPlugin {
|
|||
records.modules.byIdentifier[identifier] = moduleId;
|
||||
usedIds.add(moduleId);
|
||||
}
|
||||
records.modules.usedIds = Array.from(usedIds).sort(compareNumbers);
|
||||
records.modules.usedIds = [...usedIds].sort(compareNumbers);
|
||||
});
|
||||
compilation.hooks.reviveModules.tap(PLUGIN_NAME, (modules, records) => {
|
||||
if (!records.modules) return;
|
||||
|
|
@ -168,7 +168,7 @@ class RecordIdsPlugin {
|
|||
}
|
||||
usedIds.add(chunk.id);
|
||||
}
|
||||
records.chunks.usedIds = Array.from(usedIds).sort(compareNumbers);
|
||||
records.chunks.usedIds = [...usedIds].sort(compareNumbers);
|
||||
});
|
||||
compilation.hooks.reviveChunks.tap(PLUGIN_NAME, (chunks, records) => {
|
||||
if (!records.chunks) return;
|
||||
|
|
|
|||
|
|
@ -6,14 +6,108 @@
|
|||
"use strict";
|
||||
|
||||
/**
|
||||
* the internal require function
|
||||
* the AMD define function
|
||||
*/
|
||||
module.exports.require = "__webpack_require__";
|
||||
module.exports.amdDefine = "__webpack_require__.amdD";
|
||||
|
||||
/**
|
||||
* access to properties of the internal require function/object
|
||||
* the AMD options
|
||||
*/
|
||||
module.exports.requireScope = "__webpack_require__.*";
|
||||
module.exports.amdOptions = "__webpack_require__.amdO";
|
||||
|
||||
/**
|
||||
* Creates an async module. The body function must be a async function.
|
||||
* "module.exports" will be decorated with an AsyncModulePromise.
|
||||
* The body function will be called.
|
||||
* To handle async dependencies correctly do this: "([a, b, c] = await handleDependencies([a, b, c]));".
|
||||
* If "hasAwaitAfterDependencies" is truthy, "handleDependencies()" must be called at the end of the body function.
|
||||
* Signature: function(
|
||||
* module: Module,
|
||||
* body: (handleDependencies: (deps: AsyncModulePromise[]) => Promise<any[]> & () => void,
|
||||
* hasAwaitAfterDependencies?: boolean
|
||||
* ) => void
|
||||
*/
|
||||
module.exports.asyncModule = "__webpack_require__.a";
|
||||
|
||||
/**
|
||||
* The internal symbol that asyncModule is using.
|
||||
*/
|
||||
module.exports.asyncModuleDoneSymbol = "__webpack_require__.aD";
|
||||
|
||||
/**
|
||||
* The internal symbol that asyncModule is using.
|
||||
*/
|
||||
module.exports.asyncModuleExportSymbol = "__webpack_require__.aE";
|
||||
|
||||
/**
|
||||
* the baseURI of current document
|
||||
*/
|
||||
module.exports.baseURI = "__webpack_require__.b";
|
||||
|
||||
/**
|
||||
* global callback functions for installing chunks
|
||||
*/
|
||||
module.exports.chunkCallback = "webpackChunk";
|
||||
|
||||
/**
|
||||
* the chunk name of the chunk with the runtime
|
||||
*/
|
||||
module.exports.chunkName = "__webpack_require__.cn";
|
||||
|
||||
/**
|
||||
* compatibility get default export
|
||||
*/
|
||||
module.exports.compatGetDefaultExport = "__webpack_require__.n";
|
||||
|
||||
/**
|
||||
* create a fake namespace object
|
||||
*/
|
||||
module.exports.createFakeNamespaceObject = "__webpack_require__.t";
|
||||
|
||||
/**
|
||||
* function to promote a string to a TrustedScript using webpack's Trusted
|
||||
* Types policy
|
||||
* Arguments: (script: string) => TrustedScript
|
||||
*/
|
||||
module.exports.createScript = "__webpack_require__.ts";
|
||||
|
||||
/**
|
||||
* function to promote a string to a TrustedScriptURL using webpack's Trusted
|
||||
* Types policy
|
||||
* Arguments: (url: string) => TrustedScriptURL
|
||||
*/
|
||||
module.exports.createScriptUrl = "__webpack_require__.tu";
|
||||
|
||||
/**
|
||||
* The current scope when getting a module from a remote
|
||||
*/
|
||||
module.exports.currentRemoteGetScope = "__webpack_require__.R";
|
||||
|
||||
/**
|
||||
* the exported property define getters function
|
||||
*/
|
||||
module.exports.definePropertyGetters = "__webpack_require__.d";
|
||||
|
||||
/**
|
||||
* the chunk ensure function
|
||||
*/
|
||||
module.exports.ensureChunk = "__webpack_require__.e";
|
||||
|
||||
/**
|
||||
* an object with handlers to ensure a chunk
|
||||
*/
|
||||
module.exports.ensureChunkHandlers = "__webpack_require__.f";
|
||||
|
||||
/**
|
||||
* a runtime requirement if ensureChunkHandlers should include loading of chunk needed for entries
|
||||
*/
|
||||
module.exports.ensureChunkIncludeEntries =
|
||||
"__webpack_require__.f (include entries)";
|
||||
|
||||
/**
|
||||
* the module id of the entry point
|
||||
*/
|
||||
module.exports.entryModuleId = "__webpack_require__.s";
|
||||
|
||||
/**
|
||||
* the internal exports object
|
||||
|
|
@ -21,40 +115,143 @@ module.exports.requireScope = "__webpack_require__.*";
|
|||
module.exports.exports = "__webpack_exports__";
|
||||
|
||||
/**
|
||||
* top-level this need to be the exports object
|
||||
* method to install a chunk that was loaded somehow
|
||||
* Signature: ({ id, ids, modules, runtime }) => void
|
||||
*/
|
||||
module.exports.thisAsExports = "top-level-this-exports";
|
||||
module.exports.externalInstallChunk = "__webpack_require__.C";
|
||||
|
||||
/**
|
||||
* runtime need to return the exports of the last entry module
|
||||
* the filename of the css part of the chunk
|
||||
*/
|
||||
module.exports.returnExportsFromRuntime = "return-exports-from-runtime";
|
||||
module.exports.getChunkCssFilename = "__webpack_require__.k";
|
||||
|
||||
/**
|
||||
* the filename of the script part of the chunk
|
||||
*/
|
||||
module.exports.getChunkScriptFilename = "__webpack_require__.u";
|
||||
|
||||
/**
|
||||
* the filename of the css part of the hot update chunk
|
||||
*/
|
||||
module.exports.getChunkUpdateCssFilename = "__webpack_require__.hk";
|
||||
|
||||
/**
|
||||
* the filename of the script part of the hot update chunk
|
||||
*/
|
||||
module.exports.getChunkUpdateScriptFilename = "__webpack_require__.hu";
|
||||
|
||||
/**
|
||||
* the webpack hash
|
||||
*/
|
||||
module.exports.getFullHash = "__webpack_require__.h";
|
||||
|
||||
/**
|
||||
* function to return webpack's Trusted Types policy
|
||||
* Arguments: () => TrustedTypePolicy
|
||||
*/
|
||||
module.exports.getTrustedTypesPolicy = "__webpack_require__.tt";
|
||||
|
||||
/**
|
||||
* the filename of the HMR manifest
|
||||
*/
|
||||
module.exports.getUpdateManifestFilename = "__webpack_require__.hmrF";
|
||||
|
||||
/**
|
||||
* the global object
|
||||
*/
|
||||
module.exports.global = "__webpack_require__.g";
|
||||
|
||||
/**
|
||||
* harmony module decorator
|
||||
*/
|
||||
module.exports.harmonyModuleDecorator = "__webpack_require__.hmd";
|
||||
|
||||
/**
|
||||
* a flag when a module/chunk/tree has css modules
|
||||
*/
|
||||
module.exports.hasCssModules = "has css modules";
|
||||
|
||||
/**
|
||||
* a flag when a chunk has a fetch priority
|
||||
*/
|
||||
module.exports.hasFetchPriority = "has fetch priority";
|
||||
|
||||
/**
|
||||
* the shorthand for Object.prototype.hasOwnProperty
|
||||
* using of it decreases the compiled bundle size
|
||||
*/
|
||||
module.exports.hasOwnProperty = "__webpack_require__.o";
|
||||
|
||||
/**
|
||||
* function downloading the update manifest
|
||||
*/
|
||||
module.exports.hmrDownloadManifest = "__webpack_require__.hmrM";
|
||||
|
||||
/**
|
||||
* array with handler functions to download chunk updates
|
||||
*/
|
||||
module.exports.hmrDownloadUpdateHandlers = "__webpack_require__.hmrC";
|
||||
|
||||
/**
|
||||
* array with handler functions when a module should be invalidated
|
||||
*/
|
||||
module.exports.hmrInvalidateModuleHandlers = "__webpack_require__.hmrI";
|
||||
|
||||
/**
|
||||
* object with all hmr module data for all modules
|
||||
*/
|
||||
module.exports.hmrModuleData = "__webpack_require__.hmrD";
|
||||
|
||||
/**
|
||||
* the prefix for storing state of runtime modules when hmr is enabled
|
||||
*/
|
||||
module.exports.hmrRuntimeStatePrefix = "__webpack_require__.hmrS";
|
||||
|
||||
/**
|
||||
* The sharing init sequence function (only runs once per share scope).
|
||||
* Has one argument, the name of the share scope.
|
||||
* Creates a share scope if not existing
|
||||
*/
|
||||
module.exports.initializeSharing = "__webpack_require__.I";
|
||||
|
||||
/**
|
||||
* instantiate a wasm instance from module exports object, id, hash and importsObject
|
||||
*/
|
||||
module.exports.instantiateWasm = "__webpack_require__.v";
|
||||
|
||||
/**
|
||||
* interceptor for module executions
|
||||
*/
|
||||
module.exports.interceptModuleExecution = "__webpack_require__.i";
|
||||
|
||||
/**
|
||||
* function to load a script tag.
|
||||
* Arguments: (url: string, done: (event) => void), key?: string | number, chunkId?: string | number) => void
|
||||
* done function is called when loading has finished or timeout occurred.
|
||||
* It will attach to existing script tags with data-webpack == uniqueName + ":" + key or src == url.
|
||||
*/
|
||||
module.exports.loadScript = "__webpack_require__.l";
|
||||
|
||||
/**
|
||||
* make a deferred namespace object
|
||||
*/
|
||||
module.exports.makeDeferredNamespaceObject = "__webpack_require__.z";
|
||||
|
||||
/**
|
||||
* the internal symbol that makeDeferredNamespaceObject is using.
|
||||
*/
|
||||
module.exports.makeDeferredNamespaceObjectSymbol = "__webpack_require__.zS";
|
||||
|
||||
/**
|
||||
* define compatibility on export
|
||||
*/
|
||||
module.exports.makeNamespaceObject = "__webpack_require__.r";
|
||||
|
||||
/**
|
||||
* the internal module object
|
||||
*/
|
||||
module.exports.module = "module";
|
||||
|
||||
/**
|
||||
* the internal module object
|
||||
*/
|
||||
module.exports.moduleId = "module.id";
|
||||
|
||||
/**
|
||||
* the internal module object
|
||||
*/
|
||||
module.exports.moduleLoaded = "module.loaded";
|
||||
|
||||
/**
|
||||
* the bundle public path
|
||||
*/
|
||||
module.exports.publicPath = "__webpack_require__.p";
|
||||
|
||||
/**
|
||||
* the module id of the entry point
|
||||
*/
|
||||
module.exports.entryModuleId = "__webpack_require__.s";
|
||||
|
||||
/**
|
||||
* the module cache
|
||||
*/
|
||||
|
|
@ -71,20 +268,29 @@ module.exports.moduleFactories = "__webpack_require__.m";
|
|||
module.exports.moduleFactoriesAddOnly = "__webpack_require__.m (add only)";
|
||||
|
||||
/**
|
||||
* the chunk ensure function
|
||||
* the internal module object
|
||||
*/
|
||||
module.exports.ensureChunk = "__webpack_require__.e";
|
||||
module.exports.moduleId = "module.id";
|
||||
|
||||
/**
|
||||
* an object with handlers to ensure a chunk
|
||||
* the internal module object
|
||||
*/
|
||||
module.exports.ensureChunkHandlers = "__webpack_require__.f";
|
||||
module.exports.moduleLoaded = "module.loaded";
|
||||
|
||||
/**
|
||||
* a runtime requirement if ensureChunkHandlers should include loading of chunk needed for entries
|
||||
* node.js module decorator
|
||||
*/
|
||||
module.exports.ensureChunkIncludeEntries =
|
||||
"__webpack_require__.f (include entries)";
|
||||
module.exports.nodeModuleDecorator = "__webpack_require__.nmd";
|
||||
|
||||
/**
|
||||
* register deferred code, which will run when certain
|
||||
* chunks are loaded.
|
||||
* Signature: (chunkIds: Id[], fn: () => any, priority: int >= 0 = 0) => any
|
||||
* Returned value will be returned directly when all chunks are already loaded
|
||||
* When (priority & 1) it will wait for all other handlers with lower priority to
|
||||
* be executed before itself is executed
|
||||
*/
|
||||
module.exports.onChunksLoaded = "__webpack_require__.O";
|
||||
|
||||
/**
|
||||
* the chunk prefetch function
|
||||
|
|
@ -107,107 +313,29 @@ module.exports.preloadChunk = "__webpack_require__.G";
|
|||
module.exports.preloadChunkHandlers = "__webpack_require__.H";
|
||||
|
||||
/**
|
||||
* the exported property define getters function
|
||||
* the bundle public path
|
||||
*/
|
||||
module.exports.definePropertyGetters = "__webpack_require__.d";
|
||||
module.exports.publicPath = "__webpack_require__.p";
|
||||
|
||||
/**
|
||||
* define compatibility on export
|
||||
* a RelativeURL class when relative URLs are used
|
||||
*/
|
||||
module.exports.makeNamespaceObject = "__webpack_require__.r";
|
||||
module.exports.relativeUrl = "__webpack_require__.U";
|
||||
|
||||
/**
|
||||
* make a deferred namespace object
|
||||
* the internal require function
|
||||
*/
|
||||
module.exports.makeDeferredNamespaceObject = "__webpack_require__.z";
|
||||
module.exports.require = "__webpack_require__";
|
||||
|
||||
/**
|
||||
* the internal symbol that makeDeferredNamespaceObject is using.
|
||||
* access to properties of the internal require function/object
|
||||
*/
|
||||
module.exports.makeDeferredNamespaceObjectSymbol = "__webpack_require__.zS";
|
||||
module.exports.requireScope = "__webpack_require__.*";
|
||||
|
||||
/**
|
||||
* create a fake namespace object
|
||||
* runtime need to return the exports of the last entry module
|
||||
*/
|
||||
module.exports.createFakeNamespaceObject = "__webpack_require__.t";
|
||||
|
||||
/**
|
||||
* compatibility get default export
|
||||
*/
|
||||
module.exports.compatGetDefaultExport = "__webpack_require__.n";
|
||||
|
||||
/**
|
||||
* harmony module decorator
|
||||
*/
|
||||
module.exports.harmonyModuleDecorator = "__webpack_require__.hmd";
|
||||
|
||||
/**
|
||||
* node.js module decorator
|
||||
*/
|
||||
module.exports.nodeModuleDecorator = "__webpack_require__.nmd";
|
||||
|
||||
/**
|
||||
* the webpack hash
|
||||
*/
|
||||
module.exports.getFullHash = "__webpack_require__.h";
|
||||
|
||||
/**
|
||||
* an object containing all installed WebAssembly.Instance export objects keyed by module id
|
||||
*/
|
||||
module.exports.wasmInstances = "__webpack_require__.w";
|
||||
|
||||
/**
|
||||
* instantiate a wasm instance from module exports object, id, hash and importsObject
|
||||
*/
|
||||
module.exports.instantiateWasm = "__webpack_require__.v";
|
||||
|
||||
/**
|
||||
* the uncaught error handler for the webpack runtime
|
||||
*/
|
||||
module.exports.uncaughtErrorHandler = "__webpack_require__.oe";
|
||||
|
||||
/**
|
||||
* the script nonce
|
||||
*/
|
||||
module.exports.scriptNonce = "__webpack_require__.nc";
|
||||
|
||||
/**
|
||||
* function to load a script tag.
|
||||
* Arguments: (url: string, done: (event) => void), key?: string | number, chunkId?: string | number) => void
|
||||
* done function is called when loading has finished or timeout occurred.
|
||||
* It will attach to existing script tags with data-webpack == uniqueName + ":" + key or src == url.
|
||||
*/
|
||||
module.exports.loadScript = "__webpack_require__.l";
|
||||
|
||||
/**
|
||||
* function to promote a string to a TrustedScript using webpack's Trusted
|
||||
* Types policy
|
||||
* Arguments: (script: string) => TrustedScript
|
||||
*/
|
||||
module.exports.createScript = "__webpack_require__.ts";
|
||||
|
||||
/**
|
||||
* function to promote a string to a TrustedScriptURL using webpack's Trusted
|
||||
* Types policy
|
||||
* Arguments: (url: string) => TrustedScriptURL
|
||||
*/
|
||||
module.exports.createScriptUrl = "__webpack_require__.tu";
|
||||
|
||||
/**
|
||||
* function to return webpack's Trusted Types policy
|
||||
* Arguments: () => TrustedTypePolicy
|
||||
*/
|
||||
module.exports.getTrustedTypesPolicy = "__webpack_require__.tt";
|
||||
|
||||
/**
|
||||
* a flag when a chunk has a fetch priority
|
||||
*/
|
||||
module.exports.hasFetchPriority = "has fetch priority";
|
||||
|
||||
/**
|
||||
* the chunk name of the chunk with the runtime
|
||||
*/
|
||||
module.exports.chunkName = "__webpack_require__.cn";
|
||||
module.exports.returnExportsFromRuntime = "return-exports-from-runtime";
|
||||
|
||||
/**
|
||||
* the runtime id of the current runtime
|
||||
|
|
@ -215,29 +343,14 @@ module.exports.chunkName = "__webpack_require__.cn";
|
|||
module.exports.runtimeId = "__webpack_require__.j";
|
||||
|
||||
/**
|
||||
* the filename of the script part of the chunk
|
||||
* the script nonce
|
||||
*/
|
||||
module.exports.getChunkScriptFilename = "__webpack_require__.u";
|
||||
module.exports.scriptNonce = "__webpack_require__.nc";
|
||||
|
||||
/**
|
||||
* the filename of the css part of the chunk
|
||||
* an object with all share scopes
|
||||
*/
|
||||
module.exports.getChunkCssFilename = "__webpack_require__.k";
|
||||
|
||||
/**
|
||||
* a flag when a module/chunk/tree has css modules
|
||||
*/
|
||||
module.exports.hasCssModules = "has css modules";
|
||||
|
||||
/**
|
||||
* the filename of the script part of the hot update chunk
|
||||
*/
|
||||
module.exports.getChunkUpdateScriptFilename = "__webpack_require__.hu";
|
||||
|
||||
/**
|
||||
* the filename of the css part of the hot update chunk
|
||||
*/
|
||||
module.exports.getChunkUpdateCssFilename = "__webpack_require__.hk";
|
||||
module.exports.shareScopeMap = "__webpack_require__.S";
|
||||
|
||||
/**
|
||||
* startup signal from runtime
|
||||
|
|
@ -245,6 +358,13 @@ module.exports.getChunkUpdateCssFilename = "__webpack_require__.hk";
|
|||
*/
|
||||
module.exports.startup = "__webpack_require__.x";
|
||||
|
||||
/**
|
||||
* method to startup an entrypoint with needed chunks.
|
||||
* Signature: (moduleId: Id, chunkIds: Id[]) => any.
|
||||
* Returns the exports of the module or a Promise
|
||||
*/
|
||||
module.exports.startupEntrypoint = "__webpack_require__.X";
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* creating a default startup function with the entry modules
|
||||
|
|
@ -261,147 +381,27 @@ module.exports.startupOnlyAfter = "__webpack_require__.x (only after)";
|
|||
*/
|
||||
module.exports.startupOnlyBefore = "__webpack_require__.x (only before)";
|
||||
|
||||
/**
|
||||
* global callback functions for installing chunks
|
||||
*/
|
||||
module.exports.chunkCallback = "webpackChunk";
|
||||
|
||||
/**
|
||||
* method to startup an entrypoint with needed chunks.
|
||||
* Signature: (moduleId: Id, chunkIds: Id[]) => any.
|
||||
* Returns the exports of the module or a Promise
|
||||
*/
|
||||
module.exports.startupEntrypoint = "__webpack_require__.X";
|
||||
|
||||
/**
|
||||
* register deferred code, which will run when certain
|
||||
* chunks are loaded.
|
||||
* Signature: (chunkIds: Id[], fn: () => any, priority: int >= 0 = 0) => any
|
||||
* Returned value will be returned directly when all chunks are already loaded
|
||||
* When (priority & 1) it will wait for all other handlers with lower priority to
|
||||
* be executed before itself is executed
|
||||
*/
|
||||
module.exports.onChunksLoaded = "__webpack_require__.O";
|
||||
|
||||
/**
|
||||
* method to install a chunk that was loaded somehow
|
||||
* Signature: ({ id, ids, modules, runtime }) => void
|
||||
*/
|
||||
module.exports.externalInstallChunk = "__webpack_require__.C";
|
||||
|
||||
/**
|
||||
* interceptor for module executions
|
||||
*/
|
||||
module.exports.interceptModuleExecution = "__webpack_require__.i";
|
||||
|
||||
/**
|
||||
* the global object
|
||||
*/
|
||||
module.exports.global = "__webpack_require__.g";
|
||||
|
||||
/**
|
||||
* an object with all share scopes
|
||||
*/
|
||||
module.exports.shareScopeMap = "__webpack_require__.S";
|
||||
|
||||
/**
|
||||
* The sharing init sequence function (only runs once per share scope).
|
||||
* Has one argument, the name of the share scope.
|
||||
* Creates a share scope if not existing
|
||||
*/
|
||||
module.exports.initializeSharing = "__webpack_require__.I";
|
||||
|
||||
/**
|
||||
* The current scope when getting a module from a remote
|
||||
*/
|
||||
module.exports.currentRemoteGetScope = "__webpack_require__.R";
|
||||
|
||||
/**
|
||||
* the filename of the HMR manifest
|
||||
*/
|
||||
module.exports.getUpdateManifestFilename = "__webpack_require__.hmrF";
|
||||
|
||||
/**
|
||||
* function downloading the update manifest
|
||||
*/
|
||||
module.exports.hmrDownloadManifest = "__webpack_require__.hmrM";
|
||||
|
||||
/**
|
||||
* array with handler functions to download chunk updates
|
||||
*/
|
||||
module.exports.hmrDownloadUpdateHandlers = "__webpack_require__.hmrC";
|
||||
|
||||
/**
|
||||
* object with all hmr module data for all modules
|
||||
*/
|
||||
module.exports.hmrModuleData = "__webpack_require__.hmrD";
|
||||
|
||||
/**
|
||||
* array with handler functions when a module should be invalidated
|
||||
*/
|
||||
module.exports.hmrInvalidateModuleHandlers = "__webpack_require__.hmrI";
|
||||
|
||||
/**
|
||||
* the prefix for storing state of runtime modules when hmr is enabled
|
||||
*/
|
||||
module.exports.hmrRuntimeStatePrefix = "__webpack_require__.hmrS";
|
||||
|
||||
/**
|
||||
* the AMD define function
|
||||
*/
|
||||
module.exports.amdDefine = "__webpack_require__.amdD";
|
||||
|
||||
/**
|
||||
* the AMD options
|
||||
*/
|
||||
module.exports.amdOptions = "__webpack_require__.amdO";
|
||||
|
||||
/**
|
||||
* the System polyfill object
|
||||
*/
|
||||
module.exports.system = "__webpack_require__.System";
|
||||
|
||||
/**
|
||||
* the shorthand for Object.prototype.hasOwnProperty
|
||||
* using of it decreases the compiled bundle size
|
||||
*/
|
||||
module.exports.hasOwnProperty = "__webpack_require__.o";
|
||||
|
||||
/**
|
||||
* the System.register context object
|
||||
*/
|
||||
module.exports.systemContext = "__webpack_require__.y";
|
||||
|
||||
/**
|
||||
* the baseURI of current document
|
||||
* top-level this need to be the exports object
|
||||
*/
|
||||
module.exports.baseURI = "__webpack_require__.b";
|
||||
module.exports.thisAsExports = "top-level-this-exports";
|
||||
|
||||
/**
|
||||
* a RelativeURL class when relative URLs are used
|
||||
* the uncaught error handler for the webpack runtime
|
||||
*/
|
||||
module.exports.relativeUrl = "__webpack_require__.U";
|
||||
module.exports.uncaughtErrorHandler = "__webpack_require__.oe";
|
||||
|
||||
/**
|
||||
* Creates an async module. The body function must be a async function.
|
||||
* "module.exports" will be decorated with an AsyncModulePromise.
|
||||
* The body function will be called.
|
||||
* To handle async dependencies correctly do this: "([a, b, c] = await handleDependencies([a, b, c]));".
|
||||
* If "hasAwaitAfterDependencies" is truthy, "handleDependencies()" must be called at the end of the body function.
|
||||
* Signature: function(
|
||||
* module: Module,
|
||||
* body: (handleDependencies: (deps: AsyncModulePromise[]) => Promise<any[]> & () => void,
|
||||
* hasAwaitAfterDependencies?: boolean
|
||||
* ) => void
|
||||
* an object containing all installed WebAssembly.Instance export objects keyed by module id
|
||||
*/
|
||||
module.exports.asyncModule = "__webpack_require__.a";
|
||||
|
||||
/**
|
||||
* The internal symbol that asyncModule is using.
|
||||
*/
|
||||
module.exports.asyncModuleExportSymbol = "__webpack_require__.aE";
|
||||
|
||||
/**
|
||||
* The internal symbol that asyncModule is using.
|
||||
*/
|
||||
module.exports.asyncModuleDoneSymbol = "__webpack_require__.aD";
|
||||
module.exports.wasmInstances = "__webpack_require__.w";
|
||||
|
|
|
|||
|
|
@ -55,9 +55,7 @@ Module has these incoming connections: ${Array.from(
|
|||
`\n - ${
|
||||
connection.originModule && connection.originModule.identifier()
|
||||
} ${connection.dependency && connection.dependency.type} ${
|
||||
(connection.explanations &&
|
||||
Array.from(connection.explanations).join(", ")) ||
|
||||
""
|
||||
(connection.explanations && [...connection.explanations].join(", ")) || ""
|
||||
}`
|
||||
).join("")}`;
|
||||
|
||||
|
|
@ -776,8 +774,8 @@ class RuntimeTemplate {
|
|||
);
|
||||
runtimeRequirements.add(RuntimeGlobals.runtimeId);
|
||||
return compileBooleanMatcher.fromLists(
|
||||
Array.from(positiveRuntimeIds),
|
||||
Array.from(negativeRuntimeIds)
|
||||
[...positiveRuntimeIds],
|
||||
[...negativeRuntimeIds]
|
||||
)(RuntimeGlobals.runtimeId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const ProgressPlugin = require("./ProgressPlugin");
|
|||
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
|
||||
const createSchemaValidation = require("./util/create-schema-validation");
|
||||
const createHash = require("./util/createHash");
|
||||
const { relative, dirname } = require("./util/fs");
|
||||
const { dirname, relative } = require("./util/fs");
|
||||
const generateDebugId = require("./util/generateDebugId");
|
||||
const { makePathsAbsolute } = require("./util/identifier");
|
||||
|
||||
|
|
@ -363,13 +363,13 @@ class SourceMapDevToolPlugin {
|
|||
* all modules in defined order (longest identifier first)
|
||||
* @type {Array<string | Module>}
|
||||
*/
|
||||
const allModules = Array.from(
|
||||
moduleToSourceNameMapping.keys()
|
||||
).sort((a, b) => {
|
||||
const ai = typeof a === "string" ? a : a.identifier();
|
||||
const bi = typeof b === "string" ? b : b.identifier();
|
||||
return ai.length - bi.length;
|
||||
});
|
||||
const allModules = [...moduleToSourceNameMapping.keys()].sort(
|
||||
(a, b) => {
|
||||
const ai = typeof a === "string" ? a : a.identifier();
|
||||
const bi = typeof b === "string" ? b : b.identifier();
|
||||
return ai.length - bi.length;
|
||||
}
|
||||
);
|
||||
|
||||
// find modules with conflicting source names
|
||||
for (let idx = 0; idx < allModules.length; idx++) {
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ class Template {
|
|||
}
|
||||
|
||||
module.exports = Template;
|
||||
module.exports.NUMBER_OF_IDENTIFIER_START_CHARS =
|
||||
NUMBER_OF_IDENTIFIER_START_CHARS;
|
||||
module.exports.NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS =
|
||||
NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS;
|
||||
module.exports.NUMBER_OF_IDENTIFIER_START_CHARS =
|
||||
NUMBER_OF_IDENTIFIER_START_CHARS;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const mime = require("mime-types");
|
||||
const { basename, extname } = require("path");
|
||||
const util = require("util");
|
||||
const mime = require("mime-types");
|
||||
const Chunk = require("./Chunk");
|
||||
const Module = require("./Module");
|
||||
const { parseResource } = require("./util/identifier");
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|||
/** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
|
||||
/** @typedef {import("./util/fs").WatchMethod} WatchMethod */
|
||||
/** @typedef {import("./util/fs").Watcher} Watcher */
|
||||
|
||||
const validate = createSchemaValidation(
|
||||
require("../schemas/plugins/WatchIgnorePlugin.check"),
|
||||
() => require("../schemas/plugins/WatchIgnorePlugin.json"),
|
||||
|
|
@ -38,8 +39,8 @@ class IgnoringWatchFileSystem {
|
|||
|
||||
/** @type {WatchMethod} */
|
||||
watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
|
||||
files = Array.from(files);
|
||||
dirs = Array.from(dirs);
|
||||
files = [...files];
|
||||
dirs = [...dirs];
|
||||
/**
|
||||
* @param {string} path path to check
|
||||
* @returns {boolean} true, if path is ignored
|
||||
|
|
|
|||
|
|
@ -5,51 +5,68 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const OptionsApply = require("./OptionsApply");
|
||||
const APIPlugin = require("./APIPlugin");
|
||||
|
||||
const AssetModulesPlugin = require("./asset/AssetModulesPlugin");
|
||||
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
||||
const JsonModulesPlugin = require("./json/JsonModulesPlugin");
|
||||
const CompatibilityPlugin = require("./CompatibilityPlugin");
|
||||
|
||||
const ChunkPrefetchPreloadPlugin = require("./prefetch/ChunkPrefetchPreloadPlugin");
|
||||
const ConstPlugin = require("./ConstPlugin");
|
||||
|
||||
const EntryOptionPlugin = require("./EntryOptionPlugin");
|
||||
|
||||
const ExportsInfoApiPlugin = require("./ExportsInfoApiPlugin");
|
||||
const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
|
||||
|
||||
const JavascriptMetaInfoPlugin = require("./JavascriptMetaInfoPlugin");
|
||||
|
||||
const OptionsApply = require("./OptionsApply");
|
||||
|
||||
const RecordIdsPlugin = require("./RecordIdsPlugin");
|
||||
|
||||
const RuntimePlugin = require("./RuntimePlugin");
|
||||
|
||||
const APIPlugin = require("./APIPlugin");
|
||||
const CompatibilityPlugin = require("./CompatibilityPlugin");
|
||||
const ConstPlugin = require("./ConstPlugin");
|
||||
const ExportsInfoApiPlugin = require("./ExportsInfoApiPlugin");
|
||||
const WebpackIsIncludedPlugin = require("./WebpackIsIncludedPlugin");
|
||||
|
||||
const TemplatedPathPlugin = require("./TemplatedPathPlugin");
|
||||
|
||||
const UseStrictPlugin = require("./UseStrictPlugin");
|
||||
|
||||
const WarnCaseSensitiveModulesPlugin = require("./WarnCaseSensitiveModulesPlugin");
|
||||
|
||||
const DataUriPlugin = require("./schemes/DataUriPlugin");
|
||||
const FileUriPlugin = require("./schemes/FileUriPlugin");
|
||||
const WebpackIsIncludedPlugin = require("./WebpackIsIncludedPlugin");
|
||||
|
||||
const AssetModulesPlugin = require("./asset/AssetModulesPlugin");
|
||||
|
||||
const InferAsyncModulesPlugin = require("./async-modules/InferAsyncModulesPlugin");
|
||||
|
||||
const ResolverCachePlugin = require("./cache/ResolverCachePlugin");
|
||||
|
||||
const CommonJsPlugin = require("./dependencies/CommonJsPlugin");
|
||||
|
||||
const HarmonyModulesPlugin = require("./dependencies/HarmonyModulesPlugin");
|
||||
|
||||
const ImportMetaContextPlugin = require("./dependencies/ImportMetaContextPlugin");
|
||||
const ImportMetaPlugin = require("./dependencies/ImportMetaPlugin");
|
||||
|
||||
const ImportPlugin = require("./dependencies/ImportPlugin");
|
||||
const LoaderPlugin = require("./dependencies/LoaderPlugin");
|
||||
|
||||
const RequireContextPlugin = require("./dependencies/RequireContextPlugin");
|
||||
const RequireEnsurePlugin = require("./dependencies/RequireEnsurePlugin");
|
||||
const RequireIncludePlugin = require("./dependencies/RequireIncludePlugin");
|
||||
|
||||
const SystemPlugin = require("./dependencies/SystemPlugin");
|
||||
|
||||
const URLPlugin = require("./dependencies/URLPlugin");
|
||||
|
||||
const WorkerPlugin = require("./dependencies/WorkerPlugin");
|
||||
|
||||
const InferAsyncModulesPlugin = require("./async-modules/InferAsyncModulesPlugin");
|
||||
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
||||
|
||||
const JsonModulesPlugin = require("./json/JsonModulesPlugin");
|
||||
|
||||
const ChunkPrefetchPreloadPlugin = require("./prefetch/ChunkPrefetchPreloadPlugin");
|
||||
|
||||
const DataUriPlugin = require("./schemes/DataUriPlugin");
|
||||
const FileUriPlugin = require("./schemes/FileUriPlugin");
|
||||
|
||||
const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
|
||||
const JavascriptMetaInfoPlugin = require("./JavascriptMetaInfoPlugin");
|
||||
const DefaultStatsFactoryPlugin = require("./stats/DefaultStatsFactoryPlugin");
|
||||
const DefaultStatsPresetPlugin = require("./stats/DefaultStatsPresetPlugin");
|
||||
const DefaultStatsPrinterPlugin = require("./stats/DefaultStatsPrinterPlugin");
|
||||
|
|
|
|||
|
|
@ -5,20 +5,20 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const mimeTypes = require("mime-types");
|
||||
const path = require("path");
|
||||
const mimeTypes = require("mime-types");
|
||||
const { RawSource } = require("webpack-sources");
|
||||
const ConcatenationScope = require("../ConcatenationScope");
|
||||
const Generator = require("../Generator");
|
||||
const {
|
||||
NO_TYPES,
|
||||
ASSET_TYPES,
|
||||
ASSET_AND_JS_TYPES,
|
||||
ASSET_AND_JS_AND_CSS_URL_TYPES,
|
||||
ASSET_AND_CSS_URL_TYPES,
|
||||
JS_TYPES,
|
||||
ASSET_AND_JS_AND_CSS_URL_TYPES,
|
||||
ASSET_AND_JS_TYPES,
|
||||
ASSET_TYPES,
|
||||
CSS_URL_TYPES,
|
||||
JS_AND_CSS_URL_TYPES,
|
||||
CSS_URL_TYPES
|
||||
JS_TYPES,
|
||||
NO_TYPES
|
||||
} = require("../ModuleSourceTypesConstants");
|
||||
const { ASSET_MODULE_TYPE } = require("../ModuleTypeConstants");
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
|
|
@ -67,7 +67,7 @@ const mergeMaybeArrays = (a, b) => {
|
|||
else set.add(a);
|
||||
if (Array.isArray(b)) for (const item of b) set.add(item);
|
||||
else set.add(b);
|
||||
return Array.from(set);
|
||||
return [...set];
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
"use strict";
|
||||
|
||||
const {
|
||||
ASSET_MODULE_TYPE_RESOURCE,
|
||||
ASSET_MODULE_TYPE_INLINE,
|
||||
ASSET_MODULE_TYPE,
|
||||
ASSET_MODULE_TYPE_INLINE,
|
||||
ASSET_MODULE_TYPE_RESOURCE,
|
||||
ASSET_MODULE_TYPE_SOURCE
|
||||
} = require("../ModuleTypeConstants");
|
||||
const { cleverMerge } = require("../util/cleverMerge");
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ const { RawSource } = require("webpack-sources");
|
|||
const ConcatenationScope = require("../ConcatenationScope");
|
||||
const Generator = require("../Generator");
|
||||
const {
|
||||
NO_TYPES,
|
||||
CSS_URL_TYPES,
|
||||
JS_AND_CSS_URL_TYPES,
|
||||
JS_TYPES,
|
||||
JS_AND_CSS_URL_TYPES
|
||||
NO_TYPES
|
||||
} = require("../ModuleSourceTypesConstants");
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|||
""
|
||||
]);
|
||||
}
|
||||
const sepPromises = Array.from(promises).join(", ");
|
||||
const sepPromises = [...promises].join(", ");
|
||||
// TODO check if destructuring is supported
|
||||
return Template.asString([
|
||||
`var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${sepPromises}]);`,
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class IdleFileCachePlugin {
|
|||
}
|
||||
isIdle = false;
|
||||
const reportProgress = ProgressPlugin.getReporter(compiler);
|
||||
const jobs = Array.from(pendingIdleTasks.values());
|
||||
const jobs = [...pendingIdleTasks.values()];
|
||||
if (reportProgress) reportProgress(0, "process pending cache items");
|
||||
const promises = jobs.map(fn => fn());
|
||||
pendingIdleTasks.clear();
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ const LazySet = require("../util/LazySet");
|
|||
const makeSerializable = require("../util/makeSerializable");
|
||||
const memoize = require("../util/memoize");
|
||||
const {
|
||||
createFileSerializer,
|
||||
NOT_SERIALIZABLE
|
||||
NOT_SERIALIZABLE,
|
||||
createFileSerializer
|
||||
} = require("../util/serialization");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").SnapshotOptions} SnapshotOptions */
|
||||
|
|
@ -1378,9 +1378,7 @@ class PackFileCacheStrategy {
|
|||
if (newBuildDependencies.size > 0 || !this.buildSnapshot) {
|
||||
if (reportProgress) reportProgress(0.5, "resolve build dependencies");
|
||||
this.logger.debug(
|
||||
`Capturing build dependencies... (${Array.from(
|
||||
newBuildDependencies
|
||||
).join(", ")})`
|
||||
`Capturing build dependencies... (${[...newBuildDependencies].join(", ")})`
|
||||
);
|
||||
promise = new Promise(
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const browserslist = require("browserslist");
|
||||
const path = require("path");
|
||||
const browserslist = require("browserslist");
|
||||
|
||||
/** @typedef {import("./target").ApiTargetProperties} ApiTargetProperties */
|
||||
/** @typedef {import("./target").EcmaTargetProperties} EcmaTargetProperties */
|
||||
|
|
@ -358,6 +358,6 @@ const resolve = browsers => {
|
|||
};
|
||||
|
||||
module.exports = {
|
||||
resolve,
|
||||
load
|
||||
load,
|
||||
resolve
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,26 +8,26 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const {
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_ESM,
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
||||
JSON_MODULE_TYPE,
|
||||
WEBASSEMBLY_MODULE_TYPE_ASYNC,
|
||||
WEBASSEMBLY_MODULE_TYPE_SYNC,
|
||||
ASSET_MODULE_TYPE,
|
||||
ASSET_MODULE_TYPE_INLINE,
|
||||
ASSET_MODULE_TYPE_RESOURCE,
|
||||
CSS_MODULE_TYPE_AUTO,
|
||||
CSS_MODULE_TYPE,
|
||||
CSS_MODULE_TYPE_AUTO,
|
||||
CSS_MODULE_TYPE_GLOBAL,
|
||||
CSS_MODULE_TYPE_MODULE,
|
||||
CSS_MODULE_TYPE_GLOBAL
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
||||
JAVASCRIPT_MODULE_TYPE_ESM,
|
||||
JSON_MODULE_TYPE,
|
||||
WEBASSEMBLY_MODULE_TYPE_ASYNC,
|
||||
WEBASSEMBLY_MODULE_TYPE_SYNC
|
||||
} = require("../ModuleTypeConstants");
|
||||
const Template = require("../Template");
|
||||
const { cleverMerge } = require("../util/cleverMerge");
|
||||
const {
|
||||
getTargetsProperties,
|
||||
getDefaultTarget,
|
||||
getTargetProperties,
|
||||
getDefaultTarget
|
||||
getTargetsProperties
|
||||
} = require("./target");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CacheOptions} CacheOptions */
|
||||
|
|
@ -1354,7 +1354,7 @@ const applyOutputDefaults = (
|
|||
enabledChunkLoadingTypes.add(desc.chunkLoading);
|
||||
}
|
||||
});
|
||||
return Array.from(enabledChunkLoadingTypes);
|
||||
return [...enabledChunkLoadingTypes];
|
||||
});
|
||||
|
||||
A(output, "enabledWasmLoadingTypes", () => {
|
||||
|
|
@ -1370,7 +1370,7 @@ const applyOutputDefaults = (
|
|||
enabledWasmLoadingTypes.add(desc.wasmLoading);
|
||||
}
|
||||
});
|
||||
return Array.from(enabledWasmLoadingTypes);
|
||||
return [...enabledWasmLoadingTypes];
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -1746,7 +1746,7 @@ const applyInfrastructureLoggingDefaults = infrastructureLogging => {
|
|||
D(infrastructureLogging, "appendOnly", !tty);
|
||||
};
|
||||
|
||||
module.exports.DEFAULTS = DEFAULTS;
|
||||
module.exports.applyWebpackOptionsBaseDefaults =
|
||||
applyWebpackOptionsBaseDefaults;
|
||||
module.exports.applyWebpackOptionsDefaults = applyWebpackOptionsDefaults;
|
||||
module.exports.DEFAULTS = DEFAULTS;
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { ReplaceSource, RawSource, ConcatSource } = require("webpack-sources");
|
||||
const { ConcatSource, RawSource, ReplaceSource } = require("webpack-sources");
|
||||
const { UsageState } = require("../ExportsInfo");
|
||||
const Generator = require("../Generator");
|
||||
const InitFragment = require("../InitFragment");
|
||||
const {
|
||||
CSS_TYPE,
|
||||
CSS_TYPES,
|
||||
JS_AND_CSS_EXPORT_TYPES,
|
||||
JS_AND_CSS_TYPES,
|
||||
CSS_TYPES,
|
||||
JS_TYPE,
|
||||
CSS_TYPE
|
||||
JS_TYPE
|
||||
} = require("../ModuleSourceTypesConstants");
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
const Template = require("../Template");
|
||||
|
|
@ -292,7 +292,7 @@ class CssGenerator extends Generator {
|
|||
}
|
||||
const exports = cssData.exports;
|
||||
const stringifiedExports = JSON.stringify(
|
||||
Array.from(exports).reduce((obj, [key, value]) => {
|
||||
[...exports].reduce((obj, [key, value]) => {
|
||||
obj[key] = value;
|
||||
return obj;
|
||||
}, /** @type {Record<string, string>} */ ({}))
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { SyncWaterfallHook, SyncHook } = require("tapable");
|
||||
const { SyncHook, SyncWaterfallHook } = require("tapable");
|
||||
const {
|
||||
CachedSource,
|
||||
ConcatSource,
|
||||
PrefixSource,
|
||||
ReplaceSource,
|
||||
CachedSource,
|
||||
RawSource
|
||||
RawSource,
|
||||
ReplaceSource
|
||||
} = require("webpack-sources");
|
||||
const Compilation = require("../Compilation");
|
||||
const CssModule = require("../CssModule");
|
||||
|
|
@ -19,9 +19,9 @@ const { tryRunOrWebpackError } = require("../HookWebpackError");
|
|||
const HotUpdateChunk = require("../HotUpdateChunk");
|
||||
const {
|
||||
CSS_MODULE_TYPE,
|
||||
CSS_MODULE_TYPE_AUTO,
|
||||
CSS_MODULE_TYPE_GLOBAL,
|
||||
CSS_MODULE_TYPE_MODULE,
|
||||
CSS_MODULE_TYPE_AUTO
|
||||
CSS_MODULE_TYPE_MODULE
|
||||
} = require("../ModuleTypeConstants");
|
||||
const NormalModule = require("../NormalModule");
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
|
|
@ -393,7 +393,7 @@ class CssModulesPlugin {
|
|||
const exports = cssData.exports;
|
||||
const stringifiedExports = JSON.stringify(
|
||||
JSON.stringify(
|
||||
Array.from(exports).reduce((obj, [key, value]) => {
|
||||
[...exports].reduce((obj, [key, value]) => {
|
||||
obj[key] = value;
|
||||
return obj;
|
||||
}, /** @type {Record<string, string>} */ ({}))
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ const StaticExportsDependency = require("../dependencies/StaticExportsDependency
|
|||
const binarySearchBounds = require("../util/binarySearchBounds");
|
||||
const { parseResource } = require("../util/identifier");
|
||||
const {
|
||||
webpackCommentRegExp,
|
||||
createMagicCommentContext
|
||||
createMagicCommentContext,
|
||||
webpackCommentRegExp
|
||||
} = require("../util/magicComment");
|
||||
const walkCssTokens = require("./walkCssTokens");
|
||||
|
||||
|
|
|
|||
|
|
@ -1196,14 +1196,12 @@ module.exports = (input, pos = 0, callbacks = {}) => {
|
|||
return pos;
|
||||
};
|
||||
|
||||
module.exports.isIdentStartCodePoint = isIdentStartCodePoint;
|
||||
|
||||
/**
|
||||
* @param {string} input input
|
||||
* @param {number} pos position
|
||||
* @returns {number} position after comments
|
||||
*/
|
||||
module.exports.eatComments = (input, pos) => {
|
||||
const eatComments = (input, pos) => {
|
||||
for (;;) {
|
||||
const originalPos = pos;
|
||||
pos = consumeComments(input, pos, {});
|
||||
|
|
@ -1220,7 +1218,7 @@ module.exports.eatComments = (input, pos) => {
|
|||
* @param {number} pos position
|
||||
* @returns {number} position after whitespace
|
||||
*/
|
||||
module.exports.eatWhitespace = (input, pos) => {
|
||||
const eatWhitespace = (input, pos) => {
|
||||
while (_isWhiteSpace(input.charCodeAt(pos))) {
|
||||
pos++;
|
||||
}
|
||||
|
|
@ -1233,7 +1231,7 @@ module.exports.eatWhitespace = (input, pos) => {
|
|||
* @param {number} pos position
|
||||
* @returns {number} position after whitespace and comments
|
||||
*/
|
||||
module.exports.eatWhitespaceAndComments = (input, pos) => {
|
||||
const eatWhitespaceAndComments = (input, pos) => {
|
||||
for (;;) {
|
||||
const originalPos = pos;
|
||||
pos = consumeComments(input, pos, {});
|
||||
|
|
@ -1248,29 +1246,12 @@ module.exports.eatWhitespaceAndComments = (input, pos) => {
|
|||
return pos;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} input input
|
||||
* @param {number} pos position
|
||||
* @returns {number} position after whitespace and comments
|
||||
*/
|
||||
module.exports.eatComments = (input, pos) => {
|
||||
for (;;) {
|
||||
const originalPos = pos;
|
||||
pos = consumeComments(input, pos, {});
|
||||
if (originalPos === pos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} input input
|
||||
* @param {number} pos position
|
||||
* @returns {number} position after whitespace
|
||||
*/
|
||||
module.exports.eatWhiteLine = (input, pos) => {
|
||||
const eatWhiteLine = (input, pos) => {
|
||||
for (;;) {
|
||||
const cc = input.charCodeAt(pos);
|
||||
if (_isSpace(cc)) {
|
||||
|
|
@ -1290,8 +1271,8 @@ module.exports.eatWhiteLine = (input, pos) => {
|
|||
* @param {number} pos position
|
||||
* @returns {[number, number] | undefined} positions of ident sequence
|
||||
*/
|
||||
module.exports.skipCommentsAndEatIdentSequence = (input, pos) => {
|
||||
pos = module.exports.eatComments(input, pos);
|
||||
const skipCommentsAndEatIdentSequence = (input, pos) => {
|
||||
pos = eatComments(input, pos);
|
||||
|
||||
const start = pos;
|
||||
|
||||
|
|
@ -1315,8 +1296,8 @@ module.exports.skipCommentsAndEatIdentSequence = (input, pos) => {
|
|||
* @param {number} pos position
|
||||
* @returns {[number, number] | undefined} positions of ident sequence
|
||||
*/
|
||||
module.exports.eatString = (input, pos) => {
|
||||
pos = module.exports.eatWhitespaceAndComments(input, pos);
|
||||
const eatString = (input, pos) => {
|
||||
pos = eatWhitespaceAndComments(input, pos);
|
||||
|
||||
const start = pos;
|
||||
|
||||
|
|
@ -1336,7 +1317,7 @@ module.exports.eatString = (input, pos) => {
|
|||
* @param {CssTokenCallbacks} cbs callbacks
|
||||
* @returns {[number, number][]} positions of ident sequence
|
||||
*/
|
||||
module.exports.eatImageSetStrings = (input, pos, cbs) => {
|
||||
const eatImageSetStrings = (input, pos, cbs) => {
|
||||
/** @type {[number, number][]} */
|
||||
const result = [];
|
||||
|
||||
|
|
@ -1406,7 +1387,7 @@ module.exports.eatImageSetStrings = (input, pos, cbs) => {
|
|||
* @param {CssTokenCallbacks} cbs callbacks
|
||||
* @returns {[[number, number, number, number] | undefined, [number, number] | undefined, [number, number] | undefined, [number, number] | undefined]} positions of top level tokens
|
||||
*/
|
||||
module.exports.eatImportTokens = (input, pos, cbs) => {
|
||||
const eatImportTokens = (input, pos, cbs) => {
|
||||
const result =
|
||||
/** @type {[[number, number, number, number] | undefined, [number, number] | undefined, [number, number] | undefined, [number, number] | undefined]} */
|
||||
(Array.from({ length: 4 }));
|
||||
|
|
@ -1548,8 +1529,8 @@ module.exports.eatImportTokens = (input, pos, cbs) => {
|
|||
* @param {number} pos position
|
||||
* @returns {[number, number] | undefined} positions of ident sequence
|
||||
*/
|
||||
module.exports.eatIdentSequence = (input, pos) => {
|
||||
pos = module.exports.eatWhitespaceAndComments(input, pos);
|
||||
const eatIdentSequence = (input, pos) => {
|
||||
pos = eatWhitespaceAndComments(input, pos);
|
||||
|
||||
const start = pos;
|
||||
|
||||
|
|
@ -1573,8 +1554,8 @@ module.exports.eatIdentSequence = (input, pos) => {
|
|||
* @param {number} pos position
|
||||
* @returns {[number, number, boolean] | undefined} positions of ident sequence or string
|
||||
*/
|
||||
module.exports.eatIdentSequenceOrString = (input, pos) => {
|
||||
pos = module.exports.eatWhitespaceAndComments(input, pos);
|
||||
const eatIdentSequenceOrString = (input, pos) => {
|
||||
pos = eatWhitespaceAndComments(input, pos);
|
||||
|
||||
const start = pos;
|
||||
|
||||
|
|
@ -1602,7 +1583,7 @@ module.exports.eatIdentSequenceOrString = (input, pos) => {
|
|||
* @param {string} chars characters
|
||||
* @returns {(input: string, pos: number) => number} function to eat characters
|
||||
*/
|
||||
module.exports.eatUntil = chars => {
|
||||
const eatUntil = chars => {
|
||||
const charCodes = Array.from({ length: chars.length }, (_, i) =>
|
||||
chars.charCodeAt(i)
|
||||
);
|
||||
|
|
@ -1625,3 +1606,17 @@ module.exports.eatUntil = chars => {
|
|||
}
|
||||
};
|
||||
};
|
||||
|
||||
module.exports.eatComments = eatComments;
|
||||
module.exports.eatIdentSequence = eatIdentSequence;
|
||||
module.exports.eatIdentSequenceOrString = eatIdentSequenceOrString;
|
||||
module.exports.eatImageSetStrings = eatImageSetStrings;
|
||||
module.exports.eatImportTokens = eatImportTokens;
|
||||
module.exports.eatString = eatString;
|
||||
module.exports.eatUntil = eatUntil;
|
||||
module.exports.eatWhiteLine = eatWhiteLine;
|
||||
module.exports.eatWhitespace = eatWhitespace;
|
||||
module.exports.eatWhitespaceAndComments = eatWhitespaceAndComments;
|
||||
module.exports.isIdentStartCodePoint = isIdentStartCodePoint;
|
||||
module.exports.skipCommentsAndEatIdentSequence =
|
||||
skipCommentsAndEatIdentSequence;
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
const { Tracer } = require("chrome-trace-event");
|
||||
const {
|
||||
JAVASCRIPT_MODULES,
|
||||
CSS_MODULES,
|
||||
WEBASSEMBLY_MODULES,
|
||||
JSON_MODULE_TYPE
|
||||
JAVASCRIPT_MODULES,
|
||||
JSON_MODULE_TYPE,
|
||||
WEBASSEMBLY_MODULES
|
||||
} = require("../ModuleTypeConstants");
|
||||
const createSchemaValidation = require("../util/create-schema-validation");
|
||||
const { dirname, mkdirpSync } = require("../util/fs");
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|||
processExportInfo(
|
||||
runtime,
|
||||
referencedExports,
|
||||
ids.concat(exportInfo.name),
|
||||
[...ids, exportInfo.name],
|
||||
exportInfo,
|
||||
false
|
||||
);
|
||||
|
|
@ -193,7 +193,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|||
name => ({
|
||||
name,
|
||||
from,
|
||||
export: ids.concat(name),
|
||||
export: [...ids, name],
|
||||
canMangle: !(name in EMPTY_OBJECT) && false
|
||||
})
|
||||
),
|
||||
|
|
|
|||
|
|
@ -5,12 +5,23 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
||||
} = require("../ModuleTypeConstants");
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
const RuntimeModule = require("../RuntimeModule");
|
||||
const SelfModuleFactory = require("../SelfModuleFactory");
|
||||
const Template = require("../Template");
|
||||
const {
|
||||
evaluateToIdentifier,
|
||||
toConstantDependency
|
||||
} = require("../javascript/JavascriptParserHelpers");
|
||||
const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency");
|
||||
const CommonJsExportsDependency = require("./CommonJsExportsDependency");
|
||||
const CommonJsExportsParserPlugin = require("./CommonJsExportsParserPlugin");
|
||||
const CommonJsFullRequireDependency = require("./CommonJsFullRequireDependency");
|
||||
const CommonJsImportsParserPlugin = require("./CommonJsImportsParserPlugin");
|
||||
const CommonJsRequireContextDependency = require("./CommonJsRequireContextDependency");
|
||||
const CommonJsRequireDependency = require("./CommonJsRequireDependency");
|
||||
const CommonJsSelfReferenceDependency = require("./CommonJsSelfReferenceDependency");
|
||||
|
|
@ -21,19 +32,6 @@ const RequireResolveDependency = require("./RequireResolveDependency");
|
|||
const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency");
|
||||
const RuntimeRequirementsDependency = require("./RuntimeRequirementsDependency");
|
||||
|
||||
const CommonJsExportsParserPlugin = require("./CommonJsExportsParserPlugin");
|
||||
const CommonJsImportsParserPlugin = require("./CommonJsImportsParserPlugin");
|
||||
|
||||
const {
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
||||
} = require("../ModuleTypeConstants");
|
||||
const {
|
||||
evaluateToIdentifier,
|
||||
toConstantDependency
|
||||
} = require("../javascript/JavascriptParserHelpers");
|
||||
const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|||
.filter(Boolean)
|
||||
);
|
||||
|
||||
for (const used of usedNames.concat(names)) {
|
||||
for (const used of [...usedNames, ...names]) {
|
||||
cssData.exports.set(used, dep.value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ CssLocalIdentifierDependency.Template = class CssLocalIdentifierDependencyTempla
|
|||
(generator.convention)
|
||||
);
|
||||
const usedNames =
|
||||
/** @type {(string)[]} */
|
||||
/** @type {string[]} */
|
||||
(
|
||||
names
|
||||
.map(name =>
|
||||
|
|
@ -239,7 +239,7 @@ CssLocalIdentifierDependency.Template = class CssLocalIdentifierDependencyTempla
|
|||
|
||||
source.replace(dep.range[0], dep.range[1] - 1, identifier);
|
||||
|
||||
for (const used of usedNames.concat(names)) {
|
||||
for (const used of [...usedNames, ...names]) {
|
||||
cssData.exports.set(used, getCssParser().unescapeIdentifier(identifier));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,14 +42,11 @@ module.exports.enable = parserState => {
|
|||
|
||||
/**
|
||||
* @param {ParserState} parserState parser state
|
||||
* @returns {void}
|
||||
* @returns {boolean} true, when enabled
|
||||
*/
|
||||
module.exports.setFlagged = parserState => {
|
||||
module.exports.isEnabled = parserState => {
|
||||
const value = parserStateExportsState.get(parserState);
|
||||
if (value !== true) return;
|
||||
const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
|
||||
if (buildMeta.exportsType === "dynamic") return;
|
||||
buildMeta.exportsType = "flagged";
|
||||
return value === true;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -65,9 +62,12 @@ module.exports.setDynamic = parserState => {
|
|||
|
||||
/**
|
||||
* @param {ParserState} parserState parser state
|
||||
* @returns {boolean} true, when enabled
|
||||
* @returns {void}
|
||||
*/
|
||||
module.exports.isEnabled = parserState => {
|
||||
module.exports.setFlagged = parserState => {
|
||||
const value = parserStateExportsState.get(parserState);
|
||||
return value === true;
|
||||
if (value !== true) return;
|
||||
const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
|
||||
if (buildMeta.exportsType === "dynamic") return;
|
||||
buildMeta.exportsType = "flagged";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ const getProperty = (moduleGraph, module, _exportName, property, runtime) => {
|
|||
) {
|
||||
return usedExports;
|
||||
}
|
||||
return Array.from(usedExports).sort();
|
||||
return [...usedExports].sort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImporte
|
|||
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
|
||||
const { ExportPresenceModes } = require("./HarmonyImportDependency");
|
||||
const {
|
||||
harmonySpecifierTag,
|
||||
getImportMode
|
||||
getImportMode,
|
||||
harmonySpecifierTag
|
||||
} = require("./HarmonyImportDependencyParserPlugin");
|
||||
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
|
||||
|
||||
|
|
@ -198,6 +198,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
(statement, source, id, name, idx) => {
|
||||
const harmonyNamedExports = (parser.state.harmonyNamedExports =
|
||||
parser.state.harmonyNamedExports || new Set());
|
||||
/** @type {InstanceType<HarmonyStarExportsList> | null} */
|
||||
let harmonyStarExports = null;
|
||||
if (name) {
|
||||
harmonyNamedExports.add(name);
|
||||
|
|
@ -213,11 +214,13 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
false
|
||||
);
|
||||
const dep = new HarmonyExportImportedSpecifierDependency(
|
||||
/** @type {string} */ (source),
|
||||
/** @type {string} */
|
||||
(source),
|
||||
parser.state.lastHarmonyImportOrder,
|
||||
id ? [id] : [],
|
||||
name,
|
||||
harmonyNamedExports,
|
||||
// eslint-disable-next-line unicorn/prefer-spread
|
||||
harmonyStarExports && harmonyStarExports.slice(),
|
||||
exportPresenceMode,
|
||||
harmonyStarExports,
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ const {
|
|||
getMakeDeferredNamespaceModeFromExportsType
|
||||
} = require("../runtime/MakeDeferredNamespaceObjectRuntime");
|
||||
const { countIterable } = require("../util/IterableHelpers");
|
||||
const { first, combine } = require("../util/SetHelpers");
|
||||
const { combine, first } = require("../util/SetHelpers");
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const propertyAccess = require("../util/propertyAccess");
|
||||
const { propertyName } = require("../util/propertyName");
|
||||
const {
|
||||
filterRuntime,
|
||||
getRuntimeKey,
|
||||
keyToRuntime,
|
||||
filterRuntime
|
||||
keyToRuntime
|
||||
} = require("../util/runtime");
|
||||
const HarmonyExportInitFragment = require("./HarmonyExportInitFragment");
|
||||
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
||||
|
|
@ -133,12 +133,13 @@ const determineExportAssignments = (
|
|||
dependencies,
|
||||
additionalDependency
|
||||
) => {
|
||||
/** @type {Set<string>} */
|
||||
const names = new Set();
|
||||
/** @type {number[]} */
|
||||
const dependencyIndices = [];
|
||||
|
||||
if (additionalDependency) {
|
||||
dependencies = dependencies.concat(additionalDependency);
|
||||
dependencies = [...dependencies, additionalDependency];
|
||||
}
|
||||
|
||||
for (const dep of dependencies) {
|
||||
|
|
@ -161,7 +162,7 @@ const determineExportAssignments = (
|
|||
}
|
||||
dependencyIndices.push(names.size);
|
||||
|
||||
return { names: Array.from(names), dependencyIndices };
|
||||
return { names: [...names], dependencyIndices };
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1245,9 +1246,9 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|||
// Filter out exports which are defined by other exports
|
||||
// and filter out default export because it cannot be reexported with *
|
||||
if (ignored.size > 1) {
|
||||
content += `if(${JSON.stringify(
|
||||
Array.from(ignored)
|
||||
)}.indexOf(__WEBPACK_IMPORT_KEY__) < 0) `;
|
||||
content += `if(${JSON.stringify([
|
||||
...ignored
|
||||
])}.indexOf(__WEBPACK_IMPORT_KEY__) < 0) `;
|
||||
} else if (ignored.size === 1) {
|
||||
content += `if(__WEBPACK_IMPORT_KEY__ !== ${JSON.stringify(
|
||||
first(ignored)
|
||||
|
|
@ -1458,7 +1459,7 @@ class HarmonyStarExportsList {
|
|||
}
|
||||
|
||||
slice() {
|
||||
return this.dependencies.slice();
|
||||
return [...this.dependencies];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ class HarmonyExportInitFragment extends InitFragment {
|
|||
? `/* unused harmony export ${first(this.unusedExports)} */\n`
|
||||
: "";
|
||||
const definitions = [];
|
||||
const orderedExportMap = Array.from(this.exportMap).sort(([a], [b]) =>
|
||||
const orderedExportMap = [...this.exportMap].sort(([a], [b]) =>
|
||||
a < b ? -1 : 1
|
||||
);
|
||||
for (const [key, value] of orderedExportMap) {
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|||
|
||||
const leftPartEvaluated = parser.evaluateExpression(expression.left);
|
||||
if (leftPartEvaluated.couldHaveSideEffects()) return;
|
||||
/** @type {string | undefined} */
|
||||
const leftPart = leftPartEvaluated.asString();
|
||||
if (!leftPart) return;
|
||||
|
||||
|
|
@ -193,14 +194,16 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|||
) {
|
||||
return;
|
||||
}
|
||||
const settings = /** @type {TagData} */ (rootInfo.tagInfo.data);
|
||||
const settings =
|
||||
/** @type {TagData} */
|
||||
(rootInfo.tagInfo.data);
|
||||
const members =
|
||||
/** @type {(() => string[])} */
|
||||
(rightPart.getMembers)();
|
||||
const dep = new HarmonyEvaluatedImportSpecifierDependency(
|
||||
settings.source,
|
||||
settings.sourceOrder,
|
||||
settings.ids.concat(members).concat([leftPart]),
|
||||
[...settings.ids, ...members, leftPart],
|
||||
settings.name,
|
||||
/** @type {Range} */ (expression.range),
|
||||
settings.attributes,
|
||||
|
|
@ -264,7 +267,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|||
members.length - nonOptionalMembers.length
|
||||
)
|
||||
: expression;
|
||||
const ids = settings.ids.concat(nonOptionalMembers);
|
||||
const ids = [...settings.ids, ...nonOptionalMembers];
|
||||
const dep = new HarmonyImportSpecifierDependency(
|
||||
settings.source,
|
||||
settings.sourceOrder,
|
||||
|
|
@ -315,7 +318,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|||
members.length - nonOptionalMembers.length
|
||||
)
|
||||
: callee;
|
||||
const ids = settings.ids.concat(nonOptionalMembers);
|
||||
const ids = [...settings.ids, ...nonOptionalMembers];
|
||||
const dep = new HarmonyImportSpecifierDependency(
|
||||
settings.source,
|
||||
settings.sourceOrder,
|
||||
|
|
@ -444,5 +447,5 @@ function getImportMode(parser, node, deferImportEnabled, reportSyntaxError) {
|
|||
return result;
|
||||
}
|
||||
|
||||
module.exports.harmonySpecifierTag = harmonySpecifierTag;
|
||||
module.exports.getImportMode = getImportMode;
|
||||
module.exports.harmonySpecifierTag = harmonySpecifierTag;
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|||
/** @type {string[][]} */
|
||||
const refs = [];
|
||||
for (const { id } of this.referencedPropertiesInDestructuring) {
|
||||
refs.push(ids ? ids.concat([id]) : [id]);
|
||||
refs.push(ids ? [...ids, id] : [id]);
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
|
|
@ -381,7 +381,8 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|||
shorthand,
|
||||
range
|
||||
} of dep.referencedPropertiesInDestructuring) {
|
||||
const concatedIds = prefixedIds.concat([id]);
|
||||
/** @type {string[]} */
|
||||
const concatedIds = [...prefixedIds, id];
|
||||
const module = /** @type {Module} */ (moduleGraph.getModule(dep));
|
||||
const used = moduleGraph
|
||||
.getExportsInfo(module)
|
||||
|
|
|
|||
|
|
@ -5,24 +5,24 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const HarmonyAcceptDependency = require("./HarmonyAcceptDependency");
|
||||
const HarmonyAcceptImportDependency = require("./HarmonyAcceptImportDependency");
|
||||
const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency");
|
||||
const HarmonyEvaluatedImportSpecifierDependency = require("./HarmonyEvaluatedImportSpecifierDependency");
|
||||
const HarmonyExportExpressionDependency = require("./HarmonyExportExpressionDependency");
|
||||
const HarmonyExportHeaderDependency = require("./HarmonyExportHeaderDependency");
|
||||
const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImportedSpecifierDependency");
|
||||
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
|
||||
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
|
||||
const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
|
||||
|
||||
const {
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_ESM
|
||||
} = require("../ModuleTypeConstants");
|
||||
const HarmonyAcceptDependency = require("./HarmonyAcceptDependency");
|
||||
const HarmonyAcceptImportDependency = require("./HarmonyAcceptImportDependency");
|
||||
const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency");
|
||||
const HarmonyDetectionParserPlugin = require("./HarmonyDetectionParserPlugin");
|
||||
const HarmonyEvaluatedImportSpecifierDependency = require("./HarmonyEvaluatedImportSpecifierDependency");
|
||||
const HarmonyExportDependencyParserPlugin = require("./HarmonyExportDependencyParserPlugin");
|
||||
const HarmonyExportExpressionDependency = require("./HarmonyExportExpressionDependency");
|
||||
const HarmonyExportHeaderDependency = require("./HarmonyExportHeaderDependency");
|
||||
const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImportedSpecifierDependency");
|
||||
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
|
||||
const HarmonyImportDependencyParserPlugin = require("./HarmonyImportDependencyParserPlugin");
|
||||
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
|
||||
const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
|
||||
|
||||
const HarmonyTopLevelThisParserPlugin = require("./HarmonyTopLevelThisParserPlugin");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ const Template = require("../Template");
|
|||
const BasicEvaluatedExpression = require("../javascript/BasicEvaluatedExpression");
|
||||
const {
|
||||
evaluateToIdentifier,
|
||||
toConstantDependency,
|
||||
evaluateToNumber,
|
||||
evaluateToString,
|
||||
evaluateToNumber
|
||||
toConstantDependency
|
||||
} = require("../javascript/JavascriptParserHelpers");
|
||||
const memoize = require("../util/memoize");
|
||||
const propertyAccess = require("../util/propertyAccess");
|
||||
|
|
|
|||
|
|
@ -5,11 +5,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const RequireEnsureDependency = require("./RequireEnsureDependency");
|
||||
const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
|
||||
|
||||
const RequireEnsureDependenciesBlockParserPlugin = require("./RequireEnsureDependenciesBlockParserPlugin");
|
||||
|
||||
const {
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
||||
|
|
@ -18,6 +13,9 @@ const {
|
|||
evaluateToString,
|
||||
toConstantDependency
|
||||
} = require("../javascript/JavascriptParserHelpers");
|
||||
const RequireEnsureDependenciesBlockParserPlugin = require("./RequireEnsureDependenciesBlockParserPlugin");
|
||||
const RequireEnsureDependency = require("./RequireEnsureDependency");
|
||||
const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class RuntimeRequirementsDependency extends NullDependency {
|
|||
*/
|
||||
updateHash(hash, context) {
|
||||
if (this._hashUpdate === undefined) {
|
||||
this._hashUpdate = `${Array.from(this.runtimeRequirements).join()}`;
|
||||
this._hashUpdate = `${[...this.runtimeRequirements].join()}`;
|
||||
}
|
||||
hash.update(this._hashUpdate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ const processExportInfo = (
|
|||
referencedExports,
|
||||
defaultPointsToSelf && exportInfo.name === "default"
|
||||
? prefix
|
||||
: prefix.concat(exportInfo.name),
|
||||
: [...prefix, exportInfo.name],
|
||||
exportInfo,
|
||||
false,
|
||||
alreadyVisited
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
"use strict";
|
||||
|
||||
const { ConcatSource } = require("webpack-sources");
|
||||
const { RuntimeGlobals, HotUpdateChunk } = require("..");
|
||||
const { HotUpdateChunk, RuntimeGlobals } = require("..");
|
||||
const Template = require("../Template");
|
||||
const { getAllChunks } = require("../javascript/ChunkHelpers");
|
||||
const {
|
||||
chunkHasJs,
|
||||
getCompilationHooks,
|
||||
getChunkFilenameTemplate
|
||||
getChunkFilenameTemplate,
|
||||
getCompilationHooks
|
||||
} = require("../javascript/JavascriptModulesPlugin");
|
||||
const { updateHashForEntryStartup } = require("../javascript/StartupHelpers");
|
||||
const { getUndoPath } = require("../util/identifier");
|
||||
|
|
@ -34,9 +34,9 @@ const { getUndoPath } = require("../util/identifier");
|
|||
* @returns {{entries: Array<[Module, Entrypoint | undefined]>, runtimeChunk: Chunk|null}} Object containing chunk entries and runtime chunk
|
||||
*/
|
||||
function getChunkInfo(chunk, chunkGraph) {
|
||||
const entries = Array.from(
|
||||
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
||||
);
|
||||
const entries = [
|
||||
...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
||||
];
|
||||
const runtimeChunk =
|
||||
entries.length > 0
|
||||
? /** @type {Entrypoint[][]} */
|
||||
|
|
@ -66,7 +66,7 @@ const getRelativePath = (compilation, chunk, runtimeChunk) => {
|
|||
)
|
||||
.replace(/^\/+/g, "")
|
||||
.split("/");
|
||||
const baseOutputName = currentOutputName.slice();
|
||||
const baseOutputName = [...currentOutputName];
|
||||
const chunkOutputName = compilation
|
||||
.getPath(getChunkFilenameTemplate(chunk, compilation.outputOptions), {
|
||||
chunk,
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ const {
|
|||
generateJavascriptHMR
|
||||
} = require("../hmr/JavascriptHotModuleReplacementHelper");
|
||||
const {
|
||||
getChunkFilenameTemplate,
|
||||
chunkHasJs
|
||||
chunkHasJs,
|
||||
getChunkFilenameTemplate
|
||||
} = require("../javascript/JavascriptModulesPlugin");
|
||||
const { getInitialChunkIds } = require("../javascript/StartupHelpers");
|
||||
const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@
|
|||
|
||||
const { find } = require("../util/SetHelpers");
|
||||
const {
|
||||
compareModulesByPreOrderIndexOrIdentifier,
|
||||
compareModulesByPostOrderIndexOrIdentifier
|
||||
compareModulesByPostOrderIndexOrIdentifier,
|
||||
compareModulesByPreOrderIndexOrIdentifier
|
||||
} = require("../util/comparators");
|
||||
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
|
||||
/**
|
||||
* @typedef {object} ChunkModuleIdRangePluginOptions
|
||||
|
|
@ -52,6 +53,7 @@ class ChunkModuleIdRangePlugin {
|
|||
);
|
||||
}
|
||||
|
||||
/** @type {Module[]} */
|
||||
let chunkModules;
|
||||
if (options.order) {
|
||||
let cmpFn;
|
||||
|
|
@ -69,7 +71,7 @@ class ChunkModuleIdRangePlugin {
|
|||
}
|
||||
chunkModules = chunkGraph.getOrderedChunkModules(chunk, cmpFn);
|
||||
} else {
|
||||
chunkModules = Array.from(modules)
|
||||
chunkModules = [...modules]
|
||||
.filter(m => chunkGraph.isModuleInChunk(m, chunk))
|
||||
.sort(compareModulesByPreOrderIndexOrIdentifier(moduleGraph));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
const { compareChunksNatural } = require("../util/comparators");
|
||||
const {
|
||||
assignDeterministicIds,
|
||||
getFullChunkName,
|
||||
getUsedChunkIds,
|
||||
assignDeterministicIds
|
||||
getUsedChunkIds
|
||||
} = require("./IdHelpers");
|
||||
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
|
|
@ -49,7 +49,7 @@ class DeterministicChunkIdsPlugin {
|
|||
|
||||
const usedIds = getUsedChunkIds(compilation);
|
||||
assignDeterministicIds(
|
||||
Array.from(chunks).filter(chunk => chunk.id === null),
|
||||
[...chunks].filter(chunk => chunk.id === null),
|
||||
chunk => getFullChunkName(chunk, chunkGraph, context, compiler.root),
|
||||
compareNatural,
|
||||
(chunk, id) => {
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ const {
|
|||
compareModulesByPreOrderIndexOrIdentifier
|
||||
} = require("../util/comparators");
|
||||
const {
|
||||
getUsedModuleIdsAndModules,
|
||||
assignDeterministicIds,
|
||||
getFullModuleName,
|
||||
assignDeterministicIds
|
||||
getUsedModuleIdsAndModules
|
||||
} = require("./IdHelpers");
|
||||
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ const {
|
|||
const createSchemaValidation = require("../util/create-schema-validation");
|
||||
const createHash = require("../util/createHash");
|
||||
const {
|
||||
getUsedModuleIdsAndModules,
|
||||
getFullModuleName
|
||||
getFullModuleName,
|
||||
getUsedModuleIdsAndModules
|
||||
} = require("./IdHelpers");
|
||||
|
||||
/** @typedef {import("../../declarations/plugins/HashedModuleIdsPlugin").HashedModuleIdsPluginOptions} HashedModuleIdsPluginOptions */
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ const avoidNumber = str => {
|
|||
const requestToId = request =>
|
||||
request.replace(/^(\.\.?\/)+/, "").replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_");
|
||||
|
||||
module.exports.requestToId = requestToId;
|
||||
|
||||
/**
|
||||
* @param {string} string the string
|
||||
* @param {string} delimiter separator for string and hash
|
||||
|
|
@ -92,8 +90,6 @@ const getShortModuleName = (module, context, associatedObjectForCache) => {
|
|||
return "";
|
||||
};
|
||||
|
||||
module.exports.getShortModuleName = getShortModuleName;
|
||||
|
||||
/**
|
||||
* @param {string} shortName the short name
|
||||
* @param {Module} module the module
|
||||
|
|
@ -113,8 +109,6 @@ const getLongModuleName = (
|
|||
return `${shortName}?${getHash(fullName, 4, hashFunction)}`;
|
||||
};
|
||||
|
||||
module.exports.getLongModuleName = getLongModuleName;
|
||||
|
||||
/**
|
||||
* @param {Module} module the module
|
||||
* @param {string} context context directory
|
||||
|
|
@ -124,8 +118,6 @@ module.exports.getLongModuleName = getLongModuleName;
|
|||
const getFullModuleName = (module, context, associatedObjectForCache) =>
|
||||
makePathsRelative(context, module.identifier(), associatedObjectForCache);
|
||||
|
||||
module.exports.getFullModuleName = getFullModuleName;
|
||||
|
||||
/**
|
||||
* @param {Chunk} chunk the chunk
|
||||
* @param {ChunkGraph} chunkGraph the chunk graph
|
||||
|
|
@ -148,15 +140,12 @@ const getShortChunkName = (
|
|||
requestToId(getShortModuleName(m, context, associatedObjectForCache))
|
||||
);
|
||||
chunk.idNameHints.sort();
|
||||
const chunkName = Array.from(chunk.idNameHints)
|
||||
.concat(shortModuleNames)
|
||||
const chunkName = [...chunk.idNameHints, ...shortModuleNames]
|
||||
.filter(Boolean)
|
||||
.join(delimiter);
|
||||
return shortenLongString(chunkName, delimiter, hashFunction);
|
||||
};
|
||||
|
||||
module.exports.getShortChunkName = getShortChunkName;
|
||||
|
||||
/**
|
||||
* @param {Chunk} chunk the chunk
|
||||
* @param {ChunkGraph} chunkGraph the chunk graph
|
||||
|
|
@ -184,15 +173,16 @@ const getLongChunkName = (
|
|||
)
|
||||
);
|
||||
chunk.idNameHints.sort();
|
||||
const chunkName = Array.from(chunk.idNameHints)
|
||||
.concat(shortModuleNames, longModuleNames)
|
||||
const chunkName = [
|
||||
...chunk.idNameHints,
|
||||
...shortModuleNames,
|
||||
...longModuleNames
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(delimiter);
|
||||
return shortenLongString(chunkName, delimiter, hashFunction);
|
||||
};
|
||||
|
||||
module.exports.getLongChunkName = getLongChunkName;
|
||||
|
||||
/**
|
||||
* @param {Chunk} chunk the chunk
|
||||
* @param {ChunkGraph} chunkGraph the chunk graph
|
||||
|
|
@ -214,8 +204,6 @@ const getFullChunkName = (
|
|||
return fullModuleNames.join();
|
||||
};
|
||||
|
||||
module.exports.getFullChunkName = getFullChunkName;
|
||||
|
||||
/**
|
||||
* @template K
|
||||
* @template V
|
||||
|
|
@ -267,8 +255,6 @@ const getUsedModuleIdsAndModules = (compilation, filter) => {
|
|||
return [usedIds, modules];
|
||||
};
|
||||
|
||||
module.exports.getUsedModuleIdsAndModules = getUsedModuleIdsAndModules;
|
||||
|
||||
/**
|
||||
* @param {Compilation} compilation the compilation
|
||||
* @returns {Set<string>} used chunk ids as strings
|
||||
|
|
@ -292,8 +278,6 @@ const getUsedChunkIds = compilation => {
|
|||
return usedIds;
|
||||
};
|
||||
|
||||
module.exports.getUsedChunkIds = getUsedChunkIds;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {Iterable<T>} items list of items to be named
|
||||
|
|
@ -361,8 +345,6 @@ const assignNames = (
|
|||
return unnamedItems;
|
||||
};
|
||||
|
||||
module.exports.assignNames = assignNames;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {T[]} items list of items to be named
|
||||
|
|
@ -416,8 +398,6 @@ const assignDeterministicIds = (
|
|||
}
|
||||
};
|
||||
|
||||
module.exports.assignDeterministicIds = assignDeterministicIds;
|
||||
|
||||
/**
|
||||
* @param {Set<string>} usedIds used ids
|
||||
* @param {Iterable<Module>} modules the modules
|
||||
|
|
@ -454,8 +434,6 @@ const assignAscendingModuleIds = (usedIds, modules, compilation) => {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports.assignAscendingModuleIds = assignAscendingModuleIds;
|
||||
|
||||
/**
|
||||
* @param {Iterable<Chunk>} chunks the chunks
|
||||
* @param {Compilation} compilation the compilation
|
||||
|
|
@ -486,3 +464,15 @@ const assignAscendingChunkIds = (chunks, compilation) => {
|
|||
};
|
||||
|
||||
module.exports.assignAscendingChunkIds = assignAscendingChunkIds;
|
||||
module.exports.assignAscendingModuleIds = assignAscendingModuleIds;
|
||||
module.exports.assignDeterministicIds = assignDeterministicIds;
|
||||
module.exports.assignNames = assignNames;
|
||||
module.exports.getFullChunkName = getFullChunkName;
|
||||
module.exports.getFullModuleName = getFullModuleName;
|
||||
module.exports.getLongChunkName = getLongChunkName;
|
||||
module.exports.getLongModuleName = getLongModuleName;
|
||||
module.exports.getShortChunkName = getShortChunkName;
|
||||
module.exports.getShortModuleName = getShortModuleName;
|
||||
module.exports.getUsedChunkIds = getUsedChunkIds;
|
||||
module.exports.getUsedModuleIdsAndModules = getUsedModuleIdsAndModules;
|
||||
module.exports.requestToId = requestToId;
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
const { compareChunksNatural } = require("../util/comparators");
|
||||
const {
|
||||
getShortChunkName,
|
||||
getLongChunkName,
|
||||
assignAscendingChunkIds,
|
||||
assignNames,
|
||||
getUsedChunkIds,
|
||||
assignAscendingChunkIds
|
||||
getLongChunkName,
|
||||
getShortChunkName,
|
||||
getUsedChunkIds
|
||||
} = require("./IdHelpers");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} Output */
|
||||
|
|
@ -52,7 +52,7 @@ class NamedChunkIdsPlugin {
|
|||
const delimiter = this.delimiter;
|
||||
|
||||
const unnamedChunks = assignNames(
|
||||
Array.from(chunks).filter(chunk => {
|
||||
[...chunks].filter(chunk => {
|
||||
if (chunk.name) {
|
||||
chunk.id = chunk.name;
|
||||
chunk.ids = [chunk.name];
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
const { compareModulesByIdentifier } = require("../util/comparators");
|
||||
const {
|
||||
getShortModuleName,
|
||||
getLongModuleName,
|
||||
assignAscendingModuleIds,
|
||||
assignNames,
|
||||
getUsedModuleIdsAndModules,
|
||||
assignAscendingModuleIds
|
||||
getLongModuleName,
|
||||
getShortModuleName,
|
||||
getUsedModuleIdsAndModules
|
||||
} = require("./IdHelpers");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} Output */
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ class NaturalChunkIdsPlugin {
|
|||
compilation.hooks.chunkIds.tap(PLUGIN_NAME, chunks => {
|
||||
const chunkGraph = compilation.chunkGraph;
|
||||
const compareNatural = compareChunksNatural(chunkGraph);
|
||||
const chunksInNaturalOrder = Array.from(chunks).sort(compareNatural);
|
||||
/** @type {Chunk[]} */
|
||||
const chunksInNaturalOrder = [...chunks].sort(compareNatural);
|
||||
assignAscendingChunkIds(chunksInNaturalOrder, compilation);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ class OccurrenceChunkIdsPlugin {
|
|||
occursInInitialChunksMap.set(c, occurs);
|
||||
}
|
||||
|
||||
const chunksInOccurrenceOrder = Array.from(chunks).sort((a, b) => {
|
||||
/** @type {Chunk[]} */
|
||||
const chunksInOccurrenceOrder = [...chunks].sort((a, b) => {
|
||||
if (prioritiseInitial) {
|
||||
const aEntryOccurs =
|
||||
/** @type {number} */
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class SyncModuleIdsPlugin {
|
|||
if (!data || !dataChanged) return callback();
|
||||
/** @type {{[key: string]: string | number}} */
|
||||
const json = {};
|
||||
const sorted = Array.from(data).sort(([a], [b]) => (a < b ? -1 : 1));
|
||||
const sorted = [...data].sort(([a], [b]) => (a < b ? -1 : 1));
|
||||
for (const [key, value] of sorted) {
|
||||
json[key] = value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ const {
|
|||
} = require("./StartupHelpers");
|
||||
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
|
||||
|
||||
const PLUGIN_NAME = "ArrayPushCallbackChunkFormatPlugin";
|
||||
|
||||
|
|
@ -72,9 +73,10 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|||
);
|
||||
source.add(`${JSON.stringify(chunk.ids)},`);
|
||||
source.add(modules);
|
||||
const entries = Array.from(
|
||||
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
||||
);
|
||||
/** @type {EntryModuleWithChunkGroup[]} */
|
||||
const entries = [
|
||||
...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
||||
];
|
||||
if (runtimeModules.length > 0 || entries.length > 0) {
|
||||
const runtime = new ConcatSource(
|
||||
`${
|
||||
|
|
@ -134,9 +136,10 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|||
hash.update(
|
||||
`${PLUGIN_NAME}1${runtimeTemplate.outputOptions.chunkLoadingGlobal}${runtimeTemplate.outputOptions.hotUpdateGlobal}${runtimeTemplate.globalObject}`
|
||||
);
|
||||
const entries = Array.from(
|
||||
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
||||
);
|
||||
/** @type {EntryModuleWithChunkGroup[]} */
|
||||
const entries = [
|
||||
...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
||||
];
|
||||
updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ class CommonJsChunkFormatPlugin {
|
|||
Template.renderChunkRuntimeModules(runtimeModules, renderContext)
|
||||
);
|
||||
}
|
||||
const entries = Array.from(
|
||||
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
||||
);
|
||||
const entries = [
|
||||
...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
||||
];
|
||||
if (entries.length > 0) {
|
||||
const runtimeChunk =
|
||||
/** @type {Entrypoint} */
|
||||
|
|
@ -148,9 +148,9 @@ class CommonJsChunkFormatPlugin {
|
|||
if (chunk.hasRuntime()) return;
|
||||
hash.update(PLUGIN_NAME);
|
||||
hash.update("1");
|
||||
const entries = Array.from(
|
||||
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
||||
);
|
||||
const entries = [
|
||||
...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
||||
];
|
||||
updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,9 +53,7 @@ class EnableChunkLoadingPlugin {
|
|||
"EnableChunkLoadingPlugin need to be used to enable this type of chunk loading. " +
|
||||
'This usually happens through the "output.enabledChunkLoadingTypes" option. ' +
|
||||
'If you are using a function as entry which sets "chunkLoading", you need to add all potential chunk loading types to "output.enabledChunkLoadingTypes". ' +
|
||||
`These types are enabled: ${Array.from(
|
||||
getEnabledTypes(compiler)
|
||||
).join(", ")}`
|
||||
`These types are enabled: ${[...getEnabledTypes(compiler)].join(", ")}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const eslintScope = require("eslint-scope");
|
||||
const { SyncWaterfallHook, SyncHook, SyncBailHook } = require("tapable");
|
||||
const vm = require("vm");
|
||||
const eslintScope = require("eslint-scope");
|
||||
const { SyncBailHook, SyncHook, SyncWaterfallHook } = require("tapable");
|
||||
const {
|
||||
CachedSource,
|
||||
ConcatSource,
|
||||
OriginalSource,
|
||||
PrefixSource,
|
||||
RawSource,
|
||||
CachedSource,
|
||||
ReplaceSource
|
||||
} = require("webpack-sources");
|
||||
const Compilation = require("../Compilation");
|
||||
|
|
@ -33,11 +33,11 @@ const { last, someInIterable } = require("../util/IterableHelpers");
|
|||
const StringXor = require("../util/StringXor");
|
||||
const { compareModulesByIdOrIdentifier } = require("../util/comparators");
|
||||
const {
|
||||
getPathInAst,
|
||||
getAllReferences,
|
||||
RESERVED_NAMES,
|
||||
findNewName,
|
||||
addScopeSymbols,
|
||||
findNewName,
|
||||
getAllReferences,
|
||||
getPathInAst,
|
||||
getUsedNamesInScopeInfo
|
||||
} = require("../util/concatenate");
|
||||
const createHash = require("../util/createHash");
|
||||
|
|
@ -708,7 +708,7 @@ class JavascriptModulesPlugin {
|
|||
"javascript",
|
||||
compareModulesByIdOrIdentifier(chunkGraph)
|
||||
);
|
||||
const allModules = modules ? Array.from(modules) : [];
|
||||
const allModules = modules ? [...modules] : [];
|
||||
let strictHeader;
|
||||
let allStrict = renderContext.strictMode;
|
||||
if (
|
||||
|
|
@ -781,13 +781,14 @@ class JavascriptModulesPlugin {
|
|||
const bootstrap = this.renderBootstrap(renderContext, hooks);
|
||||
const useSourceMap = hooks.useSourceMap.call(chunk, renderContext);
|
||||
|
||||
const allModules = Array.from(
|
||||
chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
||||
/** @type {Module[]} */
|
||||
const allModules = [
|
||||
...(chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
||||
chunk,
|
||||
"javascript",
|
||||
compareModulesByIdOrIdentifier(chunkGraph)
|
||||
) || []
|
||||
);
|
||||
) || [])
|
||||
];
|
||||
|
||||
const hasEntryModules = chunkGraph.getNumberOfEntryModules(chunk) > 0;
|
||||
/** @type {Set<Module> | undefined} */
|
||||
|
|
@ -1018,7 +1019,7 @@ class JavascriptModulesPlugin {
|
|||
toSource(bootstrap.beforeStartup, "webpack/before-startup"),
|
||||
"\n",
|
||||
hooks.renderStartup.call(
|
||||
toSource(bootstrap.startup.concat(""), "webpack/startup"),
|
||||
toSource([...bootstrap.startup, ""], "webpack/startup"),
|
||||
lastEntryModule,
|
||||
{
|
||||
...renderContext,
|
||||
|
|
@ -1658,9 +1659,10 @@ class JavascriptModulesPlugin {
|
|||
|
||||
if (allUsedNames.has(name) || usedNames.has(name)) {
|
||||
const references = getAllReferences(variable);
|
||||
const allIdentifiers = new Set(
|
||||
references.map(r => r.identifier).concat(variable.identifiers)
|
||||
);
|
||||
const allIdentifiers = new Set([
|
||||
...references.map(r => r.identifier),
|
||||
...variable.identifiers
|
||||
]);
|
||||
for (const ref of references) {
|
||||
addScopeSymbols(
|
||||
ref.from,
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { Parser: AcornParser, tokTypes } = require("acorn");
|
||||
const { SyncBailHook, HookMap } = require("tapable");
|
||||
const vm = require("vm");
|
||||
const { Parser: AcornParser, tokTypes } = require("acorn");
|
||||
const { HookMap, SyncBailHook } = require("tapable");
|
||||
const Parser = require("../Parser");
|
||||
const StackedMap = require("../util/StackedMap");
|
||||
const binarySearchBounds = require("../util/binarySearchBounds");
|
||||
const {
|
||||
webpackCommentRegExp,
|
||||
createMagicCommentContext
|
||||
createMagicCommentContext,
|
||||
webpackCommentRegExp
|
||||
} = require("../util/magicComment");
|
||||
const memoize = require("../util/memoize");
|
||||
const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
||||
|
|
@ -1284,11 +1284,12 @@ class JavascriptParser extends Parser {
|
|||
left.prefix,
|
||||
right.postfix,
|
||||
left.wrappedInnerExpressions &&
|
||||
right.wrappedInnerExpressions &&
|
||||
left.wrappedInnerExpressions
|
||||
.concat(left.postfix ? [left.postfix] : [])
|
||||
.concat(right.prefix ? [right.prefix] : [])
|
||||
.concat(right.wrappedInnerExpressions)
|
||||
right.wrappedInnerExpressions && [
|
||||
...left.wrappedInnerExpressions,
|
||||
...(left.postfix ? [left.postfix] : []),
|
||||
...(right.prefix ? [right.prefix] : []),
|
||||
...right.wrappedInnerExpressions
|
||||
]
|
||||
);
|
||||
} else {
|
||||
// ("prefix" + inner + postfix) + expr
|
||||
|
|
@ -1296,10 +1297,10 @@ class JavascriptParser extends Parser {
|
|||
res.setWrapped(
|
||||
left.prefix,
|
||||
null,
|
||||
left.wrappedInnerExpressions &&
|
||||
left.wrappedInnerExpressions.concat(
|
||||
left.postfix ? [left.postfix, right] : [right]
|
||||
)
|
||||
left.wrappedInnerExpressions && [
|
||||
...left.wrappedInnerExpressions,
|
||||
...(left.postfix ? [left.postfix, right] : [right])
|
||||
]
|
||||
);
|
||||
}
|
||||
} else if (right.isString()) {
|
||||
|
|
@ -1312,10 +1313,10 @@ class JavascriptParser extends Parser {
|
|||
res.setWrapped(
|
||||
null,
|
||||
right.postfix,
|
||||
right.wrappedInnerExpressions &&
|
||||
(right.prefix ? [left, right.prefix] : [left]).concat(
|
||||
right.wrappedInnerExpressions
|
||||
)
|
||||
right.wrappedInnerExpressions && [
|
||||
...(right.prefix ? [left, right.prefix] : [left]),
|
||||
...right.wrappedInnerExpressions
|
||||
]
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
|
|
@ -1813,6 +1814,7 @@ class JavascriptParser extends Parser {
|
|||
if (!param.isString() && !param.isWrapped()) return;
|
||||
let stringSuffix = null;
|
||||
let hasUnknownParams = false;
|
||||
/** @type {BasicEvaluatedExpression[]} */
|
||||
const innerExpressions = [];
|
||||
for (let i = expr.arguments.length - 1; i >= 0; i--) {
|
||||
const arg = expr.arguments[i];
|
||||
|
|
@ -1852,7 +1854,10 @@ class JavascriptParser extends Parser {
|
|||
const prefix = param.isString() ? param : param.prefix;
|
||||
const inner =
|
||||
param.isWrapped() && param.wrappedInnerExpressions
|
||||
? param.wrappedInnerExpressions.concat(innerExpressions.reverse())
|
||||
? [
|
||||
...param.wrappedInnerExpressions,
|
||||
...innerExpressions.reverse()
|
||||
]
|
||||
: innerExpressions.reverse();
|
||||
return new BasicEvaluatedExpression()
|
||||
.setWrapped(prefix, stringSuffix, inner)
|
||||
|
|
@ -1860,7 +1865,7 @@ class JavascriptParser extends Parser {
|
|||
} else if (param.isWrapped()) {
|
||||
const postfix = stringSuffix || param.postfix;
|
||||
const inner = param.wrappedInnerExpressions
|
||||
? param.wrappedInnerExpressions.concat(innerExpressions.reverse())
|
||||
? [...param.wrappedInnerExpressions, ...innerExpressions.reverse()]
|
||||
: innerExpressions.reverse();
|
||||
return new BasicEvaluatedExpression()
|
||||
.setWrapped(param.prefix, postfix, inner)
|
||||
|
|
@ -3968,7 +3973,7 @@ class JavascriptParser extends Parser {
|
|||
expression,
|
||||
exprInfo.name,
|
||||
exprInfo.rootInfo,
|
||||
members.slice(),
|
||||
[...members],
|
||||
() =>
|
||||
this.callHooksForInfo(
|
||||
this.hooks.unhandledExpressionMemberChain,
|
||||
|
|
@ -5269,9 +5274,9 @@ class JavascriptParser extends Parser {
|
|||
|
||||
module.exports = JavascriptParser;
|
||||
module.exports.ALLOWED_MEMBER_TYPES_ALL = ALLOWED_MEMBER_TYPES_ALL;
|
||||
module.exports.ALLOWED_MEMBER_TYPES_EXPRESSION =
|
||||
ALLOWED_MEMBER_TYPES_EXPRESSION;
|
||||
module.exports.ALLOWED_MEMBER_TYPES_CALL_EXPRESSION =
|
||||
ALLOWED_MEMBER_TYPES_CALL_EXPRESSION;
|
||||
module.exports.getImportAttributes = getImportAttributes;
|
||||
module.exports.ALLOWED_MEMBER_TYPES_EXPRESSION =
|
||||
ALLOWED_MEMBER_TYPES_EXPRESSION;
|
||||
module.exports.VariableInfo = VariableInfo;
|
||||
module.exports.getImportAttributes = getImportAttributes;
|
||||
|
|
|
|||
|
|
@ -15,46 +15,7 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
|||
/** @typedef {import("./JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("./JavascriptParser").Range} Range */
|
||||
|
||||
/**
|
||||
* @param {JavascriptParser} parser the parser
|
||||
* @param {string} value the const value
|
||||
* @param {(string[] | null)=} runtimeRequirements runtime requirements
|
||||
* @returns {(expression: Expression) => true} plugin function
|
||||
*/
|
||||
module.exports.toConstantDependency = (parser, value, runtimeRequirements) =>
|
||||
function constDependency(expr) {
|
||||
const dep = new ConstDependency(
|
||||
value,
|
||||
/** @type {Range} */
|
||||
(expr.range),
|
||||
runtimeRequirements
|
||||
);
|
||||
dep.loc = /** @type {SourceLocation} */ (expr.loc);
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} value the string value
|
||||
* @returns {(expression: Expression) => BasicEvaluatedExpression} plugin function
|
||||
*/
|
||||
module.exports.evaluateToString = value =>
|
||||
function stringExpression(expr) {
|
||||
return new BasicEvaluatedExpression()
|
||||
.setString(value)
|
||||
.setRange(/** @type {Range} */ (expr.range));
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} value the number value
|
||||
* @returns {(expression: Expression) => BasicEvaluatedExpression} plugin function
|
||||
*/
|
||||
module.exports.evaluateToNumber = value =>
|
||||
function stringExpression(expr) {
|
||||
return new BasicEvaluatedExpression()
|
||||
.setNumber(value)
|
||||
.setRange(/** @type {Range} */ (expr.range));
|
||||
};
|
||||
module.exports.approve = () => true;
|
||||
|
||||
/**
|
||||
* @param {boolean} value the boolean value
|
||||
|
|
@ -100,6 +61,28 @@ module.exports.evaluateToIdentifier = (
|
|||
return evaluatedExpression;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} value the number value
|
||||
* @returns {(expression: Expression) => BasicEvaluatedExpression} plugin function
|
||||
*/
|
||||
module.exports.evaluateToNumber = value =>
|
||||
function stringExpression(expr) {
|
||||
return new BasicEvaluatedExpression()
|
||||
.setNumber(value)
|
||||
.setRange(/** @type {Range} */ (expr.range));
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} value the string value
|
||||
* @returns {(expression: Expression) => BasicEvaluatedExpression} plugin function
|
||||
*/
|
||||
module.exports.evaluateToString = value =>
|
||||
function stringExpression(expr) {
|
||||
return new BasicEvaluatedExpression()
|
||||
.setString(value)
|
||||
.setRange(/** @type {Range} */ (expr.range));
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {JavascriptParser} parser the parser
|
||||
* @param {string} message the message
|
||||
|
|
@ -126,4 +109,21 @@ module.exports.expressionIsUnsupported = (parser, message) =>
|
|||
|
||||
module.exports.skipTraversal = () => true;
|
||||
|
||||
module.exports.approve = () => true;
|
||||
/**
|
||||
* @param {JavascriptParser} parser the parser
|
||||
* @param {string} value the const value
|
||||
* @param {(string[] | null)=} runtimeRequirements runtime requirements
|
||||
* @returns {(expression: Expression) => true} plugin function
|
||||
*/
|
||||
module.exports.toConstantDependency = (parser, value, runtimeRequirements) =>
|
||||
function constDependency(expr) {
|
||||
const dep = new ConstDependency(
|
||||
value,
|
||||
/** @type {Range} */
|
||||
(expr.range),
|
||||
runtimeRequirements
|
||||
);
|
||||
dep.loc = /** @type {SourceLocation} */ (expr.loc);
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -133,6 +133,23 @@ module.exports.generateEntryStartup = (
|
|||
return Template.asString(runtime);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Chunk} chunk the chunk
|
||||
* @param {ChunkGraph} chunkGraph the chunk graph
|
||||
* @param {(chunk: Chunk, chunkGraph: ChunkGraph) => boolean} filterFn filter function
|
||||
* @returns {Set<number | string>} initially fulfilled chunk ids
|
||||
*/
|
||||
module.exports.getInitialChunkIds = (chunk, chunkGraph, filterFn) => {
|
||||
const initialChunkIds = new Set(chunk.ids);
|
||||
for (const c of chunk.getAllInitialChunks()) {
|
||||
if (c === chunk || filterFn(c, chunkGraph)) continue;
|
||||
for (const id of /** @type {ChunkId[]} */ (c.ids)) {
|
||||
initialChunkIds.add(id);
|
||||
}
|
||||
}
|
||||
return initialChunkIds;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Hash} hash the hash to update
|
||||
* @param {ChunkGraph} chunkGraph chunkGraph
|
||||
|
|
@ -161,20 +178,3 @@ module.exports.updateHashForEntryStartup = (
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Chunk} chunk the chunk
|
||||
* @param {ChunkGraph} chunkGraph the chunk graph
|
||||
* @param {(chunk: Chunk, chunkGraph: ChunkGraph) => boolean} filterFn filter function
|
||||
* @returns {Set<number | string>} initially fulfilled chunk ids
|
||||
*/
|
||||
module.exports.getInitialChunkIds = (chunk, chunkGraph, filterFn) => {
|
||||
const initialChunkIds = new Set(chunk.ids);
|
||||
for (const c of chunk.getAllInitialChunks()) {
|
||||
if (c === chunk || filterFn(c, chunkGraph)) continue;
|
||||
for (const id of /** @type {ChunkId[]} */ (c.ids)) {
|
||||
initialChunkIds.add(id);
|
||||
}
|
||||
}
|
||||
return initialChunkIds;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -191,7 +191,12 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
|
|||
*/
|
||||
_getResolvedFullName(options, chunk, compilation) {
|
||||
const prefix = this._getPrefix(compilation);
|
||||
const fullName = options.name ? prefix.concat(options.name) : prefix;
|
||||
const fullName = options.name
|
||||
? [
|
||||
...prefix,
|
||||
...(Array.isArray(options.name) ? options.name : [options.name])
|
||||
]
|
||||
: prefix;
|
||||
return fullName.map(n =>
|
||||
compilation.getPath(n, {
|
||||
chunk
|
||||
|
|
|
|||
|
|
@ -63,9 +63,7 @@ class EnableLibraryPlugin {
|
|||
"EnableLibraryPlugin need to be used to enable this type of library. " +
|
||||
'This usually happens through the "output.enabledLibraryTypes" option. ' +
|
||||
'If you are using a function as entry which sets "library", you need to add all potential library types to "output.enabledLibraryTypes". ' +
|
||||
`These types are enabled: ${Array.from(
|
||||
getEnabledTypes(compiler)
|
||||
).join(", ")}`
|
||||
`These types are enabled: ${[...getEnabledTypes(compiler)].join(", ")}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
|
|||
requiredExternals.push(m);
|
||||
}
|
||||
}
|
||||
externals = requiredExternals.concat(optionalExternals);
|
||||
externals = [...requiredExternals, ...optionalExternals];
|
||||
} else {
|
||||
requiredExternals = externals;
|
||||
}
|
||||
|
|
@ -194,7 +194,10 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
|
|||
/** @type {RequestRecord} */
|
||||
(request).root;
|
||||
}
|
||||
return `root${accessorToObjectAccess(/** @type {string[]} */ ([]).concat(request))}`;
|
||||
return `root${accessorToObjectAccess(
|
||||
/** @type {string[]} */
|
||||
([...(Array.isArray(request) ? request : [request])])
|
||||
)}`;
|
||||
})
|
||||
.join(", ")
|
||||
);
|
||||
|
|
@ -254,7 +257,10 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
|
|||
JSON.stringify(
|
||||
replaceKeys(
|
||||
/** @type {string} */
|
||||
(/** @type {string[]} */ ([]).concat(library).pop())
|
||||
(
|
||||
/** @type {string[]} */
|
||||
([...(Array.isArray(library) ? library : [library])]).pop()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -85,9 +85,9 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|||
(
|
||||
typeof debug === "boolean"
|
||||
? [() => debug]
|
||||
: /** @type {FilterItemTypes[]} */ ([])
|
||||
.concat(debug)
|
||||
.map(filterToFunction)
|
||||
: /** @type {FilterItemTypes[]} */ ([
|
||||
...(Array.isArray(debug) ? debug : [debug])
|
||||
]).map(filterToFunction)
|
||||
);
|
||||
const loglevel = LogLevel[`${level}`] || 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,15 @@ const currentDefaultLoggerOptions = {
|
|||
};
|
||||
let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
||||
|
||||
/**
|
||||
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
||||
* @returns {void}
|
||||
*/
|
||||
module.exports.configureDefaultLogger = options => {
|
||||
Object.assign(currentDefaultLoggerOptions, options);
|
||||
currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} name name of the logger
|
||||
* @returns {Logger} a logger
|
||||
|
|
@ -31,15 +40,6 @@ module.exports.getLogger = name =>
|
|||
childName => module.exports.getLogger(`${name}/${childName}`)
|
||||
);
|
||||
|
||||
/**
|
||||
* @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
||||
* @returns {void}
|
||||
*/
|
||||
module.exports.configureDefaultLogger = options => {
|
||||
Object.assign(currentDefaultLoggerOptions, options);
|
||||
currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
||||
};
|
||||
|
||||
module.exports.hooks = {
|
||||
log: new SyncBailHook(["origin", "type", "args"])
|
||||
};
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue