Skip to content

[Bug]: 'asset' module type and CJS format produces warnings and wrong output #6345

@kermanx

Description

@kermanx

Reproduction link or steps

What is expected?

No warnings and correct file path.

What is actually happening?

[EMPTY_IMPORT_META] Warning: `import.meta` is not available with the `cjs` output format and will be empty.
   ╭─[ x.ww:1:1 ]
   │
 1 │ import.meta.__ROLLDOWN_ASSET_FILENAME
   │ ─────┬─────  
   │      ╰─────── You need to set the output format to `esm` for `import.meta` to work correctly.
───╯

And part of the output is:

var require_x = /* @__PURE__ */ __commonJS({ "x.ww": ((exports, module) => {
	module.exports = {}.__ROLLDOWN_ASSET_FILENAME;
}) });

System Info

System:
    OS: Linux 6.14 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
    CPU: (16) x64 13th Gen Intel(R) Core(TM) i7-1360P
    Memory: 22.73 GB / 31.06 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 24.4.0 - /run/user/1000/fnm_multishells/243646_1758881449513/bin/node
    Yarn: 1.22.22 - /run/user/1000/fnm_multishells/243646_1758881449513/bin/yarn
    npm: 11.4.2 - /run/user/1000/fnm_multishells/243646_1758881449513/bin/npm
    pnpm: 10.15.1 - /run/user/1000/fnm_multishells/243646_1758881449513/bin/pnpm
    bun: 1.2.19 - ~/.bun/bin/bun
  npmPackages:
    rolldown: latest => 1.0.0-beta.40

Any additional comments?

No response

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions