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

dependsOn is not respected when using --scope #860

Closed
IPWright83 opened this issue Mar 10, 2022 · 6 comments
Closed

dependsOn is not respected when using --scope #860

IPWright83 opened this issue Mar 10, 2022 · 6 comments

Comments

@IPWright83
Copy link

What version of Turborepo are you using?

1.1.4

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Linux

Describe the Bug

I'm trying to run tests for a package, the equivalent of pnpm turbo run test --no-deps --scope=@iw/button. This has a dependency on @iw/log so I've therefore configured my turbo.json file to include the ^build step.

"test": {
    "dependsOn": ["^build"]
},

This however doesn't include build @iw/log because of the scope. I therefore need to pass --include-dependencies in to encourage Turborepo to run the build on any dependencies.

However this also now runs the test script against @iw/log which isn't what I wanted it to do.

Expected Behavior

I expected to be able to run my tests on just a single package, automatically triggering the build steps - but without also running their tests.

To Reproduce

This assumes you have pnpm setup:

git clone https://github.com/IPWright83/pnpm-monorepo
cd pnpm-monorepo
pnpm install

Then this will fail:

pnpm turbo run test --no-deps --scope=@iw/button -- -- --watchAll=false 

This will work, but attempts to run tests for @iw/log too as evidenced by:

@iw/log:test: > @iw/log@0.1.0 test /home/ian/src/scale-fe/pnpm/packages/log
@iw/log:test: > jest --passWithNoTests "--watchAll=false"

pnpm turbo run test --no-deps --scope=@iw/button --include-dependencies -- -- --watchAll=false
@gsoltis
Copy link
Contributor

gsoltis commented Mar 18, 2022

This is unfortunately currently a known issue. Right now, you probably want --include-dependencies nearly every time you use --scope or --since. This can result in running extra tasks, but this will get pruned down soon.

For more details, this is because we currently remove any packages not selected by the various filter flags from the package dependency graph before calculating the task dependency graph. So, if a package (@iw/log) is not selected via flags (e.g. --include-dependencies is not present) it doesn't show up as a dependency of @iw/button when we go to resolve the dependencies of @iw/button#test. This is almost certainly not the desired behavior, and will be addressed in the future.

@IPWright83
Copy link
Author

Thanks @gsoltis - is this related to the --filter flag that I've since seen talked about?

@gsoltis
Copy link
Contributor

gsoltis commented Mar 21, 2022

Unfortunately no. --filter is a more flexible tool for selecting packages, but doesn't affect dependency resolution.

@gsoltis
Copy link
Contributor

gsoltis commented Mar 21, 2022

@IPWright83 I filed #912 to track the issue.

@IPWright83
Copy link
Author

Thanks @gsoltis, I've subscribed to the other issue too to monitor. If this is now a useless duplicate feel free to close.

@gsoltis
Copy link
Contributor

gsoltis commented Mar 21, 2022

Closing in favor of #912

@gsoltis gsoltis closed this as completed Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants