Skip to content

typescript rollup config with node 22 fails with "Unexpected identifier 'assert'" #1762

@michaelglass

Description

@michaelglass

Expected Behavior

on Node V22, the keyword assert has been replaced with with,
when my rollup.config.ts includes an import using with

import pkg from "./package.json" with { type: "json" };

npx rollup -c --pluginConfig typescript
will run rollup

Actual Behavior

I get the error,

[!] SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:164:18)
    at callTranslator (node:internal/modules/esm/loader:439:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:445:30)
    at async ModuleJob._link (node:internal/modules/esm/module_job:106:19)

I get the same error when passing the tsconfig manually to rollup, e.g.
npx rollup -c --configPlugin typescript={target:\"esnext\"\,module:\"Preserve\"}

Additional Information

clone the repo above to see a small reproduction

git clone [email protected]:michaelglass/rollup-typescript-repro.git
cd rollup-typescript-repro
direnv allow # if you're using nix / direnv, or nix develop
npm install
npm run rollup-ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions