diff --git a/eslint.config.js b/eslint.config.js index a4ef0fec3..8d92d4107 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -77,6 +77,12 @@ module.exports = [ "no-inner-declarations": "error", "no-loop-func": "off", "n/no-missing-require": ["error", { allowModules: ["webpack"] }], + "n/no-unsupported-features/node-builtins": [ + "error", + { + ignores: ["zlib.createBrotliCompress", "zlib.createBrotliDecompress"] + } + ], "jsdoc/check-alignment": "off", "jsdoc/tag-lines": "off", // TODO enable me @@ -182,7 +188,6 @@ module.exports = [ "n/no-unsupported-features/node-builtins": [ "error", { - version: ">=10.13.0", allowExperimental: true } ] diff --git a/lib/ConcatenationScope.js b/lib/ConcatenationScope.js index c9d0fbc7a..382235b99 100644 --- a/lib/ConcatenationScope.js +++ b/lib/ConcatenationScope.js @@ -114,8 +114,8 @@ class ConcatenationScope { const asiSafeFlag = asiSafe ? "_asiSafe1" : asiSafe === false - ? "_asiSafe0" - : ""; + ? "_asiSafe0" + : ""; const exportData = ids ? Buffer.from(JSON.stringify(ids), "utf-8").toString("hex") : "ns"; diff --git a/lib/ContextModule.js b/lib/ContextModule.js index 505053163..df19de677 100644 --- a/lib/ContextModule.js +++ b/lib/ContextModule.js @@ -532,8 +532,8 @@ class ContextModule extends Module { this.context ? [this.context] : typeof this.options.resource === "string" - ? [this.options.resource] - : /** @type {string[]} */ (this.options.resource), + ? [this.options.resource] + : /** @type {string[]} */ (this.options.resource), null, SNAPSHOT_OPTIONS, (err, snapshot) => { @@ -992,8 +992,8 @@ module.exports = webpackAsyncContext;`; const requestPrefix = hasNoChunk ? "Promise.resolve()" : hasMultipleOrNoChunks - ? `Promise.all(ids.slice(${chunksStartPosition}).map(${RuntimeGlobals.ensureChunk}))` - : `${RuntimeGlobals.ensureChunk}(ids[${chunksStartPosition}])`; + ? `Promise.all(ids.slice(${chunksStartPosition}).map(${RuntimeGlobals.ensureChunk}))` + : `${RuntimeGlobals.ensureChunk}(ids[${chunksStartPosition}])`; const returnModuleObject = this.getReturnModuleObjectSource( fakeMap, true, diff --git a/lib/EvalDevToolModulePlugin.js b/lib/EvalDevToolModulePlugin.js index e1bd8d20e..d9d33d2b0 100644 --- a/lib/EvalDevToolModulePlugin.js +++ b/lib/EvalDevToolModulePlugin.js @@ -93,7 +93,7 @@ class EvalDevToolModulePlugin { compilation.outputOptions.trustedTypes ? `${RuntimeGlobals.createScript}(${JSON.stringify( content + footer - )})` + )})` : JSON.stringify(content + footer) });` ); diff --git a/lib/ExternalModule.js b/lib/ExternalModule.js index 9be5a5758..b981fb0a9 100644 --- a/lib/ExternalModule.js +++ b/lib/ExternalModule.js @@ -175,7 +175,7 @@ const getSourceForImportExternal = ( ? `, { assert: ${JSON.stringify( dependencyMeta.attributes, importAssertionReplacer - )} }` + )} }` : `, { with: ${JSON.stringify(dependencyMeta.attributes)} }` : ""; if (!Array.isArray(moduleAndSpecifiers)) { @@ -244,7 +244,7 @@ class ModuleExternalInitFragment extends InitFragment { ? ` assert ${JSON.stringify( dependencyMeta.attributes, importAssertionReplacer - )}` + )}` : ` with ${JSON.stringify(dependencyMeta.attributes)}` : "" };\n`, @@ -360,10 +360,10 @@ const getSourceForModuleExternal = ( ? `var x = ${runtimeTemplate.basicFunction( "y", `var x = {}; ${RuntimeGlobals.definePropertyGetters}(x, y); return x` - )} \nvar y = ${runtimeTemplate.returningFunction( + )} \nvar y = ${runtimeTemplate.returningFunction( runtimeTemplate.returningFunction("x"), "x" - )}` + )}` : undefined, runtimeRequirements: moduleRemapping ? RUNTIME_REQUIREMENTS_FOR_MODULE @@ -443,7 +443,7 @@ const getSourceForAmdOrUmdExternal = ( externalVariable, Array.isArray(request) ? request.join(".") : request, runtimeTemplate - ) + ) : undefined, expression: externalVariable }; @@ -703,7 +703,7 @@ class ExternalModule extends Module { /** @type {string} */ (runtimeTemplate.outputOptions.importMetaName), runtimeTemplate.supportNodePrefixForCoreModules() - ) + ) : getSourceForCommonJsExternal(request); case "amd": case "amd-require": diff --git a/lib/FileSystemInfo.js b/lib/FileSystemInfo.js index 94f974045..79738c512 100644 --- a/lib/FileSystemInfo.js +++ b/lib/FileSystemInfo.js @@ -3389,7 +3389,7 @@ class FileSystemInfo { : { ...timestamp, ...hash - }; + }; this._contextTshs.set(path, result); callback(null, result); }; diff --git a/lib/HotModuleReplacementPlugin.js b/lib/HotModuleReplacementPlugin.js index 5a8a13aeb..3f64dc504 100644 --- a/lib/HotModuleReplacementPlugin.js +++ b/lib/HotModuleReplacementPlugin.js @@ -500,7 +500,7 @@ class HotModuleReplacementPlugin { : compilation.codeGenerationResults.getHash( module, chunk.runtime - ); + ); if (records.chunkModuleHashes[key] !== hash) { updatedModules.add(module, chunk); } @@ -629,7 +629,7 @@ class HotModuleReplacementPlugin { : compilation.codeGenerationResults.getHash( module, newRuntime - ); + ); if (hash !== oldHash) { if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) { newRuntimeModules = newRuntimeModules || []; @@ -798,7 +798,7 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename Array.from(removedModules, m => chunkGraph.getModuleId(m) ) - ) + ) }; const source = new RawSource(JSON.stringify(hotUpdateMainJson)); diff --git a/lib/ModuleFilenameHelpers.js b/lib/ModuleFilenameHelpers.js index 4165729b2..feaca4f5a 100644 --- a/lib/ModuleFilenameHelpers.js +++ b/lib/ModuleFilenameHelpers.js @@ -164,7 +164,7 @@ ModuleFilenameHelpers.createFilename = ( ? options : { moduleFilenameTemplate: options - }) + }) }; let absoluteResourcePath; diff --git a/lib/NormalModule.js b/lib/NormalModule.js index ff0191be6..e8b49ab14 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -142,14 +142,14 @@ const contextifySourceMap = (context, sourceMap, associatedObjectForCache) => { const mapper = !sourceRoot ? source => source : sourceRoot.endsWith("/") - ? source => - source.startsWith("/") - ? `${sourceRoot.slice(0, -1)}${source}` - : `${sourceRoot}${source}` - : source => - source.startsWith("/") - ? `${sourceRoot}${source}` - : `${sourceRoot}/${source}`; + ? source => + source.startsWith("/") + ? `${sourceRoot.slice(0, -1)}${source}` + : `${sourceRoot}${source}` + : source => + source.startsWith("/") + ? `${sourceRoot}${source}` + : `${sourceRoot}/${source}`; const newSources = sourceMap.sources.map(source => contextifySourceUrl(context, mapper(source), associatedObjectForCache) ); @@ -859,7 +859,7 @@ class NormalModule extends Module { currentLoader ? compilation.runtimeTemplate.requestShortener.shorten( currentLoader.loader - ) + ) : "unknown" }) didn't return a Buffer or String` ); @@ -1156,10 +1156,10 @@ class NormalModule extends Module { if (absolute !== dep && ABSOLUTE_PATH_REGEX.test(absolute)) { (depWithoutGlob !== dep ? /** @type {NonNullable} */ - ( + ( /** @type {BuildInfo} */ (this.buildInfo) .contextDependencies - ) + ) : deps ).add(absolute); } @@ -1352,7 +1352,7 @@ class NormalModule extends Module { const source = this.error ? new RawSource( "throw new Error(" + JSON.stringify(this.error.message) + ");" - ) + ) : /** @type {Generator} */ (this.generator).generate(this, { dependencyTemplates, runtimeTemplate, @@ -1364,7 +1364,7 @@ class NormalModule extends Module { codeGenerationResults, getData, type - }); + }); if (source) { sources.set(type, new CachedSource(source)); diff --git a/lib/NormalModuleFactory.js b/lib/NormalModuleFactory.js index 02ebf63e5..1cf3ac0b2 100644 --- a/lib/NormalModuleFactory.js +++ b/lib/NormalModuleFactory.js @@ -479,8 +479,8 @@ class NormalModuleFactory extends ModuleFactory { noPreAutoLoaders || noPrePostAutoLoaders ? 2 : noAutoLoaders - ? 1 - : 0 + ? 1 + : 0 ) .split(/!+/); unresolvedResource = /** @type {string} */ (rawElements.pop()); @@ -763,7 +763,7 @@ class NormalModuleFactory extends ModuleFactory { resolveOptions || EMPTY_RESOLVE_OPTIONS, "dependencyType", dependencyType - ) + ) : resolveOptions ); this.resolveResource( @@ -1178,12 +1178,12 @@ If changing the source code is not an option there is also a resolve options cal const type = /\.mjs$/i.test(parsedResult.path) ? "module" : /\.cjs$/i.test(parsedResult.path) - ? "commonjs" - : /** @type {ResolveRequest} */ - (resolveRequest).descriptionFileData === undefined - ? undefined - : /** @type {ResolveRequest} */ - (resolveRequest).descriptionFileData.type; + ? "commonjs" + : /** @type {ResolveRequest} */ + (resolveRequest).descriptionFileData === undefined + ? undefined + : /** @type {ResolveRequest} */ + (resolveRequest).descriptionFileData.type; const resolved = { loader: parsedResult.path, type, diff --git a/lib/schemes/HttpUriPlugin.js b/lib/schemes/HttpUriPlugin.js index 24f5ad226..e44d461a7 100644 --- a/lib/schemes/HttpUriPlugin.js +++ b/lib/schemes/HttpUriPlugin.js @@ -8,12 +8,7 @@ const EventEmitter = require("events"); const { extname, basename } = require("path"); const { URL } = require("url"); -const { - createGunzip, - // eslint-disable-next-line n/no-unsupported-features/node-builtins - createBrotliDecompress, - createInflate -} = require("zlib"); +const { createGunzip, createBrotliDecompress, createInflate } = require("zlib"); const NormalModule = require("../NormalModule"); const createSchemaValidation = require("../util/create-schema-validation"); const createHash = require("../util/createHash"); @@ -205,7 +200,7 @@ class Lockfile { : { resolved: key, ...entry - } + } ); } return lockfile; diff --git a/lib/serialization/FileMiddleware.js b/lib/serialization/FileMiddleware.js index 0711b0d6e..7b81827c8 100644 --- a/lib/serialization/FileMiddleware.js +++ b/lib/serialization/FileMiddleware.js @@ -7,9 +7,7 @@ const { constants } = require("buffer"); const { pipeline } = require("stream"); const { - // eslint-disable-next-line n/no-unsupported-features/node-builtins createBrotliCompress, - // eslint-disable-next-line n/no-unsupported-features/node-builtins createBrotliDecompress, createGzip, createGunzip, @@ -62,23 +60,23 @@ const DECOMPRESSION_CHUNK_SIZE = 100 * 1024 * 1024; const writeUInt64LE = Buffer.prototype.writeBigUInt64LE ? (buf, value, offset) => { buf.writeBigUInt64LE(BigInt(value), offset); - } + } : (buf, value, offset) => { const low = value % 0x100000000; const high = (value - low) / 0x100000000; buf.writeUInt32LE(low, offset); buf.writeUInt32LE(high, offset + 4); - }; + }; const readUInt64LE = Buffer.prototype.readBigUInt64LE ? (buf, offset) => { return Number(buf.readBigUInt64LE(offset)); - } + } : (buf, offset) => { const low = buf.readUInt32LE(offset); const high = buf.readUInt32LE(offset + 4); return high * 0x100000000 + low; - }; + }; /** * @typedef {object} SerializeResult diff --git a/types.d.ts b/types.d.ts index c59ec4eaa..944e85f38 100644 --- a/types.d.ts +++ b/types.d.ts @@ -5182,8 +5182,8 @@ declare interface HashedModuleIdsPluginOptions { } declare abstract class HelperRuntimeModule extends RuntimeModule {} declare class HotModuleReplacementPlugin { - constructor(options?: Object); - options: Object; + constructor(options?: object); + options: object; /** * Apply the plugin @@ -7328,7 +7328,7 @@ declare interface LibIdentOptions { /** * object for caching */ - associatedObjectForCache?: Object; + associatedObjectForCache?: object; } declare class LibManifestPlugin { constructor(options: LibManifestPluginOptions); @@ -8352,8 +8352,8 @@ declare class ModuleGraph { setDepthIfLower(module: Module, depth: number): boolean; isAsync(module: Module): boolean; setAsync(module: Module): void; - getMeta(thing?: any): Object; - getMetaIfExisting(thing?: any): undefined | Object; + getMeta(thing?: any): object; + getMetaIfExisting(thing?: any): undefined | object; freeze(cacheStage?: string): void; unfreeze(): void; cached( @@ -8886,14 +8886,14 @@ declare class NormalModule extends Module { name: string, content: string | Buffer, sourceMap?: string | SourceMap, - associatedObjectForCache?: Object + associatedObjectForCache?: object ): Source; getCurrentLoader(loaderContext?: any, index?: number): null | LoaderItem; createSource( context: string, content: string | Buffer, sourceMap?: string | SourceMapSource, - associatedObjectForCache?: Object + associatedObjectForCache?: object ): Source; markModuleAsErrored(error: WebpackError): void; applyNoParseRule(rule: any, content: string): boolean; @@ -9027,8 +9027,8 @@ declare abstract class NormalModuleFactory extends ModuleFactory { ruleSet: RuleSet; context: string; fs: InputFileSystem; - parserCache: Map>; - generatorCache: Map>; + parserCache: Map>; + generatorCache: Map>; cleanupForCache(): void; resolveResource( contextInfo: ModuleFactoryCreateDataContextInfo, @@ -11991,7 +11991,7 @@ declare abstract class Resolver { normalize(path: string): string; } declare interface ResolverCache { - direct: WeakMap; + direct: WeakMap; stringified: Map; } declare abstract class ResolverFactory { @@ -13018,11 +13018,11 @@ declare abstract class Serializer { declare abstract class SerializerMiddleware { serialize( data: DeserializedType, - context: Object + context: object ): SerializedType | Promise; deserialize( data: SerializedType, - context: Object + context: object ): DeserializedType | Promise; } type ServerOptionsHttps< @@ -13645,7 +13645,7 @@ type StatsCompilation = KnownStatsCompilation & Record; type StatsError = KnownStatsError & Record; declare abstract class StatsFactory { hooks: Readonly<{ - extract: HookMap>; + extract: HookMap>; filter: HookMap< SyncBailHook<[any, StatsFactoryContext, number, number], any> >; @@ -14150,7 +14150,7 @@ declare abstract class StatsPrinter { print: HookMap>; result: HookMap>; }>; - print(type: string, object: Object, baseContext?: Object): string; + print(type: string, object: object, baseContext?: object): string; } type StatsPrinterContext = KnownStatsPrinterContext & Record; type StatsProfile = KnownStatsProfile & Record;