Skip to content

[Bug]: Rolldown strips with clause for externals #9160

Description

@i404788

Reproduction link or steps

Import a json which is marked as external:

import test from '/test.json' with { type: "json" };
export default defineConfig({
  ...,
  build: {
   rollupOptions: {
    external: [/test\.json/]
   }
  }
})

What is expected?

Externals remain with their original with clause, i.e. import test from '/test.json' with { type: "json" };

What is actually happening?

import test from '/test.json'; is emitted, causing unexpected mime errors

System Info

System:
    OS: Linux 6.12 Void
    Container: Yes
    Shell: 4.3.3 - /usr/bin/fish
  Binaries:
    Node: 24.12.0 - /usr/sbin/node
    pnpm: 10.26.2 - /usr/sbin/pnpm
  Browsers:
    Firefox: 147.0.2
    Firefox Developer Edition: 147.0.2

Any additional comments?

Currently workaround is:

const { default: product_list } = await import('/product_list.json', { with: { type: "json" } });

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions