Minimal reproduction using vanilla webpack, with no plugins or third-party loaders.
Reproduced with:
- Node.js 24.15.0
- Yarn 1.22.22
- webpack 5.112.0
Run from this project's directory:
yarn install --frozen-lockfile
yarn buildbuild.js runs webpack in development mode. The custom loader.js calls:
await this.importModule(
`${this.resourcePath}.webpack[asset/resource]!=!${this.resourcePath}`,
);The input is a plain text file (asset.txt); no image or application framework is required.
The resource is emitted to dist/asset.txt, and importModule() resolves to the URL string /asset.txt:
Expected "/asset.txt"; received: /asset.txt
Expected "/asset.txt"; received: {}
asset main.js 1.23 KiB [emitted] (name: main)
asset asset.txt 6 bytes [emitted] [from: asset.txt] (auxiliary name: main)
The build succeeds and emits the resource, but the loader receives an empty object instead of its URL.