Skip to content

[Bug]: json import attribute not removed in bundleless mode #1076

@Netail

Description

@Netail

Version

System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 574.64 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.12.0/bin/yarn
    npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
    bun: 1.2.10 - ~/.nvm/versions/node/v20.10.0/bin/bun
  Browsers:
    Chrome: 137.0.7151.105
    Edge: 137.0.3296.83
    Safari: 18.5
  npmPackages
    @rslib/core: 0.10.1
    @rsbuild/core: 1.4.0-beta.4
    @rspack/core: 1.4.0-beta.1

Details

Import json is transformed to js, but the import statement import attributes (with { type: 'json' }) are not removed.

import enUS from './en-US/translation.json' with { type: 'json' }; becoming import translation from './en-US/translation.js' with { type: 'json' };

Reproduce link

Reproduce Steps

Import a json file, e.g. import enUS from './en-US/translation.json' with { type: 'json' };. Build the library and see it being transformed into import translation from './en-US/translation.js' with { type: 'json' };, which is invalid

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions