-
fix(testing)!: migrate @nx/jest to local dist build (#35713)
发布于
2026-05-17 21:39:48 +00:00 Current Behavior
@nx/jestbuilds into the shareddist/packages/jestdirectory at the
workspace root and compiles withcommonjsmodule resolution. It
exposes noexportsmap, and first-party packages (@nx/detox,
@nx/node) reach into@nx/jest/src/*for internal utilities. It also
still re-exports the long-deprecatedjestProjectGeneratoralias.Expected Behavior
@nx/jestbuilds locally intopackages/jest/dist/withnodenext
module resolution and anexportsmap, matching the already-migrated
nx,devkit, andjspackages.tsconfig.lib.json/tsconfig.spec.jsonswitched to the nodenext +
local-distpattern.package.jsongains anexportsmap (.,./plugin,./preset,
./plugins/resolver,./internal, plus the JSON configs),
typesVersions, and afilesfield.project.jsongainsrelease(preserveLocalDependencyProtocols,
manifestRootsToUpdate) andnx-release-publishconfiguration.executors.json/generators.json/migrations.jsonfactory and
schema paths repointed to./dist/src/....assets.jsonoutputs to the localdist/and copies
src/**/schema.json.src/utils/versions.tsresolves its ownpackage.jsonvia a
@nx/jestself-reference instead of a../../relative path, which
breaks once source compiles intodist/.- The
@nx/jest:jestexecutor imports itsschema.jsonstatically
rather than via a dynamicawait import. - A curated
@nx/jest/internalentry (mirroring@nx/devkit/internal)
replaces deep@nx/jest/src/*imports for first-party consumers;
@nx/detoxand@nx/nodeare routed through it. - A migration (
rewrite-jest-internal-subpath-imports) rewrites user
@nx/jest/src/*imports: named imports/exports of public symbols go to
@nx/jest, everything else to@nx/jest/internal. - A migration (
rewrite-jest-project-generator) rewrites
jestProjectGeneratorimported from@nx/jestto
configurationGenerator.
The
dist-build-migrationskill is also updated to document the
symbol-aware routing rule for the migration step.Breaking Changes
- The deprecated
jestProjectGeneratorexport is removed — its "removed
in Nx v22" notice is two majors overdue. It was always just an alias for
configurationGenerator; therewrite-jest-project-generatormigration
rewrites existing usages automatically.
Related Issue(s)
Tracked by Linear NXC-3592 —
[M4] [Epic] Migrate @nx/jest to local dist. No GitHub issue.Pre-create review (run before PR open)
Critical
- The subpath-import migration originally rewrote every
@nx/jest/src/*
import to@nx/jest/internal, which would silently break consumers
importing a public symbol (e.g.findJestConfig) that way. Fixed —
the migration now partitions named imports/exports: public symbols route
to@nx/jest, internals to@nx/jest/internal, splitting mixed
declarations into two.
Important
export { ... } from '@nx/jest/src/*'and additionaljest/vimock
helpers were not handled by the initial migration. Fixed — export
declarations are now partitioned like imports, and all eight mock-helper
methods are covered with tests.
Suggestions
versions.tsself-resolve and the inferredbuild-basetarget were
flagged; both verified correct (matches the@nx/jspattern;
build-baseis inferred by@nx/js/typescriptfrom
tsconfig.lib.json).- Softened an over-broad "used only" comment in
eslint.config.mjs.
Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
下载附件