-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nx-plugin): fix angular 15.x and 16.x install support #481
feat(nx-plugin): fix angular 15.x and 16.x install support #481
Conversation
1a70a9c
to
e907d09
Compare
currently the nx plugin let the nx angular init generator pick the version of angular to be installed. this meant that when the nx angular init generator picks 16.0.0, due to ~16.0.0 version in the nx repository, our created analog application did not work anymore. this fix makes sure the correct version ^16.1.0 is picked by nx tooling. unfortunately, semver does not like ^ in its versions so we have to remove it before finding the major version or ensuring compatibility.
15efeab
to
94e756d
Compare
e907d09
to
8ee5f47
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it locally and we need one more change to make it work for Nx 15:
Where we add the analog dependencies we also need to remove the initially installed
platform version. This is kind of counter intuitive, but we are basically replacing the latest
platform with the one that works for the Nx workspace version. If we don't do that the newest plugin will kept and we get a file path error. Making this changes will take care of the file
changes in the angular builder.
import { addDependenciesToPackageJson, removeDependenciesFromPackageJson, Tree } from '@nx/devkit';
import { getAnalogDependencies } from '../versions/dependencies';
import { getAnalogDevDependencies } from '../versions/dev-dependencies';
export async function addAnalogDependencies(
tree: Tree,
nxVersion: string,
angularVersion: string
) {
const dependencies = getAnalogDependencies(nxVersion, angularVersion);
const devDependencies = getAnalogDevDependencies(nxVersion);
removeDependenciesFromPackageJson(tree, [], ['@analogjs/platform'])
addDependenciesToPackageJson(tree, dependencies, devDependencies);
}
Another thing I noticed is that I don't believe Nx follows their own version matrix. Once I have Nx 16.0.0 Angular 16.1 gets installed (with a brand new workspace)
8ee5f47
to
c782dd8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very excited for this to land! 🚀 🔥
@brandonroberts code changes look good from my side and locally tests pass for me. not sure why CI is timing out :( |
Awesome work! @allcontributors add @jeremyhofer for code, infra |
I've put up a pull request to add @jeremyhofer! 🎉 |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Which package are you modifying?
What is the current behavior?
Before this update the plugin would force the latest Angular version to be used within a Nx workspace regardless of the Angular version(s) supported by the user's current version of Nx. This led to some inconsistencies at time with the dependency versions used and installed, causing various install, build, serve, and similar issues.
This also addresses some installation and build related issues due to the
@nrwl
to@nx
scope transition, and@angular-devkit/build-angular
internal project path changes.Potentially addresses #486 which was recently opened.
What is the new behavior?
This version will install consistent dependency versions for Analog and Angular.
For Nx workspaces on Nx versions older than 15.2.0 installation will not be supported as Nx did not add Angular 15 support until 15.2.0.
For Nx workspaces on Nx versions 15.2.0 through 16.0.0 the latest 15.X version of Angular will be installed (currently ~15.2.0 as of this PR). The Analog dependency versions that work for Angular 15.X are installed.
For Nx workspaces on Nx version 16.1.0 and newer the latest 16.X version of Angular will be installed (currently ~16.1.0 as of this PR). Latest Analog dependency versions are installed as Angular 16 is the current major version.
Does this PR introduce a breaking change?
Other information
[optional] What gif best describes this PR or how it makes you feel?