From 74b10f247f2e3f993d7c8ebcbfbee967ff8b8e67 Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Tue, 17 Sep 2024 20:22:47 +0300 Subject: [PATCH 1/4] fix: work with `importModule` --- .eslintignore | 6 +- src/WorkerPool.js | 31 ++++++ src/index.js | 10 +- src/worker.js | 29 ++++++ test/__snapshots__/webpack.test.js.snap | 115 +++++++++++++++++++++ test/basic-loader-test/build-dep.js | 0 test/basic-loader-test/dep.js | 0 test/basic-loader-test/dep1.js | 0 test/basic-loader-test/directory/test.js | 0 test/basic-loader-test/index.js | 4 + test/basic-loader-test/mod.js | 1 + test/basic-loader-test/mod1.js | 1 + test/basic-loader-test/mod2.js | 3 + test/basic-loader-test/style.less | 3 + test/basic-loader-test/test-loader.js | 102 ++++++++++++++++++ test/basic-loader-test/test.js | 1 + test/basic-loader-test/webpack.config.js | 43 ++++++++ test/less-loader-example/webpack.config.js | 2 +- test/sass-loader-example/webpack.config.js | 2 +- test/ts-loader-example/webpack.config.js | 2 +- test/webpack.test.js | 50 +++++---- 21 files changed, 377 insertions(+), 28 deletions(-) create mode 100644 test/__snapshots__/webpack.test.js.snap create mode 100644 test/basic-loader-test/build-dep.js create mode 100644 test/basic-loader-test/dep.js create mode 100644 test/basic-loader-test/dep1.js create mode 100644 test/basic-loader-test/directory/test.js create mode 100644 test/basic-loader-test/index.js create mode 100644 test/basic-loader-test/mod.js create mode 100644 test/basic-loader-test/mod1.js create mode 100644 test/basic-loader-test/mod2.js create mode 100644 test/basic-loader-test/style.less create mode 100644 test/basic-loader-test/test-loader.js create mode 100644 test/basic-loader-test/test.js create mode 100644 test/basic-loader-test/webpack.config.js diff --git a/.eslintignore b/.eslintignore index c52afd1..f4d3f35 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,8 @@ /coverage /dist /node_modules -/test/fixtures \ No newline at end of file +/test/fixtures +/test/basic-loader-test/mod.js +/test/basic-loader-test/mod1.js +/test/basic-loader-test/mod2.js + diff --git a/src/WorkerPool.js b/src/WorkerPool.js index aacf8d4..0f4e412 100644 --- a/src/WorkerPool.js +++ b/src/WorkerPool.js @@ -234,6 +234,37 @@ class PoolWorker { finalCallback(); break; } + case 'importModule': { + const { request, options, questionId } = message; + const { data } = this.jobs[id]; + + data + .importModule(request, options) + .then((result) => { + this.writeJson({ + type: 'result', + id: questionId, + error: null, + result, + }); + }) + .catch((error) => { + this.writeJson({ + type: 'result', + id: questionId, + error: error + ? { + message: error.message, + details: error.details, + missing: error.missing, + } + : null, + }); + }); + + finalCallback(); + break; + } case 'resolve': { const { context, request, options, questionId } = message; const { data } = this.jobs[id]; diff --git a/src/index.js b/src/index.js index c2cc5d4..fcdd0d5 100644 --- a/src/index.js +++ b/src/index.js @@ -38,19 +38,25 @@ function pitch() { }, }, resourcePath: this.resourcePath, - resource: this.resourcePath + (this.resourceQuery || ''), + resourceQuery: this.resourceQuery, + resourceFragment: this.resourceFragment, + environment: this.environment, + resource: + this.resourcePath + + (this.resourceQuery || '') + + (this.resourceFragment || ''), sourceMap: this.sourceMap, emitError: this.emitError, emitWarning: this.emitWarning, getLogger: this.getLogger, loggers: {}, loadModule: this.loadModule, + importModule: this.importModule, resolve: this.resolve, getResolve: this.getResolve, target: this.target, mode: this.mode, minimize: this.minimize, - resourceQuery: this.resourceQuery, optionsContext: this.rootContext || this.options.context, rootContext: this.rootContext, }, diff --git a/src/worker.js b/src/worker.js index afa0b94..e05ce69 100644 --- a/src/worker.js +++ b/src/worker.js @@ -119,6 +119,17 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { }); nextQuestionId += 1; }; + const importModule = (request, options, callback) => { + callbackMap[nextQuestionId] = callback; + writeJson({ + type: 'importModule', + id, + questionId: nextQuestionId, + request, + options, + }); + nextQuestionId += 1; + }; const buildDependencies = []; @@ -141,6 +152,22 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { }); nextQuestionId += 1; }, + // eslint-disable-next-line consistent-return + importModule: (request, options, callback) => { + if (callback) { + importModule(request, options, callback); + } else { + return new Promise((resolve, reject) => { + importModule(request, options, (err, result) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + } + }, resolve: (context, request, callback) => { resolveWithOptions(context, request, callback); }, @@ -343,6 +370,8 @@ const queue = asyncQueue(({ id, data }, taskCallback) => { target: data.target, minimize: data.minimize, resourceQuery: data.resourceQuery, + resourceFragment: data.resourceFragment, + environment: data.environment, rootContext: data.rootContext, // eslint-disable-next-line no-underscore-dangle _compilation: data._compilation, diff --git a/test/__snapshots__/webpack.test.js.snap b/test/__snapshots__/webpack.test.js.snap new file mode 100644 index 0000000..393116d --- /dev/null +++ b/test/__snapshots__/webpack.test.js.snap @@ -0,0 +1,115 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Works with test-loader: errors 1`] = ` +[ + [ModuleError: Module Error (from ../../dist/index.js): +Test Message Error], +] +`; + +exports[`Works with test-loader: result 1`] = ` +{ + "addBuildDependency": "function", + "addContextDependency": "function", + "addDependency": "function", + "addMissingDependency": "function", + "async": "function", + "cacheable": "function", + "callback": "function", + "clearDependencies": "function", + "context": "/test/basic-loader-test", + "currentRequest": "/test/basic-loader-test/test-loader.js??ruleSet[1].rules[0].use[1]!/test/basic-loader-test/test.js?q=1#hash", + "data": null, + "dependency": "function", + "emitError": "function", + "emitFile": "undefined", + "emitWarning": "function", + "environment": { + "arrowFunction": true, + "asyncFunction": true, + "const": true, + "destructuring": true, + "forOf": true, + "optionalChaining": true, + "templateLiteral": true, + }, + "getContextDependencies": "function", + "getContextDependenciesResult": [ + "/test/basic-loader-test/directory", + ], + "getDependencies": "function", + "getDependenciesResult": [ + "/test/basic-loader-test/test.js", + "/test/basic-loader-test/dep1.js", + "/test/basic-loader-test/dep.js", + ], + "getLogger": "function", + "getMissingDependencies": "function", + "getMissingDependenciesResult": [], + "getOptions": "function", + "getResolve": "function", + "importModule": "function", + "importModuleResult1": { + "default": "http://test.com/first/777312cffc01c1457868.less", + }, + "importModuleResult2": { + "default": "http://test.com/first/777312cffc01c1457868.less", + }, + "loadModule": "function", + "loadModuleResult": { + "map": null, + "source": "const test = require("./mod1"); + +module.exports = new URL("./style.less", import.meta.url); +", + }, + "loaderIndex": 0, + "loaders": [ + { + "data": null, + "fragment": "", + "ident": "ruleSet[1].rules[0].use[1]", + "normalExecuted": true, + "options": { + "test": {}, + }, + "path": "/test/basic-loader-test/test-loader.js", + "pitchExecuted": true, + "query": "??ruleSet[1].rules[0].use[1]", + "request": "/test/basic-loader-test/test-loader.js??ruleSet[1].rules[0].use[1]", + }, + ], + "mode": "none", + "options": { + "test": {}, + }, + "previousRequest": "", + "query": { + "test": {}, + }, + "remainingRequest": "/test/basic-loader-test/test.js?q=1#hash", + "request": "/test/basic-loader-test/test-loader.js??ruleSet[1].rules[0].use[1]!/test/basic-loader-test/test.js?q=1#hash", + "resolve": "function", + "resource": "/test/basic-loader-test/test.js?q=1#hash", + "resourceFragment": "#hash", + "resourcePath": "/test/basic-loader-test/test.js", + "resourceQuery": "?q=1", + "rootContext": "/test/basic-loader-test", + "sourceMap": false, + "target": "web", + "utils": { + "absolutify": "undefined", + "contextify": "undefined", + "createHash": "undefined", + }, + "version": 2, + "webpack": true, +} +`; + +exports[`Works with test-loader: warnings 1`] = ` +[ + [ModuleWarning: Module Warning (from ../../dist/index.js): +Test Message Warning], +] +`; diff --git a/test/basic-loader-test/build-dep.js b/test/basic-loader-test/build-dep.js new file mode 100644 index 0000000..e69de29 diff --git a/test/basic-loader-test/dep.js b/test/basic-loader-test/dep.js new file mode 100644 index 0000000..e69de29 diff --git a/test/basic-loader-test/dep1.js b/test/basic-loader-test/dep1.js new file mode 100644 index 0000000..e69de29 diff --git a/test/basic-loader-test/directory/test.js b/test/basic-loader-test/directory/test.js new file mode 100644 index 0000000..e69de29 diff --git a/test/basic-loader-test/index.js b/test/basic-loader-test/index.js new file mode 100644 index 0000000..02f0536 --- /dev/null +++ b/test/basic-loader-test/index.js @@ -0,0 +1,4 @@ +/* eslint-disable import/no-unresolved */ +// some file +// eslint-disable-next-line import/extensions +import './test.js?q=1#hash'; diff --git a/test/basic-loader-test/mod.js b/test/basic-loader-test/mod.js new file mode 100644 index 0000000..c95267b --- /dev/null +++ b/test/basic-loader-test/mod.js @@ -0,0 +1 @@ +export default new URL('./style.less', import.meta.url); diff --git a/test/basic-loader-test/mod1.js b/test/basic-loader-test/mod1.js new file mode 100644 index 0000000..c95267b --- /dev/null +++ b/test/basic-loader-test/mod1.js @@ -0,0 +1 @@ +export default new URL('./style.less', import.meta.url); diff --git a/test/basic-loader-test/mod2.js b/test/basic-loader-test/mod2.js new file mode 100644 index 0000000..156a7a6 --- /dev/null +++ b/test/basic-loader-test/mod2.js @@ -0,0 +1,3 @@ +const test = require('./mod1'); + +module.exports = new URL('./style.less', import.meta.url); diff --git a/test/basic-loader-test/style.less b/test/basic-loader-test/style.less new file mode 100644 index 0000000..67ce83e --- /dev/null +++ b/test/basic-loader-test/style.less @@ -0,0 +1,3 @@ +body { + background: red; +} diff --git a/test/basic-loader-test/test-loader.js b/test/basic-loader-test/test-loader.js new file mode 100644 index 0000000..33ab9f1 --- /dev/null +++ b/test/basic-loader-test/test-loader.js @@ -0,0 +1,102 @@ +const path = require('path'); + +module.exports = async function testLoader() { + const options = this.getOptions(); + const callback = this.async(); + + this.emitWarning(new Error('Test Message Warning')); + this.emitError(new Error('Test Message Error')); + this.dependency(require.resolve('./dep1.js')); + this.addDependency(require.resolve('./dep.js')); + this.addBuildDependency(require.resolve('./build-dep.js')); + this.addContextDependency(path.resolve(__dirname, './directory')); + // Todo fix me + // this.addMissingDependency(require.resolve("./missing-dep.js")); + + callback( + null, + `module.exports = ${JSON.stringify({ + options, + getOptions: typeof this.getOptions, + async: typeof this.async, + version: this.version, + mode: this.mode, + webpack: this.webpack, + sourceMap: this.sourceMap, + target: this.target, + rootContext: this.rootContext, + context: this.context, + environment: this.environment, + loaderIndex: this.loaderIndex, + loaders: this.loaders, + resourcePath: this.resourcePath, + resourceQuery: this.resourceQuery, + resourceFragment: this.resourceFragment, + resource: this.resource, + request: this.request, + remainingRequest: this.remainingRequest, + currentRequest: this.currentRequest, + previousRequest: this.previousRequest, + query: this.query, + data: this.data, + hot: this.hot, + cacheable: typeof this.cacheable, + emitWarning: typeof this.emitWarning, + emitError: typeof this.emitError, + resolve: typeof this.resolve, + getResolve: typeof this.getResolve, + getLogger: typeof this.getLogger, + // Todo fix me + emitFile: typeof this.emitFile, + addBuildDependency: typeof this.addBuildDependency, + utils: { + absolutify: typeof this.absolutify, + contextify: typeof this.contextify, + createHash: typeof this.createHash, + }, + loadModule: typeof this.loadModule, + loadModuleResult: await new Promise((resolve, reject) => + this.loadModule('./mod2.js', (err, source, map, mod) => { + if (err) { + reject(err); + return; + } + + resolve({ source, map, mod }); + }) + ), + importModule: typeof this.importModule, + importModuleResult1: await this.importModule('./mod.js', { + publicPath: 'http://test.com/first/', + }), + importModuleResult2: await new Promise((resolve, reject) => + this.importModule( + './mod1.js', + { + publicPath: 'http://test.com/first/', + }, + (err, result) => { + if (err) { + reject(err); + return; + } + + resolve(result); + } + ) + ), + callback: typeof this.callback, + addDependency: typeof this.addDependency, + dependency: typeof this.addDependency, + addContextDependency: typeof this.addContextDependency, + addMissingDependency: typeof this.addMissingDependency, + getDependencies: typeof this.getDependencies, + getDependenciesResult: this.getDependencies(), + getContextDependencies: typeof this.getContextDependencies, + getContextDependenciesResult: this.getContextDependencies(), + getMissingDependencies: typeof this.getMissingDependencies, + getMissingDependenciesResult: this.getMissingDependencies(), + clearDependencies: typeof this.clearDependencies, + }).replace(new RegExp(process.cwd(), 'g'), '')};` + ); +}; diff --git a/test/basic-loader-test/test.js b/test/basic-loader-test/test.js new file mode 100644 index 0000000..a2248ef --- /dev/null +++ b/test/basic-loader-test/test.js @@ -0,0 +1 @@ +console.log('test'); diff --git a/test/basic-loader-test/webpack.config.js b/test/basic-loader-test/webpack.config.js new file mode 100644 index 0000000..c458b18 --- /dev/null +++ b/test/basic-loader-test/webpack.config.js @@ -0,0 +1,43 @@ +const path = require('path'); + +const threadLoader = require('../../dist'); // eslint-disable-line import/no-extraneous-dependencies + +module.exports = (env) => { + const workerPool = { + workers: +env.threads, + workerParallelJobs: 2, + poolTimeout: env.watch ? Infinity : 2000, + }; + if (+env.threads > 0) { + threadLoader.warmup(workerPool, [require.resolve('./test-loader.js')]); + } + return { + mode: 'none', + context: __dirname, + devtool: false, + entry: ['./index.js'], + output: { + path: path.resolve('dist'), + filename: 'bundle.js', + }, + module: { + rules: [ + { + test: /test\.js$/, + use: [ + env.threads !== 0 && { + loader: path.resolve(__dirname, '../../dist/index.js'), + options: workerPool, + }, + { + loader: require.resolve('./test-loader'), + options: { + test: /test/i, + }, + }, + ], + }, + ], + }, + }; +}; diff --git a/test/less-loader-example/webpack.config.js b/test/less-loader-example/webpack.config.js index 28e9b81..bc188db 100644 --- a/test/less-loader-example/webpack.config.js +++ b/test/less-loader-example/webpack.config.js @@ -2,7 +2,7 @@ const path = require('path'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const threadLoader = require('../../src'); // eslint-disable-line import/no-extraneous-dependencies +const threadLoader = require('../../dist'); // eslint-disable-line import/no-extraneous-dependencies module.exports = (env) => { const workerPool = { diff --git a/test/sass-loader-example/webpack.config.js b/test/sass-loader-example/webpack.config.js index dcf7360..ff5c45c 100644 --- a/test/sass-loader-example/webpack.config.js +++ b/test/sass-loader-example/webpack.config.js @@ -2,7 +2,7 @@ const path = require('path'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); // eslint-disable-line import/no-extraneous-dependencies -const threadLoader = require('../../src'); // eslint-disable-line import/no-extraneous-dependencies +const threadLoader = require('../../dist'); // eslint-disable-line import/no-extraneous-dependencies module.exports = (env) => { const workerPool = { diff --git a/test/ts-loader-example/webpack.config.js b/test/ts-loader-example/webpack.config.js index da2b931..0894ba8 100644 --- a/test/ts-loader-example/webpack.config.js +++ b/test/ts-loader-example/webpack.config.js @@ -1,6 +1,6 @@ const path = require('path'); -const threadLoader = require('../../src'); // eslint-disable-line import/no-extraneous-dependencies +const threadLoader = require('../../dist'); // eslint-disable-line import/no-extraneous-dependencies module.exports = (env) => { const workerPool = { diff --git a/test/webpack.test.js b/test/webpack.test.js index 543d967..2bf3039 100644 --- a/test/webpack.test.js +++ b/test/webpack.test.js @@ -1,65 +1,71 @@ import webpack from 'webpack'; +import basicLoaderConfig from './basic-loader-test/webpack.config'; import sassLoaderConfig from './sass-loader-example/webpack.config'; import tsLoaderConfig from './ts-loader-example/webpack.config'; import lessLoaderConfig from './less-loader-example/webpack.config'; test("Processes sass-loader's @import correctly", (done) => { - const config = sassLoaderConfig({}); + const config = sassLoaderConfig({ threads: 1 }); webpack(config, (err, stats) => { if (err) { - // eslint-disable-next-line no-console - console.error(err); + throw err; } expect(err).toBe(null); - - if (stats.hasErrors()) { - // eslint-disable-next-line no-console - console.error(stats.toJson().errors); - } expect(stats.hasErrors()).toBe(false); done(); }); }, 30000); test('Processes ts-loader correctly', (done) => { - const config = tsLoaderConfig({}); + const config = tsLoaderConfig({ threads: 1 }); webpack(config, (err, stats) => { if (err) { - // eslint-disable-next-line no-console - console.error(err); + throw err; } expect(err).toBe(null); - - if (stats.hasErrors()) { - // eslint-disable-next-line no-console - console.error(stats.toJson().errors); - } expect(stats.hasErrors()).toBe(false); done(); }); }, 30000); test('Works with less-loader', (done) => { - const config = lessLoaderConfig({}); + const config = lessLoaderConfig({ threads: 1 }); webpack(config, (err, stats) => { if (err) { - // eslint-disable-next-line no-console - console.error(err); + throw err; } expect(err).toBe(null); + expect(stats.hasErrors()).toBe(false); + done(); + }); +}, 30000); - if (stats.hasErrors()) { +test('Works with test-loader', (done) => { + const config = basicLoaderConfig({ threads: 1 }); + + webpack(config, (err, stats) => { + if (err) { // eslint-disable-next-line no-console - console.error(stats.toJson().errors); + console.error(err); } - expect(stats.hasErrors()).toBe(false); + + expect(stats.compilation.errors).toMatchSnapshot('errors'); + expect(stats.compilation.warnings).toMatchSnapshot('warnings'); + + const [testMod] = [...stats.compilation.modules].filter( + (i) => i.rawRequest === './test.js?q=1#hash' + ); + + // eslint-disable-next-line no-eval, no-underscore-dangle + expect(eval(testMod._source.source())).toMatchSnapshot('result'); + done(); }); }, 30000); From 31075433eda22c466b3ac616e355f3c755d98893 Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Tue, 17 Sep 2024 20:25:52 +0300 Subject: [PATCH 2/4] test: fix --- test/__snapshots__/webpack.test.js.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/__snapshots__/webpack.test.js.snap b/test/__snapshots__/webpack.test.js.snap index 393116d..93cad60 100644 --- a/test/__snapshots__/webpack.test.js.snap +++ b/test/__snapshots__/webpack.test.js.snap @@ -58,9 +58,9 @@ exports[`Works with test-loader: result 1`] = ` "loadModule": "function", "loadModuleResult": { "map": null, - "source": "const test = require("./mod1"); + "source": "const test = require('./mod1'); -module.exports = new URL("./style.less", import.meta.url); +module.exports = new URL('./style.less', import.meta.url); ", }, "loaderIndex": 0, From bc4b4a50a6d31e690c1e4e0d0c0c0eb45517d114 Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Tue, 17 Sep 2024 20:29:29 +0300 Subject: [PATCH 3/4] test: fix --- test/__snapshots__/webpack.test.js.snap | 12 ++++++------ .../basic-loader-test/directory/{test.js => file.js} | 0 test/basic-loader-test/{test.js => file.js} | 0 test/basic-loader-test/index.js | 2 +- test/basic-loader-test/webpack.config.js | 2 +- test/webpack.test.js | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) rename test/basic-loader-test/directory/{test.js => file.js} (100%) rename test/basic-loader-test/{test.js => file.js} (100%) diff --git a/test/__snapshots__/webpack.test.js.snap b/test/__snapshots__/webpack.test.js.snap index 93cad60..3632182 100644 --- a/test/__snapshots__/webpack.test.js.snap +++ b/test/__snapshots__/webpack.test.js.snap @@ -18,7 +18,7 @@ exports[`Works with test-loader: result 1`] = ` "callback": "function", "clearDependencies": "function", "context": "/test/basic-loader-test", - "currentRequest": "/test/basic-loader-test/test-loader.js??ruleSet[1].rules[0].use[1]!/test/basic-loader-test/test.js?q=1#hash", + "currentRequest": "/test/basic-loader-test/test-loader.js??ruleSet[1].rules[0].use[1]!/test/basic-loader-test/file.js?q=1#hash", "data": null, "dependency": "function", "emitError": "function", @@ -39,7 +39,7 @@ exports[`Works with test-loader: result 1`] = ` ], "getDependencies": "function", "getDependenciesResult": [ - "/test/basic-loader-test/test.js", + "/test/basic-loader-test/file.js", "/test/basic-loader-test/dep1.js", "/test/basic-loader-test/dep.js", ], @@ -87,12 +87,12 @@ module.exports = new URL('./style.less', import.meta.url); "query": { "test": {}, }, - "remainingRequest": "/test/basic-loader-test/test.js?q=1#hash", - "request": "/test/basic-loader-test/test-loader.js??ruleSet[1].rules[0].use[1]!/test/basic-loader-test/test.js?q=1#hash", + "remainingRequest": "/test/basic-loader-test/file.js?q=1#hash", + "request": "/test/basic-loader-test/test-loader.js??ruleSet[1].rules[0].use[1]!/test/basic-loader-test/file.js?q=1#hash", "resolve": "function", - "resource": "/test/basic-loader-test/test.js?q=1#hash", + "resource": "/test/basic-loader-test/file.js?q=1#hash", "resourceFragment": "#hash", - "resourcePath": "/test/basic-loader-test/test.js", + "resourcePath": "/test/basic-loader-test/file.js", "resourceQuery": "?q=1", "rootContext": "/test/basic-loader-test", "sourceMap": false, diff --git a/test/basic-loader-test/directory/test.js b/test/basic-loader-test/directory/file.js similarity index 100% rename from test/basic-loader-test/directory/test.js rename to test/basic-loader-test/directory/file.js diff --git a/test/basic-loader-test/test.js b/test/basic-loader-test/file.js similarity index 100% rename from test/basic-loader-test/test.js rename to test/basic-loader-test/file.js diff --git a/test/basic-loader-test/index.js b/test/basic-loader-test/index.js index 02f0536..7219359 100644 --- a/test/basic-loader-test/index.js +++ b/test/basic-loader-test/index.js @@ -1,4 +1,4 @@ /* eslint-disable import/no-unresolved */ // some file // eslint-disable-next-line import/extensions -import './test.js?q=1#hash'; +import './file.js?q=1#hash'; diff --git a/test/basic-loader-test/webpack.config.js b/test/basic-loader-test/webpack.config.js index c458b18..36c71bb 100644 --- a/test/basic-loader-test/webpack.config.js +++ b/test/basic-loader-test/webpack.config.js @@ -23,7 +23,7 @@ module.exports = (env) => { module: { rules: [ { - test: /test\.js$/, + test: /file\.js$/, use: [ env.threads !== 0 && { loader: path.resolve(__dirname, '../../dist/index.js'), diff --git a/test/webpack.test.js b/test/webpack.test.js index 2bf3039..a968451 100644 --- a/test/webpack.test.js +++ b/test/webpack.test.js @@ -60,7 +60,7 @@ test('Works with test-loader', (done) => { expect(stats.compilation.warnings).toMatchSnapshot('warnings'); const [testMod] = [...stats.compilation.modules].filter( - (i) => i.rawRequest === './test.js?q=1#hash' + (i) => i.rawRequest === './file.js?q=1#hash' ); // eslint-disable-next-line no-eval, no-underscore-dangle From 66be8d996862835ee2856b09e210e2586827d05b Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Tue, 17 Sep 2024 20:30:53 +0300 Subject: [PATCH 4/4] test: fix --- .cspell.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cspell.json b/.cspell.json index 79dd4a8..09aa9f1 100644 --- a/.cspell.json +++ b/.cspell.json @@ -18,9 +18,9 @@ "opencollective", "Koppers", "sokra", - "lifecycles" + "lifecycles", + "absolutify" ], - "ignorePaths": [ "CHANGELOG.md", "package.json",