Closed trumbitta closed 5 months ago
Thank you for submitting the issue.
Currently, running a target imperatively runs that target, and not all the targets it depends on. It doesn't go through the tasks runner etc. We should be able to extend it in H2 2021 after combining the tao and workspace packages. For now though, this isn't possible. Sorry about this.
The workaround you provided works. A different workaround would be to create a separate target: "serve-using-nx" and do something like this there:
target: 'serve-using-nx',
executor: '@nrwl/workspace:run-commands',
options: {
command: 'nx serve myapp'
}
In this case you will create a separate process using Nx, so the tasks runner will schedule all the right tasks.
I see, makes sense! I'm glad there are workarounds and some hope for the near future ๐
I'll just keep on following the releases ๐ต๏ธ until I can dismantle my workaround, then!
Will you add suppport for for dependsOn for serve targets?
Hi, I encountered the same issue, trying to configure Cypress, running e2e test on Storybook server, with compodoc as dependency.
@trumbitta thank you for the workaround. It works pretty well.
Here is the config file I use:
"my-lib": {
"projectType": "library",
"root": "libs/my-lib",
"sourceRoot": "libs/my-lib/src",
"prefix": "awesome",
"architect": {
"_storybook": {
"builder": "@nrwl/storybook:storybook",
"options": {
"projectBuildConfig": "my-app",
"uiFramework": "@storybook/angular",
"port": 4400,
"config": {
"configFolder": "libs/my-lib/.storybook"
}
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"_build-storybook": {
"builder": "@nrwl/storybook:build",
"outputs": ["{options.outputPath}"],
"options": {
"projectBuildConfig": "my-app",
"uiFramework": "@storybook/angular",
"outputPath": "dist/storybook/my-lib",
"config": {
"configFolder": "libs/my-lib/.storybook"
}
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"compodoc": {
"builder": "@twittwer/compodoc:compodoc",
"options": {
"tsConfig": "libs/my-lib/tsconfig.lib.json",
"outputPath": "dist/compodoc/my-lib",
"exportFormat": "json"
}
},
"storybook": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
"npx nx run my-lib:compodoc --watch",
"npx nx run my-lib:_storybook"
],
"parallel": true
}
},
"build-storybook": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
"npx nx run my-lib:compodoc",
"npx nx run my-lib:_build-storybook"
],
"parallel": false
}
}
}
},
"my-lib-e2e": {
"root": "apps/my-lib-e2e",
"sourceRoot": "apps/my-lib-e2e/src",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@nrwl/cypress:cypress",
"dependsOn": [
{
"target": "compodoc",
"projects": "dependencies"
}
],
"options": {
"cypressConfig": "apps/my-lib-e2e/cypress.json",
"devServerTarget": "my-lib:_storybook"
},
"configurations": {
"ci": {
"devServerTarget": "my-lib:_storybook:ci"
}
}
}
}
},
As a side effect, when I run all e2e test with the command nx run-many --target=e2e --all --headless
, only compodoc
tasks are executed for e2e targets.
It seems that e2e test execution stops after dependsOn
target is executed.
Did someone encountered this issue ?
Thank you for submitting the issue.
Currently, running a target imperatively runs that target, and not all the targets it depends on. It doesn't go through the tasks runner etc. We should be able to extend it in H2 2021 after combining the tao and workspace packages. For now though, this isn't possible. Sorry about this.
The workaround you provided works. A different workaround would be to create a separate target: "serve-using-nx" and do something like this there:
target: 'serve-using-nx', executor: '@nrwl/workspace:run-commands', options: { command: 'nx serve myapp' }
In this case you will create a separate process using Nx, so the tasks runner will schedule all the right tasks.
I tried using the workaround described above and it hangs on the serve target in the command
. Is that normal?
Is there any progress till now?
Thank you for submitting the issue.
Currently, running a target imperatively runs that target, and not all the targets it depends on. It doesn't go through the tasks runner etc. We should be able to extend it in H2 2021 after combining the tao and workspace packages. For now though, this isn't possible. Sorry about this.
The workaround you provided works. A different workaround would be to create a separate target: "serve-using-nx" and do something like this there:
target: 'serve-using-nx', executor: '@nrwl/workspace:run-commands', options: { command: 'nx serve myapp' }
In this case you will create a separate process using Nx, so the tasks runner will schedule all the right tasks.
Is there any progress till now?
Thank you for submitting the issue.
Currently, running a target imperatively runs that target, and not all the targets it depends on. It doesn't go through the tasks runner etc. We should be able to extend it in H2 2021 after combining the tao and workspace packages. For now though, this isn't possible. Sorry about this.
The workaround you provided works. A different workaround would be to create a separate target: "serve-using-nx" and do something like this there:
target: 'serve-using-nx', executor: '@nrwl/workspace:run-commands', options: { command: 'nx serve myapp' }
In this case you will create a separate process using Nx, so the tasks runner will schedule all the right tasks.
Any update on this? It's very frustrating.
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
It's still an issue.
Same for us
I have the same problem.
FYI - seeing another consequence of not using the task runner. nx will not respect the proper configuration env file for the devServerTarget.
Eg. having a
"static-serve": {
// statically serve the app
},
"e2e2": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/my-app/cypress.config.ts",
"testingType": "e2e",
"devServerTarget": "my-app:serve-static:e2e",
"port": 3030,
"browser": "chrome"
}
},
running nx run my-app:e2e2
will run the e2e2
target but when it runs the devServerTarget it will use the configuration e2e2
when looking for it's .env
file so it'll look for .env.e2e2
even though the devServerTarget specifies the configuration should be called e2e
.
What's worse is that this is only an issue if the e2e2
task is in the same project as the devServerTarget, if I have another feature Eg. nx run my-feature:e2e2
that has a similar e2e2
but serves the app project Ie.
"e2e2": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/my-app/cypress.config.ts",
"testingType": "e2e",
"devServerTarget": "my-app:serve-static:e2e",
"port": 3030,
"browser": "chrome"
}
},
then it will pick up the .env.e2e
environment variable file from the my-app project when running the devServerTarget
The new command based Cypress Plugin fixes this issue. Running the command will invoke dependent tasks while running a target in an executor did not.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
In
workspace.json
, for an e2e app with@nrlw/cypress
,"devServerTarget": "my-project:serve"
makes Nx runmy-project:serve
but it skips the newdependsOn
option formy-project:serve
.To make it work, I have to add a
dependsOn
block tomy-project-e2e
instead.Expected Behavior
I'd expect for targets to always follow the
dependsOn
chainSteps to Reproduce
Have a e2e testing project for a react project. The react project uses the new
dependsOn
configuration:nx serve my-project
my-project:some-custom-target
will be correctly launched beforemy-project:serve
nx e2e my-project-e2e
devServerTarget
will make Nx runmy-project:serve
first, but it will skipmy-project:some-custom-target
my-project-e2e:e2e
:Environment