rpt2: built-in options overrides: {
"noEmitHelpers": false,
"importHelpers": true,
"noResolve": false,
"noEmit": false,
"noEmitOnError": false,
"inlineSourceMap": false,
"outDir": "D:/tmp/repro-rollup-import-assertion/node_modules/.cache/rollup-plugin-typescript2/placeholder",
"allowNonTsExtensions": true
}
rpt2: parsed tsconfig: {
"options": {
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"lib": [
"lib.es2020.d.ts"
],
"module": 99,
"moduleResolution": 100,
"skipLibCheck": true,
"strict": true,
"target": 99,
"composite": true,
"noEmit": false,
"outDir": "D:/tmp/repro-rollup-import-assertion/node_modules/.cache/rollup-plugin-typescript2/placeholder",
"configFilePath": "D:/tmp/repro-rollup-import-assertion/tsconfig.dev.json",
"noEmitHelpers": false,
"importHelpers": true,
"noResolve": false,
"noEmitOnError": false,
"inlineSourceMap": false,
"allowNonTsExtensions": true
},
"fileNames": [
"D:/tmp/repro-rollup-import-assertion/rollup.config.ts",
"D:/tmp/repro-rollup-import-assertion/package.json"
],
"typeAcquisition": {
"enable": false,
"include": [],
"exclude": []
},
"raw": {
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": true,
"noEmit": false,
"outDir": "out"
},
"include": [
"package.json",
"rollup.config.ts"
],
"compileOnSave": false
},
"errors": [],
"wildcardDirectories": {},
"compileOnSave": false
}
rpt2: typescript version: 5.4.3
rpt2: tslib version: 2.7.0
rpt2: rollup version: 4.13.0
rpt2: rollup-plugin-typescript2 version: 0.36.0
rpt2: plugin options:
{
"check": true,
"verbosity": 3,
"clean": true,
"cacheRoot": "D:\\tmp\\repro-rollup-import-assertion\\node_modules\\.cache\\rollup-plugin-typescript2",
"include": [
"*.ts+(|x)",
"**/*.ts+(|x)",
"**/*.cts",
"**/*.mts"
],
"exclude": [
"*.d.ts",
"**/*.d.ts",
"**/*.d.cts",
"**/*.d.mts"
],
"abortOnError": true,
"rollupCommonJSResolveHack": false,
"tsconfig": "tsconfig.dev.json",
"useTsconfigDeclarationDir": false,
"tsconfigOverride": {},
"transformers": [],
"tsconfigDefaults": {},
"objectHashIgnoreUnknownHack": false,
"cwd": "D:\\tmp\\repro-rollup-import-assertion",
"typescript": "version 5.4.3"
}
rpt2: rollup config:
{
"input": "D:\\tmp\\repro-rollup-import-assertion\\rollup.config.ts",
"plugins": [
{
"name": "rpt2"
}
],
"treeshake": false
}
rpt2: tsconfig path: D:/tmp/repro-rollup-import-assertion/tsconfig.dev.json
rpt2: included:
[
"*.ts+(|x)",
"**/*.ts+(|x)",
"**/*.cts",
"**/*.mts"
]
rpt2: excluded:
[
"*.d.ts",
"**/*.d.ts",
"**/*.d.cts",
"**/*.d.mts"
]
rpt2: transpiling 'D:\tmp\repro-rollup-import-assertion\rollup.config.ts'
rpt2: generated declarations for 'D:/tmp/repro-rollup-import-assertion/rollup.config.ts'
rpt2: generating target 1
rpt2: emitting declarations for 'D:/tmp/repro-rollup-import-assertion/rollup.config.ts' to 'rollup.config.d.ts'
[!] SyntaxError: Unexpected identifier 'assert'
at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:166:18)
at callTranslator (node:internal/modules/esm/loader:437:14)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:443:30)
at async ModuleJob._link (node:internal/modules/esm/module_job:106:19)
Summary
Running
rollup -c --configPlugin=typescript2withrollup.config.ts:
under Node 22.9.0 produces
Repro: https://github.com/earshinov/repro-rollup-import-assertion
Troubleshooting
tschave the same output?No,
tscdoesn't have the problemYes
https://github.com/earshinov/repro-rollup-import-assertion
What happens and why it is incorrect
I resumed working on one of my older projects, ran it under Node 22 and discovered that Rollup + rollup-plugin-typescript2 are no longer able to process my
rollup.config.ts, where I hadimport pkg from './package.json' assert { type: 'json' }.I converted this import into
import pkg from './package.json' with { type: 'json' };as expected by the ECMAScript standard and Node 22, but the problem persisted.Upgrading Rollup and rollup-plugin-typescript2 didn't help.
Typescript itself (
tsc) has no problems with transpilingrollup.config.tswhatsoever.Environment
Copying
package.jsonfrom the test repo:Windows 11.
Versions
:rollup.config.ts
:tsconfig.json
:tsconfig.dev.json
:package.json{ "name": "test", "description": "", "exports": { ".": { "import": "dist/index.mjs" } }, "scripts": { "build": "bash scripts/build.sh" }, "packageManager": "yarn@4.1.1", "devDependencies": { "rollup": "4.13.0", "rollup-plugin-typescript2": "^0.36.0", "typescript": "5.4.3" }, "engineStrict": true, "engines": { "node": "22.9.0" } }plugin output with verbosity 3
: