mirror of https://github.com/webpack/webpack.git
style: improve style of code
This commit is contained in:
parent
500ee96dcb
commit
ac0bd21801
|
@ -112,6 +112,7 @@ module.exports = [
|
|||
"object-shorthand": "error",
|
||||
"no-else-return": "error",
|
||||
"no-lonely-if": "error",
|
||||
"no-undef-init": "error",
|
||||
"n/no-missing-require": ["error", { allowModules: ["webpack"] }],
|
||||
"n/no-unsupported-features/node-builtins": [
|
||||
"error",
|
||||
|
@ -182,6 +183,7 @@ module.exports = [
|
|||
rules: {
|
||||
"prefer-const": "off",
|
||||
"object-shorthand": "off",
|
||||
"no-undef-init": "off",
|
||||
"n/exports-style": "off"
|
||||
}
|
||||
},
|
||||
|
@ -231,5 +233,11 @@ module.exports = [
|
|||
rules: {
|
||||
"n/no-missing-require": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ["lib/util/semver.js"],
|
||||
rules: {
|
||||
"n/exports-style": "off"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
const asyncLib = require("neo-async");
|
||||
const { SyncBailHook } = require("tapable");
|
||||
const Compilation = require("../lib/Compilation");
|
||||
const Compilation = require("./Compilation");
|
||||
const createSchemaValidation = require("./util/create-schema-validation");
|
||||
const { join } = require("./util/fs");
|
||||
const processAsyncTree = require("./util/processAsyncTree");
|
||||
|
|
|
@ -448,7 +448,7 @@ class Compilation {
|
|||
* @returns {CompilationAssets} new assets
|
||||
*/
|
||||
const popNewAssets = assets => {
|
||||
let newAssets = undefined;
|
||||
let newAssets;
|
||||
for (const file of Object.keys(assets)) {
|
||||
if (savedAssets.has(file)) continue;
|
||||
if (newAssets === undefined) {
|
||||
|
@ -1960,7 +1960,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
callback
|
||||
) {
|
||||
// Check for cycles when build is trigger inside another build
|
||||
let creatingModuleDuringBuildSet = undefined;
|
||||
let creatingModuleDuringBuildSet;
|
||||
if (checkCycle && this.buildQueue.isProcessing(originModule)) {
|
||||
// Track build dependency
|
||||
creatingModuleDuringBuildSet =
|
||||
|
@ -2361,7 +2361,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
*/
|
||||
const computeReferences = module => {
|
||||
/** @type {References | undefined} */
|
||||
let references = undefined;
|
||||
let references;
|
||||
for (const connection of moduleGraph.getOutgoingConnections(module)) {
|
||||
const d = connection.dependency;
|
||||
const m = connection.module;
|
||||
|
@ -2530,9 +2530,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
const computeReferences = module => {
|
||||
const id = chunkGraph.getModuleId(module);
|
||||
/** @type {Map<Module, string | number | undefined> | undefined} */
|
||||
let modules = undefined;
|
||||
let modules;
|
||||
/** @type {(string | number | null)[] | undefined} */
|
||||
let blocks = undefined;
|
||||
let blocks;
|
||||
const outgoing = moduleGraph.getOutgoingConnectionsByModule(module);
|
||||
if (outgoing !== undefined) {
|
||||
for (const m of outgoing.keys()) {
|
||||
|
@ -3328,7 +3328,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|||
/** @type {WebpackError[]} */
|
||||
const errors = [];
|
||||
/** @type {NotCodeGeneratedModules | undefined} */
|
||||
let notCodeGeneratedModules = undefined;
|
||||
let notCodeGeneratedModules;
|
||||
const runIteration = () => {
|
||||
/** @type {CodeGenerationJobs} */
|
||||
let delayedJobs = [];
|
||||
|
|
|
@ -14,7 +14,7 @@ const {
|
|||
AsyncSeriesHook
|
||||
} = require("tapable");
|
||||
const { SizeOnlySource } = require("webpack-sources");
|
||||
const webpack = require("./");
|
||||
const webpack = require(".");
|
||||
const Cache = require("./Cache");
|
||||
const CacheFacade = require("./CacheFacade");
|
||||
const ChunkGraph = require("./ChunkGraph");
|
||||
|
|
|
@ -846,7 +846,7 @@ class ExternalModule extends Module {
|
|||
if (sourceData.init)
|
||||
sourceString = `${sourceData.init}\n${sourceString}`;
|
||||
|
||||
let data = undefined;
|
||||
let data;
|
||||
if (sourceData.chunkInitFragments) {
|
||||
data = new Map();
|
||||
data.set("chunkInitFragments", sourceData.chunkInitFragments);
|
||||
|
|
|
@ -573,7 +573,7 @@ class SnapshotOptimization {
|
|||
};
|
||||
|
||||
/** @type {SnapshotOptimizationEntry | undefined} */
|
||||
let newOptimizationEntry = undefined;
|
||||
let newOptimizationEntry;
|
||||
|
||||
const capturedFilesSize = capturedFiles.size;
|
||||
|
||||
|
@ -2501,7 +2501,7 @@ class FileSystemInfo {
|
|||
*/
|
||||
_checkSnapshotValidNoCache(snapshot, callback) {
|
||||
/** @type {number | undefined} */
|
||||
let startTime = undefined;
|
||||
let startTime;
|
||||
if (snapshot.hasStartTime()) {
|
||||
startTime = snapshot.startTime;
|
||||
}
|
||||
|
@ -3181,7 +3181,7 @@ class FileSystemInfo {
|
|||
});
|
||||
},
|
||||
reduce: (files, tsEntries) => {
|
||||
let symlinks = undefined;
|
||||
let symlinks;
|
||||
|
||||
const hash = createHash(this._hashFunction);
|
||||
|
||||
|
@ -3306,7 +3306,7 @@ class FileSystemInfo {
|
|||
* @returns {ContextHash} reduced hash
|
||||
*/
|
||||
reduce: (files, fileHashes) => {
|
||||
let symlinks = undefined;
|
||||
let symlinks;
|
||||
const hash = createHash(this._hashFunction);
|
||||
|
||||
for (const file of files) hash.update(file);
|
||||
|
@ -3437,7 +3437,7 @@ class FileSystemInfo {
|
|||
* @returns {ContextTimestampAndHash} tsh
|
||||
*/
|
||||
reduce: (files, results) => {
|
||||
let symlinks = undefined;
|
||||
let symlinks;
|
||||
|
||||
const tsHash = createHash(this._hashFunction);
|
||||
const hash = createHash(this._hashFunction);
|
||||
|
|
|
@ -30,7 +30,7 @@ class FlagAllModulesAsUsedPlugin {
|
|||
const moduleGraph = compilation.moduleGraph;
|
||||
compilation.hooks.optimizeDependencies.tap(PLUGIN_NAME, modules => {
|
||||
/** @type {RuntimeSpec} */
|
||||
let runtime = undefined;
|
||||
let runtime;
|
||||
for (const [name, { options }] of compilation.entries) {
|
||||
runtime = mergeRuntimeOwned(
|
||||
runtime,
|
||||
|
|
|
@ -189,9 +189,9 @@ class FlagDependencyExportsPlugin {
|
|||
let name;
|
||||
let canMangle = globalCanMangle;
|
||||
let terminalBinding = globalTerminalBinding;
|
||||
let exports = undefined;
|
||||
let exports;
|
||||
let from = globalFrom;
|
||||
let fromExport = undefined;
|
||||
let fromExport;
|
||||
let priority = globalPriority;
|
||||
let hidden = false;
|
||||
if (typeof exportNameOrSpec === "string") {
|
||||
|
@ -261,7 +261,7 @@ class FlagDependencyExportsPlugin {
|
|||
|
||||
// Recalculate target exportsInfo
|
||||
const target = exportInfo.getTarget(moduleGraph);
|
||||
let targetExportsInfo = undefined;
|
||||
let targetExportsInfo;
|
||||
if (target) {
|
||||
const targetModuleExportsInfo =
|
||||
moduleGraph.getExportsInfo(target.module);
|
||||
|
|
|
@ -308,7 +308,7 @@ class FlagDependencyUsagePlugin {
|
|||
}
|
||||
};
|
||||
/** @type {RuntimeSpec} */
|
||||
let globalRuntime = undefined;
|
||||
let globalRuntime;
|
||||
for (const [
|
||||
entryName,
|
||||
{ dependencies: deps, includeDependencies: includeDeps, options }
|
||||
|
|
|
@ -19,7 +19,7 @@ class ModuleBuildError extends WebpackError {
|
|||
*/
|
||||
constructor(err, { from = null } = {}) {
|
||||
let message = "Module build failed";
|
||||
let details = undefined;
|
||||
let details;
|
||||
|
||||
if (from) {
|
||||
message += ` (from ${from}):\n`;
|
||||
|
|
|
@ -36,7 +36,7 @@ const getConnectionsByOriginModule = set => {
|
|||
/** @type {Module | 0} */
|
||||
let lastModule = 0;
|
||||
/** @type {ModuleGraphConnection[] | undefined} */
|
||||
let lastList = undefined;
|
||||
let lastList;
|
||||
for (const connection of set) {
|
||||
const { originModule } = connection;
|
||||
if (lastModule === originModule) {
|
||||
|
@ -67,7 +67,7 @@ const getConnectionsByModule = set => {
|
|||
/** @type {Module | 0} */
|
||||
let lastModule = 0;
|
||||
/** @type {ModuleGraphConnection[] | undefined} */
|
||||
let lastList = undefined;
|
||||
let lastList;
|
||||
for (const connection of set) {
|
||||
const { module } = connection;
|
||||
if (lastModule === module) {
|
||||
|
|
|
@ -22,7 +22,7 @@ class ModuleParseError extends WebpackError {
|
|||
*/
|
||||
constructor(source, err, loaders, type) {
|
||||
let message = "Module parse failed: " + (err && err.message);
|
||||
let loc = undefined;
|
||||
let loc;
|
||||
|
||||
if (
|
||||
((Buffer.isBuffer(source) && source.slice(0, 4).equals(WASM_HEADER)) ||
|
||||
|
|
|
@ -1138,7 +1138,7 @@ class NormalModule extends Module {
|
|||
// add warning for all non-absolute paths in fileDependencies, etc
|
||||
// This makes it easier to find problems with watching and/or caching
|
||||
/** @type {undefined | Set<string>} */
|
||||
let nonAbsoluteDependencies = undefined;
|
||||
let nonAbsoluteDependencies;
|
||||
/**
|
||||
* @param {LazySet<string>} deps deps
|
||||
*/
|
||||
|
|
|
@ -426,7 +426,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|||
const loaderResolver = this.getResolver("loader");
|
||||
|
||||
/** @type {ResourceData | undefined} */
|
||||
let matchResourceData = undefined;
|
||||
let matchResourceData;
|
||||
/** @type {string} */
|
||||
let unresolvedResource;
|
||||
/** @type {ParsedLoaderRequest[]} */
|
||||
|
|
|
@ -255,7 +255,7 @@ class Watching {
|
|||
(compilation && compilation.getLogger("webpack.Watching"));
|
||||
|
||||
/** @type {Stats | undefined} */
|
||||
let stats = undefined;
|
||||
let stats;
|
||||
|
||||
/**
|
||||
* @param {Error} err error
|
||||
|
|
|
@ -137,7 +137,7 @@ class AssetModulesPlugin {
|
|||
.tap(plugin, generatorOptions => {
|
||||
validateGeneratorOptions[type](generatorOptions);
|
||||
|
||||
let dataUrl = undefined;
|
||||
let dataUrl;
|
||||
if (type !== ASSET_MODULE_TYPE_RESOURCE) {
|
||||
dataUrl = generatorOptions.dataUrl;
|
||||
if (!dataUrl || typeof dataUrl === "object") {
|
||||
|
@ -149,9 +149,9 @@ class AssetModulesPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
let filename = undefined;
|
||||
let publicPath = undefined;
|
||||
let outputPath = undefined;
|
||||
let filename;
|
||||
let publicPath;
|
||||
let outputPath;
|
||||
if (type !== ASSET_MODULE_TYPE_INLINE) {
|
||||
filename = generatorOptions.filename;
|
||||
publicPath = generatorOptions.publicPath;
|
||||
|
|
|
@ -175,7 +175,7 @@ class IdleFileCachePlugin {
|
|||
}
|
||||
};
|
||||
/** @type {ReturnType<typeof setTimeout> | undefined} */
|
||||
let idleTimer = undefined;
|
||||
let idleTimer;
|
||||
compiler.cache.hooks.beginIdle.tap(
|
||||
{ name: "IdleFileCachePlugin", stage: Cache.STAGE_DISK },
|
||||
() => {
|
||||
|
|
|
@ -527,7 +527,7 @@ class Pack {
|
|||
*/
|
||||
_gcOldestContent() {
|
||||
/** @type {PackItemInfo | undefined} */
|
||||
let oldest = undefined;
|
||||
let oldest;
|
||||
for (const info of this.itemInfo.values()) {
|
||||
if (oldest === undefined || info.lastAccess < oldest.lastAccess) {
|
||||
oldest = info;
|
||||
|
|
|
@ -124,7 +124,7 @@ const A = (obj, prop, factory) => {
|
|||
obj[prop] = factory();
|
||||
} else if (Array.isArray(value)) {
|
||||
/** @type {any[] | undefined} */
|
||||
let newArray = undefined;
|
||||
let newArray;
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const item = value[i];
|
||||
if (item === "...") {
|
||||
|
|
|
@ -508,7 +508,7 @@ class CssModulesPlugin {
|
|||
}
|
||||
/** @type {Module} */
|
||||
let selectedModule = list[list.length - 1];
|
||||
let hasFailed = undefined;
|
||||
let hasFailed;
|
||||
outer: for (;;) {
|
||||
for (const { list, set } of modulesByChunkGroup) {
|
||||
if (list.length === 0) continue;
|
||||
|
|
|
@ -201,13 +201,13 @@ class CssParser extends Parser {
|
|||
/** @type {boolean} */
|
||||
let allowImportAtRule = true;
|
||||
/** @type {"local" | "global" | undefined} */
|
||||
let modeData = undefined;
|
||||
let modeData;
|
||||
/** @type {[number, number] | undefined} */
|
||||
let lastIdentifier = undefined;
|
||||
let lastIdentifier;
|
||||
/** @type [string, number, number][] */
|
||||
const balanced = [];
|
||||
/** @type {undefined | { start: number, url?: string, urlStart?: number, urlEnd?: number, layer?: string, layerStart?: number, layerEnd?: number, supports?: string, supportsStart?: number, supportsEnd?: number, inSupports?:boolean, media?: string }} */
|
||||
let importData = undefined;
|
||||
let importData;
|
||||
/** @type {boolean} */
|
||||
let inAnimationProperty = false;
|
||||
/** @type {boolean} */
|
||||
|
|
|
@ -36,7 +36,7 @@ const validate = createSchemaValidation(
|
|||
);
|
||||
|
||||
/** @type {Inspector | undefined} */
|
||||
let inspector = undefined;
|
||||
let inspector;
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||
|
|
|
@ -22,7 +22,7 @@ module.exports.handleDependencyBase = (
|
|||
module,
|
||||
runtimeRequirements
|
||||
) => {
|
||||
let base = undefined;
|
||||
let base;
|
||||
let type;
|
||||
switch (depBase) {
|
||||
case "exports":
|
||||
|
|
|
@ -120,7 +120,7 @@ CommonJsSelfReferenceDependency.Template = class CommonJsSelfReferenceDependency
|
|||
);
|
||||
}
|
||||
|
||||
let base = undefined;
|
||||
let base;
|
||||
switch (dep.base) {
|
||||
case "exports":
|
||||
runtimeRequirements.add(RuntimeGlobals.exports);
|
||||
|
|
|
@ -444,7 +444,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
|
||||
const ignoredExports = new Set(["default", ...this.activeExports]);
|
||||
|
||||
let hiddenExports = undefined;
|
||||
let hiddenExports;
|
||||
const otherStarExports =
|
||||
this._discoverActiveExportsFromOtherStarExports(moduleGraph);
|
||||
if (otherStarExports !== undefined) {
|
||||
|
|
|
@ -1210,9 +1210,9 @@ class JavascriptParser extends Parser {
|
|||
*/
|
||||
const tapEvaluateWithVariableInfo = (exprType, getInfo) => {
|
||||
/** @type {Expression | undefined} */
|
||||
let cachedExpression = undefined;
|
||||
let cachedExpression;
|
||||
/** @type {GetInfoResult | undefined} */
|
||||
let cachedInfo = undefined;
|
||||
let cachedInfo;
|
||||
this.hooks.evaluate.for(exprType).tap("JavascriptParser", expr => {
|
||||
const expression = /** @type {MemberExpression} */ (expr);
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ module.exports.generateEntryStartup = (
|
|||
}
|
||||
};
|
||||
|
||||
let currentChunks = undefined;
|
||||
let currentModuleIds = undefined;
|
||||
let currentChunks;
|
||||
let currentModuleIds;
|
||||
|
||||
for (const [module, entrypoint] of entries) {
|
||||
const runtimeChunk =
|
||||
|
|
|
@ -19,7 +19,7 @@ const truncateArgs = require("../logging/truncateArgs");
|
|||
*/
|
||||
module.exports = ({ colors, appendOnly, stream }) => {
|
||||
/** @type {string[] | undefined} */
|
||||
let currentStatusMessage = undefined;
|
||||
let currentStatusMessage;
|
||||
let hasStatusMessage = false;
|
||||
let currentIndent = "";
|
||||
let currentCollapsed = 0;
|
||||
|
|
|
@ -74,7 +74,7 @@ class FlagIncludedChunksPlugin {
|
|||
const chunkAModulesCount =
|
||||
chunkGraph.getNumberOfChunkModules(chunkA);
|
||||
if (chunkAModulesCount === 0) continue;
|
||||
let bestModule = undefined;
|
||||
let bestModule;
|
||||
for (const module of chunkGraph.getChunkModulesIterable(chunkA)) {
|
||||
if (
|
||||
bestModule === undefined ||
|
||||
|
|
|
@ -278,7 +278,7 @@ class ModuleConcatenationPlugin {
|
|||
// TODO reconsider that when it's only used in a different runtime
|
||||
if (usedAsInner.has(currentRoot)) continue;
|
||||
|
||||
let chunkRuntime = undefined;
|
||||
let chunkRuntime;
|
||||
for (const r of chunkGraph.getModuleRuntimes(currentRoot)) {
|
||||
chunkRuntime = mergeRuntimeOwned(chunkRuntime, r);
|
||||
}
|
||||
|
@ -675,7 +675,7 @@ class ModuleConcatenationPlugin {
|
|||
if (chunkGraph.getNumberOfModuleChunks(originModule) === 0) continue;
|
||||
|
||||
// We don't care for connections from other runtimes
|
||||
let originRuntime = undefined;
|
||||
let originRuntime;
|
||||
for (const r of chunkGraph.getModuleRuntimes(originModule)) {
|
||||
originRuntime = mergeRuntimeOwned(originRuntime, r);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ const proxyFetch = (request, proxy) => (url, options, callback) => {
|
|||
};
|
||||
|
||||
/** @type {(() => void)[] | undefined} */
|
||||
let inProgressWrite = undefined;
|
||||
let inProgressWrite;
|
||||
|
||||
const validate = createSchemaValidation(
|
||||
require("../../schemas/plugins/schemes/HttpUriPlugin.check.js"),
|
||||
|
@ -239,11 +239,11 @@ class Lockfile {
|
|||
const cachedWithoutKey = fn => {
|
||||
let inFlight = false;
|
||||
/** @type {Error | undefined} */
|
||||
let cachedError = undefined;
|
||||
let cachedError;
|
||||
/** @type {R | undefined} */
|
||||
let cachedResult = undefined;
|
||||
let cachedResult;
|
||||
/** @type {(function(Error=, R=): void)[] | undefined} */
|
||||
let cachedCallbacks = undefined;
|
||||
let cachedCallbacks;
|
||||
return callback => {
|
||||
if (inFlight) {
|
||||
if (cachedResult !== undefined) return callback(null, cachedResult);
|
||||
|
@ -481,7 +481,7 @@ class HttpUriPlugin {
|
|||
);
|
||||
|
||||
/** @type {Map<string, LockfileEntry | "ignore" | "no-cache"> | undefined} */
|
||||
let lockfileUpdates = undefined;
|
||||
let lockfileUpdates;
|
||||
|
||||
/**
|
||||
* @param {Lockfile} lockfile lockfile instance
|
||||
|
|
|
@ -105,7 +105,7 @@ const serialize = async (
|
|||
/** @type {WeakMap<SerializeResult, function(): any | Promise<any>>} */
|
||||
const resultToLazy = new WeakMap();
|
||||
/** @type {Buffer[]} */
|
||||
let lastBuffers = undefined;
|
||||
let lastBuffers;
|
||||
for (const item of await data) {
|
||||
if (typeof item === "function") {
|
||||
if (!SerializerMiddleware.isLazy(item))
|
||||
|
|
|
@ -589,7 +589,7 @@ const SIMPLE_EXTRACTORS = {
|
|||
if (depthInCollapsedGroup > 0) depthInCollapsedGroup--;
|
||||
continue;
|
||||
}
|
||||
let message = undefined;
|
||||
let message;
|
||||
if (entry.type === LogType.time) {
|
||||
message = `${entry.args[0]}: ${
|
||||
entry.args[1] * 1000 + entry.args[2] / 1000000
|
||||
|
@ -1689,9 +1689,9 @@ const spaceLimited = (
|
|||
};
|
||||
}
|
||||
/** @type {any[] | undefined} */
|
||||
let children = undefined;
|
||||
let children;
|
||||
/** @type {number | undefined} */
|
||||
let filteredChildren = undefined;
|
||||
let filteredChildren;
|
||||
// This are the groups, which take 1+ lines each
|
||||
const groups = [];
|
||||
// The sizes of the groups are stored in groupSizes
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const binarySearchBounds = require("../util/binarySearchBounds");
|
||||
const binarySearchBounds = require("./binarySearchBounds");
|
||||
|
||||
/** @typedef {function(number): void} Callback */
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ class TupleSet {
|
|||
[Symbol.iterator]() {
|
||||
const iteratorStack = [];
|
||||
const tuple = [];
|
||||
let currentSetIterator = undefined;
|
||||
let currentSetIterator;
|
||||
|
||||
const next = it => {
|
||||
const result = it.next();
|
||||
|
|
|
@ -133,13 +133,13 @@ class DebugHash extends Hash {
|
|||
}
|
||||
|
||||
/** @type {typeof import("crypto") | undefined} */
|
||||
let crypto = undefined;
|
||||
let crypto;
|
||||
/** @type {typeof import("./hash/xxhash64") | undefined} */
|
||||
let createXXHash64 = undefined;
|
||||
let createXXHash64;
|
||||
/** @type {typeof import("./hash/md4") | undefined} */
|
||||
let createMd4 = undefined;
|
||||
let createMd4;
|
||||
/** @type {typeof import("./hash/BatchedHash") | undefined} */
|
||||
let BatchedHash = undefined;
|
||||
let BatchedHash;
|
||||
|
||||
/**
|
||||
* Creates a hash by name or function
|
||||
|
|
|
@ -259,7 +259,7 @@ const getSimilarities = nodes => {
|
|||
// calculate similarities between lexically adjacent nodes
|
||||
/** @type {number[]} */
|
||||
const similarities = [];
|
||||
let last = undefined;
|
||||
let last;
|
||||
for (const node of nodes) {
|
||||
if (last !== undefined) {
|
||||
similarities.push(similarity(last.key, node.key));
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
const memoize = fn => {
|
||||
let cache = false;
|
||||
/** @type {T | undefined} */
|
||||
let result = undefined;
|
||||
let result;
|
||||
return () => {
|
||||
if (cache) {
|
||||
return /** @type {T} */ (result);
|
||||
|
|
|
@ -5,10 +5,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
SAFE_IDENTIFIER,
|
||||
RESERVED_IDENTIFIER
|
||||
} = require("../util/propertyName");
|
||||
const { SAFE_IDENTIFIER, RESERVED_IDENTIFIER } = require("./propertyName");
|
||||
|
||||
/**
|
||||
* @param {ArrayLike<string>} properties properties
|
||||
|
|
|
@ -31,7 +31,7 @@ module.exports.getEntryRuntime = (compilation, name, options) => {
|
|||
}
|
||||
if (dependOn) {
|
||||
/** @type {RuntimeSpec} */
|
||||
let result = undefined;
|
||||
let result;
|
||||
const queue = new Set(dependOn);
|
||||
for (const name of queue) {
|
||||
const dep = compilation.entries.get(name);
|
||||
|
@ -396,7 +396,7 @@ module.exports.filterRuntime = (runtime, filter) => {
|
|||
if (typeof runtime === "string") return filter(runtime);
|
||||
let some = false;
|
||||
let every = true;
|
||||
let result = undefined;
|
||||
let result;
|
||||
for (const r of runtime) {
|
||||
const v = filter(r);
|
||||
if (v) {
|
||||
|
|
|
@ -452,19 +452,15 @@ module.exports.stringifyHoley = json => {
|
|||
};
|
||||
|
||||
//#region runtime code: parseVersion
|
||||
module.exports.parseVersionRuntimeCode = runtimeTemplate =>
|
||||
exports.parseVersionRuntimeCode = runtimeTemplate =>
|
||||
`var parseVersion = ${runtimeTemplate.basicFunction("str", [
|
||||
"// see webpack/lib/util/semver.js for original code",
|
||||
`var p=${
|
||||
runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"
|
||||
}{return p.split(".").map((${
|
||||
runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"
|
||||
}{return+p==p?+p:p}))},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r;`
|
||||
`var p=${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return p.split(".").map((${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return+p==p?+p:p}))},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r;`
|
||||
])}`;
|
||||
//#endregion
|
||||
|
||||
//#region runtime code: versionLt
|
||||
module.exports.versionLtRuntimeCode = runtimeTemplate =>
|
||||
exports.versionLtRuntimeCode = runtimeTemplate =>
|
||||
`var versionLt = ${runtimeTemplate.basicFunction("a, b", [
|
||||
"// see webpack/lib/util/semver.js for original code",
|
||||
'a=parseVersion(a),b=parseVersion(b);for(var r=0;;){if(r>=a.length)return r<b.length&&"u"!=(typeof b[r])[0];var e=a[r],n=(typeof e)[0];if(r>=b.length)return"u"==n;var t=b[r],f=(typeof t)[0];if(n!=f)return"o"==n&&"n"==f||("s"==f||"u"==n);if("o"!=n&&"u"!=n&&e!=t)return e<t;r++}'
|
||||
|
@ -472,7 +468,7 @@ module.exports.versionLtRuntimeCode = runtimeTemplate =>
|
|||
//#endregion
|
||||
|
||||
//#region runtime code: rangeToString
|
||||
module.exports.rangeToStringRuntimeCode = runtimeTemplate =>
|
||||
exports.rangeToStringRuntimeCode = runtimeTemplate =>
|
||||
`var rangeToString = ${runtimeTemplate.basicFunction("range", [
|
||||
"// see webpack/lib/util/semver.js for original code",
|
||||
'var r=range[0],n="";if(1===range.length)return"*";if(r+.5){n+=0==r?">=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var e=1,a=1;a<range.length;a++){e--,n+="u"==(typeof(t=range[a]))[0]?"-":(e>0?".":"")+(e=2,t)}return n}var g=[];for(a=1;a<range.length;a++){var t=range[a];g.push(0===t?"not("+o()+")":1===t?"("+o()+" || "+o()+")":2===t?g.pop()+" "+g.pop():rangeToString(t))}return o();function o(){return g.pop().replace(/^\\((.+)\\)$/,"$1")}'
|
||||
|
@ -480,7 +476,7 @@ module.exports.rangeToStringRuntimeCode = runtimeTemplate =>
|
|||
//#endregion
|
||||
|
||||
//#region runtime code: satisfy
|
||||
module.exports.satisfyRuntimeCode = runtimeTemplate =>
|
||||
exports.satisfyRuntimeCode = runtimeTemplate =>
|
||||
`var satisfy = ${runtimeTemplate.basicFunction("range, version", [
|
||||
"// see webpack/lib/util/semver.js for original code",
|
||||
'if(0 in range){version=parseVersion(version);var e=range[0],r=e<0;r&&(e=-e-1);for(var n=0,i=1,a=!0;;i++,n++){var f,s,g=i<range.length?(typeof range[i])[0]:"";if(n>=version.length||"o"==(s=(typeof(f=version[n]))[0]))return!a||("u"==g?i>e&&!r:""==g!=r);if("u"==s){if(!a||"u"!=g)return!1}else if(a)if(g==s)if(i<=e){if(f!=range[i])return!1}else{if(r?f>range[i]:f<range[i])return!1;f!=range[i]&&(a=!1)}else if("s"!=g&&"n"!=g){if(r||i<=e)return!1;a=!1,i--}else{if(i<=e||s<g!=r)return!1;a=!1}else"s"!=g&&"n"!=g&&(a=!1,i--)}}var t=[],o=t.pop.bind(t);for(n=1;n<range.length;n++){var u=range[n];t.push(1==u?o()|o():2==u?o()&o():u?satisfy(u,version):!o())}return!!o();'
|
||||
|
|
|
@ -111,10 +111,10 @@ const smartGrouping = (items, groupConfigs) => {
|
|||
const results = [];
|
||||
for (;;) {
|
||||
/** @type {Group<T, R> | undefined} */
|
||||
let bestGroup = undefined;
|
||||
let bestGroup;
|
||||
let bestGroupSize = -1;
|
||||
let bestGroupItems = undefined;
|
||||
let bestGroupOptions = undefined;
|
||||
let bestGroupItems;
|
||||
let bestGroupOptions;
|
||||
for (const [group, state] of groupMap) {
|
||||
const { items, used } = state;
|
||||
let options = state.options;
|
||||
|
|
|
@ -187,7 +187,7 @@ class FakeSheet {
|
|||
const walkCssTokens = require("../../lib/css/walkCssTokens");
|
||||
const rules = [];
|
||||
let currentRule = { getPropertyValue };
|
||||
let selector = undefined;
|
||||
let selector;
|
||||
let last = 0;
|
||||
const processDeclaration = str => {
|
||||
const colon = str.indexOf(":");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
const util = require("util");
|
||||
|
||||
let interception = undefined;
|
||||
let interception;
|
||||
|
||||
const originalDeprecate = util.deprecate;
|
||||
util.deprecate = (fn, message, code) => {
|
||||
|
|
Loading…
Reference in New Issue