Skip to content
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

dev-server does not run dependencies #26701

Open
1 of 4 tasks
fhaag opened this issue Jun 26, 2024 · 0 comments
Open
1 of 4 tasks

dev-server does not run dependencies #26701

fhaag opened this issue Jun 26, 2024 · 0 comments

Comments

@fhaag
Copy link

fhaag commented Jun 26, 2024

Current Behavior

In my project.json file, I have a build target using the @angular-devkit/build-angular:browser executor. I can add another target testoutput to its dependsOn array.

If I invoke build directly (nx run build) or indirectly (nx run testcaller, where testcaller is a target that depends on build), testoutput is run before build.

If build is run as the build target of @angular-devkit/build-angular:dev-server, on the other hand, testoutput is not run before each build.

This renders it difficult to enrich the build process with pre-processing/code generation steps.

Expected Behavior

When @angular-devkit/build-angular:dev-server does its live-reload, I expect it to run the dependencies of its build target and only then the build target itself.

GitHub Repo

https://github.com/fhaag/angular-cli-bug-repro/tree/dev-server-build-dependency-issue

Steps to Reproduce

Just start with the default sample from ng new repro-app and init NX.

In the project.json file, add the following two targets:

"testoutput": {
	"command": "echo 'TEST'"
},
"testcaller": {
	"dependsOn": ["build"],
	"command": "echo 'CALLER'"
}

Then modify the build target to depend on testoutput:

"build": {
	"executor": "@angular-devkit/build-angular:browser",
		"dependsOn": ["testoutput"],
		"options": {

Now, run:

  • nx run build - will display TEST and then execute the build process, as expected
  • nx run testcaller - will display TEST, then execute the build process, and then execute CALLER, as expected
  • nx run serve - will just execute the build process; unexpectedly, the TEST output is nowhere to be seen

Nx Report

NX   Report complete - copy this into the issue template

Node   : 18.17.0
OS     : win32-x64
npm    : 8.9.0

nx (global)    : 19.3.1
nx             : 19.0.8
@nx/js         : 19.0.8
@nx/linter     : 19.0.8
@nx/eslint     : 19.0.8
@nx/workspace  : 19.0.8
@nx/angular    : 19.0.8
@nx/devkit     : 19.0.8
@nrwl/tao      : 19.0.8
@nx/web        : 19.0.8
@nx/webpack    : 19.0.8
typescript     : 4.9.5

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Given that this issue occurred for me in the @angular-devkit/build-angular:dev-server executor, I had first reported it on the Angular CLI issue tracker: angular/angular-cli#27937

However, I was told over there that

this issue is not caused by Angular CLI. Please contact the author(s) of the NX project or file an issue on their issue tracker.

And indeed, the @angular-devkit/build-angular:dev-server has exactly the same issue.

Also, the existing issue #5803 sounds a bit similar to this one, but it appears to be specific to a Cypress executor and also is supposedly fixed already, while mine still occurs.

@fhaag fhaag changed the title @angular-devkit/build-angular:dev-server does not run dependencies dev-server does not run dependencies Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant