发布

  • fix(js): build to local dist and use nodenext (#35538)

    frostbyte_neo 发布于 2026-05-15 22:41:15 +00:00

    Current Behavior

    @nx/js builds to the shared workspace-root dist/packages/js/
    directory, uses CommonJS module/moduleResolution, has no exports
    map, and relies on .npmignore-style filtering through assets.json
    copies. This makes the package layout diverge from the new pattern
    already adopted by nx and @nx/devkit.

    Expected Behavior

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

    • Builds to packages/js/dist/ instead of dist/packages/js/.
    • tsconfig.lib.json uses module/moduleResolution: "nodenext" with
      composite, rootDir: ".", and declarationDir: "dist".
    • package.json declares an exports map with the @nx/nx-source
      condition (workspace consumers resolve to .ts source, published
      consumers get built .js), plus a ./src/* wildcard so the ~296
      existing internal imports of @nx/js/src/... keep working.
    • typesVersions added for legacy moduleResolution: "node" consumers.
    • Adopts an explicit files field on package.json instead of
      asset-copying the root JSONs.
    • generators.json, executors.json, migrations.json factory/schema
      paths rewritten ./src/..../dist/src/... (matches nx). 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/js/README.md. Root .gitignore now ignores
      packages/js/README.md and packages/js/**/*.d.ts (with
      !packages/js/src/**/schema.d.ts exception for committed schema
      declarations).
    • ESLint flat config ignores dist and **/*.d.ts.
    • project.json adds release.version config (with
      preserveLocalDependencyProtocols: false so the not-yet-migrated
      @nx/workspace dep is substituted to a concrete version at version-time
      rather than left as workspace:* for pnpm publish to resolve from the
      un-bumped source packages/workspace/package.json) and
      nx-release-publish.packageRoot. The build target keeps its existing
      dependsOn: ["build-base"] (cannot use ^build because js's
      implicitDependencies create a cycle through eslint /
      eslint-plugin).
    • scripts/nx-release.ts: adds packages/js to packagesToReset so
      the source packages/js/package.json is restored after release.

    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

    下载附件