Skip to content

Add experimental TS7 native API mode for transpile/emit workflows - #1703

Closed
johnnyreilly with Copilot wants to merge 3 commits into
mainfrom
copilot/emit-api-analysis
Closed

Add experimental TS7 native API mode for transpile/emit workflows#1703
johnnyreilly with Copilot wants to merge 3 commits into
mainfrom
copilot/emit-api-analysis

Conversation

Copilot AI commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

This introduces a scoped, opt-in native TypeScript 7 path in ts-loader focused on transpile/emit use cases, without attempting full parity with the existing compiler integration. The existing TypeScript path remains unchanged while native mode is added behind explicit guardrails.

  • Scope and activation

    • Adds experimentalNativeApi loader option (default false).
    • Native mode is explicitly constrained to emit-focused usage (transpileOnly: true).
  • Native adapter path (parallel, not compiler swap)

    • Adds a dedicated native integration layer (src/native.ts) instead of reusing legacy compiler assumptions.
    • Creates and reuses a native API session/snapshot lifecycle across rebuilds.
  • Per-file emit + output mapping

    • Uses native per-file emit APIs for JS and source maps.
    • Maps native emit outputs into ts-loader’s expected { outputText, sourceMapText } contract.
    • Captures declaration outputs for webpack asset emission when declaration-related options are enabled.
  • Diagnostics integration

    • Pulls native diagnostics (emit/program/global/config parsing), de-duplicates, and surfaces them through existing webpack error plumbing.
    • Respects existing loader-level diagnostic filtering behavior.
  • Dependency/watch compatibility

    • Reworks dependency registration in native mode from native project/program metadata and config files.
    • Preserves webpack-facing dependency tracking behavior.
  • Initial guardrails for unsupported features

    • Native mode currently rejects: getCustomTransformers, projectReferences, experimentalWatchApi, custom module/type resolvers, and happyPackMode.
    • Emits clear runtime option errors for unsupported combinations.
  • Docs and compatibility fixtures

    • Documents the new opt-in mode and limitations in README.md.
    • Adds native-mode comparison/execution fixtures and updates related option-validation snapshots.
// webpack.config.js
{
  test: /\.ts$/,
  loader: 'ts-loader',
  options: {
    transpileOnly: true,
    experimentalNativeApi: true,
    compiler: 'typescript-native-preview' // npm alias to TS7 dev build
  }
}

@johnnyreilly

Copy link
Copy Markdown
Member

Closing in favour of #1704 which seems more promising

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants