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

docs(core): project linking concept and recipe #29652

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

isaacplmann
Copy link
Collaborator

@isaacplmann isaacplmann commented Jan 16, 2025

Adds two pages:

Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Jan 16, 2025 4:53pm

Copy link

nx-cloud bot commented Jan 16, 2025

View your CI Pipeline Execution ↗ for commit e154593.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 8m 44s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 1m 5s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check --base=ad96c... ✅ Succeeded 31s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 28s View ↗
nx documentation --no-dte ✅ Succeeded 47s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-16 16:59:46 UTC


### Set Up Package Manager Workspaces

The configuration for package manager workspaces varies based on which package manager you're using.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you mention the package.json linking in the various tabs since PNPM has a different protocol. Can we bring it up more clearly though that for the "workspaces" based pacakge linking you need to have the dependency to the packages defined in the project's package.json?

like if A -> B then A's package.json needs to have a dependency to B.

I know in theory NPM (and maybe yarn and bun) don't strictly require this, while PNPM (and yarn pnp?) do. But I'd almost lean towards defining it so things don't go wrong.

"compilerOptions": {
// Required compiler options
"composite": true,
"declaration": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also add declarationMaps: true.

## Project Linking with TypeScript Path Aliases

{% callout type="warning" title="Incompatible with TypeScript Project References" %}
You can not use TypeScript project references with this style of project linking.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is technically not correct.

You can use TS path aliases with project references. The former is for the name resolution while the latter defines how TS creates "programs" for type checking/compilation.

Now, while possible, it's not what we recommend for sure. We should somewhere mention though that the recommendation goes:

  • Workspaces + proj references (preferred for new workspaces)
  • TS path aliases (how Nx does it now and will still be valid for a long time)

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

Successfully merging this pull request may close these issues.

2 participants