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

feat(js): remove nx property from generated package.json files #29705

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

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Jan 21, 2025

This PR updates our generators to no longer generate with nx in package.json by default. The only times it is needed is if you pass add tags or implicitDependencies to the project config.

This PR replaces our projectType checks to use the getProjectType util from @nx/js to prefer the project config, but otherwise will check for our conventions (e.g. using exports for libs, tsconfig.lib.json vs tsconfig.app.json).

Impact

  • There shouldn't be any behavioral changes to existing projects that have explicit projectType, name, etc. in with project.json or package.json (via nx property).
  • For new projects created under the new TS setup, the nx property will no longer be there. Generators with logic that depend on projectType will now check for tsconfig.lib.json and tsconfig.app.json (so all of our generators are covered). If none of those tsconfig files are found, then we check package.json, since libraries are required to have exports to be consumed.

Copy link

vercel bot commented Jan 21, 2025

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

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Jan 23, 2025 5:07pm

@jaysoo jaysoo force-pushed the feat/remove-nx-from-package-json branch from 7836fb2 to 8ae3480 Compare January 21, 2025 19:53
Copy link

nx-cloud bot commented Jan 21, 2025

View your CI Pipeline Execution ↗ for commit 2a402a9.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ❌ Failed 44m 45s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 1m 7s View ↗
nx-cloud record -- nx format:check --base=d6015... ✅ Succeeded 23s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 19s View ↗
nx documentation --no-dte ✅ Succeeded 52s View ↗
nx affected -t e2e-macos-local --parallel=1 --b... ✅ Succeeded 22m 21s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-23 17:55:44 UTC

@jaysoo jaysoo force-pushed the feat/remove-nx-from-package-json branch 2 times, most recently from 79c94ef to 59b78b0 Compare January 21, 2025 21:58
FrozenPandaz pushed a commit that referenced this pull request Jan 21, 2025
…+ skip writing empty nx property to pacakge.json for non-root projects (#29707)

This PR is a prerequisite to removing `nx` property from `package.json`
files in the new TS setup. It fixes two issues:

1. We always write `nx` property in `package.json` even if it is empty.
This should be done for root projects.
2. Adding an entry to `pnpm-workspace.yaml` is not picked up because
`readProjectConfiguration` only reads the file from disk, not from
virtual `Tree`

This is the next PR to remove the property:
#29705
@jaysoo jaysoo force-pushed the feat/remove-nx-from-package-json branch 19 times, most recently from 28d2a6c to bc2a0dd Compare January 22, 2025 21:41
@jaysoo jaysoo marked this pull request as ready for review January 22, 2025 23:23
@jaysoo jaysoo requested review from a team as code owners January 22, 2025 23:23
@jaysoo jaysoo requested review from a team and Coly010 as code owners January 22, 2025 23:23
@jaysoo jaysoo requested a review from AgentEnder January 22, 2025 23:23
Copy link

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx create-nx-workspace@0.0.0-pr-29705-bc2a0dd my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-29705-bc2a0dd
Release details 📑
Published version 0.0.0-pr-29705-bc2a0dd
Triggered by @jaysoo
Branch feat/remove-nx-from-package-json
Commit bc2a0dd
Workflow run 12918968325

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

@jaysoo jaysoo force-pushed the feat/remove-nx-from-package-json branch from bc2a0dd to f0047ae Compare January 23, 2025 14:49
@jaysoo jaysoo force-pushed the feat/remove-nx-from-package-json branch from f0047ae to 055af63 Compare January 23, 2025 16:07
@jaysoo jaysoo force-pushed the feat/remove-nx-from-package-json branch from 055af63 to 2a402a9 Compare January 23, 2025 17:05
Copy link

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx create-nx-workspace@0.0.0-pr-29705-2a402a9 my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-29705-2a402a9
Release details 📑
Published version 0.0.0-pr-29705-2a402a9
Triggered by @jaysoo
Branch feat/remove-nx-from-package-json
Commit 2a402a9
Workflow run 12934550081

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

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