From 5e73a5372181136824f3e62287d934de5321abef Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Sun, 1 Jun 2025 19:47:50 +0530 Subject: [PATCH 1/8] docs: fix typos and improve clarity in README.md --- README.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f3ffd51..47ecb80 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ # thread-loader -Runs the following loaders in a worker pool. +Runs the specified loaders in a worker pool. ## Getting Started @@ -33,17 +33,18 @@ or pnpm add -D thread-loader ``` -Put this loader in front of other loaders. The following loaders run in a worker pool. +Put this loader in front of other loaders. +The following loaders run in a worker pool. Loaders running in a worker pool are limited. Examples: - Loaders cannot emit files. -- Loaders cannot use custom loader API (i. e. by plugins). -- Loaders cannot access the webpack options. +- Loaders cannot use custom loader APIs (i. e. by plugins). +- Loaders cannot access webpack options. -Each worker is a separate node.js process, which has an overhead of ~600ms. There is also an overhead of inter-process communication. +Each worker is a separate Node.js process, which has an overhead of ~600ms. There is also additional overhead from inter-process communication. -Use this loader only for expensive operations! +> Use this loader only for expensive operations! ### Examples @@ -111,9 +112,9 @@ use: [ **prewarming** -To prevent the high delay when booting workers it possible to warmup the worker pool. +To prevent the high delays when booting workers, it is possible to warm up the worker pool. -This boots the max number of workers in the pool and loads specified modules into the node.js module cache. +This boots the max number of workers in the pool and loads the specified modules into the Node.js module cache. ```js const threadLoader = require('thread-loader'); @@ -129,13 +130,14 @@ threadLoader.warmup( 'babel-loader', 'babel-preset-es2015', 'sass-loader', - ], + ] ); ``` ## Contributing -Please take a moment to read our contributing guidelines if you haven't yet done so. +We welcome all contributions! +If you're new here, please take a moment to review our contributing guidelines before submitting issues or pull requests. [CONTRIBUTING](./.github/CONTRIBUTING.md) From 455a6520b51cb27ce104790daa6981e4ca536eb0 Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Mon, 2 Jun 2025 09:03:42 +0530 Subject: [PATCH 2/8] docs: fix typos and improve clarity in README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 47ecb80..5e1b4c0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@
- +
@@ -36,10 +36,10 @@ pnpm add -D thread-loader Put this loader in front of other loaders. The following loaders run in a worker pool. -Loaders running in a worker pool are limited. Examples: +Loaders running in a worker pool have limitations. Examples: - Loaders cannot emit files. -- Loaders cannot use custom loader APIs (i. e. by plugins). +- Loaders cannot use custom loader APIs (i.e. by plugins). - Loaders cannot access webpack options. Each worker is a separate Node.js process, which has an overhead of ~600ms. There is also additional overhead from inter-process communication. @@ -98,11 +98,11 @@ use: [ // number of jobs the pool distributes to the workers // defaults to 200 - // decrease of less efficient but more fair distribution + // decrease for less efficient but more fair distribution poolParallelJobs: 50, // name of the pool - // can be used to create different pools with elsewise identical options + // can be used to create different pools with otherwise identical options name: 'my-pool', }, }, @@ -126,9 +126,9 @@ threadLoader.warmup( }, [ // modules to load - // can be any module, i. e. + // can be any module, i.e. 'babel-loader', - 'babel-preset-es2015', + '@babel/preset-env', 'sass-loader', ] ); From 67fb6b823676448189c3d156612542906f0b4e8b Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Mon, 2 Jun 2025 09:10:16 +0530 Subject: [PATCH 3/8] chore: fixed lint problems --- src/WorkerPool.js | 18 +++++++------- src/index.js | 4 +-- src/template.js | 36 +++++++++++++-------------- src/worker.js | 10 ++++---- test/basic-loader-test/test-loader.js | 8 +++--- test/pitch.test.js | 4 +-- test/serializer.test.js | 4 +-- test/webpack.test.js | 2 +- test/workerPool.test.js | 4 +-- 9 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/WorkerPool.js b/src/WorkerPool.js index 15db06f..d304dd2 100644 --- a/src/WorkerPool.js +++ b/src/WorkerPool.js @@ -32,7 +32,7 @@ class PoolWorker { { detached: true, stdio: ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'], - }, + } ); this.worker.unref(); @@ -43,8 +43,8 @@ class PoolWorker { if (!this.worker.stdio) { throw new Error( `Failed to create the worker pool with workerId: ${workerId} and ${''}configuration: ${JSON.stringify( - options, - )}. Please verify if you hit the OS open files limit.`, + options + )}. Please verify if you hit the OS open files limit.` ); } @@ -125,7 +125,7 @@ class PoolWorker { this.readBuffer(4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with worker (read length) ${lengthReadError}`, + `Failed to communicate with worker (read length) ${lengthReadError}` ); return; } @@ -136,7 +136,7 @@ class PoolWorker { this.readBuffer(length, (messageError, messageBuffer) => { if (messageError) { console.error( - `Failed to communicate with worker (read message) ${messageError}`, + `Failed to communicate with worker (read message) ${messageError}` ); return; } @@ -147,7 +147,7 @@ class PoolWorker { this.onWorkerMessage(message, (err) => { if (err) { console.error( - `Failed to communicate with worker (process message) ${err}`, + `Failed to communicate with worker (process message) ${err}` ); return; } @@ -204,7 +204,7 @@ class PoolWorker { return; } callback(null, result); - }, + } ); break; } @@ -379,7 +379,7 @@ export default class WorkerPool { this.timeout = null; this.poolQueue = asyncQueue( this.distributeJob.bind(this), - options.poolParallelJobs, + options.poolParallelJobs ); this.terminated = false; @@ -441,7 +441,7 @@ export default class WorkerPool { nodeArgs: this.workerNodeArgs, parallelJobs: this.workerParallelJobs, }, - () => this.onJobDone(), + () => this.onJobDone() ); this.workers.add(newWorker); return newWorker; diff --git a/src/index.js b/src/index.js index 7bc5fee..fd25122 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,7 @@ function pitch() { // Compatibility with webpack v4 this.addBuildDependency ? this.addBuildDependency(d) - : this.addDependency(d), + : this.addDependency(d) ); } @@ -82,7 +82,7 @@ function pitch() { } callback(null, ...r.result); - }, + } ); } diff --git a/src/template.js b/src/template.js index 992e7c8..c50efb4 100644 --- a/src/template.js +++ b/src/template.js @@ -92,7 +92,7 @@ const replacer = (value, allowEmpty) => { if (value === null || value === undefined) { if (!allowEmpty) { throw new Error( - `Path variable ${match} not implemented in this context: ${input}`, + `Path variable ${match} not implemented in this context: ${input}` ); } @@ -174,8 +174,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( replacer(base), '[filebase] is now [base]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME', - ), + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME' + ) ); } @@ -193,7 +193,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacer(data.hash), data.hashWithLength, assetInfo, - 'fullhash', + 'fullhash' ); replacements.set('fullhash', hashReplacer); @@ -204,8 +204,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( hashReplacer, '[hash] is now [fullhash] (also consider using [chunkhash] or [contenthash], see documentation for details)', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH', - ), + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH' + ) ); } @@ -229,14 +229,14 @@ const replacePathVariables = (path, data, assetInfo) => { // eslint-disable-next-line no-undefined 'hashWithLength' in chunk ? chunk.hashWithLength : undefined, assetInfo, - 'chunkhash', + 'chunkhash' ); const contenthashReplacer = hashLength( replacer( data.contentHash || (contentHashType && chunk.contentHash && - chunk.contentHash[contentHashType]), + chunk.contentHash[contentHashType]) ), data.contentHashWithLength || ('contentHashWithLength' in chunk && chunk.contentHashWithLength @@ -244,7 +244,7 @@ const replacePathVariables = (path, data, assetInfo) => { : // eslint-disable-next-line no-undefined undefined), assetInfo, - 'contenthash', + 'contenthash' ); replacements.set('id', idReplacer); @@ -272,27 +272,27 @@ const replacePathVariables = (path, data, assetInfo) => { module instanceof Module ? /** @type {ModuleId} */ (/** @type {ChunkGraph} */ (chunkGraph).getModuleId(module)) - : module.id, - ), + : module.id + ) ); const moduleHashReplacer = hashLength( replacer(() => module instanceof Module ? /** @type {ChunkGraph} */ (chunkGraph).getRenderedModuleHash(module, data.runtime) - : module.hash, + : module.hash ), // eslint-disable-next-line no-undefined 'hashWithLength' in module ? module.hashWithLength : undefined, assetInfo, - 'modulehash', + 'modulehash' ); const contentHashReplacer = hashLength( replacer(/** @type {string} */ (data.contentHash)), // eslint-disable-next-line no-undefined undefined, assetInfo, - 'contenthash', + 'contenthash' ); replacements.set('id', idReplacer); @@ -300,7 +300,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacements.set('contenthash', contentHashReplacer); replacements.set( 'hash', - data.contentHash ? contentHashReplacer : moduleHashReplacer, + data.contentHash ? contentHashReplacer : moduleHashReplacer ); // Legacy replacements.set( @@ -308,8 +308,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( idReplacer, '[moduleid] is now [id]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID', - ), + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID' + ) ); } @@ -320,7 +320,7 @@ const replacePathVariables = (path, data, assetInfo) => { if (typeof data.runtime === 'string') { replacements.set( 'runtime', - replacer(() => prepareId(/** @type {string} */ (data.runtime))), + replacer(() => prepareId(/** @type {string} */ (data.runtime))) ); } else { replacements.set('runtime', replacer('_')); diff --git a/src/worker.js b/src/worker.js index 903a2f5..b7f91c8 100644 --- a/src/worker.js +++ b/src/worker.js @@ -204,7 +204,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { resolve(result); } }, - options, + options ); }); } @@ -383,7 +383,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { return createHash( // eslint-disable-next-line no-underscore-dangle - type || data._compilation.outputOptions.hashFunction, + type || data._compilation.outputOptions.hashFunction ); }, }, @@ -454,7 +454,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { writePipeWrite(buffer); }); setImmediate(taskCallback); - }, + } ); } catch (e) { writeJson({ @@ -513,7 +513,7 @@ function readNextMessage() { readBuffer(readPipe, 4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with main process (read length) ${lengthReadError}`, + `Failed to communicate with main process (read length) ${lengthReadError}` ); return; } @@ -532,7 +532,7 @@ function readNextMessage() { if (messageError) { console.error( - `Failed to communicate with main process (read message) ${messageError}`, + `Failed to communicate with main process (read message) ${messageError}` ); return; } diff --git a/test/basic-loader-test/test-loader.js b/test/basic-loader-test/test-loader.js index a1795bf..f7635d0 100644 --- a/test/basic-loader-test/test-loader.js +++ b/test/basic-loader-test/test-loader.js @@ -89,7 +89,7 @@ module.exports = async function testLoader() { } resolve({ source, map, mod }); - }), + }) ), importModule: typeof this.importModule, importModuleResult1: await this.importModule('./mod.js', { @@ -108,8 +108,8 @@ module.exports = async function testLoader() { } resolve(result); - }, - ), + } + ) ), callback: typeof this.callback, addDependency: typeof this.addDependency, @@ -124,6 +124,6 @@ module.exports = async function testLoader() { getMissingDependencies: typeof this.getMissingDependencies, getMissingDependenciesResult: this.getMissingDependencies(), clearDependencies: typeof this.clearDependencies, - })};`, + })};` ); }; diff --git a/test/pitch.test.js b/test/pitch.test.js index 9c3a207..87c8497 100644 --- a/test/pitch.test.js +++ b/test/pitch.test.js @@ -104,8 +104,8 @@ const runPitch = (options) => throw error; } }, - }, - ), + } + ) ); // it('runs pitch successfully when workPool not throw an error', () => { diff --git a/test/serializer.test.js b/test/serializer.test.js index c4245f7..a39e444 100644 --- a/test/serializer.test.js +++ b/test/serializer.test.js @@ -7,7 +7,7 @@ test('round-trips plain objects', () => { b: 'foo', c: [null, false], }, - replacer, + replacer ); expect(JSON.parse(json, reviver)).toEqual({ a: 1, @@ -22,7 +22,7 @@ test('round-trips regular expressions', () => { r: /hoge/g, s: /^(\w\s)+$/m, }, - replacer, + replacer ); expect(JSON.parse(json, reviver)).toEqual({ r: /hoge/g, diff --git a/test/webpack.test.js b/test/webpack.test.js index ab13bad..5f2562b 100644 --- a/test/webpack.test.js +++ b/test/webpack.test.js @@ -85,7 +85,7 @@ test('Works with test-loader', (done) => { expect(logs).toMatchSnapshot('logs'); const [testMod] = [...stats.compilation.modules].filter( - (i) => i.rawRequest === './file.js?q=1#hash', + (i) => i.rawRequest === './file.js?q=1#hash' ); expect(testMod.buildInfo.cacheable).toBe(false); diff --git a/test/workerPool.test.js b/test/workerPool.test.js index c262eb0..c76c057 100644 --- a/test/workerPool.test.js +++ b/test/workerPool.test.js @@ -18,7 +18,7 @@ describe('workerPool', () => { const workerPool = new WorkerPool({}); expect(() => workerPool.createWorker()).toThrowErrorMatchingSnapshot(); expect(() => workerPool.createWorker()).toThrowError( - 'Please verify if you hit the OS open files limit', + 'Please verify if you hit the OS open files limit' ); }); @@ -62,7 +62,7 @@ describe('workerPool', () => { expect(() => workerPool.createWorker()).not.toThrow(); const nonSanitizedNodeArgs = childProcess.spawn.mock.calls[0][1].filter( - (opt) => !opt, + (opt) => !opt ); expect(nonSanitizedNodeArgs.length).toEqual(0); }); From 9494b9e3044e18202ed416d15a49a893432e614a Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Mon, 2 Jun 2025 09:15:07 +0530 Subject: [PATCH 4/8] Revert "chore: fixed lint problems" This reverts commit 67fb6b823676448189c3d156612542906f0b4e8b. git push# --- src/WorkerPool.js | 18 +++++++------- src/index.js | 4 +-- src/template.js | 36 +++++++++++++-------------- src/worker.js | 10 ++++---- test/basic-loader-test/test-loader.js | 8 +++--- test/pitch.test.js | 4 +-- test/serializer.test.js | 4 +-- test/webpack.test.js | 2 +- test/workerPool.test.js | 4 +-- 9 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/WorkerPool.js b/src/WorkerPool.js index d304dd2..15db06f 100644 --- a/src/WorkerPool.js +++ b/src/WorkerPool.js @@ -32,7 +32,7 @@ class PoolWorker { { detached: true, stdio: ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'], - } + }, ); this.worker.unref(); @@ -43,8 +43,8 @@ class PoolWorker { if (!this.worker.stdio) { throw new Error( `Failed to create the worker pool with workerId: ${workerId} and ${''}configuration: ${JSON.stringify( - options - )}. Please verify if you hit the OS open files limit.` + options, + )}. Please verify if you hit the OS open files limit.`, ); } @@ -125,7 +125,7 @@ class PoolWorker { this.readBuffer(4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with worker (read length) ${lengthReadError}` + `Failed to communicate with worker (read length) ${lengthReadError}`, ); return; } @@ -136,7 +136,7 @@ class PoolWorker { this.readBuffer(length, (messageError, messageBuffer) => { if (messageError) { console.error( - `Failed to communicate with worker (read message) ${messageError}` + `Failed to communicate with worker (read message) ${messageError}`, ); return; } @@ -147,7 +147,7 @@ class PoolWorker { this.onWorkerMessage(message, (err) => { if (err) { console.error( - `Failed to communicate with worker (process message) ${err}` + `Failed to communicate with worker (process message) ${err}`, ); return; } @@ -204,7 +204,7 @@ class PoolWorker { return; } callback(null, result); - } + }, ); break; } @@ -379,7 +379,7 @@ export default class WorkerPool { this.timeout = null; this.poolQueue = asyncQueue( this.distributeJob.bind(this), - options.poolParallelJobs + options.poolParallelJobs, ); this.terminated = false; @@ -441,7 +441,7 @@ export default class WorkerPool { nodeArgs: this.workerNodeArgs, parallelJobs: this.workerParallelJobs, }, - () => this.onJobDone() + () => this.onJobDone(), ); this.workers.add(newWorker); return newWorker; diff --git a/src/index.js b/src/index.js index fd25122..7bc5fee 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,7 @@ function pitch() { // Compatibility with webpack v4 this.addBuildDependency ? this.addBuildDependency(d) - : this.addDependency(d) + : this.addDependency(d), ); } @@ -82,7 +82,7 @@ function pitch() { } callback(null, ...r.result); - } + }, ); } diff --git a/src/template.js b/src/template.js index c50efb4..992e7c8 100644 --- a/src/template.js +++ b/src/template.js @@ -92,7 +92,7 @@ const replacer = (value, allowEmpty) => { if (value === null || value === undefined) { if (!allowEmpty) { throw new Error( - `Path variable ${match} not implemented in this context: ${input}` + `Path variable ${match} not implemented in this context: ${input}`, ); } @@ -174,8 +174,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( replacer(base), '[filebase] is now [base]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME' - ) + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME', + ), ); } @@ -193,7 +193,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacer(data.hash), data.hashWithLength, assetInfo, - 'fullhash' + 'fullhash', ); replacements.set('fullhash', hashReplacer); @@ -204,8 +204,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( hashReplacer, '[hash] is now [fullhash] (also consider using [chunkhash] or [contenthash], see documentation for details)', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH' - ) + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH', + ), ); } @@ -229,14 +229,14 @@ const replacePathVariables = (path, data, assetInfo) => { // eslint-disable-next-line no-undefined 'hashWithLength' in chunk ? chunk.hashWithLength : undefined, assetInfo, - 'chunkhash' + 'chunkhash', ); const contenthashReplacer = hashLength( replacer( data.contentHash || (contentHashType && chunk.contentHash && - chunk.contentHash[contentHashType]) + chunk.contentHash[contentHashType]), ), data.contentHashWithLength || ('contentHashWithLength' in chunk && chunk.contentHashWithLength @@ -244,7 +244,7 @@ const replacePathVariables = (path, data, assetInfo) => { : // eslint-disable-next-line no-undefined undefined), assetInfo, - 'contenthash' + 'contenthash', ); replacements.set('id', idReplacer); @@ -272,27 +272,27 @@ const replacePathVariables = (path, data, assetInfo) => { module instanceof Module ? /** @type {ModuleId} */ (/** @type {ChunkGraph} */ (chunkGraph).getModuleId(module)) - : module.id - ) + : module.id, + ), ); const moduleHashReplacer = hashLength( replacer(() => module instanceof Module ? /** @type {ChunkGraph} */ (chunkGraph).getRenderedModuleHash(module, data.runtime) - : module.hash + : module.hash, ), // eslint-disable-next-line no-undefined 'hashWithLength' in module ? module.hashWithLength : undefined, assetInfo, - 'modulehash' + 'modulehash', ); const contentHashReplacer = hashLength( replacer(/** @type {string} */ (data.contentHash)), // eslint-disable-next-line no-undefined undefined, assetInfo, - 'contenthash' + 'contenthash', ); replacements.set('id', idReplacer); @@ -300,7 +300,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacements.set('contenthash', contentHashReplacer); replacements.set( 'hash', - data.contentHash ? contentHashReplacer : moduleHashReplacer + data.contentHash ? contentHashReplacer : moduleHashReplacer, ); // Legacy replacements.set( @@ -308,8 +308,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( idReplacer, '[moduleid] is now [id]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID' - ) + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID', + ), ); } @@ -320,7 +320,7 @@ const replacePathVariables = (path, data, assetInfo) => { if (typeof data.runtime === 'string') { replacements.set( 'runtime', - replacer(() => prepareId(/** @type {string} */ (data.runtime))) + replacer(() => prepareId(/** @type {string} */ (data.runtime))), ); } else { replacements.set('runtime', replacer('_')); diff --git a/src/worker.js b/src/worker.js index b7f91c8..903a2f5 100644 --- a/src/worker.js +++ b/src/worker.js @@ -204,7 +204,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { resolve(result); } }, - options + options, ); }); } @@ -383,7 +383,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { return createHash( // eslint-disable-next-line no-underscore-dangle - type || data._compilation.outputOptions.hashFunction + type || data._compilation.outputOptions.hashFunction, ); }, }, @@ -454,7 +454,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { writePipeWrite(buffer); }); setImmediate(taskCallback); - } + }, ); } catch (e) { writeJson({ @@ -513,7 +513,7 @@ function readNextMessage() { readBuffer(readPipe, 4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with main process (read length) ${lengthReadError}` + `Failed to communicate with main process (read length) ${lengthReadError}`, ); return; } @@ -532,7 +532,7 @@ function readNextMessage() { if (messageError) { console.error( - `Failed to communicate with main process (read message) ${messageError}` + `Failed to communicate with main process (read message) ${messageError}`, ); return; } diff --git a/test/basic-loader-test/test-loader.js b/test/basic-loader-test/test-loader.js index f7635d0..a1795bf 100644 --- a/test/basic-loader-test/test-loader.js +++ b/test/basic-loader-test/test-loader.js @@ -89,7 +89,7 @@ module.exports = async function testLoader() { } resolve({ source, map, mod }); - }) + }), ), importModule: typeof this.importModule, importModuleResult1: await this.importModule('./mod.js', { @@ -108,8 +108,8 @@ module.exports = async function testLoader() { } resolve(result); - } - ) + }, + ), ), callback: typeof this.callback, addDependency: typeof this.addDependency, @@ -124,6 +124,6 @@ module.exports = async function testLoader() { getMissingDependencies: typeof this.getMissingDependencies, getMissingDependenciesResult: this.getMissingDependencies(), clearDependencies: typeof this.clearDependencies, - })};` + })};`, ); }; diff --git a/test/pitch.test.js b/test/pitch.test.js index 87c8497..9c3a207 100644 --- a/test/pitch.test.js +++ b/test/pitch.test.js @@ -104,8 +104,8 @@ const runPitch = (options) => throw error; } }, - } - ) + }, + ), ); // it('runs pitch successfully when workPool not throw an error', () => { diff --git a/test/serializer.test.js b/test/serializer.test.js index a39e444..c4245f7 100644 --- a/test/serializer.test.js +++ b/test/serializer.test.js @@ -7,7 +7,7 @@ test('round-trips plain objects', () => { b: 'foo', c: [null, false], }, - replacer + replacer, ); expect(JSON.parse(json, reviver)).toEqual({ a: 1, @@ -22,7 +22,7 @@ test('round-trips regular expressions', () => { r: /hoge/g, s: /^(\w\s)+$/m, }, - replacer + replacer, ); expect(JSON.parse(json, reviver)).toEqual({ r: /hoge/g, diff --git a/test/webpack.test.js b/test/webpack.test.js index 5f2562b..ab13bad 100644 --- a/test/webpack.test.js +++ b/test/webpack.test.js @@ -85,7 +85,7 @@ test('Works with test-loader', (done) => { expect(logs).toMatchSnapshot('logs'); const [testMod] = [...stats.compilation.modules].filter( - (i) => i.rawRequest === './file.js?q=1#hash' + (i) => i.rawRequest === './file.js?q=1#hash', ); expect(testMod.buildInfo.cacheable).toBe(false); diff --git a/test/workerPool.test.js b/test/workerPool.test.js index c76c057..c262eb0 100644 --- a/test/workerPool.test.js +++ b/test/workerPool.test.js @@ -18,7 +18,7 @@ describe('workerPool', () => { const workerPool = new WorkerPool({}); expect(() => workerPool.createWorker()).toThrowErrorMatchingSnapshot(); expect(() => workerPool.createWorker()).toThrowError( - 'Please verify if you hit the OS open files limit' + 'Please verify if you hit the OS open files limit', ); }); @@ -62,7 +62,7 @@ describe('workerPool', () => { expect(() => workerPool.createWorker()).not.toThrow(); const nonSanitizedNodeArgs = childProcess.spawn.mock.calls[0][1].filter( - (opt) => !opt + (opt) => !opt, ); expect(nonSanitizedNodeArgs.length).toEqual(0); }); From 312d5fcb5e0afbf0f97e1e338fff28b92b01250d Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Thu, 5 Jun 2025 13:48:01 +0530 Subject: [PATCH 5/8] chore: fixed lint problems --- src/WorkerPool.js | 18 +++++++------- src/index.js | 4 +-- src/template.js | 36 +++++++++++++-------------- src/worker.js | 10 ++++---- test/basic-loader-test/test-loader.js | 8 +++--- test/pitch.test.js | 4 +-- test/serializer.test.js | 4 +-- test/webpack.test.js | 2 +- test/workerPool.test.js | 4 +-- 9 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/WorkerPool.js b/src/WorkerPool.js index 15db06f..d304dd2 100644 --- a/src/WorkerPool.js +++ b/src/WorkerPool.js @@ -32,7 +32,7 @@ class PoolWorker { { detached: true, stdio: ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'], - }, + } ); this.worker.unref(); @@ -43,8 +43,8 @@ class PoolWorker { if (!this.worker.stdio) { throw new Error( `Failed to create the worker pool with workerId: ${workerId} and ${''}configuration: ${JSON.stringify( - options, - )}. Please verify if you hit the OS open files limit.`, + options + )}. Please verify if you hit the OS open files limit.` ); } @@ -125,7 +125,7 @@ class PoolWorker { this.readBuffer(4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with worker (read length) ${lengthReadError}`, + `Failed to communicate with worker (read length) ${lengthReadError}` ); return; } @@ -136,7 +136,7 @@ class PoolWorker { this.readBuffer(length, (messageError, messageBuffer) => { if (messageError) { console.error( - `Failed to communicate with worker (read message) ${messageError}`, + `Failed to communicate with worker (read message) ${messageError}` ); return; } @@ -147,7 +147,7 @@ class PoolWorker { this.onWorkerMessage(message, (err) => { if (err) { console.error( - `Failed to communicate with worker (process message) ${err}`, + `Failed to communicate with worker (process message) ${err}` ); return; } @@ -204,7 +204,7 @@ class PoolWorker { return; } callback(null, result); - }, + } ); break; } @@ -379,7 +379,7 @@ export default class WorkerPool { this.timeout = null; this.poolQueue = asyncQueue( this.distributeJob.bind(this), - options.poolParallelJobs, + options.poolParallelJobs ); this.terminated = false; @@ -441,7 +441,7 @@ export default class WorkerPool { nodeArgs: this.workerNodeArgs, parallelJobs: this.workerParallelJobs, }, - () => this.onJobDone(), + () => this.onJobDone() ); this.workers.add(newWorker); return newWorker; diff --git a/src/index.js b/src/index.js index 7bc5fee..fd25122 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,7 @@ function pitch() { // Compatibility with webpack v4 this.addBuildDependency ? this.addBuildDependency(d) - : this.addDependency(d), + : this.addDependency(d) ); } @@ -82,7 +82,7 @@ function pitch() { } callback(null, ...r.result); - }, + } ); } diff --git a/src/template.js b/src/template.js index 992e7c8..c50efb4 100644 --- a/src/template.js +++ b/src/template.js @@ -92,7 +92,7 @@ const replacer = (value, allowEmpty) => { if (value === null || value === undefined) { if (!allowEmpty) { throw new Error( - `Path variable ${match} not implemented in this context: ${input}`, + `Path variable ${match} not implemented in this context: ${input}` ); } @@ -174,8 +174,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( replacer(base), '[filebase] is now [base]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME', - ), + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME' + ) ); } @@ -193,7 +193,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacer(data.hash), data.hashWithLength, assetInfo, - 'fullhash', + 'fullhash' ); replacements.set('fullhash', hashReplacer); @@ -204,8 +204,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( hashReplacer, '[hash] is now [fullhash] (also consider using [chunkhash] or [contenthash], see documentation for details)', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH', - ), + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH' + ) ); } @@ -229,14 +229,14 @@ const replacePathVariables = (path, data, assetInfo) => { // eslint-disable-next-line no-undefined 'hashWithLength' in chunk ? chunk.hashWithLength : undefined, assetInfo, - 'chunkhash', + 'chunkhash' ); const contenthashReplacer = hashLength( replacer( data.contentHash || (contentHashType && chunk.contentHash && - chunk.contentHash[contentHashType]), + chunk.contentHash[contentHashType]) ), data.contentHashWithLength || ('contentHashWithLength' in chunk && chunk.contentHashWithLength @@ -244,7 +244,7 @@ const replacePathVariables = (path, data, assetInfo) => { : // eslint-disable-next-line no-undefined undefined), assetInfo, - 'contenthash', + 'contenthash' ); replacements.set('id', idReplacer); @@ -272,27 +272,27 @@ const replacePathVariables = (path, data, assetInfo) => { module instanceof Module ? /** @type {ModuleId} */ (/** @type {ChunkGraph} */ (chunkGraph).getModuleId(module)) - : module.id, - ), + : module.id + ) ); const moduleHashReplacer = hashLength( replacer(() => module instanceof Module ? /** @type {ChunkGraph} */ (chunkGraph).getRenderedModuleHash(module, data.runtime) - : module.hash, + : module.hash ), // eslint-disable-next-line no-undefined 'hashWithLength' in module ? module.hashWithLength : undefined, assetInfo, - 'modulehash', + 'modulehash' ); const contentHashReplacer = hashLength( replacer(/** @type {string} */ (data.contentHash)), // eslint-disable-next-line no-undefined undefined, assetInfo, - 'contenthash', + 'contenthash' ); replacements.set('id', idReplacer); @@ -300,7 +300,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacements.set('contenthash', contentHashReplacer); replacements.set( 'hash', - data.contentHash ? contentHashReplacer : moduleHashReplacer, + data.contentHash ? contentHashReplacer : moduleHashReplacer ); // Legacy replacements.set( @@ -308,8 +308,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( idReplacer, '[moduleid] is now [id]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID', - ), + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID' + ) ); } @@ -320,7 +320,7 @@ const replacePathVariables = (path, data, assetInfo) => { if (typeof data.runtime === 'string') { replacements.set( 'runtime', - replacer(() => prepareId(/** @type {string} */ (data.runtime))), + replacer(() => prepareId(/** @type {string} */ (data.runtime))) ); } else { replacements.set('runtime', replacer('_')); diff --git a/src/worker.js b/src/worker.js index 903a2f5..b7f91c8 100644 --- a/src/worker.js +++ b/src/worker.js @@ -204,7 +204,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { resolve(result); } }, - options, + options ); }); } @@ -383,7 +383,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { return createHash( // eslint-disable-next-line no-underscore-dangle - type || data._compilation.outputOptions.hashFunction, + type || data._compilation.outputOptions.hashFunction ); }, }, @@ -454,7 +454,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { writePipeWrite(buffer); }); setImmediate(taskCallback); - }, + } ); } catch (e) { writeJson({ @@ -513,7 +513,7 @@ function readNextMessage() { readBuffer(readPipe, 4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with main process (read length) ${lengthReadError}`, + `Failed to communicate with main process (read length) ${lengthReadError}` ); return; } @@ -532,7 +532,7 @@ function readNextMessage() { if (messageError) { console.error( - `Failed to communicate with main process (read message) ${messageError}`, + `Failed to communicate with main process (read message) ${messageError}` ); return; } diff --git a/test/basic-loader-test/test-loader.js b/test/basic-loader-test/test-loader.js index a1795bf..f7635d0 100644 --- a/test/basic-loader-test/test-loader.js +++ b/test/basic-loader-test/test-loader.js @@ -89,7 +89,7 @@ module.exports = async function testLoader() { } resolve({ source, map, mod }); - }), + }) ), importModule: typeof this.importModule, importModuleResult1: await this.importModule('./mod.js', { @@ -108,8 +108,8 @@ module.exports = async function testLoader() { } resolve(result); - }, - ), + } + ) ), callback: typeof this.callback, addDependency: typeof this.addDependency, @@ -124,6 +124,6 @@ module.exports = async function testLoader() { getMissingDependencies: typeof this.getMissingDependencies, getMissingDependenciesResult: this.getMissingDependencies(), clearDependencies: typeof this.clearDependencies, - })};`, + })};` ); }; diff --git a/test/pitch.test.js b/test/pitch.test.js index 9c3a207..87c8497 100644 --- a/test/pitch.test.js +++ b/test/pitch.test.js @@ -104,8 +104,8 @@ const runPitch = (options) => throw error; } }, - }, - ), + } + ) ); // it('runs pitch successfully when workPool not throw an error', () => { diff --git a/test/serializer.test.js b/test/serializer.test.js index c4245f7..a39e444 100644 --- a/test/serializer.test.js +++ b/test/serializer.test.js @@ -7,7 +7,7 @@ test('round-trips plain objects', () => { b: 'foo', c: [null, false], }, - replacer, + replacer ); expect(JSON.parse(json, reviver)).toEqual({ a: 1, @@ -22,7 +22,7 @@ test('round-trips regular expressions', () => { r: /hoge/g, s: /^(\w\s)+$/m, }, - replacer, + replacer ); expect(JSON.parse(json, reviver)).toEqual({ r: /hoge/g, diff --git a/test/webpack.test.js b/test/webpack.test.js index ab13bad..5f2562b 100644 --- a/test/webpack.test.js +++ b/test/webpack.test.js @@ -85,7 +85,7 @@ test('Works with test-loader', (done) => { expect(logs).toMatchSnapshot('logs'); const [testMod] = [...stats.compilation.modules].filter( - (i) => i.rawRequest === './file.js?q=1#hash', + (i) => i.rawRequest === './file.js?q=1#hash' ); expect(testMod.buildInfo.cacheable).toBe(false); diff --git a/test/workerPool.test.js b/test/workerPool.test.js index c262eb0..c76c057 100644 --- a/test/workerPool.test.js +++ b/test/workerPool.test.js @@ -18,7 +18,7 @@ describe('workerPool', () => { const workerPool = new WorkerPool({}); expect(() => workerPool.createWorker()).toThrowErrorMatchingSnapshot(); expect(() => workerPool.createWorker()).toThrowError( - 'Please verify if you hit the OS open files limit', + 'Please verify if you hit the OS open files limit' ); }); @@ -62,7 +62,7 @@ describe('workerPool', () => { expect(() => workerPool.createWorker()).not.toThrow(); const nonSanitizedNodeArgs = childProcess.spawn.mock.calls[0][1].filter( - (opt) => !opt, + (opt) => !opt ); expect(nonSanitizedNodeArgs.length).toEqual(0); }); From d0e9b2e876c8269e6240f80608d9c1de79a1904e Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Thu, 5 Jun 2025 14:08:39 +0530 Subject: [PATCH 6/8] chore: fixed lint problems --- README.md | 2 +- package-lock.json | 326 ++------------------------ src/WorkerPool.js | 18 +- src/index.js | 4 +- src/template.js | 36 +-- src/worker.js | 10 +- test/basic-loader-test/test-loader.js | 8 +- test/pitch.test.js | 4 +- test/serializer.test.js | 4 +- test/webpack.test.js | 2 +- test/workerPool.test.js | 4 +- 11 files changed, 64 insertions(+), 354 deletions(-) diff --git a/README.md b/README.md index 5e1b4c0..d8e90b3 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ threadLoader.warmup( 'babel-loader', '@babel/preset-env', 'sass-loader', - ] + ], ); ``` diff --git a/package-lock.json b/package-lock.json index c144e3b..df3276a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5819,19 +5819,6 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, - "node_modules/copy-anything": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-2.0.6.tgz", - "integrity": "sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==", - "dev": true, - "peer": true, - "dependencies": { - "is-what": "^3.14.1" - }, - "funding": { - "url": "https://github.com/sponsors/mesqueeb" - } - }, "node_modules/core-js-compat": { "version": "3.38.1", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz", @@ -7084,20 +7071,6 @@ "node": ">=10.13.0" } }, - "node_modules/errno": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", - "integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "prr": "~1.0.1" - }, - "bin": { - "errno": "cli.js" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -8739,20 +8712,6 @@ "node": ">=10.18" } }, - "node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/icss-utils": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", @@ -8774,20 +8733,6 @@ "node": ">= 4" } }, - "node_modules/image-size": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz", - "integrity": "sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==", - "dev": true, - "optional": true, - "peer": true, - "bin": { - "image-size": "bin/image-size.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/immutable": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.7.tgz", @@ -9385,13 +9330,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-what": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz", - "integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==", - "dev": true, - "peer": true - }, "node_modules/is-woff": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-woff/-/is-woff-1.0.3.tgz", @@ -11293,33 +11231,6 @@ "node": ">=6" } }, - "node_modules/less": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/less/-/less-4.2.0.tgz", - "integrity": "sha512-P3b3HJDBtSzsXUl0im2L7gTO5Ubg8mEN6G8qoTS77iXxXX4Hvu4Qj540PZDvQ8V6DmX6iXo98k7Md0Cm1PrLaA==", - "dev": true, - "peer": true, - "dependencies": { - "copy-anything": "^2.0.1", - "parse-node-version": "^1.0.1", - "tslib": "^2.3.0" - }, - "bin": { - "lessc": "bin/lessc" - }, - "engines": { - "node": ">=6" - }, - "optionalDependencies": { - "errno": "^0.1.1", - "graceful-fs": "^4.1.2", - "image-size": "~0.5.0", - "make-dir": "^2.1.0", - "mime": "^1.4.1", - "needle": "^3.1.0", - "source-map": "~0.6.0" - } - }, "node_modules/less-loader": { "version": "11.1.4", "resolved": "https://registry.npmjs.org/less-loader/-/less-loader-11.1.4.tgz", @@ -12168,20 +12079,6 @@ "node": ">=8.6" } }, - "node_modules/mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true, - "optional": true, - "peer": true, - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -12315,24 +12212,6 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, - "node_modules/needle": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/needle/-/needle-3.3.1.tgz", - "integrity": "sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==", - "dev": true, - "optional": true, - "peer": true, - "dependencies": { - "iconv-lite": "^0.6.3", - "sax": "^1.2.4" - }, - "bin": { - "needle": "bin/needle" - }, - "engines": { - "node": ">= 4.4.x" - } - }, "node_modules/neo-async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", @@ -12762,16 +12641,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/parse-node-version": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", - "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", - "dev": true, - "peer": true, - "engines": { - "node": ">= 0.10" - } - }, "node_modules/path-exists": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", @@ -13128,14 +12997,6 @@ "node": ">= 6" } }, - "node_modules/prr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==", - "dev": true, - "optional": true, - "peer": true - }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -13680,14 +13541,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true, - "optional": true, - "peer": true - }, "node_modules/sass": { "version": "1.79.1", "resolved": "https://registry.npmjs.org/sass/-/sass-1.79.1.tgz", @@ -13773,14 +13626,6 @@ "url": "https://paulmillr.com/funding/" } }, - "node_modules/sax": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz", - "integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==", - "dev": true, - "optional": true, - "peer": true - }, "node_modules/schema-utils": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz", @@ -16021,8 +15866,7 @@ "version": "7.21.0-placeholder-for-preset-env.2", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", - "dev": true, - "requires": {} + "dev": true }, "@babel/plugin-syntax-async-generators": { "version": "7.8.4", @@ -18438,8 +18282,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@jsonjoy.com/base64/-/base64-1.1.2.tgz", "integrity": "sha512-q6XAnWQDIMA3+FTiOYajoYqySkO+JSat0ytXGSuRdq9uXE7o92gzuQwQM14xaCRlBLGq3v5miDGC4vkVTn54xA==", - "dev": true, - "requires": {} + "dev": true }, "@jsonjoy.com/json-pack": { "version": "1.1.0", @@ -18457,8 +18300,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/@jsonjoy.com/util/-/util-1.3.0.tgz", "integrity": "sha512-Cebt4Vk7k1xHy87kHY7KSPLT77A7Ev7IfOblyLZhtYEhrdQ6fX4EoLq3xOQ3O/DRMEh2ok5nyC180E+ABS8Wmw==", - "dev": true, - "requires": {} + "dev": true }, "@nicolo-ribaudo/chokidar-2": { "version": "2.1.8-no-fsevents.3", @@ -18836,8 +18678,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@webpack-contrib/eslint-config-webpack/-/eslint-config-webpack-3.0.0.tgz", "integrity": "sha512-3f0dwuTZ1JZpnoGQ6tAKBWluZKZZBXr1ADoaOAbPiW0OvSN7o0wXFLGyfw6J+fW756xIkZLZ8JDYP5zInIRvBA==", - "dev": true, - "requires": {} + "dev": true }, "@xtuc/ieee754": { "version": "1.2.0", @@ -18861,15 +18702,13 @@ "version": "1.9.5", "resolved": "https://registry.npmjs.org/acorn-import-attributes/-/acorn-import-attributes-1.9.5.tgz", "integrity": "sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ==", - "dev": true, - "requires": {} + "dev": true }, "acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "requires": {} + "dev": true }, "acorn-walk": { "version": "8.3.4", @@ -20007,16 +19846,6 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, - "copy-anything": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-2.0.6.tgz", - "integrity": "sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==", - "dev": true, - "peer": true, - "requires": { - "is-what": "^3.14.1" - } - }, "core-js-compat": { "version": "3.38.1", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz", @@ -20065,8 +19894,7 @@ "version": "4.4.0", "resolved": "https://registry.npmjs.org/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-4.4.0.tgz", "integrity": "sha512-BabizFdC3wBHhbI4kJh0VkQP9GkBfoHPydD0COMce1nJ1kJAB3F2TmJ/I7diULBKtmEWSwEbuN/KDtgnmUUVmw==", - "dev": true, - "requires": {} + "dev": true }, "create-jest": { "version": "29.7.0", @@ -20499,8 +20327,7 @@ "version": "1.5.3", "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.3.tgz", "integrity": "sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==", - "dev": true, - "requires": {} + "dev": true }, "deep-is": { "version": "0.1.4", @@ -20878,17 +20705,6 @@ "tapable": "^2.2.0" } }, - "errno": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", - "integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==", - "dev": true, - "optional": true, - "peer": true, - "requires": { - "prr": "~1.0.1" - } - }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -21201,8 +21017,7 @@ "version": "9.1.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", - "dev": true, - "requires": {} + "dev": true }, "eslint-import-resolver-node": { "version": "0.3.9", @@ -21994,8 +21809,7 @@ "version": "2.2.3", "resolved": "https://registry.npmjs.org/google-fonts-complete/-/google-fonts-complete-2.2.3.tgz", "integrity": "sha512-/0EkrmRkh4qdNmlcM55LU6fRp2pdF2tvWA908wqx0cWxzAP3FSNKAZg8SxjynGhkhiPQeM7UxH659cGYbFz3EQ==", - "dev": true, - "requires": {} + "dev": true }, "gopd": { "version": "1.0.1", @@ -22124,23 +21938,11 @@ "integrity": "sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A==", "dev": true }, - "iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, - "optional": true, - "peer": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - } - }, "icss-utils": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", - "dev": true, - "requires": {} + "dev": true }, "ignore": { "version": "5.3.2", @@ -22148,14 +21950,6 @@ "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true }, - "image-size": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz", - "integrity": "sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==", - "dev": true, - "optional": true, - "peer": true - }, "immutable": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.7.tgz", @@ -22554,13 +22348,6 @@ "call-bind": "^1.0.2" } }, - "is-what": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz", - "integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==", - "dev": true, - "peer": true - }, "is-woff": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-woff/-/is-woff-1.0.3.tgz", @@ -23271,8 +23058,7 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", - "dev": true, - "requires": {} + "dev": true }, "jest-regex-util": { "version": "29.6.3", @@ -23969,31 +23755,11 @@ "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", "dev": true }, - "less": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/less/-/less-4.2.0.tgz", - "integrity": "sha512-P3b3HJDBtSzsXUl0im2L7gTO5Ubg8mEN6G8qoTS77iXxXX4Hvu4Qj540PZDvQ8V6DmX6iXo98k7Md0Cm1PrLaA==", - "dev": true, - "peer": true, - "requires": { - "copy-anything": "^2.0.1", - "errno": "^0.1.1", - "graceful-fs": "^4.1.2", - "image-size": "~0.5.0", - "make-dir": "^2.1.0", - "mime": "^1.4.1", - "needle": "^3.1.0", - "parse-node-version": "^1.0.1", - "source-map": "~0.6.0", - "tslib": "^2.3.0" - } - }, "less-loader": { "version": "11.1.4", "resolved": "https://registry.npmjs.org/less-loader/-/less-loader-11.1.4.tgz", "integrity": "sha512-6/GrYaB6QcW6Vj+/9ZPgKKs6G10YZai/l/eJ4SLwbzqNTBsAqt5hSLVF47TgsiBxV1P6eAU0GYRH3YRuQU9V3A==", - "dev": true, - "requires": {} + "dev": true }, "leven": { "version": "3.1.0", @@ -24601,14 +24367,6 @@ "picomatch": "^2.3.1" } }, - "mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true, - "optional": true, - "peer": true - }, "mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -24696,18 +24454,6 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, - "needle": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/needle/-/needle-3.3.1.tgz", - "integrity": "sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==", - "dev": true, - "optional": true, - "peer": true, - "requires": { - "iconv-lite": "^0.6.3", - "sax": "^1.2.4" - } - }, "neo-async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", @@ -25010,13 +24756,6 @@ "lines-and-columns": "^1.1.6" } }, - "parse-node-version": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", - "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", - "dev": true, - "peer": true - }, "path-exists": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", @@ -25149,8 +24888,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.1.0.tgz", "integrity": "sha512-k3kNe0aNFQDAZGbin48pL2VNidTF0w4/eASDsxlyspobzU3wZQLOGj7L9gfRe0Jo9/4uud09DsjFNH7winGv8Q==", - "dev": true, - "requires": {} + "dev": true }, "postcss-modules-local-by-default": { "version": "4.0.5", @@ -25244,14 +24982,6 @@ "sisteransi": "^1.0.5" } }, - "prr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==", - "dev": true, - "optional": true, - "peer": true - }, "punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -25625,14 +25355,6 @@ "is-regex": "^1.1.4" } }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true, - "optional": true, - "peer": true - }, "sass": { "version": "1.79.1", "resolved": "https://registry.npmjs.org/sass/-/sass-1.79.1.tgz", @@ -25670,14 +25392,6 @@ "neo-async": "^2.6.2" } }, - "sax": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz", - "integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==", - "dev": true, - "optional": true, - "peer": true - }, "schema-utils": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz", @@ -26246,8 +25960,7 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "requires": {} + "dev": true }, "has-flag": { "version": "4.0.0", @@ -26321,8 +26034,7 @@ "version": "1.21.0", "resolved": "https://registry.npmjs.org/thingies/-/thingies-1.21.0.tgz", "integrity": "sha512-hsqsJsFMsV+aD4s3CWKk85ep/3I9XzYV/IXaSouJMYIoDlgyi11cBhsqYe9/geRfB0YIikBQg6raRaM+nIMP9g==", - "dev": true, - "requires": {} + "dev": true }, "through": { "version": "2.3.8", @@ -26370,8 +26082,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/tree-dump/-/tree-dump-1.0.2.tgz", "integrity": "sha512-dpev9ABuLWdEubk+cIaI9cHwRNNDjkBBLXTwI4UCUFdQ5xXKqNXoK4FEciw/vxf+NQ7Cb7sGUyeUtORvHIdRXQ==", - "dev": true, - "requires": {} + "dev": true }, "trim-newlines": { "version": "3.0.1", @@ -26809,8 +26520,7 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "requires": {} + "dev": true }, "eslint-scope": { "version": "5.1.1", diff --git a/src/WorkerPool.js b/src/WorkerPool.js index d304dd2..15db06f 100644 --- a/src/WorkerPool.js +++ b/src/WorkerPool.js @@ -32,7 +32,7 @@ class PoolWorker { { detached: true, stdio: ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'], - } + }, ); this.worker.unref(); @@ -43,8 +43,8 @@ class PoolWorker { if (!this.worker.stdio) { throw new Error( `Failed to create the worker pool with workerId: ${workerId} and ${''}configuration: ${JSON.stringify( - options - )}. Please verify if you hit the OS open files limit.` + options, + )}. Please verify if you hit the OS open files limit.`, ); } @@ -125,7 +125,7 @@ class PoolWorker { this.readBuffer(4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with worker (read length) ${lengthReadError}` + `Failed to communicate with worker (read length) ${lengthReadError}`, ); return; } @@ -136,7 +136,7 @@ class PoolWorker { this.readBuffer(length, (messageError, messageBuffer) => { if (messageError) { console.error( - `Failed to communicate with worker (read message) ${messageError}` + `Failed to communicate with worker (read message) ${messageError}`, ); return; } @@ -147,7 +147,7 @@ class PoolWorker { this.onWorkerMessage(message, (err) => { if (err) { console.error( - `Failed to communicate with worker (process message) ${err}` + `Failed to communicate with worker (process message) ${err}`, ); return; } @@ -204,7 +204,7 @@ class PoolWorker { return; } callback(null, result); - } + }, ); break; } @@ -379,7 +379,7 @@ export default class WorkerPool { this.timeout = null; this.poolQueue = asyncQueue( this.distributeJob.bind(this), - options.poolParallelJobs + options.poolParallelJobs, ); this.terminated = false; @@ -441,7 +441,7 @@ export default class WorkerPool { nodeArgs: this.workerNodeArgs, parallelJobs: this.workerParallelJobs, }, - () => this.onJobDone() + () => this.onJobDone(), ); this.workers.add(newWorker); return newWorker; diff --git a/src/index.js b/src/index.js index fd25122..7bc5fee 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,7 @@ function pitch() { // Compatibility with webpack v4 this.addBuildDependency ? this.addBuildDependency(d) - : this.addDependency(d) + : this.addDependency(d), ); } @@ -82,7 +82,7 @@ function pitch() { } callback(null, ...r.result); - } + }, ); } diff --git a/src/template.js b/src/template.js index c50efb4..992e7c8 100644 --- a/src/template.js +++ b/src/template.js @@ -92,7 +92,7 @@ const replacer = (value, allowEmpty) => { if (value === null || value === undefined) { if (!allowEmpty) { throw new Error( - `Path variable ${match} not implemented in this context: ${input}` + `Path variable ${match} not implemented in this context: ${input}`, ); } @@ -174,8 +174,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( replacer(base), '[filebase] is now [base]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME' - ) + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME', + ), ); } @@ -193,7 +193,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacer(data.hash), data.hashWithLength, assetInfo, - 'fullhash' + 'fullhash', ); replacements.set('fullhash', hashReplacer); @@ -204,8 +204,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( hashReplacer, '[hash] is now [fullhash] (also consider using [chunkhash] or [contenthash], see documentation for details)', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH' - ) + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH', + ), ); } @@ -229,14 +229,14 @@ const replacePathVariables = (path, data, assetInfo) => { // eslint-disable-next-line no-undefined 'hashWithLength' in chunk ? chunk.hashWithLength : undefined, assetInfo, - 'chunkhash' + 'chunkhash', ); const contenthashReplacer = hashLength( replacer( data.contentHash || (contentHashType && chunk.contentHash && - chunk.contentHash[contentHashType]) + chunk.contentHash[contentHashType]), ), data.contentHashWithLength || ('contentHashWithLength' in chunk && chunk.contentHashWithLength @@ -244,7 +244,7 @@ const replacePathVariables = (path, data, assetInfo) => { : // eslint-disable-next-line no-undefined undefined), assetInfo, - 'contenthash' + 'contenthash', ); replacements.set('id', idReplacer); @@ -272,27 +272,27 @@ const replacePathVariables = (path, data, assetInfo) => { module instanceof Module ? /** @type {ModuleId} */ (/** @type {ChunkGraph} */ (chunkGraph).getModuleId(module)) - : module.id - ) + : module.id, + ), ); const moduleHashReplacer = hashLength( replacer(() => module instanceof Module ? /** @type {ChunkGraph} */ (chunkGraph).getRenderedModuleHash(module, data.runtime) - : module.hash + : module.hash, ), // eslint-disable-next-line no-undefined 'hashWithLength' in module ? module.hashWithLength : undefined, assetInfo, - 'modulehash' + 'modulehash', ); const contentHashReplacer = hashLength( replacer(/** @type {string} */ (data.contentHash)), // eslint-disable-next-line no-undefined undefined, assetInfo, - 'contenthash' + 'contenthash', ); replacements.set('id', idReplacer); @@ -300,7 +300,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacements.set('contenthash', contentHashReplacer); replacements.set( 'hash', - data.contentHash ? contentHashReplacer : moduleHashReplacer + data.contentHash ? contentHashReplacer : moduleHashReplacer, ); // Legacy replacements.set( @@ -308,8 +308,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( idReplacer, '[moduleid] is now [id]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID' - ) + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID', + ), ); } @@ -320,7 +320,7 @@ const replacePathVariables = (path, data, assetInfo) => { if (typeof data.runtime === 'string') { replacements.set( 'runtime', - replacer(() => prepareId(/** @type {string} */ (data.runtime))) + replacer(() => prepareId(/** @type {string} */ (data.runtime))), ); } else { replacements.set('runtime', replacer('_')); diff --git a/src/worker.js b/src/worker.js index b7f91c8..903a2f5 100644 --- a/src/worker.js +++ b/src/worker.js @@ -204,7 +204,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { resolve(result); } }, - options + options, ); }); } @@ -383,7 +383,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { return createHash( // eslint-disable-next-line no-underscore-dangle - type || data._compilation.outputOptions.hashFunction + type || data._compilation.outputOptions.hashFunction, ); }, }, @@ -454,7 +454,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { writePipeWrite(buffer); }); setImmediate(taskCallback); - } + }, ); } catch (e) { writeJson({ @@ -513,7 +513,7 @@ function readNextMessage() { readBuffer(readPipe, 4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with main process (read length) ${lengthReadError}` + `Failed to communicate with main process (read length) ${lengthReadError}`, ); return; } @@ -532,7 +532,7 @@ function readNextMessage() { if (messageError) { console.error( - `Failed to communicate with main process (read message) ${messageError}` + `Failed to communicate with main process (read message) ${messageError}`, ); return; } diff --git a/test/basic-loader-test/test-loader.js b/test/basic-loader-test/test-loader.js index f7635d0..a1795bf 100644 --- a/test/basic-loader-test/test-loader.js +++ b/test/basic-loader-test/test-loader.js @@ -89,7 +89,7 @@ module.exports = async function testLoader() { } resolve({ source, map, mod }); - }) + }), ), importModule: typeof this.importModule, importModuleResult1: await this.importModule('./mod.js', { @@ -108,8 +108,8 @@ module.exports = async function testLoader() { } resolve(result); - } - ) + }, + ), ), callback: typeof this.callback, addDependency: typeof this.addDependency, @@ -124,6 +124,6 @@ module.exports = async function testLoader() { getMissingDependencies: typeof this.getMissingDependencies, getMissingDependenciesResult: this.getMissingDependencies(), clearDependencies: typeof this.clearDependencies, - })};` + })};`, ); }; diff --git a/test/pitch.test.js b/test/pitch.test.js index 87c8497..9c3a207 100644 --- a/test/pitch.test.js +++ b/test/pitch.test.js @@ -104,8 +104,8 @@ const runPitch = (options) => throw error; } }, - } - ) + }, + ), ); // it('runs pitch successfully when workPool not throw an error', () => { diff --git a/test/serializer.test.js b/test/serializer.test.js index a39e444..c4245f7 100644 --- a/test/serializer.test.js +++ b/test/serializer.test.js @@ -7,7 +7,7 @@ test('round-trips plain objects', () => { b: 'foo', c: [null, false], }, - replacer + replacer, ); expect(JSON.parse(json, reviver)).toEqual({ a: 1, @@ -22,7 +22,7 @@ test('round-trips regular expressions', () => { r: /hoge/g, s: /^(\w\s)+$/m, }, - replacer + replacer, ); expect(JSON.parse(json, reviver)).toEqual({ r: /hoge/g, diff --git a/test/webpack.test.js b/test/webpack.test.js index 5f2562b..ab13bad 100644 --- a/test/webpack.test.js +++ b/test/webpack.test.js @@ -85,7 +85,7 @@ test('Works with test-loader', (done) => { expect(logs).toMatchSnapshot('logs'); const [testMod] = [...stats.compilation.modules].filter( - (i) => i.rawRequest === './file.js?q=1#hash' + (i) => i.rawRequest === './file.js?q=1#hash', ); expect(testMod.buildInfo.cacheable).toBe(false); diff --git a/test/workerPool.test.js b/test/workerPool.test.js index c76c057..c262eb0 100644 --- a/test/workerPool.test.js +++ b/test/workerPool.test.js @@ -18,7 +18,7 @@ describe('workerPool', () => { const workerPool = new WorkerPool({}); expect(() => workerPool.createWorker()).toThrowErrorMatchingSnapshot(); expect(() => workerPool.createWorker()).toThrowError( - 'Please verify if you hit the OS open files limit' + 'Please verify if you hit the OS open files limit', ); }); @@ -62,7 +62,7 @@ describe('workerPool', () => { expect(() => workerPool.createWorker()).not.toThrow(); const nonSanitizedNodeArgs = childProcess.spawn.mock.calls[0][1].filter( - (opt) => !opt + (opt) => !opt, ); expect(nonSanitizedNodeArgs.length).toEqual(0); }); From 8d9e250aa054573dbe5045d0d50fe19bd1773fcc Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Thu, 5 Jun 2025 14:13:53 +0530 Subject: [PATCH 7/8] Revert "chore: fixed lint problems" This reverts commit d0e9b2e876c8269e6240f80608d9c1de79a1904e. --- README.md | 2 +- package-lock.json | 326 ++++++++++++++++++++++++-- src/WorkerPool.js | 18 +- src/index.js | 4 +- src/template.js | 36 +-- src/worker.js | 10 +- test/basic-loader-test/test-loader.js | 8 +- test/pitch.test.js | 4 +- test/serializer.test.js | 4 +- test/webpack.test.js | 2 +- test/workerPool.test.js | 4 +- 11 files changed, 354 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index d8e90b3..5e1b4c0 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ threadLoader.warmup( 'babel-loader', '@babel/preset-env', 'sass-loader', - ], + ] ); ``` diff --git a/package-lock.json b/package-lock.json index df3276a..c144e3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5819,6 +5819,19 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, + "node_modules/copy-anything": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-2.0.6.tgz", + "integrity": "sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==", + "dev": true, + "peer": true, + "dependencies": { + "is-what": "^3.14.1" + }, + "funding": { + "url": "https://github.com/sponsors/mesqueeb" + } + }, "node_modules/core-js-compat": { "version": "3.38.1", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz", @@ -7071,6 +7084,20 @@ "node": ">=10.13.0" } }, + "node_modules/errno": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", + "integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==", + "dev": true, + "optional": true, + "peer": true, + "dependencies": { + "prr": "~1.0.1" + }, + "bin": { + "errno": "cli.js" + } + }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -8712,6 +8739,20 @@ "node": ">=10.18" } }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "optional": true, + "peer": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/icss-utils": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", @@ -8733,6 +8774,20 @@ "node": ">= 4" } }, + "node_modules/image-size": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz", + "integrity": "sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==", + "dev": true, + "optional": true, + "peer": true, + "bin": { + "image-size": "bin/image-size.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/immutable": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.7.tgz", @@ -9330,6 +9385,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-what": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz", + "integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==", + "dev": true, + "peer": true + }, "node_modules/is-woff": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-woff/-/is-woff-1.0.3.tgz", @@ -11231,6 +11293,33 @@ "node": ">=6" } }, + "node_modules/less": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/less/-/less-4.2.0.tgz", + "integrity": "sha512-P3b3HJDBtSzsXUl0im2L7gTO5Ubg8mEN6G8qoTS77iXxXX4Hvu4Qj540PZDvQ8V6DmX6iXo98k7Md0Cm1PrLaA==", + "dev": true, + "peer": true, + "dependencies": { + "copy-anything": "^2.0.1", + "parse-node-version": "^1.0.1", + "tslib": "^2.3.0" + }, + "bin": { + "lessc": "bin/lessc" + }, + "engines": { + "node": ">=6" + }, + "optionalDependencies": { + "errno": "^0.1.1", + "graceful-fs": "^4.1.2", + "image-size": "~0.5.0", + "make-dir": "^2.1.0", + "mime": "^1.4.1", + "needle": "^3.1.0", + "source-map": "~0.6.0" + } + }, "node_modules/less-loader": { "version": "11.1.4", "resolved": "https://registry.npmjs.org/less-loader/-/less-loader-11.1.4.tgz", @@ -12079,6 +12168,20 @@ "node": ">=8.6" } }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true, + "optional": true, + "peer": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -12212,6 +12315,24 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node_modules/needle": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/needle/-/needle-3.3.1.tgz", + "integrity": "sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==", + "dev": true, + "optional": true, + "peer": true, + "dependencies": { + "iconv-lite": "^0.6.3", + "sax": "^1.2.4" + }, + "bin": { + "needle": "bin/needle" + }, + "engines": { + "node": ">= 4.4.x" + } + }, "node_modules/neo-async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", @@ -12641,6 +12762,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parse-node-version": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", + "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", + "dev": true, + "peer": true, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/path-exists": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", @@ -12997,6 +13128,14 @@ "node": ">= 6" } }, + "node_modules/prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==", + "dev": true, + "optional": true, + "peer": true + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -13541,6 +13680,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "optional": true, + "peer": true + }, "node_modules/sass": { "version": "1.79.1", "resolved": "https://registry.npmjs.org/sass/-/sass-1.79.1.tgz", @@ -13626,6 +13773,14 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/sax": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz", + "integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==", + "dev": true, + "optional": true, + "peer": true + }, "node_modules/schema-utils": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz", @@ -15866,7 +16021,8 @@ "version": "7.21.0-placeholder-for-preset-env.2", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", - "dev": true + "dev": true, + "requires": {} }, "@babel/plugin-syntax-async-generators": { "version": "7.8.4", @@ -18282,7 +18438,8 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@jsonjoy.com/base64/-/base64-1.1.2.tgz", "integrity": "sha512-q6XAnWQDIMA3+FTiOYajoYqySkO+JSat0ytXGSuRdq9uXE7o92gzuQwQM14xaCRlBLGq3v5miDGC4vkVTn54xA==", - "dev": true + "dev": true, + "requires": {} }, "@jsonjoy.com/json-pack": { "version": "1.1.0", @@ -18300,7 +18457,8 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/@jsonjoy.com/util/-/util-1.3.0.tgz", "integrity": "sha512-Cebt4Vk7k1xHy87kHY7KSPLT77A7Ev7IfOblyLZhtYEhrdQ6fX4EoLq3xOQ3O/DRMEh2ok5nyC180E+ABS8Wmw==", - "dev": true + "dev": true, + "requires": {} }, "@nicolo-ribaudo/chokidar-2": { "version": "2.1.8-no-fsevents.3", @@ -18678,7 +18836,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/@webpack-contrib/eslint-config-webpack/-/eslint-config-webpack-3.0.0.tgz", "integrity": "sha512-3f0dwuTZ1JZpnoGQ6tAKBWluZKZZBXr1ADoaOAbPiW0OvSN7o0wXFLGyfw6J+fW756xIkZLZ8JDYP5zInIRvBA==", - "dev": true + "dev": true, + "requires": {} }, "@xtuc/ieee754": { "version": "1.2.0", @@ -18702,13 +18861,15 @@ "version": "1.9.5", "resolved": "https://registry.npmjs.org/acorn-import-attributes/-/acorn-import-attributes-1.9.5.tgz", "integrity": "sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ==", - "dev": true + "dev": true, + "requires": {} }, "acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true + "dev": true, + "requires": {} }, "acorn-walk": { "version": "8.3.4", @@ -19846,6 +20007,16 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, + "copy-anything": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-2.0.6.tgz", + "integrity": "sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==", + "dev": true, + "peer": true, + "requires": { + "is-what": "^3.14.1" + } + }, "core-js-compat": { "version": "3.38.1", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz", @@ -19894,7 +20065,8 @@ "version": "4.4.0", "resolved": "https://registry.npmjs.org/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-4.4.0.tgz", "integrity": "sha512-BabizFdC3wBHhbI4kJh0VkQP9GkBfoHPydD0COMce1nJ1kJAB3F2TmJ/I7diULBKtmEWSwEbuN/KDtgnmUUVmw==", - "dev": true + "dev": true, + "requires": {} }, "create-jest": { "version": "29.7.0", @@ -20327,7 +20499,8 @@ "version": "1.5.3", "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.3.tgz", "integrity": "sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==", - "dev": true + "dev": true, + "requires": {} }, "deep-is": { "version": "0.1.4", @@ -20705,6 +20878,17 @@ "tapable": "^2.2.0" } }, + "errno": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", + "integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==", + "dev": true, + "optional": true, + "peer": true, + "requires": { + "prr": "~1.0.1" + } + }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -21017,7 +21201,8 @@ "version": "9.1.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", - "dev": true + "dev": true, + "requires": {} }, "eslint-import-resolver-node": { "version": "0.3.9", @@ -21809,7 +21994,8 @@ "version": "2.2.3", "resolved": "https://registry.npmjs.org/google-fonts-complete/-/google-fonts-complete-2.2.3.tgz", "integrity": "sha512-/0EkrmRkh4qdNmlcM55LU6fRp2pdF2tvWA908wqx0cWxzAP3FSNKAZg8SxjynGhkhiPQeM7UxH659cGYbFz3EQ==", - "dev": true + "dev": true, + "requires": {} }, "gopd": { "version": "1.0.1", @@ -21938,11 +22124,23 @@ "integrity": "sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A==", "dev": true }, + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "optional": true, + "peer": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + }, "icss-utils": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", - "dev": true + "dev": true, + "requires": {} }, "ignore": { "version": "5.3.2", @@ -21950,6 +22148,14 @@ "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true }, + "image-size": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz", + "integrity": "sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==", + "dev": true, + "optional": true, + "peer": true + }, "immutable": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.7.tgz", @@ -22348,6 +22554,13 @@ "call-bind": "^1.0.2" } }, + "is-what": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz", + "integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==", + "dev": true, + "peer": true + }, "is-woff": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-woff/-/is-woff-1.0.3.tgz", @@ -23058,7 +23271,8 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", - "dev": true + "dev": true, + "requires": {} }, "jest-regex-util": { "version": "29.6.3", @@ -23755,11 +23969,31 @@ "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", "dev": true }, + "less": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/less/-/less-4.2.0.tgz", + "integrity": "sha512-P3b3HJDBtSzsXUl0im2L7gTO5Ubg8mEN6G8qoTS77iXxXX4Hvu4Qj540PZDvQ8V6DmX6iXo98k7Md0Cm1PrLaA==", + "dev": true, + "peer": true, + "requires": { + "copy-anything": "^2.0.1", + "errno": "^0.1.1", + "graceful-fs": "^4.1.2", + "image-size": "~0.5.0", + "make-dir": "^2.1.0", + "mime": "^1.4.1", + "needle": "^3.1.0", + "parse-node-version": "^1.0.1", + "source-map": "~0.6.0", + "tslib": "^2.3.0" + } + }, "less-loader": { "version": "11.1.4", "resolved": "https://registry.npmjs.org/less-loader/-/less-loader-11.1.4.tgz", "integrity": "sha512-6/GrYaB6QcW6Vj+/9ZPgKKs6G10YZai/l/eJ4SLwbzqNTBsAqt5hSLVF47TgsiBxV1P6eAU0GYRH3YRuQU9V3A==", - "dev": true + "dev": true, + "requires": {} }, "leven": { "version": "3.1.0", @@ -24367,6 +24601,14 @@ "picomatch": "^2.3.1" } }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true, + "optional": true, + "peer": true + }, "mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -24454,6 +24696,18 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "needle": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/needle/-/needle-3.3.1.tgz", + "integrity": "sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==", + "dev": true, + "optional": true, + "peer": true, + "requires": { + "iconv-lite": "^0.6.3", + "sax": "^1.2.4" + } + }, "neo-async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", @@ -24756,6 +25010,13 @@ "lines-and-columns": "^1.1.6" } }, + "parse-node-version": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz", + "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", + "dev": true, + "peer": true + }, "path-exists": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", @@ -24888,7 +25149,8 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.1.0.tgz", "integrity": "sha512-k3kNe0aNFQDAZGbin48pL2VNidTF0w4/eASDsxlyspobzU3wZQLOGj7L9gfRe0Jo9/4uud09DsjFNH7winGv8Q==", - "dev": true + "dev": true, + "requires": {} }, "postcss-modules-local-by-default": { "version": "4.0.5", @@ -24982,6 +25244,14 @@ "sisteransi": "^1.0.5" } }, + "prr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", + "integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==", + "dev": true, + "optional": true, + "peer": true + }, "punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -25355,6 +25625,14 @@ "is-regex": "^1.1.4" } }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "optional": true, + "peer": true + }, "sass": { "version": "1.79.1", "resolved": "https://registry.npmjs.org/sass/-/sass-1.79.1.tgz", @@ -25392,6 +25670,14 @@ "neo-async": "^2.6.2" } }, + "sax": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz", + "integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==", + "dev": true, + "optional": true, + "peer": true + }, "schema-utils": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz", @@ -25960,7 +26246,8 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true + "dev": true, + "requires": {} }, "has-flag": { "version": "4.0.0", @@ -26034,7 +26321,8 @@ "version": "1.21.0", "resolved": "https://registry.npmjs.org/thingies/-/thingies-1.21.0.tgz", "integrity": "sha512-hsqsJsFMsV+aD4s3CWKk85ep/3I9XzYV/IXaSouJMYIoDlgyi11cBhsqYe9/geRfB0YIikBQg6raRaM+nIMP9g==", - "dev": true + "dev": true, + "requires": {} }, "through": { "version": "2.3.8", @@ -26082,7 +26370,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/tree-dump/-/tree-dump-1.0.2.tgz", "integrity": "sha512-dpev9ABuLWdEubk+cIaI9cHwRNNDjkBBLXTwI4UCUFdQ5xXKqNXoK4FEciw/vxf+NQ7Cb7sGUyeUtORvHIdRXQ==", - "dev": true + "dev": true, + "requires": {} }, "trim-newlines": { "version": "3.0.1", @@ -26520,7 +26809,8 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true + "dev": true, + "requires": {} }, "eslint-scope": { "version": "5.1.1", diff --git a/src/WorkerPool.js b/src/WorkerPool.js index 15db06f..d304dd2 100644 --- a/src/WorkerPool.js +++ b/src/WorkerPool.js @@ -32,7 +32,7 @@ class PoolWorker { { detached: true, stdio: ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'], - }, + } ); this.worker.unref(); @@ -43,8 +43,8 @@ class PoolWorker { if (!this.worker.stdio) { throw new Error( `Failed to create the worker pool with workerId: ${workerId} and ${''}configuration: ${JSON.stringify( - options, - )}. Please verify if you hit the OS open files limit.`, + options + )}. Please verify if you hit the OS open files limit.` ); } @@ -125,7 +125,7 @@ class PoolWorker { this.readBuffer(4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with worker (read length) ${lengthReadError}`, + `Failed to communicate with worker (read length) ${lengthReadError}` ); return; } @@ -136,7 +136,7 @@ class PoolWorker { this.readBuffer(length, (messageError, messageBuffer) => { if (messageError) { console.error( - `Failed to communicate with worker (read message) ${messageError}`, + `Failed to communicate with worker (read message) ${messageError}` ); return; } @@ -147,7 +147,7 @@ class PoolWorker { this.onWorkerMessage(message, (err) => { if (err) { console.error( - `Failed to communicate with worker (process message) ${err}`, + `Failed to communicate with worker (process message) ${err}` ); return; } @@ -204,7 +204,7 @@ class PoolWorker { return; } callback(null, result); - }, + } ); break; } @@ -379,7 +379,7 @@ export default class WorkerPool { this.timeout = null; this.poolQueue = asyncQueue( this.distributeJob.bind(this), - options.poolParallelJobs, + options.poolParallelJobs ); this.terminated = false; @@ -441,7 +441,7 @@ export default class WorkerPool { nodeArgs: this.workerNodeArgs, parallelJobs: this.workerParallelJobs, }, - () => this.onJobDone(), + () => this.onJobDone() ); this.workers.add(newWorker); return newWorker; diff --git a/src/index.js b/src/index.js index 7bc5fee..fd25122 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,7 @@ function pitch() { // Compatibility with webpack v4 this.addBuildDependency ? this.addBuildDependency(d) - : this.addDependency(d), + : this.addDependency(d) ); } @@ -82,7 +82,7 @@ function pitch() { } callback(null, ...r.result); - }, + } ); } diff --git a/src/template.js b/src/template.js index 992e7c8..c50efb4 100644 --- a/src/template.js +++ b/src/template.js @@ -92,7 +92,7 @@ const replacer = (value, allowEmpty) => { if (value === null || value === undefined) { if (!allowEmpty) { throw new Error( - `Path variable ${match} not implemented in this context: ${input}`, + `Path variable ${match} not implemented in this context: ${input}` ); } @@ -174,8 +174,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( replacer(base), '[filebase] is now [base]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME', - ), + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME' + ) ); } @@ -193,7 +193,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacer(data.hash), data.hashWithLength, assetInfo, - 'fullhash', + 'fullhash' ); replacements.set('fullhash', hashReplacer); @@ -204,8 +204,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( hashReplacer, '[hash] is now [fullhash] (also consider using [chunkhash] or [contenthash], see documentation for details)', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH', - ), + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH' + ) ); } @@ -229,14 +229,14 @@ const replacePathVariables = (path, data, assetInfo) => { // eslint-disable-next-line no-undefined 'hashWithLength' in chunk ? chunk.hashWithLength : undefined, assetInfo, - 'chunkhash', + 'chunkhash' ); const contenthashReplacer = hashLength( replacer( data.contentHash || (contentHashType && chunk.contentHash && - chunk.contentHash[contentHashType]), + chunk.contentHash[contentHashType]) ), data.contentHashWithLength || ('contentHashWithLength' in chunk && chunk.contentHashWithLength @@ -244,7 +244,7 @@ const replacePathVariables = (path, data, assetInfo) => { : // eslint-disable-next-line no-undefined undefined), assetInfo, - 'contenthash', + 'contenthash' ); replacements.set('id', idReplacer); @@ -272,27 +272,27 @@ const replacePathVariables = (path, data, assetInfo) => { module instanceof Module ? /** @type {ModuleId} */ (/** @type {ChunkGraph} */ (chunkGraph).getModuleId(module)) - : module.id, - ), + : module.id + ) ); const moduleHashReplacer = hashLength( replacer(() => module instanceof Module ? /** @type {ChunkGraph} */ (chunkGraph).getRenderedModuleHash(module, data.runtime) - : module.hash, + : module.hash ), // eslint-disable-next-line no-undefined 'hashWithLength' in module ? module.hashWithLength : undefined, assetInfo, - 'modulehash', + 'modulehash' ); const contentHashReplacer = hashLength( replacer(/** @type {string} */ (data.contentHash)), // eslint-disable-next-line no-undefined undefined, assetInfo, - 'contenthash', + 'contenthash' ); replacements.set('id', idReplacer); @@ -300,7 +300,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacements.set('contenthash', contentHashReplacer); replacements.set( 'hash', - data.contentHash ? contentHashReplacer : moduleHashReplacer, + data.contentHash ? contentHashReplacer : moduleHashReplacer ); // Legacy replacements.set( @@ -308,8 +308,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( idReplacer, '[moduleid] is now [id]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID', - ), + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID' + ) ); } @@ -320,7 +320,7 @@ const replacePathVariables = (path, data, assetInfo) => { if (typeof data.runtime === 'string') { replacements.set( 'runtime', - replacer(() => prepareId(/** @type {string} */ (data.runtime))), + replacer(() => prepareId(/** @type {string} */ (data.runtime))) ); } else { replacements.set('runtime', replacer('_')); diff --git a/src/worker.js b/src/worker.js index 903a2f5..b7f91c8 100644 --- a/src/worker.js +++ b/src/worker.js @@ -204,7 +204,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { resolve(result); } }, - options, + options ); }); } @@ -383,7 +383,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { return createHash( // eslint-disable-next-line no-underscore-dangle - type || data._compilation.outputOptions.hashFunction, + type || data._compilation.outputOptions.hashFunction ); }, }, @@ -454,7 +454,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { writePipeWrite(buffer); }); setImmediate(taskCallback); - }, + } ); } catch (e) { writeJson({ @@ -513,7 +513,7 @@ function readNextMessage() { readBuffer(readPipe, 4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with main process (read length) ${lengthReadError}`, + `Failed to communicate with main process (read length) ${lengthReadError}` ); return; } @@ -532,7 +532,7 @@ function readNextMessage() { if (messageError) { console.error( - `Failed to communicate with main process (read message) ${messageError}`, + `Failed to communicate with main process (read message) ${messageError}` ); return; } diff --git a/test/basic-loader-test/test-loader.js b/test/basic-loader-test/test-loader.js index a1795bf..f7635d0 100644 --- a/test/basic-loader-test/test-loader.js +++ b/test/basic-loader-test/test-loader.js @@ -89,7 +89,7 @@ module.exports = async function testLoader() { } resolve({ source, map, mod }); - }), + }) ), importModule: typeof this.importModule, importModuleResult1: await this.importModule('./mod.js', { @@ -108,8 +108,8 @@ module.exports = async function testLoader() { } resolve(result); - }, - ), + } + ) ), callback: typeof this.callback, addDependency: typeof this.addDependency, @@ -124,6 +124,6 @@ module.exports = async function testLoader() { getMissingDependencies: typeof this.getMissingDependencies, getMissingDependenciesResult: this.getMissingDependencies(), clearDependencies: typeof this.clearDependencies, - })};`, + })};` ); }; diff --git a/test/pitch.test.js b/test/pitch.test.js index 9c3a207..87c8497 100644 --- a/test/pitch.test.js +++ b/test/pitch.test.js @@ -104,8 +104,8 @@ const runPitch = (options) => throw error; } }, - }, - ), + } + ) ); // it('runs pitch successfully when workPool not throw an error', () => { diff --git a/test/serializer.test.js b/test/serializer.test.js index c4245f7..a39e444 100644 --- a/test/serializer.test.js +++ b/test/serializer.test.js @@ -7,7 +7,7 @@ test('round-trips plain objects', () => { b: 'foo', c: [null, false], }, - replacer, + replacer ); expect(JSON.parse(json, reviver)).toEqual({ a: 1, @@ -22,7 +22,7 @@ test('round-trips regular expressions', () => { r: /hoge/g, s: /^(\w\s)+$/m, }, - replacer, + replacer ); expect(JSON.parse(json, reviver)).toEqual({ r: /hoge/g, diff --git a/test/webpack.test.js b/test/webpack.test.js index ab13bad..5f2562b 100644 --- a/test/webpack.test.js +++ b/test/webpack.test.js @@ -85,7 +85,7 @@ test('Works with test-loader', (done) => { expect(logs).toMatchSnapshot('logs'); const [testMod] = [...stats.compilation.modules].filter( - (i) => i.rawRequest === './file.js?q=1#hash', + (i) => i.rawRequest === './file.js?q=1#hash' ); expect(testMod.buildInfo.cacheable).toBe(false); diff --git a/test/workerPool.test.js b/test/workerPool.test.js index c262eb0..c76c057 100644 --- a/test/workerPool.test.js +++ b/test/workerPool.test.js @@ -18,7 +18,7 @@ describe('workerPool', () => { const workerPool = new WorkerPool({}); expect(() => workerPool.createWorker()).toThrowErrorMatchingSnapshot(); expect(() => workerPool.createWorker()).toThrowError( - 'Please verify if you hit the OS open files limit', + 'Please verify if you hit the OS open files limit' ); }); @@ -62,7 +62,7 @@ describe('workerPool', () => { expect(() => workerPool.createWorker()).not.toThrow(); const nonSanitizedNodeArgs = childProcess.spawn.mock.calls[0][1].filter( - (opt) => !opt, + (opt) => !opt ); expect(nonSanitizedNodeArgs.length).toEqual(0); }); From b1bef50cd33b734e0b124c147a18663623b707d7 Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Thu, 5 Jun 2025 14:19:11 +0530 Subject: [PATCH 8/8] chore: fixed lint problems --- README.md | 2 +- src/WorkerPool.js | 18 +++++++------- src/index.js | 4 +-- src/template.js | 36 +++++++++++++-------------- src/worker.js | 10 ++++---- test/basic-loader-test/test-loader.js | 8 +++--- test/pitch.test.js | 4 +-- test/serializer.test.js | 4 +-- test/webpack.test.js | 2 +- test/workerPool.test.js | 4 +-- 10 files changed, 46 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 5e1b4c0..d8e90b3 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ threadLoader.warmup( 'babel-loader', '@babel/preset-env', 'sass-loader', - ] + ], ); ``` diff --git a/src/WorkerPool.js b/src/WorkerPool.js index d304dd2..15db06f 100644 --- a/src/WorkerPool.js +++ b/src/WorkerPool.js @@ -32,7 +32,7 @@ class PoolWorker { { detached: true, stdio: ['ignore', 'pipe', 'pipe', 'pipe', 'pipe'], - } + }, ); this.worker.unref(); @@ -43,8 +43,8 @@ class PoolWorker { if (!this.worker.stdio) { throw new Error( `Failed to create the worker pool with workerId: ${workerId} and ${''}configuration: ${JSON.stringify( - options - )}. Please verify if you hit the OS open files limit.` + options, + )}. Please verify if you hit the OS open files limit.`, ); } @@ -125,7 +125,7 @@ class PoolWorker { this.readBuffer(4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with worker (read length) ${lengthReadError}` + `Failed to communicate with worker (read length) ${lengthReadError}`, ); return; } @@ -136,7 +136,7 @@ class PoolWorker { this.readBuffer(length, (messageError, messageBuffer) => { if (messageError) { console.error( - `Failed to communicate with worker (read message) ${messageError}` + `Failed to communicate with worker (read message) ${messageError}`, ); return; } @@ -147,7 +147,7 @@ class PoolWorker { this.onWorkerMessage(message, (err) => { if (err) { console.error( - `Failed to communicate with worker (process message) ${err}` + `Failed to communicate with worker (process message) ${err}`, ); return; } @@ -204,7 +204,7 @@ class PoolWorker { return; } callback(null, result); - } + }, ); break; } @@ -379,7 +379,7 @@ export default class WorkerPool { this.timeout = null; this.poolQueue = asyncQueue( this.distributeJob.bind(this), - options.poolParallelJobs + options.poolParallelJobs, ); this.terminated = false; @@ -441,7 +441,7 @@ export default class WorkerPool { nodeArgs: this.workerNodeArgs, parallelJobs: this.workerParallelJobs, }, - () => this.onJobDone() + () => this.onJobDone(), ); this.workers.add(newWorker); return newWorker; diff --git a/src/index.js b/src/index.js index fd25122..7bc5fee 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,7 @@ function pitch() { // Compatibility with webpack v4 this.addBuildDependency ? this.addBuildDependency(d) - : this.addDependency(d) + : this.addDependency(d), ); } @@ -82,7 +82,7 @@ function pitch() { } callback(null, ...r.result); - } + }, ); } diff --git a/src/template.js b/src/template.js index c50efb4..992e7c8 100644 --- a/src/template.js +++ b/src/template.js @@ -92,7 +92,7 @@ const replacer = (value, allowEmpty) => { if (value === null || value === undefined) { if (!allowEmpty) { throw new Error( - `Path variable ${match} not implemented in this context: ${input}` + `Path variable ${match} not implemented in this context: ${input}`, ); } @@ -174,8 +174,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( replacer(base), '[filebase] is now [base]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME' - ) + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME', + ), ); } @@ -193,7 +193,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacer(data.hash), data.hashWithLength, assetInfo, - 'fullhash' + 'fullhash', ); replacements.set('fullhash', hashReplacer); @@ -204,8 +204,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( hashReplacer, '[hash] is now [fullhash] (also consider using [chunkhash] or [contenthash], see documentation for details)', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH' - ) + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH', + ), ); } @@ -229,14 +229,14 @@ const replacePathVariables = (path, data, assetInfo) => { // eslint-disable-next-line no-undefined 'hashWithLength' in chunk ? chunk.hashWithLength : undefined, assetInfo, - 'chunkhash' + 'chunkhash', ); const contenthashReplacer = hashLength( replacer( data.contentHash || (contentHashType && chunk.contentHash && - chunk.contentHash[contentHashType]) + chunk.contentHash[contentHashType]), ), data.contentHashWithLength || ('contentHashWithLength' in chunk && chunk.contentHashWithLength @@ -244,7 +244,7 @@ const replacePathVariables = (path, data, assetInfo) => { : // eslint-disable-next-line no-undefined undefined), assetInfo, - 'contenthash' + 'contenthash', ); replacements.set('id', idReplacer); @@ -272,27 +272,27 @@ const replacePathVariables = (path, data, assetInfo) => { module instanceof Module ? /** @type {ModuleId} */ (/** @type {ChunkGraph} */ (chunkGraph).getModuleId(module)) - : module.id - ) + : module.id, + ), ); const moduleHashReplacer = hashLength( replacer(() => module instanceof Module ? /** @type {ChunkGraph} */ (chunkGraph).getRenderedModuleHash(module, data.runtime) - : module.hash + : module.hash, ), // eslint-disable-next-line no-undefined 'hashWithLength' in module ? module.hashWithLength : undefined, assetInfo, - 'modulehash' + 'modulehash', ); const contentHashReplacer = hashLength( replacer(/** @type {string} */ (data.contentHash)), // eslint-disable-next-line no-undefined undefined, assetInfo, - 'contenthash' + 'contenthash', ); replacements.set('id', idReplacer); @@ -300,7 +300,7 @@ const replacePathVariables = (path, data, assetInfo) => { replacements.set('contenthash', contentHashReplacer); replacements.set( 'hash', - data.contentHash ? contentHashReplacer : moduleHashReplacer + data.contentHash ? contentHashReplacer : moduleHashReplacer, ); // Legacy replacements.set( @@ -308,8 +308,8 @@ const replacePathVariables = (path, data, assetInfo) => { deprecated( idReplacer, '[moduleid] is now [id]', - 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID' - ) + 'DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_MODULE_ID', + ), ); } @@ -320,7 +320,7 @@ const replacePathVariables = (path, data, assetInfo) => { if (typeof data.runtime === 'string') { replacements.set( 'runtime', - replacer(() => prepareId(/** @type {string} */ (data.runtime))) + replacer(() => prepareId(/** @type {string} */ (data.runtime))), ); } else { replacements.set('runtime', replacer('_')); diff --git a/src/worker.js b/src/worker.js index b7f91c8..903a2f5 100644 --- a/src/worker.js +++ b/src/worker.js @@ -204,7 +204,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { resolve(result); } }, - options + options, ); }); } @@ -383,7 +383,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { return createHash( // eslint-disable-next-line no-underscore-dangle - type || data._compilation.outputOptions.hashFunction + type || data._compilation.outputOptions.hashFunction, ); }, }, @@ -454,7 +454,7 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { writePipeWrite(buffer); }); setImmediate(taskCallback); - } + }, ); } catch (e) { writeJson({ @@ -513,7 +513,7 @@ function readNextMessage() { readBuffer(readPipe, 4, (lengthReadError, lengthBuffer) => { if (lengthReadError) { console.error( - `Failed to communicate with main process (read length) ${lengthReadError}` + `Failed to communicate with main process (read length) ${lengthReadError}`, ); return; } @@ -532,7 +532,7 @@ function readNextMessage() { if (messageError) { console.error( - `Failed to communicate with main process (read message) ${messageError}` + `Failed to communicate with main process (read message) ${messageError}`, ); return; } diff --git a/test/basic-loader-test/test-loader.js b/test/basic-loader-test/test-loader.js index f7635d0..a1795bf 100644 --- a/test/basic-loader-test/test-loader.js +++ b/test/basic-loader-test/test-loader.js @@ -89,7 +89,7 @@ module.exports = async function testLoader() { } resolve({ source, map, mod }); - }) + }), ), importModule: typeof this.importModule, importModuleResult1: await this.importModule('./mod.js', { @@ -108,8 +108,8 @@ module.exports = async function testLoader() { } resolve(result); - } - ) + }, + ), ), callback: typeof this.callback, addDependency: typeof this.addDependency, @@ -124,6 +124,6 @@ module.exports = async function testLoader() { getMissingDependencies: typeof this.getMissingDependencies, getMissingDependenciesResult: this.getMissingDependencies(), clearDependencies: typeof this.clearDependencies, - })};` + })};`, ); }; diff --git a/test/pitch.test.js b/test/pitch.test.js index 87c8497..9c3a207 100644 --- a/test/pitch.test.js +++ b/test/pitch.test.js @@ -104,8 +104,8 @@ const runPitch = (options) => throw error; } }, - } - ) + }, + ), ); // it('runs pitch successfully when workPool not throw an error', () => { diff --git a/test/serializer.test.js b/test/serializer.test.js index a39e444..c4245f7 100644 --- a/test/serializer.test.js +++ b/test/serializer.test.js @@ -7,7 +7,7 @@ test('round-trips plain objects', () => { b: 'foo', c: [null, false], }, - replacer + replacer, ); expect(JSON.parse(json, reviver)).toEqual({ a: 1, @@ -22,7 +22,7 @@ test('round-trips regular expressions', () => { r: /hoge/g, s: /^(\w\s)+$/m, }, - replacer + replacer, ); expect(JSON.parse(json, reviver)).toEqual({ r: /hoge/g, diff --git a/test/webpack.test.js b/test/webpack.test.js index 5f2562b..ab13bad 100644 --- a/test/webpack.test.js +++ b/test/webpack.test.js @@ -85,7 +85,7 @@ test('Works with test-loader', (done) => { expect(logs).toMatchSnapshot('logs'); const [testMod] = [...stats.compilation.modules].filter( - (i) => i.rawRequest === './file.js?q=1#hash' + (i) => i.rawRequest === './file.js?q=1#hash', ); expect(testMod.buildInfo.cacheable).toBe(false); diff --git a/test/workerPool.test.js b/test/workerPool.test.js index c76c057..c262eb0 100644 --- a/test/workerPool.test.js +++ b/test/workerPool.test.js @@ -18,7 +18,7 @@ describe('workerPool', () => { const workerPool = new WorkerPool({}); expect(() => workerPool.createWorker()).toThrowErrorMatchingSnapshot(); expect(() => workerPool.createWorker()).toThrowError( - 'Please verify if you hit the OS open files limit' + 'Please verify if you hit the OS open files limit', ); }); @@ -62,7 +62,7 @@ describe('workerPool', () => { expect(() => workerPool.createWorker()).not.toThrow(); const nonSanitizedNodeArgs = childProcess.spawn.mock.calls[0][1].filter( - (opt) => !opt + (opt) => !opt, ); expect(nonSanitizedNodeArgs.length).toEqual(0); });