diff --git a/packages/rspack/src/config/adapter-rule-use.ts b/packages/rspack/src/config/adapter-rule-use.ts index ada995f7733..48aa77ca92a 100644 --- a/packages/rspack/src/config/adapter-rule-use.ts +++ b/packages/rspack/src/config/adapter-rule-use.ts @@ -51,21 +51,21 @@ export interface LoaderObject { normalExecuted: boolean; } -export interface LoaderContext { +export interface LoaderContext { version: 2; resource: string; resourcePath: string; resourceQuery: string; resourceFragment: string; async(): ( - err: Error | null, - content: string | Buffer, + err?: Error | null, + content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData ) => void; callback( - err: Error | null, - content: string | Buffer, + err?: Error | null, + content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData ): void; @@ -99,7 +99,7 @@ export interface LoaderContext { loaders: LoaderObject[]; mode?: Mode; hot?: boolean; - getOptions(schema?: any): unknown; + getOptions(schema?: any): OptionsType; resolve( context: string, request: string, @@ -136,7 +136,7 @@ export interface LoaderContext { contextify: (context: string, request: string) => string; createHash: (algorithm?: string) => Hash; }; - query: unknown; + query: string | OptionsType; data: unknown; _compiler: Compiler; _compilation: Compiler["compilation"]; @@ -147,6 +147,7 @@ export interface LoaderContext { * @internal */ __internal__isPitching: boolean; + // TODO: LoaderPluginLoaderContext } export interface LoaderResult { @@ -160,6 +161,38 @@ export interface LoaderResult { buildDependencies: string[]; } +export interface LoaderDefinitionFunction< + OptionsType = {}, + ContextAdditions = {} +> { + ( + this: LoaderContext & ContextAdditions, + content: string, + sourceMap?: string | SourceMap, + additionalData?: AdditionalData + ): string | void | Buffer | Promise; +} + +export interface PitchLoaderDefinitionFunction< + OptionsType = {}, + ContextAdditions = {} +> { + ( + this: LoaderContext & ContextAdditions, + remainingRequest: string, + previousRequest: string, + data: object + ): string | void | Buffer | Promise; +} + +export type LoaderDefinition< + OptionsType = {}, + ContextAdditions = {} +> = LoaderDefinitionFunction & { + raw?: false; + pitch?: PitchLoaderDefinitionFunction; +}; + export function createRawModuleRuleUses( uses: RuleSetUse, options: ComposeJsUseOptions diff --git a/packages/rspack/src/config/types.ts b/packages/rspack/src/config/types.ts index ae2c0626fa9..c36483d1698 100644 --- a/packages/rspack/src/config/types.ts +++ b/packages/rspack/src/config/types.ts @@ -15,7 +15,11 @@ import * as oldBuiltins from "./builtins"; export type { BannerConditions, BannerCondition } from "./builtins"; -export type { LoaderContext } from "./adapter-rule-use"; +export type { + LoaderContext, + LoaderDefinitionFunction, + LoaderDefinition +} from "./adapter-rule-use"; export type Configuration = RspackOptions; diff --git a/packages/rspack/tests/configCases/loader/pre-post-loader/loader1.js b/packages/rspack/tests/configCases/loader/pre-post-loader/loader1.js index bf6d1335221..97d144fc5bc 100644 --- a/packages/rspack/tests/configCases/loader/pre-post-loader/loader1.js +++ b/packages/rspack/tests/configCases/loader/pre-post-loader/loader1.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source + 'module.exports += " loader1";\n'; }; diff --git a/packages/rspack/tests/configCases/loader/pre-post-loader/loader2.js b/packages/rspack/tests/configCases/loader/pre-post-loader/loader2.js index b611c84f62b..944a6b3523b 100644 --- a/packages/rspack/tests/configCases/loader/pre-post-loader/loader2.js +++ b/packages/rspack/tests/configCases/loader/pre-post-loader/loader2.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source + 'module.exports += " loader2";\n'; }; diff --git a/packages/rspack/tests/configCases/loader/pre-post-loader/loader3.js b/packages/rspack/tests/configCases/loader/pre-post-loader/loader3.js index ec526cbac53..06d72ccdccf 100644 --- a/packages/rspack/tests/configCases/loader/pre-post-loader/loader3.js +++ b/packages/rspack/tests/configCases/loader/pre-post-loader/loader3.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source + 'module.exports += " loader3";\n'; }; diff --git a/packages/rspack/tests/fixtures/count-loader.js b/packages/rspack/tests/fixtures/count-loader.js index 9da5ce227be..12b5ba61922 100644 --- a/packages/rspack/tests/fixtures/count-loader.js +++ b/packages/rspack/tests/fixtures/count-loader.js @@ -1,6 +1,6 @@ let counter = 0; -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { return `module.exports = ${counter++};`; }; diff --git a/packages/rspack/tests/fixtures/delay-loader.js b/packages/rspack/tests/fixtures/delay-loader.js index 01e71f3fb6d..34d23f4a392 100644 --- a/packages/rspack/tests/fixtures/delay-loader.js +++ b/packages/rspack/tests/fixtures/delay-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { var cb = this.async(); setTimeout(function () { diff --git a/packages/rspack/tests/fixtures/errors/add-comment-loader.js b/packages/rspack/tests/fixtures/errors/add-comment-loader.js index 586bfbce576..ed6dc02ceeb 100644 --- a/packages/rspack/tests/fixtures/errors/add-comment-loader.js +++ b/packages/rspack/tests/fixtures/errors/add-comment-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source + "// some comment"; }; diff --git a/packages/rspack/tests/fixtures/errors/async-error-loader.js b/packages/rspack/tests/fixtures/errors/async-error-loader.js index 9826e36c3b7..5bd4cbbad32 100644 --- a/packages/rspack/tests/fixtures/errors/async-error-loader.js +++ b/packages/rspack/tests/fixtures/errors/async-error-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { const callback = this.async(); const error = new Error("this is a callback error"); diff --git a/packages/rspack/tests/fixtures/errors/emit-error-loader.js b/packages/rspack/tests/fixtures/errors/emit-error-loader.js index 1cd648e665d..9cc82f914af 100644 --- a/packages/rspack/tests/fixtures/errors/emit-error-loader.js +++ b/packages/rspack/tests/fixtures/errors/emit-error-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { this.emitWarning(new Error("this is a warning")); this.emitError(new Error("this is an error")); diff --git a/packages/rspack/tests/fixtures/errors/identity-loader.js b/packages/rspack/tests/fixtures/errors/identity-loader.js index c6d8a635121..3ae53b4dca3 100644 --- a/packages/rspack/tests/fixtures/errors/identity-loader.js +++ b/packages/rspack/tests/fixtures/errors/identity-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source; }; diff --git a/packages/rspack/tests/fixtures/errors/irregular-error-loader.js b/packages/rspack/tests/fixtures/errors/irregular-error-loader.js index 6ed0ba935ef..4950c5990c1 100644 --- a/packages/rspack/tests/fixtures/errors/irregular-error-loader.js +++ b/packages/rspack/tests/fixtures/errors/irregular-error-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { const empty = null; const emptyError = new Error(); diff --git a/packages/rspack/tests/fixtures/errors/no-return-loader.js b/packages/rspack/tests/fixtures/errors/no-return-loader.js index 63c5d351ef1..fb59fd7e8a4 100644 --- a/packages/rspack/tests/fixtures/errors/no-return-loader.js +++ b/packages/rspack/tests/fixtures/errors/no-return-loader.js @@ -1,2 +1,2 @@ -/** @type {import("../../../../").LoaderDefinition} */ -module.exports = function () {}; +/** @type {import("@rspack/core").LoaderDefinition} */ +module.exports = function () { }; diff --git a/packages/rspack/tests/fixtures/errors/throw-error-loader.js b/packages/rspack/tests/fixtures/errors/throw-error-loader.js index 59014e2a1b3..18dbe380958 100644 --- a/packages/rspack/tests/fixtures/errors/throw-error-loader.js +++ b/packages/rspack/tests/fixtures/errors/throw-error-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { throw new Error("this is a thrown error"); }; diff --git a/webpack-test/cases/async-modules/runtime-performance/loader.js b/webpack-test/cases/async-modules/runtime-performance/loader.js index ea46f2bea9b..98b342adc39 100644 --- a/webpack-test/cases/async-modules/runtime-performance/loader.js +++ b/webpack-test/cases/async-modules/runtime-performance/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ i: string }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ i: string }>} */ module.exports = function () { const options = this.getOptions(); const i = +options.i; diff --git a/webpack-test/cases/compile/error-hide-stack/loader.js b/webpack-test/cases/compile/error-hide-stack/loader.js index b499c32a083..c66ad8ed977 100644 --- a/webpack-test/cases/compile/error-hide-stack/loader.js +++ b/webpack-test/cases/compile/error-hide-stack/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { var err = new Error("Message"); err.stack = "Stack"; diff --git a/webpack-test/cases/errors/load-module-cycle-multiple/loader.js b/webpack-test/cases/errors/load-module-cycle-multiple/loader.js index e91f9dc4b60..e7931ada1a8 100644 --- a/webpack-test/cases/errors/load-module-cycle-multiple/loader.js +++ b/webpack-test/cases/errors/load-module-cycle-multiple/loader.js @@ -1,6 +1,6 @@ const { promisify } = require("util"); -/** @type {import("../../../../").LoaderDefinitionFunction} */ +/** @type {import("@rspack/core").LoaderDefinitionFunction} */ exports.default = function (source) { const content = JSON.parse(source); // content is one reference or an array of references @@ -13,11 +13,11 @@ exports.default = function (source) { // bug from https://github.com/webpack/webpack/issues/14379 doesn't occur if // they are loaded in parallel. const loadedRefs = [] - for(const ref of refs) { + for (const ref of refs) { try { const source = await loadModulePromise("../loader!" + ref); loadedRefs.push([ref, JSON.parse(source)]); - } catch(err) { + } catch (err) { loadedRefs.push([ref, `err: ${err && err.message}`]); } } diff --git a/webpack-test/cases/errors/load-module-cycle/loader.js b/webpack-test/cases/errors/load-module-cycle/loader.js index ed4a740b947..9c05ac03440 100644 --- a/webpack-test/cases/errors/load-module-cycle/loader.js +++ b/webpack-test/cases/errors/load-module-cycle/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinitionFunction} */ +/** @type {import("@rspack/core").LoaderDefinitionFunction} */ exports.default = function (source) { const ref = JSON.parse(source); const callback = this.async(); diff --git a/webpack-test/cases/errors/load-module-error/error-loader.js b/webpack-test/cases/errors/load-module-error/error-loader.js index 5758c7646c7..57973f4e15c 100644 --- a/webpack-test/cases/errors/load-module-error/error-loader.js +++ b/webpack-test/cases/errors/load-module-error/error-loader.js @@ -1,5 +1,5 @@ -/** @type {import("../../../../types").LoaderDefinition} */ -module.exports = function(source) { +/** @type {import("@rspack/core").LoaderDefinition} */ +module.exports = function (source) { const callback = this.async(); callback(new Error("err: abc")); } diff --git a/webpack-test/cases/errors/load-module-error/loader.js b/webpack-test/cases/errors/load-module-error/loader.js index 3eb4fa42c63..38a483da9bd 100644 --- a/webpack-test/cases/errors/load-module-error/loader.js +++ b/webpack-test/cases/errors/load-module-error/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinitionFunction} */ +/** @type {import("@rspack/core").LoaderDefinitionFunction} */ exports.default = function (source) { const callback = this.async(); const ref = JSON.parse(source); diff --git a/webpack-test/cases/errors/loader-error-warning/error-loader.js b/webpack-test/cases/errors/loader-error-warning/error-loader.js index 981790bb520..eb49c114dc4 100644 --- a/webpack-test/cases/errors/loader-error-warning/error-loader.js +++ b/webpack-test/cases/errors/loader-error-warning/error-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { //@ts-expect-error errors must be Errors, string is not recommended and should lead to type error this.emitError(this.query.slice(1)); diff --git a/webpack-test/cases/errors/loader-error-warning/warning-loader.js b/webpack-test/cases/errors/loader-error-warning/warning-loader.js index 90c6ad19d72..d0f0dd92240 100644 --- a/webpack-test/cases/errors/loader-error-warning/warning-loader.js +++ b/webpack-test/cases/errors/loader-error-warning/warning-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { //@ts-expect-error warnings must be Errors, string is not recommended and should lead to type error this.emitWarning(this.query.slice(1)); diff --git a/webpack-test/cases/loaders/async/loaders/asyncloader.js b/webpack-test/cases/loaders/async/loaders/asyncloader.js index c6c0eb8d422..85e433becf9 100644 --- a/webpack-test/cases/loaders/async/loaders/asyncloader.js +++ b/webpack-test/cases/loaders/async/loaders/asyncloader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (content) { var cb = this.async(); if (!cb) throw new Error("Loader should allow async mode"); diff --git a/webpack-test/cases/loaders/async/loaders/syncloader.js b/webpack-test/cases/loaders/async/loaders/syncloader.js index fe0c014dba4..9c7598c5823 100644 --- a/webpack-test/cases/loaders/async/loaders/syncloader.js +++ b/webpack-test/cases/loaders/async/loaders/syncloader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (content) { return content; }; diff --git a/webpack-test/cases/loaders/emit-file/loader.js b/webpack-test/cases/loaders/emit-file/loader.js index c53b3e18fbc..1b4586fb660 100644 --- a/webpack-test/cases/loaders/emit-file/loader.js +++ b/webpack-test/cases/loaders/emit-file/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (content) { this.emitFile("extra-file.js", content); return ""; diff --git a/webpack-test/cases/loaders/import-module/loader.js b/webpack-test/cases/loaders/import-module/loader.js index 960d39ff9fa..c2d6f57c134 100644 --- a/webpack-test/cases/loaders/import-module/loader.js +++ b/webpack-test/cases/loaders/import-module/loader.js @@ -2,7 +2,7 @@ const path = require("path"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { const callback = this.async(); this.importModule( @@ -16,8 +16,7 @@ module.exports = function () { callback( null, - `module.exports = ${ - exports.asset ? JSON.stringify(exports.asset) : undefined + `module.exports = ${exports.asset ? JSON.stringify(exports.asset) : undefined }` ); } diff --git a/webpack-test/cases/loaders/issue-10725/loader.js b/webpack-test/cases/loaders/issue-10725/loader.js index af9af2d2418..c5a79efac71 100644 --- a/webpack-test/cases/loaders/issue-10725/loader.js +++ b/webpack-test/cases/loaders/issue-10725/loader.js @@ -2,7 +2,7 @@ const { getRemainingRequest, stringifyRequest } = require("loader-utils"); const loaderPath = require.resolve("./loader"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { if (this.query === "?load") { return ` diff --git a/webpack-test/cases/loaders/module-description-file/reverseloader.js b/webpack-test/cases/loaders/module-description-file/reverseloader.js index 4cbb644664a..4e87cd4859e 100644 --- a/webpack-test/cases/loaders/module-description-file/reverseloader.js +++ b/webpack-test/cases/loaders/module-description-file/reverseloader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (content) { return content.split("").reverse().join(""); }; diff --git a/webpack-test/cases/loaders/query/loaders/queryloader.js b/webpack-test/cases/loaders/query/loaders/queryloader.js index f9bb23e1f55..49e00632c24 100644 --- a/webpack-test/cases/loaders/query/loaders/queryloader.js +++ b/webpack-test/cases/loaders/query/loaders/queryloader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (content) { return ( "module.exports = " + diff --git a/webpack-test/cases/loaders/resolve/loader.js b/webpack-test/cases/loaders/resolve/loader.js index 53fc4aaf2f1..05895399a21 100644 --- a/webpack-test/cases/loaders/resolve/loader.js +++ b/webpack-test/cases/loaders/resolve/loader.js @@ -1,5 +1,5 @@ const path = require("path"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { const resolve1 = this.getResolve(); const resolve2 = this.getResolve({ diff --git a/webpack-test/cases/loaders/utils/loader.js b/webpack-test/cases/loaders/utils/loader.js index 2d9e6e37073..6569a027aca 100644 --- a/webpack-test/cases/loaders/utils/loader.js +++ b/webpack-test/cases/loaders/utils/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { return `module.exports = { request1: ${JSON.stringify( diff --git a/webpack-test/cases/parsing/context/loaders/queryloader.js b/webpack-test/cases/parsing/context/loaders/queryloader.js index f9bb23e1f55..49e00632c24 100644 --- a/webpack-test/cases/parsing/context/loaders/queryloader.js +++ b/webpack-test/cases/parsing/context/loaders/queryloader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (content) { return ( "module.exports = " + diff --git a/webpack-test/cases/parsing/precreated-ast/ast-loader.js b/webpack-test/cases/parsing/precreated-ast/ast-loader.js index e150377260e..9cddf561132 100644 --- a/webpack-test/cases/parsing/precreated-ast/ast-loader.js +++ b/webpack-test/cases/parsing/precreated-ast/ast-loader.js @@ -3,7 +3,7 @@ const acorn = require("acorn"); const acornParser = acorn.Parser; -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { const comments = []; @@ -23,7 +23,7 @@ module.exports = function (source) { //@ts-ignore ast.comments = comments; - this.callback(null, source, null, { + this.callback(null, source, undefined, { webpackAST: ast }); }; diff --git a/webpack-test/cases/resolving/context/loaders/queryloader.js b/webpack-test/cases/resolving/context/loaders/queryloader.js index f9bb23e1f55..49e00632c24 100644 --- a/webpack-test/cases/resolving/context/loaders/queryloader.js +++ b/webpack-test/cases/resolving/context/loaders/queryloader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (content) { return ( "module.exports = " + diff --git a/webpack-test/configCases/asset-modules/data-url/loader.js b/webpack-test/configCases/asset-modules/data-url/loader.js index c5048a9c3df..c74f23080dc 100644 --- a/webpack-test/configCases/asset-modules/data-url/loader.js +++ b/webpack-test/configCases/asset-modules/data-url/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ f(): any }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ f(): any }>} */ module.exports = function (source) { return `${source}, World!`; }; diff --git a/webpack-test/configCases/cache-dependencies/managed-items-unsafe-cache/loader.js b/webpack-test/configCases/cache-dependencies/managed-items-unsafe-cache/loader.js index 3a6935623f6..92f84958613 100644 --- a/webpack-test/configCases/cache-dependencies/managed-items-unsafe-cache/loader.js +++ b/webpack-test/configCases/cache-dependencies/managed-items-unsafe-cache/loader.js @@ -1,6 +1,6 @@ const path = require("path"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { this.addDependency(path.resolve(__dirname, "node_modules/package/extra.js")); this.addDependency(path.resolve(__dirname, "extra.js")); diff --git a/webpack-test/configCases/cache-dependencies/managed-items/loader.js b/webpack-test/configCases/cache-dependencies/managed-items/loader.js index 3a6935623f6..92f84958613 100644 --- a/webpack-test/configCases/cache-dependencies/managed-items/loader.js +++ b/webpack-test/configCases/cache-dependencies/managed-items/loader.js @@ -1,6 +1,6 @@ const path = require("path"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { this.addDependency(path.resolve(__dirname, "node_modules/package/extra.js")); this.addDependency(path.resolve(__dirname, "extra.js")); diff --git a/webpack-test/configCases/concatenate-modules/import-module/loader.js b/webpack-test/configCases/concatenate-modules/import-module/loader.js index d09266dadfa..46c26844dc8 100644 --- a/webpack-test/configCases/concatenate-modules/import-module/loader.js +++ b/webpack-test/configCases/concatenate-modules/import-module/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinitionFunction} */ +/** @type {import("@rspack/core").LoaderDefinitionFunction} */ module.exports = function () { const callback = this.async(); this.importModule("./module1", { baseUri: "webpack://" }, (err, exports) => { diff --git a/webpack-test/configCases/context-replacement/d/queryloader.js b/webpack-test/configCases/context-replacement/d/queryloader.js index 821519145eb..46325fc2b73 100644 --- a/webpack-test/configCases/context-replacement/d/queryloader.js +++ b/webpack-test/configCases/context-replacement/d/queryloader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (content) { return ( "module.exports = " + diff --git a/webpack-test/configCases/deprecations/invalid-dependencies/loader.js b/webpack-test/configCases/deprecations/invalid-dependencies/loader.js index 71212ed09b8..194f6a50d64 100644 --- a/webpack-test/configCases/deprecations/invalid-dependencies/loader.js +++ b/webpack-test/configCases/deprecations/invalid-dependencies/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { this.addDependency("loader.js"); this.addDependency("../**/dir/*.js"); diff --git a/webpack-test/configCases/dll-plugin/0-create-dll/g-loader.js b/webpack-test/configCases/dll-plugin/0-create-dll/g-loader.js index c6d8a635121..3ae53b4dca3 100644 --- a/webpack-test/configCases/dll-plugin/0-create-dll/g-loader.js +++ b/webpack-test/configCases/dll-plugin/0-create-dll/g-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source; }; diff --git a/webpack-test/configCases/inner-graph/_helpers/entryLoader.js b/webpack-test/configCases/inner-graph/_helpers/entryLoader.js index 7e129b81030..15dcfcd555b 100644 --- a/webpack-test/configCases/inner-graph/_helpers/entryLoader.js +++ b/webpack-test/configCases/inner-graph/_helpers/entryLoader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { const { name, expect, usedExports } = JSON.parse(this.query.slice(1)); return [ diff --git a/webpack-test/configCases/inner-graph/_helpers/testModuleLoader.js b/webpack-test/configCases/inner-graph/_helpers/testModuleLoader.js index b6d54748dda..42b3463bdf4 100644 --- a/webpack-test/configCases/inner-graph/_helpers/testModuleLoader.js +++ b/webpack-test/configCases/inner-graph/_helpers/testModuleLoader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { const usedExports = JSON.parse(this.query.slice(1)); return [ diff --git a/webpack-test/configCases/layer/rules/loader.js b/webpack-test/configCases/layer/rules/loader.js index 7e5acde631c..1ebddcae4e0 100644 --- a/webpack-test/configCases/layer/rules/loader.js +++ b/webpack-test/configCases/layer/rules/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ value: any }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ value: any }>} */ module.exports = function (source) { const options = this.getOptions(); return `${source} diff --git a/webpack-test/configCases/loaders/generate-ident/loader2.js b/webpack-test/configCases/loaders/generate-ident/loader2.js index 40788042801..68cced9bd24 100644 --- a/webpack-test/configCases/loaders/generate-ident/loader2.js +++ b/webpack-test/configCases/loaders/generate-ident/loader2.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ f(): any }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ f(): any }>} */ module.exports = function (source) { if (typeof this.query === "string") throw new Error("query must be an object"); diff --git a/webpack-test/configCases/loaders/hot-in-context/loader.js b/webpack-test/configCases/loaders/hot-in-context/loader.js index 608faaddb21..3a4a88e0e96 100644 --- a/webpack-test/configCases/loaders/hot-in-context/loader.js +++ b/webpack-test/configCases/loaders/hot-in-context/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition}} */ +/** @type {import("@rspack/core").LoaderDefinition}} */ module.exports = function () { return `module.exports = ${JSON.stringify(!!this.hot)};`; }; diff --git a/webpack-test/configCases/loaders/mode-default/loader.js b/webpack-test/configCases/loaders/mode-default/loader.js index b9c10626bc4..dc4abc46863 100644 --- a/webpack-test/configCases/loaders/mode-default/loader.js +++ b/webpack-test/configCases/loaders/mode-default/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return `module.exports = "${this.mode}";`; }; diff --git a/webpack-test/configCases/loaders/mode-development/loader.js b/webpack-test/configCases/loaders/mode-development/loader.js index b9c10626bc4..dc4abc46863 100644 --- a/webpack-test/configCases/loaders/mode-development/loader.js +++ b/webpack-test/configCases/loaders/mode-development/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return `module.exports = "${this.mode}";`; }; diff --git a/webpack-test/configCases/loaders/mode-none/loader.js b/webpack-test/configCases/loaders/mode-none/loader.js index b9c10626bc4..dc4abc46863 100644 --- a/webpack-test/configCases/loaders/mode-none/loader.js +++ b/webpack-test/configCases/loaders/mode-none/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return `module.exports = "${this.mode}";`; }; diff --git a/webpack-test/configCases/loaders/mode-production/loader.js b/webpack-test/configCases/loaders/mode-production/loader.js index b9c10626bc4..dc4abc46863 100644 --- a/webpack-test/configCases/loaders/mode-production/loader.js +++ b/webpack-test/configCases/loaders/mode-production/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return `module.exports = "${this.mode}";`; }; diff --git a/webpack-test/configCases/loaders/options/loader-1.js b/webpack-test/configCases/loaders/options/loader-1.js index 18e183cbbb0..4614a709d80 100644 --- a/webpack-test/configCases/loaders/options/loader-1.js +++ b/webpack-test/configCases/loaders/options/loader-1.js @@ -1,6 +1,6 @@ const schema = require("./loader-1.options.json"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { const options = this.getOptions(schema); diff --git a/webpack-test/configCases/loaders/options/loader-2.js b/webpack-test/configCases/loaders/options/loader-2.js index faea214da83..c645b12a668 100644 --- a/webpack-test/configCases/loaders/options/loader-2.js +++ b/webpack-test/configCases/loaders/options/loader-2.js @@ -1,6 +1,6 @@ const schema = require("./loader-2.options.json"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { const options = this.getOptions(schema); diff --git a/webpack-test/configCases/loaders/options/loader.js b/webpack-test/configCases/loaders/options/loader.js index d1bc02fcd3c..95ce29ab040 100644 --- a/webpack-test/configCases/loaders/options/loader.js +++ b/webpack-test/configCases/loaders/options/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { const options = this.getOptions(); diff --git a/webpack-test/configCases/loaders/pr-14384/loader.js b/webpack-test/configCases/loaders/pr-14384/loader.js index 27d54132d70..eea7a4b1bca 100644 --- a/webpack-test/configCases/loaders/pr-14384/loader.js +++ b/webpack-test/configCases/loaders/pr-14384/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { return `module.exports = "success";`; }; diff --git a/webpack-test/configCases/loaders/pre-post-loader/loader1.js b/webpack-test/configCases/loaders/pre-post-loader/loader1.js index bf6d1335221..97d144fc5bc 100644 --- a/webpack-test/configCases/loaders/pre-post-loader/loader1.js +++ b/webpack-test/configCases/loaders/pre-post-loader/loader1.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source + 'module.exports += " loader1";\n'; }; diff --git a/webpack-test/configCases/loaders/pre-post-loader/loader2.js b/webpack-test/configCases/loaders/pre-post-loader/loader2.js index b611c84f62b..944a6b3523b 100644 --- a/webpack-test/configCases/loaders/pre-post-loader/loader2.js +++ b/webpack-test/configCases/loaders/pre-post-loader/loader2.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source + 'module.exports += " loader2";\n'; }; diff --git a/webpack-test/configCases/loaders/pre-post-loader/loader3.js b/webpack-test/configCases/loaders/pre-post-loader/loader3.js index ec526cbac53..06d72ccdccf 100644 --- a/webpack-test/configCases/loaders/pre-post-loader/loader3.js +++ b/webpack-test/configCases/loaders/pre-post-loader/loader3.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source + 'module.exports += " loader3";\n'; }; diff --git a/webpack-test/configCases/loaders/remaining-request/loader2.js b/webpack-test/configCases/loaders/remaining-request/loader2.js index 40788042801..68cced9bd24 100644 --- a/webpack-test/configCases/loaders/remaining-request/loader2.js +++ b/webpack-test/configCases/loaders/remaining-request/loader2.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ f(): any }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ f(): any }>} */ module.exports = function (source) { if (typeof this.query === "string") throw new Error("query must be an object"); diff --git a/webpack-test/configCases/module-name/different-issuers-for-same-module/loader-a.js b/webpack-test/configCases/module-name/different-issuers-for-same-module/loader-a.js index 4e8352ee90e..8ec49d20b32 100644 --- a/webpack-test/configCases/module-name/different-issuers-for-same-module/loader-a.js +++ b/webpack-test/configCases/module-name/different-issuers-for-same-module/loader-a.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (src) { return `module.exports = "loader-a" + module.id`; }; diff --git a/webpack-test/configCases/module-name/different-issuers-for-same-module/loader-b.js b/webpack-test/configCases/module-name/different-issuers-for-same-module/loader-b.js index 7fa193f020f..82496edc965 100644 --- a/webpack-test/configCases/module-name/different-issuers-for-same-module/loader-b.js +++ b/webpack-test/configCases/module-name/different-issuers-for-same-module/loader-b.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (src) { return `module.exports = "loader-b" + module.id`; }; diff --git a/webpack-test/configCases/performance/many-async-imports/reexport.loader.js b/webpack-test/configCases/performance/many-async-imports/reexport.loader.js index 3105e517fef..13c0d79d9a6 100644 --- a/webpack-test/configCases/performance/many-async-imports/reexport.loader.js +++ b/webpack-test/configCases/performance/many-async-imports/reexport.loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { var str = "export default Promise.all([\n"; for (var i = 0; i < 6; i++) { diff --git a/webpack-test/configCases/performance/many-exports/file.loader.js b/webpack-test/configCases/performance/many-exports/file.loader.js index 1dd13c65f5c..b0e2fb70384 100644 --- a/webpack-test/configCases/performance/many-exports/file.loader.js +++ b/webpack-test/configCases/performance/many-exports/file.loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { var str = ""; for (var i = 0; i < 1000; i++) { diff --git a/webpack-test/configCases/performance/many-exports/reexport.loader.js b/webpack-test/configCases/performance/many-exports/reexport.loader.js index e4a2a31352a..e04aecc173c 100644 --- a/webpack-test/configCases/performance/many-exports/reexport.loader.js +++ b/webpack-test/configCases/performance/many-exports/reexport.loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { var str = 'import * as i from "./file.loader.js!";\n'; str += "var sum = 0;\n"; diff --git a/webpack-test/configCases/plugins/loader-options-plugin/loader.js b/webpack-test/configCases/plugins/loader-options-plugin/loader.js index 8fcf0774460..fcaf4260bec 100644 --- a/webpack-test/configCases/plugins/loader-options-plugin/loader.js +++ b/webpack-test/configCases/plugins/loader-options-plugin/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{}, { minimize: boolean, jsfile: boolean }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{}, { minimize: boolean, jsfile: boolean }>} */ module.exports = function () { return ( "module.exports = " + diff --git a/webpack-test/configCases/race-conditions/load-module/loader.js b/webpack-test/configCases/race-conditions/load-module/loader.js index b741c194e99..b9d07c97bba 100644 --- a/webpack-test/configCases/race-conditions/load-module/loader.js +++ b/webpack-test/configCases/race-conditions/load-module/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { const callback = this.async(); let finished = false; diff --git a/webpack-test/configCases/rebuild/finishModules/loader.js b/webpack-test/configCases/rebuild/finishModules/loader.js index 347e3b5be32..78b4d239922 100644 --- a/webpack-test/configCases/rebuild/finishModules/loader.js +++ b/webpack-test/configCases/rebuild/finishModules/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{}, { shouldReplace: boolean }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{}, { shouldReplace: boolean }>} */ module.exports = function (source) { if (this.shouldReplace) { this._module.buildInfo._isReplaced = true; diff --git a/webpack-test/configCases/rebuild/rebuildWithNewDependencies/loader.js b/webpack-test/configCases/rebuild/rebuildWithNewDependencies/loader.js index f33697b4f1a..583f0240085 100644 --- a/webpack-test/configCases/rebuild/rebuildWithNewDependencies/loader.js +++ b/webpack-test/configCases/rebuild/rebuildWithNewDependencies/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{}, { shouldReplace: boolean }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{}, { shouldReplace: boolean }>} */ module.exports = function (source) { if (this.shouldReplace) { this._module.buildInfo._isReplaced = true; diff --git a/webpack-test/configCases/records/issue-295/loader.js b/webpack-test/configCases/records/issue-295/loader.js index c6d8a635121..3ae53b4dca3 100644 --- a/webpack-test/configCases/records/issue-295/loader.js +++ b/webpack-test/configCases/records/issue-295/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source; }; diff --git a/webpack-test/configCases/resolve-merging/override/loader.js b/webpack-test/configCases/resolve-merging/override/loader.js index 961891c5e19..9706c8f8afb 100644 --- a/webpack-test/configCases/resolve-merging/override/loader.js +++ b/webpack-test/configCases/resolve-merging/override/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = async function () { const defaultResolve = this.getResolve({}); const overrideResolve = this.getResolve({ diff --git a/webpack-test/configCases/rule-set/chaining/loader.js b/webpack-test/configCases/rule-set/chaining/loader.js index 84836e5dae5..5b9c27597bd 100644 --- a/webpack-test/configCases/rule-set/chaining/loader.js +++ b/webpack-test/configCases/rule-set/chaining/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ get(): string }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ get(): string }>} */ module.exports = function (source) { var query = this.query; if (typeof query === "object" && typeof query.get === "function") { diff --git a/webpack-test/configCases/rule-set/compiler/loader.js b/webpack-test/configCases/rule-set/compiler/loader.js index b57f18e5dae..2a658332cc3 100644 --- a/webpack-test/configCases/rule-set/compiler/loader.js +++ b/webpack-test/configCases/rule-set/compiler/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return "module.exports = " + JSON.stringify("loader matched"); }; diff --git a/webpack-test/configCases/rule-set/custom/loader.js b/webpack-test/configCases/rule-set/custom/loader.js index 84836e5dae5..5b9c27597bd 100644 --- a/webpack-test/configCases/rule-set/custom/loader.js +++ b/webpack-test/configCases/rule-set/custom/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ get(): string }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ get(): string }>} */ module.exports = function (source) { var query = this.query; if (typeof query === "object" && typeof query.get === "function") { diff --git a/webpack-test/configCases/rule-set/query/loader.js b/webpack-test/configCases/rule-set/query/loader.js index 84836e5dae5..5b9c27597bd 100644 --- a/webpack-test/configCases/rule-set/query/loader.js +++ b/webpack-test/configCases/rule-set/query/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ get(): string }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ get(): string }>} */ module.exports = function (source) { var query = this.query; if (typeof query === "object" && typeof query.get === "function") { diff --git a/webpack-test/configCases/rule-set/simple-use-array-fn/loader.js b/webpack-test/configCases/rule-set/simple-use-array-fn/loader.js index 84836e5dae5..5b9c27597bd 100644 --- a/webpack-test/configCases/rule-set/simple-use-array-fn/loader.js +++ b/webpack-test/configCases/rule-set/simple-use-array-fn/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ get(): string }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ get(): string }>} */ module.exports = function (source) { var query = this.query; if (typeof query === "object" && typeof query.get === "function") { diff --git a/webpack-test/configCases/rule-set/simple-use-fn-array/loader.js b/webpack-test/configCases/rule-set/simple-use-fn-array/loader.js index 84836e5dae5..5b9c27597bd 100644 --- a/webpack-test/configCases/rule-set/simple-use-fn-array/loader.js +++ b/webpack-test/configCases/rule-set/simple-use-fn-array/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ get(): string }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ get(): string }>} */ module.exports = function (source) { var query = this.query; if (typeof query === "object" && typeof query.get === "function") { diff --git a/webpack-test/configCases/rule-set/simple/loader.js b/webpack-test/configCases/rule-set/simple/loader.js index 84836e5dae5..5b9c27597bd 100644 --- a/webpack-test/configCases/rule-set/simple/loader.js +++ b/webpack-test/configCases/rule-set/simple/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition<{ get(): string }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{ get(): string }>} */ module.exports = function (source) { var query = this.query; if (typeof query === "object" && typeof query.get === "function") { diff --git a/webpack-test/configCases/source-map/no-source-map/loader.js b/webpack-test/configCases/source-map/no-source-map/loader.js index 84613ab8e99..24c226787b5 100644 --- a/webpack-test/configCases/source-map/no-source-map/loader.js +++ b/webpack-test/configCases/source-map/no-source-map/loader.js @@ -1,5 +1,5 @@ const path = require("path"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { this.callback(null, "module.exports = 'ok';", { version: 3, diff --git a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-no-source-root.js b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-no-source-root.js index f2ca2e44e87..94c815bad56 100644 --- a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-no-source-root.js +++ b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-no-source-root.js @@ -1,5 +1,5 @@ const path = require("path"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { this.callback(null, "module.exports = 'ok';", { version: 3, diff --git a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-pre-relative.js b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-pre-relative.js index e70ef8ec6ca..969ed3106f2 100644 --- a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-pre-relative.js +++ b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-pre-relative.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { this.callback(null, "module.exports = 'ok';", { version: 3, diff --git a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-2-slash.js b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-2-slash.js index eb49d6a3ce5..03621c82c42 100644 --- a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-2-slash.js +++ b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-2-slash.js @@ -1,5 +1,5 @@ const path = require("path"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { this.callback(null, "module.exports = 'ok';", { version: 3, diff --git a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-slash.js b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-slash.js index 2fb7f62e1f5..a817050ac9f 100644 --- a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-slash.js +++ b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-slash.js @@ -1,5 +1,5 @@ const path = require("path"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { this.callback(null, "module.exports = 'ok';", { version: 3, diff --git a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-source-slash.js b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-source-slash.js index 5e25c38b2b3..c7ecf8df34f 100644 --- a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-source-slash.js +++ b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root-source-slash.js @@ -1,5 +1,5 @@ const path = require("path"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { this.callback(null, "module.exports = 'ok';", { version: 3, diff --git a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root.js b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root.js index 84613ab8e99..24c226787b5 100644 --- a/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root.js +++ b/webpack-test/configCases/source-map/relative-source-maps-by-loader/loader-source-root.js @@ -1,5 +1,5 @@ const path = require("path"); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { this.callback(null, "module.exports = 'ok';", { version: 3, diff --git a/webpack-test/fixtures/count-loader.js b/webpack-test/fixtures/count-loader.js index 9da5ce227be..12b5ba61922 100644 --- a/webpack-test/fixtures/count-loader.js +++ b/webpack-test/fixtures/count-loader.js @@ -1,6 +1,6 @@ let counter = 0; -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { return `module.exports = ${counter++};`; }; diff --git a/webpack-test/fixtures/delay-loader.js b/webpack-test/fixtures/delay-loader.js index 01e71f3fb6d..34d23f4a392 100644 --- a/webpack-test/fixtures/delay-loader.js +++ b/webpack-test/fixtures/delay-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { var cb = this.async(); setTimeout(function () { diff --git a/webpack-test/fixtures/errors/add-comment-loader.js b/webpack-test/fixtures/errors/add-comment-loader.js index 586bfbce576..ed6dc02ceeb 100644 --- a/webpack-test/fixtures/errors/add-comment-loader.js +++ b/webpack-test/fixtures/errors/add-comment-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source + "// some comment"; }; diff --git a/webpack-test/fixtures/errors/async-error-loader.js b/webpack-test/fixtures/errors/async-error-loader.js index 9826e36c3b7..5bd4cbbad32 100644 --- a/webpack-test/fixtures/errors/async-error-loader.js +++ b/webpack-test/fixtures/errors/async-error-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { const callback = this.async(); const error = new Error("this is a callback error"); diff --git a/webpack-test/fixtures/errors/emit-error-loader.js b/webpack-test/fixtures/errors/emit-error-loader.js index 1cd648e665d..9cc82f914af 100644 --- a/webpack-test/fixtures/errors/emit-error-loader.js +++ b/webpack-test/fixtures/errors/emit-error-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { this.emitWarning(new Error("this is a warning")); this.emitError(new Error("this is an error")); diff --git a/webpack-test/fixtures/errors/identity-loader.js b/webpack-test/fixtures/errors/identity-loader.js index c6d8a635121..3ae53b4dca3 100644 --- a/webpack-test/fixtures/errors/identity-loader.js +++ b/webpack-test/fixtures/errors/identity-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { return source; }; diff --git a/webpack-test/fixtures/errors/irregular-error-loader.js b/webpack-test/fixtures/errors/irregular-error-loader.js index 6ed0ba935ef..4950c5990c1 100644 --- a/webpack-test/fixtures/errors/irregular-error-loader.js +++ b/webpack-test/fixtures/errors/irregular-error-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { const empty = null; const emptyError = new Error(); diff --git a/webpack-test/fixtures/errors/no-return-loader.js b/webpack-test/fixtures/errors/no-return-loader.js index 63c5d351ef1..fb59fd7e8a4 100644 --- a/webpack-test/fixtures/errors/no-return-loader.js +++ b/webpack-test/fixtures/errors/no-return-loader.js @@ -1,2 +1,2 @@ -/** @type {import("../../../../").LoaderDefinition} */ -module.exports = function () {}; +/** @type {import("@rspack/core").LoaderDefinition} */ +module.exports = function () { }; diff --git a/webpack-test/fixtures/errors/throw-error-loader.js b/webpack-test/fixtures/errors/throw-error-loader.js index 59014e2a1b3..18dbe380958 100644 --- a/webpack-test/fixtures/errors/throw-error-loader.js +++ b/webpack-test/fixtures/errors/throw-error-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { throw new Error("this is a thrown error"); }; diff --git a/webpack-test/hotCases/child-compiler/issue-9706/report-child-assets-loader.js b/webpack-test/hotCases/child-compiler/issue-9706/report-child-assets-loader.js index 95bbe37ed0d..4049566900d 100644 --- a/webpack-test/hotCases/child-compiler/issue-9706/report-child-assets-loader.js +++ b/webpack-test/hotCases/child-compiler/issue-9706/report-child-assets-loader.js @@ -5,7 +5,7 @@ const { const compilerCache = new WeakMap(); -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { let childCompiler = compilerCache.get(this._compiler); if (childCompiler === undefined) { diff --git a/webpack-test/hotCases/fake-update-loader.js b/webpack-test/hotCases/fake-update-loader.js index 705d8feedad..6be06e09f44 100644 --- a/webpack-test/hotCases/fake-update-loader.js +++ b/webpack-test/hotCases/fake-update-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../").LoaderDefinition<{}, { updateIndex: number }>} */ +/** @type {import("@rspack/core").LoaderDefinition<{}, { updateIndex: number }>} */ module.exports = function (source) { var idx = this.updateIndex; var items = source.split(/---+\r?\n/g); diff --git a/webpack-test/hotCases/recover/recover-after-loader-error/loader.js b/webpack-test/hotCases/recover/recover-after-loader-error/loader.js index 4f935bbc6ad..f72f65cb03f 100644 --- a/webpack-test/hotCases/recover/recover-after-loader-error/loader.js +++ b/webpack-test/hotCases/recover/recover-after-loader-error/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { if (source.indexOf("error") >= 0) throw new Error(source.trim()); return source; diff --git a/webpack-test/watchCases/cache/child-compilation-cache/0/report-cache-counters-loader.js b/webpack-test/watchCases/cache/child-compilation-cache/0/report-cache-counters-loader.js index adedcfa8531..da20a56964d 100644 --- a/webpack-test/watchCases/cache/child-compilation-cache/0/report-cache-counters-loader.js +++ b/webpack-test/watchCases/cache/child-compilation-cache/0/report-cache-counters-loader.js @@ -16,7 +16,7 @@ const getCache = (associate, path) => { return c; }; -/** @type {import("../../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { if (map.has(currentWatchStepModule.step)) return map.get(currentWatchStepModule.step); diff --git a/webpack-test/watchCases/context/loader-context-dep/0/loader.js b/webpack-test/watchCases/context/loader-context-dep/0/loader.js index ed1f2044e2f..fba691d36a8 100644 --- a/webpack-test/watchCases/context/loader-context-dep/0/loader.js +++ b/webpack-test/watchCases/context/loader-context-dep/0/loader.js @@ -1,7 +1,7 @@ const path = require("path"); const directory = path.resolve(__dirname, "directory"); -/** @type {import("../../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { this.addContextDependency(directory); const callback = this.async(); diff --git a/webpack-test/watchCases/resolve/in-loader/0/loader.js b/webpack-test/watchCases/resolve/in-loader/0/loader.js index d43844f852c..28fae7bf40a 100644 --- a/webpack-test/watchCases/resolve/in-loader/0/loader.js +++ b/webpack-test/watchCases/resolve/in-loader/0/loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function () { const callback = this.async(); this.resolve(this.context, "./file", (err, file) => { diff --git a/webpack-test/watchCases/warnings/warnings-contribute-to-hash/0/warning-loader.js b/webpack-test/watchCases/warnings/warnings-contribute-to-hash/0/warning-loader.js index dbf6abe1827..65a33e1d374 100644 --- a/webpack-test/watchCases/warnings/warnings-contribute-to-hash/0/warning-loader.js +++ b/webpack-test/watchCases/warnings/warnings-contribute-to-hash/0/warning-loader.js @@ -1,4 +1,4 @@ -/** @type {import("../../../../../").LoaderDefinition} */ +/** @type {import("@rspack/core").LoaderDefinition} */ module.exports = function (source) { this.emitWarning(new Error(source.trim())); return "";