Skip to content

Build with TypeScript 7 once 7.1 ships the programmatic API #9924

Description

@domoritz

Follow-up to #9923, which moved tsc typechecking to the native TypeScript 7 compiler. The rollup build still runs TypeScript 6, because TS 7.0 ships the native compiler without a programmatic API and @rollup/plugin-typescript needs that API. typescript is therefore aliased to @typescript/typescript6, which the plugin (and typescript-eslint) consume.

Trigger

TypeScript 7.1 shipping the programmatic API, and @rollup/plugin-typescript supporting it. The concrete signal to watch is the plugin declaring a typescript peer range that admits 7.x (it is currently >=3.7.0, which accepts 7 by version number but not in practice, since 7.0 has no API to call).

Expected change

Ideally just a dependency bump:

  • @rollup/plugin-typescript → a version supporting TS 7
  • drop the typescript@typescript/typescript6 alias and the @typescript/native alias, going back to a plain typescript dependency — only if typescript-eslint also supports 7.x by then; otherwise the alias has to stay for eslint even once the build is migrated

Motivation (measured on #9923's branch)

TS 6 TS 7 native
emit 748 files (.js + .d.ts + maps) 2.25 s 0.47 s
tsc --noEmit typecheck (837 files) 2.86 s 0.58 s

rollup.config.js has two builds, each with its own typescript() plugin instance on the same src/index.ts input, so TypeScript compiles twice — roughly 4.5 s of the ~7.3 s build. A native build should land around ~3.5 s.

Things to check beyond bumping the dep

  • Do not split into a separate tsc emit + rollup bundle step. This was considered and deliberately rejected. Chained sourcemaps (tsc → rollup, with both sourceMap and declarationMap) are easy to get subtly wrong, and it is the main reason to wait for the plugin rather than restructure the pipeline.
  • npm run watch (rollup -c -w) must keep working. A separate tsc emit step would not integrate with rollup's watch loop, which is the other reason to keep the plugin driving emit rather than doing it ourselves.
  • Expect .d.ts churn. TS 7 emits single quotes for string literal types — export declare const ROW: 'row' where TS 6 emits "row". Measured: 38 of 187 .d.ts files affected, plus every .d.ts.map. Semantically identical, but it is published output, so decide consciously whether to accept it.
  • Byte-compare the build output. Clean build before and after, comparing all 378 files in build/ (bundle, minified bundle, .d.ts, .map). chore(deps): typecheck with TypeScript 7 #9923 did exactly this to prove the alias arrangement changed nothing; the same check should gate this change, with the .d.ts quote-style diff as the only expected delta.
  • Confirm bin/vl2vg and friends still work against the rebuilt bundle (the CLI job covers this).

Related

Metadata

Metadata

Assignees

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