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

fix(core): swc should be an optional peer dependency #10461

Merged
merged 4 commits into from May 26, 2022

Conversation

AgentEnder
Copy link
Member

Current Behavior

A minimal install of nx includes @swc/core as well as @swc-node/register

Expected Behavior

  • A minimal install of nx doesn't reference swc
  • Attempting to use behavior that requires swc-node (e.g. workspace lint rules or local plugins) provide good feedback when the dependency is missing, and install it if possible.

Screenshots

Attempting to run a local plugin's generator that was created manually, in a @nrwl/js publishable lib
Note, pulling in @nrwl/js pulls in @nrwl/jest, which itself includes ts-node. This PR adds a fallback such that it was able to be used.
image

Attempting to run the same generator, with ts-node removed manually
image

Changes to package.json from running nx g @nrwl/nx-plugin:plugin

diff --git a/package.json b/package.json
index 5d73c3c..780fb30 100644
--- a/package.json
+++ b/package.json
@@ -5,15 +5,21 @@
   "scripts": {},
   "private": true,
   "dependencies": {
+    "@nrwl/nx-plugin": "^14.2.0",
+    "@swc/helpers": "~0.3.3",
     "tslib": "^2.3.0"
   },
   "devDependencies": {
     "@nrwl/cli": "14.2.0",
+    "@nrwl/devkit": "14.2.0",
     "@nrwl/eslint-plugin-nx": "14.2.0",
     "@nrwl/jest": "14.2.0",
     "@nrwl/js": "14.2.0",
     "@nrwl/linter": "14.2.0",
     "@nrwl/workspace": "14.2.0",
+    "@swc-node/register": "^1.4.2",
+    "@swc/cli": "~0.1.55",
+    "@swc/core": "^1.2.173",
     "@types/jest": "27.4.1",
     "@types/node": "16.11.7",
     "@typescript-eslint/eslint-plugin": "~5.18.0",
@@ -25,6 +31,7 @@
     "prettier": "^2.5.1",
     "ts-jest": "27.1.4",
     "ts-node": "9.1.1",
+    "tslib": "^2.0.0",
     "typescript": "~4.6.2"
   }
 }

Related Issue(s)

Fixes #ts-node

@nx-cloud
Copy link

nx-cloud bot commented May 24, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit ee0268a. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 12 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented May 24, 2022

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

Name Status Preview Updated
nx-dev ✅ Ready (Inspect) Visit Preview May 25, 2022 at 4:36PM (UTC)

Copy link
Contributor

@meeroslav meeroslav left a comment

Choose a reason for hiding this comment

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

I left two minor comments. Otherwise looks good to me

packages/nx/src/utils/register.ts Outdated Show resolved Hide resolved
@AgentEnder AgentEnder requested a review from meeroslav May 25, 2022 16:24
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

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

Successfully merging this pull request may close these issues.

None yet

2 participants