Skip to content

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

importModule() returns {} for asset/resource

Minimal reproduction using vanilla webpack, with no plugins or third-party loaders.

Environment

Reproduced with:

  • Node.js 24.15.0
  • Yarn 1.22.22
  • webpack 5.112.0

Steps to reproduce

Run from this project's directory:

yarn install --frozen-lockfile
yarn build

build.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.

Expected result

The resource is emitted to dist/asset.txt, and importModule() resolves to the URL string /asset.txt:

Expected "/asset.txt"; received: /asset.txt

Actual result

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.