发布

  • chore(core)!: build @nx/workspace to local dist and use nodenext (#35643)

    frostbyte_neo 发布于 2026-05-13 02:27:49 +00:00

    Current Behavior

    @nx/workspace builds to the shared workspace-root
    dist/packages/workspace/ directory, uses CommonJS
    module/moduleResolution, and has no exports map. Other Nx packages
    and external plugins reach into @nx/workspace/src/* subpaths for
    internal utilities.

    Expected Behavior

    @nx/workspace follows the same local-dist build pattern as nx and
    @nx/devkit:

    • Builds to packages/workspace/dist/ instead of
      dist/packages/workspace/.
    • tsconfig.lib.json uses module/moduleResolution: "nodenext" with
      composite, rootDir: ".", declarationDir: "dist".
    • package.json declares an exports map matching @nx/devkit's
      locked-down surface — only named entry points, no ./src/* wildcard.
    • generators.json / executors.json factory/schema paths rewritten
      ./src/..../dist/src/.... Workspace dev still works via the
      tryResolveFromSource fallback in
      packages/nx/src/config/schema-utils.ts.
    • README.mdreadme-template.md; build command writes the rendered
      README to packages/workspace/README.md.
    • project.json adds release.version config
      (preserveLocalDependencyProtocols: true, matching nx/devkit).
    • scripts/nx-release.ts: adds packages/workspace to
      packagesToReset.

    Internal-leak cleanup so the locked-down exports map doesn't break
    first-party callers:

    • TypeScriptCompilationOptions + compileTypeScript moved from
      @nx/workspace to @nx/js (the package that owns TypeScript
      compilation).
    • @nx/remix inlines directoryExists (was a one-line re-export
      wrapper).
    • @nx/rspack drops the Nx 15.7-era
      @nx/workspace/src/utils/create-ts-config fallback.
    • e2e helpers source angularDevkitVersion from @nx/angular/src/utils
      instead.
    • @nx/workspace and @nx/remix no longer declare @nx/workspace deps
      they don't use.
    • Adds a preflight step to the dist-build-migration skill that warns
      about workspace:* deps on not-yet-migrated packages.

    Breaking Changes

    @nx/workspace/src/* subpath imports are no longer supported. The
    exports map no longer declares a ./src/* wildcard. ~150 public
    consumers across GitHub use these subpaths today (the largest cluster is
    src/utilities/fileutils with ~60 hits). Migration:

    • @nx/workspace/src/utilities/fileutils (directoryExists,
      fileExists, isRelativePath, createDirectory) — these are thin
      re-exports from nx/src/utils/fileutils. Inline with node:fs
      (statSync(p).isDirectory() for directoryExists) or import from
      @nx/devkit where equivalent.
    • @nx/workspace/src/utilities/typescript/compilation — moved to
      @nx/js. Internal callers should import from there; if you were
      depending on the type externally, copy it or use the equivalent from
      @nx/js.
    • @nx/workspace/src/utils/versions — values are duplicated across
      packages; reimplement against the version of Nx you're targeting.
    • Other subpaths — check the @nx/workspace's public index.ts
      re-exports first; otherwise reimplement.

    @nx/workspace/tasks-runners/default now throws when invoked. This
    module was an alias for nx/src/tasks-runner/default-tasks-runner. The
    Nx 17 (use-minimal-config-for-tasks-runner-options) and Nx 21
    (remove-custom-tasks-runner) migrations rewrite/remove legacy
    tasksRunnerOptions entries. If your nx.json still references
    @nx/workspace/tasks-runners/default, replace it with
    nx/tasks-runners/default.

    Related Issue(s)

    Part of the ongoing migration of Nx packages to the local-dist build
    layout (following nx and @nx/devkit).


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

    下载附件