diff --git a/src/rspack/loaders/load.ts b/src/rspack/loaders/load.ts index d4189919..8d42c794 100644 --- a/src/rspack/loaders/load.ts +++ b/src/rspack/loaders/load.ts @@ -16,13 +16,18 @@ export default async function load(this: LoaderContext, source: string, map: any id = decodeVirtualModuleId(id, plugin) const context = createContext(this) + + id = normalizeAbsolutePath(id) + if (id.startsWith('\\')) + id = id.replace(/\\/g, '/') + const res = await plugin.load.call( Object.assign( {}, this._compilation && createBuildContext(this._compiler, this._compilation, this), context, ), - normalizeAbsolutePath(id), + id, ) if (res == null) diff --git a/src/webpack/loaders/load.ts b/src/webpack/loaders/load.ts index 16a1010c..ac06db3e 100644 --- a/src/webpack/loaders/load.ts +++ b/src/webpack/loaders/load.ts @@ -16,6 +16,11 @@ export default async function load(this: LoaderContext<{ unpluginName: string }> id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length)) const context = createContext(this) + + id = normalizeAbsolutePath(id) + if (id.startsWith('\\')) + id = id.replace(/\\/g, '/') + const res = await plugin.load.call( Object.assign({}, createBuildContext({ addWatchFile: (file) => { @@ -25,7 +30,7 @@ export default async function load(this: LoaderContext<{ unpluginName: string }> return this.getDependencies() }, }, this._compiler!, this._compilation, this), context), - normalizeAbsolutePath(id), + id, ) if (res == null)