fix(core): run migrations ordered by their target version #21799
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current Behavior
Most of the time, all migrations of a given plugin are run ordered by their target version. This can be problematic sometimes when a migration of a plugin checks stuff from another plugin.
Such an issue occurred and is explained in #20407 (comment):
update-tsconfig-spec-jest
migration from the@nx/angular
package targets the version15.9.0-beta.3
@nrwl/jest:jest
executor to perform an update to thetsconfig.spec.json
update-16-0-0-add-nx-packages
migration from the@nx/jest
package targets the version16.0.0-beta.1
@nrwl/jest
with@nx/jest
@nx/jest
package migrations run before the@nx/angular
package migrationsNote how
@nrwl/jest:jest
will be replaced@nx/jest:jest
before running theupdate-tsconfig-spec-jest
migration from the@nx/angular
package, even though that migration was written/released and targets a lower version of Nx. That migration shouldn't know about the@nx/*
scoped packages because it was written for a version where the rescoping hadn't occurred yet.Expected Behavior
Migrations should be run ordered by their target version regardless of the plugin they are for.
Note: the
15-7-0-split-configuration-into-project-json-files
migration from@nx/workspace
is a special case that's meant to run first.Related Issue(s)
Fixes #