Skip to content

parser failure for json import in js files #172

@orgads

Description

@orgads

Describe the bug

foo.json:

{
  "str": "bar"
}

foo.js:

import foo from './foo.json' with { type: 'json' };
export { foo };

json-import.ts:

import { foo } from './foo.js';
console.log(foo.str);

tsconfig.json:

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "NodeNext",
    "moduleResolution": "nodenext",
    "resolveJsonModule": true
  }
}

The plugin fails with x Expected ';', got 'with'

Reproduction

See above. Will push a PR with failing test

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
    Memory: 7.19 GB / 31.89 GB
  Binaries:
    Node: 22.15.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\ProgramData\npm\yarn.CMD
    npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.11.0 - C:\Program Files\nodejs\pnpm.CMD

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions