feat(@angular/build): add process.env.PORT support to the dev server#32705
feat(@angular/build): add process.env.PORT support to the dev server#32705hawkgs wants to merge 1 commit intoangular:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for setting the dev server port via the PORT environment variable, which is a useful feature for deployment flexibility. The implementation correctly parses and validates the environment variable before applying it. However, there are failing assertions in the newly added test cases that need to be addressed.
packages/angular/build/src/builders/dev-server/tests/options/port_spec.ts
Outdated
Show resolved
Hide resolved
packages/angular_devkit/build_angular/src/builders/dev-server/tests/options/port_spec.ts
Outdated
Show resolved
Hide resolved
5a5dbfb to
d53396e
Compare
There was a problem hiding this comment.
- Let's not do this in build-angular, as no new features are added there.
- Update the option in
Handle issue:is not a valid keyword. Please choose Closes, Fixes, Resolves. See: https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword- Since this can be a breaking change, please mention it in the commit message using
BREAKING CHANGE: - Add the PR description as part of the commit message body.
packages/angular/build/src/builders/dev-server/tests/options/port_spec.ts
Outdated
Show resolved
Hide resolved
d53396e to
d5c5bc1
Compare
|
Done. The commit already had a message body but I updated it with the breaking change comment. |
There was a problem hiding this comment.
-
Resolves #32236 (This should always be part of the footer of the commit not the body. (Tools only handle this in the footer)
-
BREAKING CHANGE:process.env.PORToverwrites both the default port (4200) and the user-specified one using theng serve --port` option. Is not totally correct and it doesn't have "context".
"The @angular/build:dev-server (ng serve) now assigns the highest priority to the PORT environment variable. This value will override any port configurations specified in angular.json or via the --port command-line flag. This includes the default port 4200.
Make possible to set the dev server port via `process.env.PORT`. BREAKING CHANGE: The `@angular/build:dev-server (ng serve)` now assigns the highest priority to the `PORT` environment variable. This value will override any port configurations specified in `angular.json` or via the `--port` command-line flag. This includes the default port 4200. Resolves angular#32236
d5c5bc1 to
1f71a9e
Compare
The change allows setting the dev server port via the
PORTenvironment variable.BREAKING CHANGE: The
@angular/build:dev-server (ng serve)now assigns the highest priority to thePORTenvironment variable. This value will override any port configurations specified inangular.jsonor via the--portcommand-line flag. This includes the default port 4200.Since the
portoption is handled by the dev server options JSON schema from what I get, we can only overwrite the already set port (whether that's using the default4200or the user-specified--port). This means thatprocess.env.PORThas the highest priority when it comes to port selection unless the port is already in use. I am not sure if this the desired result, precisely, but the alternative would be to dropportfrom the schema and handle it in the builder execution code instead, if I read the things correctly, which is not an option, I guess.Resolves #32236