chore(core): build nx to local dist and use nodenext#34111
chore(core): build nx to local dist and use nodenext#34111FrozenPandaz merged 71 commits intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
❌ Deploy Preview for nx-docs failed. Why did it fail? →
|
|
View your CI Pipeline Execution ↗ for commit aa747a3
☁️ Nx Cloud last updated this comment at |
1845ef4 to
e88f09d
Compare
e88f09d to
355cb3c
Compare
0e73eba to
3038774
Compare
3038774 to
bce8591
Compare
bce8591 to
4b4f86a
Compare
0defccd to
8db4c8c
Compare
4304d08 to
ecfcaec
Compare
Co-authored-by: Coly010 <Coly010@users.noreply.github.com>
…esbuild import The react-native vite config template imported esbuild directly, which fails during project graph processing in pnpm strict mode because esbuild is only a transitive dependency of vite and not hoisted to root node_modules. Fixes e2e-detox:e2e-macos-local failure.
When Nx is built to a local dist directory, resolveNx(null) computes the "global root" by going 4 directories up from __dirname, which lands in the wrong location and resolves to a different nx. This causes isLocalInstall to be false, so the bin tries to require itself (cached no-op) and nothing happens. Adding localNx === __filename as a fallback check: if the workspace wants this exact file, we are the local install by definition.
With nodenext module resolution, Node requires explicit file extensions when resolving module paths. The daemon server spawn already uses start.js with the extension, but the plugin worker path was missing it.
The conformance runner can't resolve TS conformance rules without @swc-node/register. Build workspace-plugin to JS first, then point conformance rule paths to the compiled dist output.
Add dist/ to eslint ignore patterns since the new outDir puts compiled output inside packages/nx/dist/. Also add module boundary eslint-disable for jest-resolver.js which needs a relative import.
When running from TS source (tests), use plugin-worker.ts. When running from compiled dist (production), use plugin-worker.js.
There was a problem hiding this comment.
Nx Cloud is proposing a fix for your failed CI:
We updated tools/workspace-plugin/package.json to fix the @nx/dependency-checks lint errors introduced when conformance rules were added to the workspace plugin. The missing packages (@nx/conformance, glob, js-yaml, shiki, semver) are now declared as dependencies, and the unused @nx/eslint entry has been removed. This aligns the declared dependencies with what is actually imported in the conformance rule source files.
Note
⏳ We are verifying this fix by re-running workspace-plugin:lint.
diff --git a/tools/workspace-plugin/package.json b/tools/workspace-plugin/package.json
index a9f9ef81bf..2fd35f48ba 100644
--- a/tools/workspace-plugin/package.json
+++ b/tools/workspace-plugin/package.json
@@ -5,12 +5,16 @@
"generators": "./generators.json",
"executors": "./executors.json",
"dependencies": {
+ "@nx/conformance": "4.0.0",
"@nx/devkit": "workspace:*",
- "@nx/eslint": "workspace:*",
"@nx/plugin": "workspace:*",
"@nx/js": "workspace:*",
"@xmldom/xmldom": "^0.8.10",
+ "glob": "7.1.4",
+ "js-yaml": "^4.1.0",
"nx": "workspace:*",
+ "semver": "catalog:",
+ "shiki": "^4.0.2",
"tslib": "catalog:typescript"
},
"type": "commonjs",
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
Or Apply changes locally with:
npx nx-cloud apply-locally lXvn-PtJK
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud is proposing a fix for your failed CI:
We updated tools/workspace-plugin/package.json to fix the @nx/dependency-checks lint errors introduced when conformance rules were added to the workspace plugin. The missing packages (@nx/conformance, glob, js-yaml, shiki, semver) are now declared as dependencies, and the unused @nx/eslint entry has been removed. This aligns the declared dependencies with what is actually imported in the conformance rule source files.
Tip
✅ We verified this fix by re-running workspace-plugin:lint.
diff --git a/tools/workspace-plugin/package.json b/tools/workspace-plugin/package.json
index a9f9ef81bf..2fd35f48ba 100644
--- a/tools/workspace-plugin/package.json
+++ b/tools/workspace-plugin/package.json
@@ -5,12 +5,16 @@
"generators": "./generators.json",
"executors": "./executors.json",
"dependencies": {
+ "@nx/conformance": "4.0.0",
"@nx/devkit": "workspace:*",
- "@nx/eslint": "workspace:*",
"@nx/plugin": "workspace:*",
"@nx/js": "workspace:*",
"@xmldom/xmldom": "^0.8.10",
+ "glob": "7.1.4",
+ "js-yaml": "^4.1.0",
"nx": "workspace:*",
+ "semver": "catalog:",
+ "shiki": "^4.0.2",
"tslib": "catalog:typescript"
},
"type": "commonjs",
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
Or Apply changes locally with:
npx nx-cloud apply-locally lXvn-PtJK
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
Add missing dependencies (conformance, glob, js-yaml, semver, shiki) and remove unused @nx/eslint.
There was a problem hiding this comment.
Nx Cloud is proposing a fix for your failed CI:
We ran nx sync to remove the stale project reference to packages/eslint/tsconfig.lib.json from tools/workspace-plugin/tsconfig.lib.json. This reference became stale as a result of the workspace-plugin dependency changes introduced in this PR. Running nx sync keeps TypeScript project references consistent with the actual project dependency graph.
Note
⏳ We are verifying this fix by re-running nx-cloud record -- nx sync:check.
diff --git a/tools/workspace-plugin/tsconfig.lib.json b/tools/workspace-plugin/tsconfig.lib.json
index 19a65594..c6ce8fb2 100644
--- a/tools/workspace-plugin/tsconfig.lib.json
+++ b/tools/workspace-plugin/tsconfig.lib.json
@@ -26,9 +26,6 @@
{
"path": "../../packages/plugin/tsconfig.lib.json"
},
- {
- "path": "../../packages/eslint/tsconfig.lib.json"
- },
{
"path": "../../packages/devkit/tsconfig.lib.json"
}
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
Or Apply changes locally with:
npx nx-cloud apply-locally L6fs-qRIq
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
There was a problem hiding this comment.
Nx Cloud is proposing a fix for your failed CI:
We ran nx sync to remove the stale project reference to packages/eslint/tsconfig.lib.json from tools/workspace-plugin/tsconfig.lib.json. This reference became stale as a result of the workspace-plugin dependency changes introduced in this PR. Running nx sync keeps TypeScript project references consistent with the actual project dependency graph.
Tip
✅ We verified this fix by re-running nx-cloud record -- nx sync:check.
diff --git a/tools/workspace-plugin/tsconfig.lib.json b/tools/workspace-plugin/tsconfig.lib.json
index 19a65594..c6ce8fb2 100644
--- a/tools/workspace-plugin/tsconfig.lib.json
+++ b/tools/workspace-plugin/tsconfig.lib.json
@@ -26,9 +26,6 @@
{
"path": "../../packages/plugin/tsconfig.lib.json"
},
- {
- "path": "../../packages/eslint/tsconfig.lib.json"
- },
{
"path": "../../packages/devkit/tsconfig.lib.json"
}
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
Or Apply changes locally with:
npx nx-cloud apply-locally L6fs-qRIq
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
Co-authored-by: Coly010 <Coly010@users.noreply.github.com>
There was a problem hiding this comment.
✅ The fix from Nx Cloud was applied automatically
We ran nx sync to remove the stale project reference to packages/eslint/tsconfig.lib.json from tools/workspace-plugin/tsconfig.lib.json. This reference became stale as a result of the workspace-plugin dependency changes introduced in this PR. Running nx sync keeps TypeScript project references consistent with the actual project dependency graph.
Tip
✅ We verified this fix by re-running nx-cloud record -- nx sync:check.
Suggested Fix changes
diff --git a/tools/workspace-plugin/tsconfig.lib.json b/tools/workspace-plugin/tsconfig.lib.json
index 19a65594..c6ce8fb2 100644
--- a/tools/workspace-plugin/tsconfig.lib.json
+++ b/tools/workspace-plugin/tsconfig.lib.json
@@ -26,9 +26,6 @@
{
"path": "../../packages/plugin/tsconfig.lib.json"
},
- {
- "path": "../../packages/eslint/tsconfig.lib.json"
- },
{
"path": "../../packages/devkit/tsconfig.lib.json"
}
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
View interactive diff ↗🎓 Learn more about Self-Healing CI on nx.dev
|
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. |
Current Behavior
The
nxpackage compiles its TypeScript output to../../dist/packages/nx/(relative to the package root), which places build artifacts outside the package directory at the repo root level (dist/packages/nx/). This makes the package structure harder to reason about, complicates the build pipeline, and doesn't align with how most packages organize their output.The package uses
"module": "commonjs"with basic module resolution, which limits future migration paths toward ESM.Expected Behavior
The
nxpackage now builds to a localdist/directory within the package itself (packages/nx/dist/). This is a cleaner, more standard layout — like having your tools in your own toolbox instead of scattered across the workshop.Key changes:
Build configuration (
packages/nx/tsconfig.lib.json):outDirchanged from../../dist/packages/nxtodist(local to package)modulechanged tonodenextwithmoduleResolution: nodenextincludepatterns to explicitly list source directoriesPackage entry points (
packages/nx/package.json):binpaths updated:./bin/nx.js→./dist/bin/nx.js"type": "commonjs"explicitlyexportsmap with@nx/nx-sourcecondition for dev/test resolution back to TS sourcepostinstallpath update to./dist/bin/post-installModule resolution fixes:
src/utils/handle-import.ts— a CJS-first import utility that falls back to ESMimport()for ESM-only packages, providing a single migration point for future ESM workawait import()calls torequire(require.resolve())pattern where needed to satisfynodenextextension requirements.ts/.jsextension based on runtime context (source vs compiled)Test infrastructure:
jest-resolver.jsfor thenxpackage that resolvesnx/...imports using the@nx/nx-sourceexports condition, so tests run against TS sourcejest.preset.jswith SWC transformer configurationCI and tooling:
workspace-pluginfirst (the Nx Cloud runner lacks@swc-node/registerfor TS resolution)nx.jsonnow point to compileddist/workspace-plugin/src/...outputdistto eslint ignore patterns to prevent linting compiled outputOther fixes:
create-nx-workspace, gradle, and other packages to work withnodenextresolution.gitignoreand.npmignorefor the new output structureRelated Issue(s)
Internal infrastructure improvement — no external issue.