发布

  • feat(repo): enable the tsgo compiler workspace-wide (#35926)

    frostbyte_neo 发布于 2026-06-18 20:34:46 +00:00

    Current Behavior

    The workspace builds and typechecks every first-party package with
    tsc. An earlier attempt to enable the Go-based TypeScript compiler
    (tsgo) for just packages/nx (#35047) was reverted (#35167) because
    mixing compilers caused .tsbuildinfo version-mismatch cascades — a
    downstream tsc --build would see a tsgo-stamped build info and
    recompile everything.

    Expected Behavior

    The entire @nx/js/typescript build + typecheck graph — packages,
    graph, tools, e2e/**, and nx-dev/ui-fence — compiles with tsgo.
    Now that every package is on nodenext (NXC-4538), a single compiler
    runs across the whole graph, so there is no cross-compiler
    .tsbuildinfo cascade.

    Changes

    • Install @typescript/native-preview and set compiler: "tsgo" on
      both @nx/js/typescript plugin entries (the package build/typecheck
      entry and the e2e/nx-dev typecheck entry — the latter does tsc --build
      with references into packages/*, so it had to move too).
    • tsconfig.base.json: switch to nodenext module resolution, remove
      baseUrl (tsgo removed it — TS5102), and set strict: false to
      preserve current tsc behavior (tsgo defaults strict on).
    • Align spec/e2e tsconfig module to nodenext (TS5110) and add
      customConditions: ["@nx/nx-source"] to the spec tsconfigs so test
      files resolve @nx/* subpaths to workspace source — notably
      @nx/devkit/internal-testing-utils, which is excluded from devkit's
      build so no declaration is emitted under nodenext.
    • Source fixes surfaced by tsgo: two accidental workspace-root
      (baseUrl-anchored) imports now use package names; @nx/expo addJest
      gets an explicit Promise<GeneratorCallback> return type; @nx/angular
      webpack-browser casts past the angular/webpack plugin type difference;
      graph/client-e2e cypress global augmentations and AUTWindow casts;
      Task mocks get the required cache field;
      update-repos/create-embeddings config fixes.

    Validation

    • build-base: 42 projects green under tsgo.
    • typecheck: 53 projects, 0 errors under tsgo (entire
      @nx/js/typescript graph).
    • lint / test / e2e: pending CI.

    Note: tsgo's incremental/cached builds occasionally drop emitted
    declarations (observed with devkit's internal-testing-utils); a
    from-scratch build emits them. Worth watching in CI.

    The remaining tsc users — astro-docs (astro check), nx-dev's
    Next.js build, and @nx/angular's ng-packagr (ngc) — do not tsc --build the packages, so they don't share .tsbuildinfo with the tsgo
    graph and coexist safely.

    Related Issue(s)

    Implements Linear NXC-4539 (builds on NXC-4538 — all packages on
    nodenext). No GitHub issue to close.


    Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>

    下载附件