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

@nx/js:tsc executor is required for implicitDependencies in batch mode #28839

Closed
1 of 4 tasks
cogwirrel opened this issue Nov 8, 2024 · 1 comment · Fixed by #28840
Closed
1 of 4 tasks

@nx/js:tsc executor is required for implicitDependencies in batch mode #28839

cogwirrel opened this issue Nov 8, 2024 · 1 comment · Fixed by #28840

Comments

@cogwirrel
Copy link
Contributor

cogwirrel commented Nov 8, 2024

Current Behavior

When I create a workspace with both a TypeScript and Python project, with the TypeScript project having an implicit dependency on the Python one, the TypeScript project fails to compile in batch mode with the error:

The "@nx/js:tsc" batch executor requires all dependencies to use the "@nx/js:tsc" executor.
None of the following tasks in the "my-python-project" project use the "@nx/js:tsc" executor:
- my-python-project:build

Expected Behavior

The @nx/js:tsc executor should not attempt to incrementally build implicit dependencies, since this indicates there isn't an explicit reference in code, and therefore incremental builds with tsc aren't applicable.

GitHub Repo

https://github.com/cogwirrel/nx-tsc-batch-implicit-deps-example

Steps to Reproduce

  1. Clone the example repo
  2. pnpm install
  3. pnpm nx run-many --target build --batch --all --verbose
  4. Observe error

Alternatively set up from scratch:

  1. pnpm dlx create-nx-workspace --preset=ts --ci=skip
  2. pnpm exec nx generate @nx/js:library --directory=packages/my-js-lib --bundler=tsc --linter=none --name=my-js-lib --unitTestRunner=none --no-interactive
  3. Add some other project (eg a python one)
  4. Add an implicit dependency on the other project in packages/my-js-lib/project.json
  5. Build in batch mode and observe error

Nx Report

Node           : 20.18.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.12.3

nx             : 20.0.11
@nx/js         : 20.0.11
@nx/workspace  : 20.0.11
@nx/devkit     : 20.0.11
@nrwl/devkit   : 19.8.10
@nrwl/tao      : 19.8.10
typescript     : 5.5.4
---------------------------------------
Registered Plugins:
@nx/js/typescript
---------------------------------------
Community plugins:
@nxlv/python : 19.2.1
---------------------------------------
The following packages should match the installed version of nx
  - @nrwl/[email protected]
  - @nrwl/[email protected]

To fix this, run `nx migrate [email protected]`

Failure Logs

> nx run my-js-lib:build

The "@nx/js:tsc" batch executor requires all dependencies to use the "@nx/js:tsc" executor.
None of the following tasks in the "my-python-project" project use the "@nx/js:tsc" executor:
- my-python-project:build

Package Manager Version

pnpm 9.12.3

Operating System

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

Additional Information

I believe it should work as expected if the following filters out tasks for projects which are implicit dependencies:

function getDependencyTasksInOtherProjects(
task: string,
project: string,
context: ExecutorContext
): string[] {
return context.taskGraph.dependencies[task].filter(
(t) => t !== task && parseTargetString(t, context).project !== project
);
}

cogwirrel added a commit to cogwirrel/nx that referenced this issue Nov 8, 2024
Implicit dependencies are not referenced in code and therefore TSC incremental builds are not
applicable

closed nrwl#28839
cogwirrel added a commit to cogwirrel/nx that referenced this issue Nov 8, 2024
Implicit dependencies are not referenced in code and therefore TSC incremental builds are not
applicable

closed nrwl#28839
cogwirrel added a commit to cogwirrel/nx that referenced this issue Nov 8, 2024
Implicit dependencies are not referenced in code and therefore TSC incremental builds are not
applicable

closed nrwl#28839
cogwirrel added a commit to cogwirrel/nx that referenced this issue Nov 8, 2024
Implicit dependencies are not referenced in code and therefore TSC incremental builds are not
applicable

closed nrwl#28839
cogwirrel added a commit to cogwirrel/nx that referenced this issue Nov 14, 2024
Implicit dependencies are not referenced in code and therefore TSC incremental builds are not
applicable

closed nrwl#28839
leosvelperez pushed a commit that referenced this issue Nov 14, 2024
Implicit dependencies are not referenced in code and therefore TSC
incremental builds are not applicable.

## Current Behavior
A project using the `@nx/js:tsc` executor will fail to build if it has
implicit dependencies on projects which do not use the `@nx/js:tsc`
executor.

To reproduce:
* Clone https://github.com/cogwirrel/nx-tsc-batch-implicit-deps-example
* `pnpm i && pnpm nx run-many --target build --batch --all`

## Expected Behavior
- Implicit dependencies that do not use the `@nx/js:tsc` executor are
permitted. For example, a TypeScript project may implicitly depend on a
Python project, but the TypeScript project should still be buildable in
batch mode.
- Projects using the `@nx/js:tsc` executor will still fail to build if
they have explicit dependencies on projects which do not use the
`@nx/js:tsc` executor.

Tested by publishing to the local registry, upgrading the [example
repo](https://github.com/cogwirrel/nx-tsc-batch-implicit-deps-example)
to use my local version, and built successfully in batch mode.

## Related Issue(s)
Fixes #28839
FrozenPandaz pushed a commit that referenced this issue Nov 14, 2024
Implicit dependencies are not referenced in code and therefore TSC
incremental builds are not applicable.

## Current Behavior
A project using the `@nx/js:tsc` executor will fail to build if it has
implicit dependencies on projects which do not use the `@nx/js:tsc`
executor.

To reproduce:
* Clone https://github.com/cogwirrel/nx-tsc-batch-implicit-deps-example
* `pnpm i && pnpm nx run-many --target build --batch --all`

## Expected Behavior
- Implicit dependencies that do not use the `@nx/js:tsc` executor are
permitted. For example, a TypeScript project may implicitly depend on a
Python project, but the TypeScript project should still be buildable in
batch mode.
- Projects using the `@nx/js:tsc` executor will still fail to build if
they have explicit dependencies on projects which do not use the
`@nx/js:tsc` executor.

Tested by publishing to the local registry, upgrading the [example
repo](https://github.com/cogwirrel/nx-tsc-batch-implicit-deps-example)
to use my local version, and built successfully in batch mode.

## Related Issue(s)
Fixes #28839

(cherry picked from commit e32079c)
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants