chore(devkit): build devkit to local dist and use nodenext (#34946)

## Current Behavior

`@nx/devkit` builds to `<workspaceRoot>/dist/packages/devkit/` — outside
its own package directory. Other packages reach into that shared
workspace `dist/` to consume devkit, and consumers using
`moduleResolution: nodenext` need a custom Module._resolveFilename hack
to find it.

This is inconsistent with `nx` itself, which already builds to
`packages/nx/dist/` (#34111).

## Expected Behavior

`@nx/devkit` builds to `packages/devkit/dist/` and is consumed via a
standard `exports` map. Workspace consumers resolve through normal pnpm
symlinks; the `@nx/nx-source` condition still lets in-repo code resolve
to `.ts` source during dev.

This unblocks the rest of the workspace from migrating in the same
direction (a `dist-build-migration` Claude skill is included as a
per-package playbook).

## How to review

The PR has **307 files but only 3 categories of work**. Most of the diff
is mechanical.

### 1. The actual migration — review carefully (~10 files)

Devkit package config and the `@nx/nx-source` condition wiring:

- `packages/devkit/package.json` — `exports` map, `typesVersions`,
`files`, `type: commonjs`, `main`/`types` repointed to `dist/`
- `packages/devkit/tsconfig.lib.json` — `outDir: dist`, `nodenext`
module/resolution
- `packages/devkit/project.json` — `build-base` outputs,
`nx-release-publish.packageRoot`, `manifestRootsToUpdate`
- `packages/devkit/internal.ts` — re-exports `src/utils/*` and
`src/generators/*` symbols (replaces the `@nx/devkit/src/*` deep-import
pattern)
- `packages/devkit/eslint.config.mjs` — ignore `dist`
- `packages/devkit/{README.md → readme-template.md}` — README is now
generated, gitignored
- `.gitignore` — ignore the generated `packages/devkit/README.md`
- `scripts/nx-release.ts` — devkit's `package.json` now lives at
`packages/devkit/package.json`, not `dist/packages/devkit/package.json`
- `scripts/patched-jest-resolver.js` — adds `@nx/nx-source` condition

### 2. Mass import rewrites — already marked viewed (~205 files)

Every internal import of `@nx/devkit/src/utils/<x>` or
`@nx/devkit/src/generators/<x>` was rewritten to `@nx/devkit/internal`:

```diff
-import { foo } from '@nx/devkit/src/utils/bar';
+import { foo } from '@nx/devkit/internal';
```

I marked these files as **viewed** in the GitHub review UI to clear them
from the unread queue. They're across nearly every plugin (angular,
react, next, vite, webpack, rspack, expo, jest, etc.).

### 3. Follow-on cleanups (~10 files)

These appear in their own commits and are easy to review individually:

- **`cleanup(angular-rspack)`** — removes the `patchDevkitRequestPath`
runtime hack from 14 example configs; devkit now resolves through
standard node_modules (the MF patch stays — module-federation isn't
migrated yet).
- **`cleanup(devkit)` typedoc** — drops dead path mappings + redundant
include manipulation in
`astro-docs/src/plugins/utils/typedoc/typedoc.ts` (verified docs build
is byte-identical with/without the removed config).
- **`cleanup(devkit)` eslint ignores** — drops `'**/*.d.ts'` from
`packages/devkit/eslint.config.mjs` since `.d.ts` files only emit to
`dist/` (already ignored).
- **`fix(angular)` eslint quote** — quote-agnostic regex in
`e2e/angular/src/projects-linting.test.ts` so the test still disables
`prefer-standalone` after the angular-eslint generator switched to
double quotes (latent bug surfaced by CI).
- **`fix(testing)` jest migration** — removes a stray unused
`@nx/devkit/internal` import.
- **e2e test fallout** — `e2e/{angular,next}/src/*.test.ts` lose access
to `@nx/devkit/src/utils/string-utils` (e2e tests can't use
`/internal`); inline equivalents using public `names()` API.
`e2e/nx-build/src/nx-build.test.ts` updates the expected output path.

## Local verification

- `pnpm nx run-many -t test,build,lint -p devkit` ✓
- `pnpm nx run astro-docs:build` ✓ — devkit reference pages still
generate (148 markdown files; identical to a build with the path
mappings re-added as a control)
- `pnpm nx run-many -t build -p
examples-angular-rspack-csr-css,examples-angular-rspack-ssr-css,examples-angular-rspack-zoneless-csr-css,examples-angular-rspack-mf-host,examples-angular-rspack-mf-remote
--skip-nx-cache` ✓ — examples build without the devkit patch

## Known follow-up (not in this PR)

- `scripts/nx-release.ts` still has `hackFixForDevkitPeerDependencies()`
(a band-aid from #32406 that re-adds `<=` to devkit's `nx` peer-dep
range after `nx release version` strips it). The proper fix is to set
`preserveMatchingDependencyRanges: true` in
`packages/devkit/project.json` and delete the hack — that needs a
release dry-run to verify, so it's queued separately.

## Related Issue(s)

Follow-up to #34111.

---------

Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
This commit is contained in:
Jason Jean
2026-05-01 22:42:16 -04:00
committed by GitHub
parent c4ca481574
commit 59e2e51a42
307 changed files with 908 additions and 606 deletions
@@ -0,0 +1,278 @@
---
name: dist-build-migration
description: Migrate an Nx package to build to a local dist/ directory with nodenext module resolution, exports map, and @nx/nx-source condition.
allowed-tools: Bash, Read, Glob, Grep, Agent, Edit, Write
---
# Migrate Package to Local Dist Build
You are migrating an Nx monorepo package from building to `../../dist/packages/<name>` to building locally to `packages/<name>/dist/`. This matches the pattern already used by `nx` and `devkit`.
## Argument
The user provides a package name (e.g., `js`, `webpack`, `angular`). The package lives at `packages/<name>/`.
## Steps
### 1. Read current state
Read these files for the target package:
- `packages/<name>/package.json`
- `packages/<name>/project.json`
- `packages/<name>/tsconfig.lib.json`
- `packages/<name>/tsconfig.spec.json` (if exists)
- `packages/<name>/.eslintrc.json` (if exists)
- `packages/<name>/assets.json` (if exists)
- `packages/<name>/.npmignore` (if exists)
- `packages/<name>/.gitignore` (if exists)
Also read the reference implementations:
- `packages/devkit/tsconfig.lib.json`
- `packages/devkit/package.json`
- `packages/devkit/project.json`
- `packages/devkit/.npmignore`
Run `pnpm nx show target <name>:build-base` to see the inferred build target.
Run `pnpm nx show target <name>:build` to see the full build target.
### 2. Identify entry points
Look at the package's root `.ts` files and any existing `exports` field. Common entry points:
- `index.ts` (main)
- `testing.ts`
- `internal.ts`
- `ngcli-adapter.ts`
- Any other `.ts` files at the package root that re-export from `src/`
Also check for `migrations.json` and `generators.json`/`executors.json` — these need exports entries too.
### 3. Update `tsconfig.lib.json`
Transform from the old pattern to the new pattern:
**Before:**
```json
{
"compilerOptions": {
"module": "commonjs",
"outDir": "../../dist/packages/<name>",
"tsBuildInfoFile": "../../dist/packages/<name>/tsconfig.tsbuildinfo"
}
}
```
**After:**
```json
{
"compilerOptions": {
"outDir": "dist",
"rootDir": ".",
"declarationDir": "dist",
"declarationMap": false,
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"types": ["node"],
"composite": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
"exclude": ["node_modules", "dist", ...existing excludes, ".eslintrc.json"],
"include": ["*.ts", "src/**/*.ts"]
}
```
**Important**: Adjust `include` based on the package's actual structure. If the package has directories like `bin/`, `plugins/`, etc. at the root level (like `nx` does), include those too.
### 4. Update `tsconfig.spec.json` (if exists)
Change `outDir` from `../../dist/packages/<name>/spec` to `dist/spec`.
### 5. Update `package.json`
Key changes:
- Add `"type": "commonjs"` near the top (after `private`)
- Change `"main"` to `"./dist/index.js"`
- Change `"types"` to `"./dist/index.d.ts"`
- Add `"typesVersions"` for backwards compatibility with `moduleResolution: "node"` consumers
- Add `"exports"` map with entries for each entry point
Each export entry follows this pattern:
```json
"./entry-name": {
"@nx/nx-source": "./entry-name.ts",
"types": "./entry-name.d.ts",
"default": "./dist/entry-name.js"
}
```
The main entry (`.`) uses `./index.ts`, `./index.d.ts`, `./dist/index.js`.
Always include:
```json
"./package.json": "./package.json"
```
Include `"./migrations.json": "./migrations.json"` if the package has migrations.
**Note**: The `@nx/nx-source` condition is a custom condition used for source-level resolution within the workspace (so other packages import from source, not dist).
Add a `typesVersions` field for consumers using `moduleResolution: "node"` (which doesn't read `exports`):
```json
"typesVersions": {
"*": {
"testing": ["dist/testing.d.ts"],
"ngcli-adapter": ["dist/ngcli-adapter.d.ts"]
}
}
```
Add an entry for each subpath export (excluding `.`, `./package.json`, and `./migrations.json`).
### 6. Update `project.json`
Add these sections:
```json
{
"release": {
"version": {
"generator": "@nx/js:release-version",
"preserveLocalDependencyProtocols": true,
"manifestRootsToUpdate": ["packages/{projectName}"]
}
},
"targets": {
"nx-release-publish": {
"options": {
"packageRoot": "packages/{projectName}"
}
},
"build-base": {
"outputs": [
"{projectRoot}/dist/**/*.{js,cjs,mjs,d.ts}",
"{projectRoot}/*.d.ts",
"{projectRoot}/src/**/*.d.ts"
]
}
}
}
```
Update the existing `build` target's `outputs` if they reference `{workspaceRoot}/dist/packages/<name>` — they should now reference `{projectRoot}/dist/`.
Also update `dependsOn` in the `build` target: replace `"^build"` with `"^build"` if it isn't already, and make sure `"build-base"` is listed.
### 7. Update `.eslintrc.json`
Add `"dist"` and `"*.d.ts"` to `ignorePatterns`:
```json
"ignorePatterns": ["!**/*", "node_modules", "dist", "*.d.ts"]
```
### 8. Update `assets.json` (if exists)
Change `outDir` from `"dist/packages/<name>"` to `"packages/<name>/dist"`.
### 9. Add `files` field to `package.json`
Instead of using `.npmignore`, add a `"files"` field to `package.json` (matching the `nx` package pattern). Remove `.npmignore` if it exists.
```json
"files": [
"dist",
"!dist/tsconfig.tsbuildinfo",
"migrations.json"
]
```
Adjust based on the package's needs:
- Add `"executors.json"` and/or `"generators.json"` if the package has them
- Add any other non-TS files that need to be published
- npm always includes `package.json` and `README.md` automatically — no need to list them
### 10. Rename README.md and update build command
If the package has a `README.md` at its root and uses the `copy-readme.js` script in its build target:
1. Rename `README.md` to `readme-template.md` (`git mv`)
2. Update the build command to pass explicit paths:
```
node ./scripts/copy-readme.js <name> packages/<name>/readme-template.md packages/<name>/README.md
```
3. Update the build target `outputs` to `["{projectRoot}/README.md"]`
The script's default behavior reads `packages/<name>/README.md` and writes to `dist/packages/<name>/README.md` — both wrong for the new layout. Passing explicit args fixes both.
### 11. Update root `.gitignore`
Add two entries to the workspace root `.gitignore`:
1. Under the section that lists generated README files (look for `packages/nx/README.md`), add:
```
packages/<name>/README.md
```
2. Under the section that lists generated `.d.ts` files (look for `packages/nx/**/*.d.ts`), add:
```
packages/<name>/**/*.d.ts
```
These are build outputs that shouldn't be committed.
### 12. Update docs generation paths
Check `astro-docs/src/plugins/utils/` for any code that references `.d.ts` files from the package. The docs generation reads `.d.ts` entry points to build API reference pages. Paths that previously pointed to `dist/packages/<name>/foo.d.ts` (workspace root dist) or `packages/<name>/foo.d.ts` (package root) now need to point to `packages/<name>/dist/foo.d.ts`.
For example, `devkit-generation.ts` had to be updated to look for `packages/devkit/dist/index.d.ts` instead of `packages/devkit/index.d.ts`.
### 13. Update `scripts/nx-release.ts`
If the package has special release handling in `scripts/nx-release.ts` (like devkit's `hackFixForDevkitPeerDependencies`), update any paths from `./dist/packages/<name>/` to `./packages/<name>/`.
### 14. Update imports across the workspace
Search for imports from `@nx/<name>/src/` across all other packages. These internal imports need to be updated:
- If the imported thing is re-exported through a public entry point (index.ts, internal.ts, etc.), update the import to use that entry point
- If not, consider adding it to `internal.ts` or the appropriate entry point
Use: `grep -r "from '@nx/<name>/src/" packages/ --include="*.ts" -l` to find affected files.
Also check for imports in:
- `e2e/` tests
- `scripts/`
- `tools/workspace-plugin/`
- `astro-docs/`
- `examples/`
### 15. Verify
Run:
```bash
pnpm nx run-many -t test,build,lint -p <name>
```
Then:
```bash
pnpm nx affected -t build,test,lint
```
### Summary of the pattern
The core idea is simple: instead of building to a shared `dist/packages/<name>/` at the workspace root, each package builds to its own `packages/<name>/dist/`. The `exports` map with `@nx/nx-source` condition lets workspace packages resolve to `.ts` source files during development, while external consumers get the built `.js` from `dist/`. This is like giving each package its own "output mailbox" instead of sharing one big mailbox.
+1
View File
@@ -133,6 +133,7 @@ packages/angular-rspack-compiler/README.md
packages/dotnet/README.md
packages/maven/README.md
packages/nx/README.md
packages/devkit/README.md
test-output
test-results
@@ -24,9 +24,9 @@ export async function loadDevkitPackage(
// generate main @nx/devkit docs
const devkitEntryPoint = join(
workspaceRoot,
'dist',
'packages',
'devkit',
'dist',
'index.d.ts'
);
if (existsSync(devkitEntryPoint)) {
@@ -47,9 +47,9 @@ export async function loadDevkitPackage(
// generate ngcli docs in same dir
const ngcliEntryPoint = join(
workspaceRoot,
'dist',
'packages',
'devkit',
'dist',
'ngcli-adapter.d.ts'
);
if (existsSync(ngcliEntryPoint)) {
@@ -75,18 +75,12 @@ export function setupTypeDoc(logger: LoaderContext['logger']) {
join(projectRoot, 'node_modules', '@types'),
];
// This ensures that nx and @nx/<plugin> modules resolve to `dist` rather than what's installed in node_modules.
// TODO(jack,caleb): If we move outDir from `dist/packages/nx` to `packages/nx/dist` like standard TS solution setup,
// then this isn't needed anymore since we should have devDependencies that resolve to local
// `node_modules` not the root one.
tsconfigObj.compilerOptions.baseUrl = workspaceRoot;
tsconfigObj.compilerOptions.paths = {
'nx/*': ['dist/packages/nx/*', 'packages/nx/src/*'],
'@nx/*': ['dist/packages/*', 'packages/*/src/*'],
};
// TypeDoc requires its entry points to be referenced by `include` or
// `files` in the tsconfig. Point at devkit's compiled .d.ts files.
tsconfigObj.include = [join(devkitPath, 'dist', '**', '*.d.ts')];
tsconfigObj.exclude = [
...(tsconfigObj.exclude || []),
...(tsconfigObj.exclude || []).filter((e: string) => e !== 'dist'),
'**/*.spec.ts',
'**/*.test.ts',
'**/test/**',
@@ -95,16 +89,6 @@ export function setupTypeDoc(logger: LoaderContext['logger']) {
'node_modules/@types/jest/**',
];
// The tsconfig now lives in tempDir but it operates on devkit's compiled
// dist (entry point is dist/packages/devkit/index.d.ts). Resolve include
// patterns to absolute paths anchored at the dist directory so TypeDoc
// picks up the .d.ts files instead of looking for sources next to the temp
// tsconfig.
const distDevkitDir = join(workspaceRoot, 'dist', 'packages', 'devkit');
tsconfigObj.include = (tsconfigObj.include || ['**/*.ts']).map(
(pattern: string) => join(distDevkitDir, pattern)
);
writeFileSync(generatedTsconfigPath, JSON.stringify(tsconfigObj, null, 2));
rmSync(outDir, { recursive: true, force: true });
+2 -1
View File
@@ -7,7 +7,8 @@ import {
uniq,
updateFile,
} from '@nx/e2e-utils';
import { classify } from '@nx/devkit/src/utils/string-utils';
import { names } from '@nx/devkit';
const classify = (s: string) => names(s).className;
describe('Move Angular Project', () => {
let proj: string;
+11 -8
View File
@@ -23,14 +23,17 @@ describe('Angular Projects - Linting', () => {
it('should lint correctly with eslint and handle external HTML files and inline templates', async () => {
const { app1, lib1 } = setup;
// disable the prefer-standalone rule for app1 which is not standalone
let app1EslintConfig = readFile(`${app1}/eslint.config.mjs`);
app1EslintConfig = app1EslintConfig.replace(
`'@angular-eslint/directive-selector': [`,
`'@angular-eslint/prefer-standalone': 'off',
'@angular-eslint/directive-selector': [`
);
updateFile(`${app1}/eslint.config.mjs`, app1EslintConfig);
// disable the prefer-standalone rule for app1 and lib1 which are not standalone.
// Use a regex so we match regardless of whether the generated config uses
// single or double quotes around the rule name.
for (const project of [app1, lib1]) {
let eslintConfig = readFile(`${project}/eslint.config.mjs`);
eslintConfig = eslintConfig.replace(
/(['"])@angular-eslint\/directive-selector\1:\s*\[/,
`"@angular-eslint/prefer-standalone": "off",\n "@angular-eslint/directive-selector": [`
);
updateFile(`${project}/eslint.config.mjs`, eslintConfig);
}
// check apps and lib pass linting for initial generated code
runCLI(`run-many --target lint --projects=${app1},${lib1} --parallel`);
+4 -5
View File
@@ -1,5 +1,4 @@
import { capitalize } from '@nx/devkit/src/utils/string-utils';
import { joinPathFragments } from '@nx/devkit';
import { joinPathFragments, names } from '@nx/devkit';
import {
checkFilesExist,
cleanupProject,
@@ -199,9 +198,9 @@ describe('@nx/next (legacy)', () => {
import dynamic from 'next/dynamic';
const TestComponent = dynamic(
() => import('@${proj}/${nextLib}').then(d => d.${capitalize(
nextLib
)})
() => import('@${proj}/${nextLib}').then(d => d.${
names(nextLib).className
})
);
${content.replace(
`</h2>`,
+1 -1
View File
@@ -15,7 +15,7 @@ const packagesToVerify = [
{
name: 'devkit',
sourceFile: 'index.ts',
outputFile: 'dist/packages/devkit/index.js',
outputFile: 'packages/devkit/dist/index.js',
},
{
name: 'js',
@@ -20,7 +20,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json"
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -32,7 +27,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -33,7 +33,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json",
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -101,7 +96,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -33,7 +33,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json",
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -101,7 +96,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -32,7 +32,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json"
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -41,7 +36,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -23,7 +23,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json",
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -50,7 +45,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -21,7 +21,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json"
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -39,7 +34,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -1,20 +1,12 @@
/* eslint-disable @nx/enforce-module-boundaries */
const {
patchDevkitRequestPath,
patchModuleFederationRequestPath,
} = require('../../patch-devkit-request-path');
/* eslint-enable @nx/enforce-module-boundaries */
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/module-federation`.
// TODO(colum): Remove this once @nx/module-federation builds to local dist.
/* eslint-disable @nx/enforce-module-boundaries */
const {
patchDevkitRequestPath,
patchModuleFederationRequestPath,
} = require('../../patch-devkit-request-path');
/* eslint-enable @nx/enforce-module-boundaries */
const cleanupDevkitPatch = patchDevkitRequestPath();
const cleanupModuleFederationPatch = patchModuleFederationRequestPath();
const {
NxModuleFederationPlugin,
@@ -83,7 +75,6 @@ module.exports = () => {
},
}
);
cleanupDevkitPatch();
cleanupModuleFederationPatch();
return config;
}
@@ -1,14 +1,12 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/module-federation`.
// TODO(colum): Remove this once @nx/module-federation builds to local dist.
/* eslint-disable @nx/enforce-module-boundaries */
const {
patchDevkitRequestPath,
patchModuleFederationRequestPath,
} = require('../../patch-devkit-request-path');
/* eslint-enable @nx/enforce-module-boundaries */
const cleanupDevkitPatch = patchDevkitRequestPath();
const cleanupModuleFederationPatch = patchModuleFederationRequestPath();
const {
NxModuleFederationPlugin,
@@ -77,7 +75,6 @@ module.exports = () => {
},
}
);
cleanupDevkitPatch();
cleanupModuleFederationPatch();
return config;
}
-27
View File
@@ -2,33 +2,6 @@ const Module = require('module');
const path = require('path');
module.exports = {
patchDevkitRequestPath() {
const originalResolveFilename = Module._resolveFilename;
Module._resolveFilename = function (request, parent, isMain) {
if (request === '@nx/devkit') {
const possiblePaths = [
path.resolve(__dirname, '../../dist/packages/devkit'),
];
for (const tryPath of possiblePaths) {
try {
return originalResolveFilename.call(this, tryPath, parent, isMain);
} catch (err) {
// Continue to next path
}
}
// If none work, fall back to original error
console.error(`Could not find @nx/devkit in any of the fallback paths`);
}
return originalResolveFilename.call(this, request, parent, isMain);
};
return () => {
Module._resolveFilename = originalResolveFilename;
};
},
// Required to use the built module federation package rather than installed
patchModuleFederationRequestPath() {
const originalResolveFilename = Module._resolveFilename;
@@ -20,7 +20,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json"
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -32,7 +27,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -20,7 +20,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json"
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -32,7 +27,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -33,7 +33,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json",
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -101,7 +96,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -32,7 +32,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json"
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -41,7 +36,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -20,7 +20,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json"
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -32,7 +27,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -20,7 +20,6 @@
"dependentTasksOutputFiles": "**/*.js",
"transitive": true
},
"{workspaceRoot}/examples/angular-rspack/patch-devkit-request-path.js",
"{workspaceRoot}/examples/angular-rspack/tsconfig.base.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/tsconfig.json"
@@ -1,10 +1,5 @@
module.exports = () => {
if (global.NX_GRAPH_CREATION === undefined) {
// This is needed to ensure that the `@nx/angular-rspack` package can find the build artefact for `@nx/devkit`
// TODO(colum): Remove this once packages in Nx are built to local dist
// eslint-disable-next-line @nx/enforce-module-boundaries
const { patchDevkitRequestPath } = require('../patch-devkit-request-path');
const cleanupPatch = patchDevkitRequestPath();
const { createConfig } = require('@nx/angular-rspack');
const config = createConfig(
{
@@ -32,7 +27,6 @@ module.exports = () => {
},
}
);
cleanupPatch();
return config;
}
return {};
@@ -1,3 +1,9 @@
import {
eachValueFrom,
combineAsyncIterables,
createAsyncIterable,
mapAsyncIterable,
} from '@nx/devkit/internal';
import {
type ExecutorContext,
logger,
@@ -5,12 +11,6 @@ import {
} from '@nx/devkit';
import { type Schema } from './schema';
import { normalizeOptions, startRemotes } from './lib';
import { eachValueFrom } from '@nx/devkit/src/utils/rxjs-for-await';
import {
combineAsyncIterables,
createAsyncIterable,
mapAsyncIterable,
} from '@nx/devkit/src/utils/async-iterable';
import { startRemoteIterators } from '@nx/module-federation/src/executors/utils';
import { waitForPortOpen } from '@nx/web/src/utils/wait-for-port-open';
import fileServerExecutor from '@nx/web/src/executors/file-server/file-server.impl';
@@ -3,8 +3,8 @@ import {
combineAsyncIterables,
createAsyncIterable,
mapAsyncIterable,
} from '@nx/devkit/src/utils/async-iterable';
import { eachValueFrom } from '@nx/devkit/src/utils/rxjs-for-await';
eachValueFrom,
} from '@nx/devkit/internal';
import { startRemoteIterators } from '@nx/module-federation/src/executors/utils';
import { waitForPortOpen } from '@nx/web/src/utils/wait-for-port-open';
import { existsSync } from 'fs';
@@ -1,5 +1,5 @@
import type { ExecutorContext } from '@nx/devkit';
import { eachValueFrom } from '@nx/devkit/src/utils/rxjs-for-await';
import { eachValueFrom } from '@nx/devkit/internal';
import {
calculateProjectBuildableDependencies,
createTmpTsConfig,
@@ -1,3 +1,4 @@
import { camelize, dasherize } from '@nx/devkit/internal';
import {
formatFiles,
joinPathFragments,
@@ -5,7 +6,6 @@ import {
type GeneratorCallback,
type Tree,
} from '@nx/devkit';
import { camelize, dasherize } from '@nx/devkit/src/utils/string-utils';
import { lintProjectGenerator } from '@nx/eslint';
import {
javaScriptOverride,
@@ -1,3 +1,4 @@
import { logShowProjectCommand } from '@nx/devkit/internal';
import {
addDependenciesToPackageJson,
formatFiles,
@@ -10,7 +11,6 @@ import {
Tree,
updateNxJson,
} from '@nx/devkit';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';
import { initGenerator as jsInitGenerator } from '@nx/js';
import { convertToRspack } from '../convert-to-rspack/convert-to-rspack';
import { angularInitGenerator } from '../init/init';
@@ -1,4 +1,5 @@
import { Tree } from '@nx/devkit';
import { E2EWebServerDetails } from '@nx/devkit/internal';
import {
addProjectConfiguration,
ensurePackage,
@@ -8,7 +9,6 @@ import {
} from '@nx/devkit';
import { nxVersion } from '../../../utils/versions';
import type { NormalizedSchema } from './normalized-schema';
import { E2EWebServerDetails } from '@nx/devkit/src/generators/e2e-web-server-info-utils';
export async function addE2e(tree: Tree, options: NormalizedSchema) {
// since e2e are separate projects, default to adding plugins
@@ -1,10 +1,10 @@
import { addBuildTargetDefaults } from '@nx/devkit/internal';
import {
addProjectConfiguration,
joinPathFragments,
type ProjectConfiguration,
type Tree,
} from '@nx/devkit';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
import type { AngularProjectConfiguration } from '../../../utils/types';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
import type { NormalizedSchema } from './normalized-schema';
@@ -2,7 +2,7 @@ import { joinPathFragments, readNxJson, type Tree } from '@nx/devkit';
import {
determineProjectNameAndRootOptions,
ensureRootProjectName,
} from '@nx/devkit/src/generators/project-name-and-root-utils';
} from '@nx/devkit/internal';
import { E2eTestRunner, UnitTestRunner } from '../../../utils/test-runners';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
import type { Schema } from '../schema';
@@ -1,6 +1,6 @@
import type { Tree } from '@nx/devkit';
import { names, readProjectConfiguration } from '@nx/devkit';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/internal';
import type { AngularProjectConfiguration } from '../../../utils/types';
import { buildSelector, validateHtmlSelector } from '../../utils/selector';
import { validateClassName } from '../../utils/validations';
@@ -1,3 +1,4 @@
import { forEachExecutorOptions, getNamedInputs } from '@nx/devkit/internal';
import {
addDependenciesToPackageJson,
ensurePackage,
@@ -16,8 +17,6 @@ import {
type TargetConfiguration,
type Tree,
} from '@nx/devkit';
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
import { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';
import type { RspackPluginOptions } from '@nx/rspack/plugin';
import { prompt } from 'enquirer';
import { relative, resolve } from 'path';
@@ -1,5 +1,5 @@
import { logger, Tree } from '@nx/devkit';
import { loadConfigFile } from '@nx/devkit/src/utils/config-utils';
import { loadConfigFile } from '@nx/devkit/internal';
import { join, relative } from 'path';
import { ast, query } from '@phenomnomnominal/tsquery';
@@ -1,6 +1,6 @@
import type { Tree } from '@nx/devkit';
import { names, readProjectConfiguration } from '@nx/devkit';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/internal';
import type { AngularProjectConfiguration } from '../../../utils/types';
import { buildSelector, validateHtmlSelector } from '../../utils/selector';
import { validateClassName } from '../../utils/validations';
@@ -1,5 +1,5 @@
import type { GeneratorCallback, Tree } from '@nx/devkit';
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
import { determineProjectNameAndRootOptions } from '@nx/devkit/internal';
import { E2eTestRunner, UnitTestRunner } from '../../../utils/test-runners';
import remoteGenerator from '../../remote/remote';
import { type Schema } from '../schema';
+4 -4
View File
@@ -1,3 +1,7 @@
import {
determineProjectNameAndRootOptions,
ensureRootProjectName,
} from '@nx/devkit/internal';
import {
formatFiles,
getProjects,
@@ -7,10 +11,6 @@ import {
Tree,
updateProjectConfiguration,
} from '@nx/devkit';
import {
determineProjectNameAndRootOptions,
ensureRootProjectName,
} from '@nx/devkit/src/generators/project-name-and-root-utils';
import { isValidVariable } from '@nx/js';
import { E2eTestRunner } from '../../utils/test-runners';
import applicationGenerator from '../application/application';
+1 -1
View File
@@ -1,3 +1,4 @@
import { addPlugin } from '@nx/devkit/internal';
import {
addDependenciesToPackageJson,
createProjectGraphAsync,
@@ -9,7 +10,6 @@ import {
readNxJson,
type Tree,
} from '@nx/devkit';
import { addPlugin } from '@nx/devkit/src/utils/add-plugin';
import { createNodesV2 } from '../../plugins/plugin';
import { assertNotUsingTsSolutionSetup } from '../utils/validations';
import {
@@ -1,10 +1,10 @@
import type { Tree } from '@nx/devkit';
import { addBuildTargetDefaults } from '@nx/devkit/internal';
import {
addProjectConfiguration,
joinPathFragments,
readJson,
} from '@nx/devkit';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
import { addReleaseConfigForNonTsSolution } from '@nx/js/src/generators/library/utils/add-release-config';
import type { AngularProjectConfiguration } from '../../../utils/types';
import type { NormalizedSchema } from './normalized-schema';
@@ -2,7 +2,7 @@ import { names, type Tree } from '@nx/devkit';
import {
determineProjectNameAndRootOptions,
ensureRootProjectName,
} from '@nx/devkit/src/generators/project-name-and-root-utils';
} from '@nx/devkit/internal';
import { UnitTestRunner } from '../../../utils/test-runners';
import {
getComponentType,
@@ -1,3 +1,4 @@
import { logShowProjectCommand } from '@nx/devkit/internal';
import {
addDependenciesToPackageJson,
formatFiles,
@@ -7,7 +8,6 @@ import {
runTasksInSerial,
Tree,
} from '@nx/devkit';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';
import { initGenerator as jsInitGenerator } from '@nx/js';
import { releaseTasks } from '@nx/js/src/generators/library/utils/add-release-config';
import init from '../../generators/init/init';
@@ -1,6 +1,6 @@
import type { Tree } from '@nx/devkit';
import { joinPathFragments, names, readJson } from '@nx/devkit';
import { checkAndCleanWithSemver } from '@nx/devkit/src/utils/semver';
import { checkAndCleanWithSemver } from '@nx/devkit/internal';
import { dirname } from 'path';
import { major } from 'semver';
import { rxjsVersion as defaultRxjsVersion } from '../../../utils/versions';
@@ -1,11 +1,11 @@
import type { Tree } from '@nx/devkit';
import { checkAndCleanWithSemver } from '@nx/devkit/internal';
import {
getDependencyVersionFromPackageJson,
joinPathFragments,
names,
readProjectConfiguration,
} from '@nx/devkit';
import { checkAndCleanWithSemver } from '@nx/devkit/src/utils/semver';
import { rxjsVersion as defaultRxjsVersion } from '../../../utils/versions';
import type { Schema } from '../schema';
import { isNgStandaloneApp } from '../../../utils/nx-devkit/ast-utils';
@@ -1,5 +1,5 @@
import { names, readJson, Tree } from '@nx/devkit';
import { checkAndCleanWithSemver } from '@nx/devkit/src/utils/semver';
import { checkAndCleanWithSemver } from '@nx/devkit/internal';
import { dirname } from 'path';
import { major } from 'semver';
import { rxjsVersion as defaultRxjsVersion } from '../../../utils/versions';
@@ -1,6 +1,6 @@
import type { Tree } from '@nx/devkit';
import { names } from '@nx/devkit';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/internal';
import { validateClassName } from '../../utils/validations';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
import type { NormalizedSchema, Schema } from '../schema';
@@ -1,3 +1,7 @@
import {
determineProjectNameAndRootOptions,
ensureRootProjectName,
} from '@nx/devkit/internal';
import {
addDependenciesToPackageJson,
formatFiles,
@@ -8,10 +12,6 @@ import {
Tree,
updateProjectConfiguration,
} from '@nx/devkit';
import {
determineProjectNameAndRootOptions,
ensureRootProjectName,
} from '@nx/devkit/src/generators/project-name-and-root-utils';
import { swcHelpersVersion } from '@nx/js/src/utils/versions';
import { E2eTestRunner } from '../../utils/test-runners';
import { applicationGenerator } from '../application/application';
@@ -1,6 +1,6 @@
import type { Tree } from '@nx/devkit';
import { joinPathFragments, names } from '@nx/devkit';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/internal';
import { getModuleTypeSeparator } from '../../utils/artifact-types';
import { validateClassName } from '../../utils/validations';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
@@ -1,6 +1,6 @@
import type { Tree } from '@nx/devkit';
import { joinPathFragments, names } from '@nx/devkit';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/internal';
import { getModuleTypeSeparator } from '../../utils/artifact-types';
import { validateClassName } from '../../utils/validations';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
@@ -1,6 +1,6 @@
import type { Tree } from '@nx/devkit';
import { joinPathFragments, names } from '@nx/devkit';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/internal';
import { getModuleTypeSeparator } from '../../utils/artifact-types';
import { validateClassName } from '../../utils/validations';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
@@ -1,11 +1,11 @@
import type { Tree } from '@nx/devkit';
import { addBuildTargetDefaults } from '@nx/devkit/internal';
import type { Schema } from '../schema';
import {
readProjectConfiguration,
updateProjectConfiguration,
} from '@nx/devkit';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
export function changeBuildTarget(host: Tree, options: Schema) {
const appConfig = readProjectConfiguration(host, options.appName);
@@ -1,9 +1,9 @@
import { promptWhenInteractive } from '@nx/devkit/internal';
import {
joinPathFragments,
readProjectConfiguration,
type Tree,
} from '@nx/devkit';
import { promptWhenInteractive } from '@nx/devkit/src/generators/prompt';
import { isNgStandaloneApp } from '../../../utils/nx-devkit/ast-utils';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
import type { NormalizedGeneratorOptions, Schema } from '../schema';
@@ -1,3 +1,4 @@
import { forEachExecutorOptions } from '@nx/devkit/internal';
import {
formatFiles,
readNxJson,
@@ -6,7 +7,6 @@ import {
updateProjectConfiguration,
type Tree,
} from '@nx/devkit';
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
export const executors = [
'@angular-devkit/build-angular:dev-server',
@@ -1,5 +1,5 @@
import { type Tree, formatFiles, visitNotIgnoredFiles } from '@nx/devkit';
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
import { forEachExecutorOptions } from '@nx/devkit/internal';
import picomatch = require('picomatch');
import { ast, query } from '@phenomnomnominal/tsquery';
@@ -1,5 +1,5 @@
import { formatFiles, readNxJson, type Tree, updateNxJson } from '@nx/devkit';
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
import { forEachExecutorOptions } from '@nx/devkit/internal';
import type { WebpackExecutorOptions } from '@nx/webpack';
export default async function (tree: Tree) {
@@ -1,3 +1,4 @@
import { forEachExecutorOptions } from '@nx/devkit/internal';
import {
type Tree,
formatFiles,
@@ -5,7 +6,6 @@ import {
visitNotIgnoredFiles,
addDependenciesToPackageJson,
} from '@nx/devkit';
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
import { ast, query } from '@phenomnomnominal/tsquery';
import { nxVersion } from '../../utils/versions';
@@ -1,3 +1,4 @@
import { forEachExecutorOptions } from '@nx/devkit/internal';
import {
formatFiles,
readNxJson,
@@ -6,7 +7,6 @@ import {
updateProjectConfiguration,
type Tree,
} from '@nx/devkit';
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
export const executors = ['@nx/angular:ng-packagr-lite', '@nx/angular:package'];
@@ -1,9 +1,9 @@
import { forEachExecutorOptions } from '@nx/devkit/internal';
import {
type Tree,
readProjectConfiguration,
addDependenciesToPackageJson,
} from '@nx/devkit';
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
import { nxVersion } from '../../utils/versions';
export default async function ensureMfPackage(tree: Tree) {
+4 -2
View File
@@ -1,3 +1,7 @@
import {
calculateHashForCreateNodes,
getNamedInputs,
} from '@nx/devkit/internal';
import {
type CreateNodesContextV2,
createNodesFromFiles,
@@ -11,8 +15,6 @@ import {
type TargetConfiguration,
writeJsonFile,
} from '@nx/devkit';
import { calculateHashForCreateNodes } from '@nx/devkit/src/utils/calculate-hash-for-create-nodes';
import { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';
import { getLockFileName } from '@nx/js';
import { existsSync, readdirSync, statSync } from 'node:fs';
import { dirname, isAbsolute, join, relative } from 'node:path';
@@ -1,5 +1,5 @@
import type { Tree } from '@nx/devkit';
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
import { forEachExecutorOptions } from '@nx/devkit/internal';
function _getMfProjects(
tree: Tree,
@@ -1,3 +1,4 @@
import { resolveImportPath, promptWhenInteractive } from '@nx/devkit/internal';
import {
addDependenciesToPackageJson,
createProjectGraphAsync,
@@ -19,8 +20,6 @@ import {
updateProjectConfiguration,
writeJson,
} from '@nx/devkit';
import { resolveImportPath } from '@nx/devkit/src/generators/project-name-and-root-utils';
import { promptWhenInteractive } from '@nx/devkit/src/generators/prompt';
import { Linter, LinterType } from '@nx/eslint';
import {
getRelativePathToRootTsConfig,
@@ -1,17 +1,15 @@
import {
migrateProjectExecutorsToPlugin,
NoTargetsToMigrateError,
processTargetOutputs,
toProjectRelativePath,
} from '@nx/devkit/internal';
import {
createProjectGraphAsync,
formatFiles,
type TargetConfiguration,
type Tree,
} from '@nx/devkit';
import {
migrateProjectExecutorsToPlugin,
NoTargetsToMigrateError,
} from '@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator';
import {
processTargetOutputs,
toProjectRelativePath,
} from '@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils';
import { createNodesV2, type CypressPluginOptions } from '../../plugins/plugin';
import { addDevServerTargetToConfig } from './lib/add-dev-server-target-to-config';
import { addExcludeSpecPattern } from './lib/add-exclude-spec-pattern';
+1 -1
View File
@@ -1,3 +1,4 @@
import { addPlugin as _addPlugin } from '@nx/devkit/internal';
import {
addDependenciesToPackageJson,
createProjectGraphAsync,
@@ -10,7 +11,6 @@ import {
Tree,
updateNxJson,
} from '@nx/devkit';
import { addPlugin as _addPlugin } from '@nx/devkit/src/utils/add-plugin';
import { createNodesV2 } from '../../plugins/plugin';
import {
cypressVersion,
@@ -1,3 +1,4 @@
import { forEachExecutorOptions } from '@nx/devkit/internal';
import {
formatFiles,
installPackagesTask,
@@ -10,7 +11,6 @@ import {
updateJson,
updateProjectConfiguration,
} from '@nx/devkit';
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
import { CypressExecutorOptions } from '../../executors/cypress/cypress.impl';
import {
assertMinimumCypressVersion,
@@ -1,5 +1,5 @@
import { formatFiles, workspaceRoot, type Tree } from '@nx/devkit';
import { loadConfigFile } from '@nx/devkit/src/utils/config-utils';
import { loadConfigFile } from '@nx/devkit/internal';
import { ensureTypescript } from '@nx/js/src/utils/typescript/ensure-typescript';
import { ast, query } from '@phenomnomnominal/tsquery';
import { join } from 'node:path';
@@ -1,3 +1,4 @@
import { forEachExecutorOptions } from '@nx/devkit/internal';
import {
formatFiles,
type ProjectConfiguration,
@@ -8,7 +9,6 @@ import {
updateNxJson,
updateProjectConfiguration,
} from '@nx/devkit';
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';
import type { CypressExecutorOptions } from '../../executors/cypress/cypress.impl';
const EXECUTOR_TO_MIGRATE = '@nx/cypress:cypress';
+5 -3
View File
@@ -1,3 +1,8 @@
import {
calculateHashForCreateNodes,
loadConfigFile,
getNamedInputs,
} from '@nx/devkit/internal';
import {
type CreateNodesContextV2,
createNodesFromFiles,
@@ -10,9 +15,6 @@ import {
type ProjectConfiguration,
type TargetConfiguration,
} from '@nx/devkit';
import { calculateHashForCreateNodes } from '@nx/devkit/src/utils/calculate-hash-for-create-nodes';
import { loadConfigFile } from '@nx/devkit/src/utils/config-utils';
import { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';
import { getLockFileName } from '@nx/js';
import { readdirSync } from 'fs';
import { hashObject } from 'nx/src/devkit-internals';
@@ -1,5 +1,5 @@
import { names, readNxJson, readProjectConfiguration, Tree } from '@nx/devkit';
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
import { determineProjectNameAndRootOptions } from '@nx/devkit/internal';
import { Schema } from '../schema';
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
@@ -1,3 +1,8 @@
import {
AggregatedLog,
migrateProjectExecutorsToPlugin,
NoTargetsToMigrateError,
} from '@nx/devkit/internal';
import {
createProjectGraphAsync,
formatFiles,
@@ -5,11 +10,6 @@ import {
type Tree,
updateNxJson,
} from '@nx/devkit';
import { AggregatedLog } from '@nx/devkit/src/generators/plugin-migrations/aggregate-log-util';
import {
migrateProjectExecutorsToPlugin,
NoTargetsToMigrateError,
} from '@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator';
import { createNodesV2 } from '../../plugins/plugin';
import { processBuildOptions } from './lib/process-build-options';
import { postTargetTransformer } from './lib/post-target-transformer';
@@ -1,6 +1,5 @@
import type { TargetConfiguration, Tree } from '@nx/devkit';
import type { AggregatedLog } from '@nx/devkit/src/generators/plugin-migrations/aggregate-log-util';
import { processTargetOutputs } from '@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils';
import { processTargetOutputs, type AggregatedLog } from '@nx/devkit/internal';
export function postTargetTransformer(
migrationLogs: AggregatedLog,
@@ -1,5 +1,5 @@
import { names, type TargetConfiguration, type Tree } from '@nx/devkit';
import type { AggregatedLog } from '@nx/devkit/src/generators/plugin-migrations/aggregate-log-util';
import type { AggregatedLog } from '@nx/devkit/internal';
export function processBuildOptions(
_tree: Tree,
@@ -1,5 +1,5 @@
import { names, type TargetConfiguration, type Tree } from '@nx/devkit';
import type { AggregatedLog } from '@nx/devkit/src/generators/plugin-migrations/aggregate-log-util';
import type { AggregatedLog } from '@nx/devkit/internal';
export function processTestOptions(
_tree: Tree,
+1 -1
View File
@@ -1,3 +1,4 @@
import { addPlugin } from '@nx/devkit/internal';
import {
addDependenciesToPackageJson,
createProjectGraphAsync,
@@ -8,7 +9,6 @@ import {
runTasksInSerial,
Tree,
} from '@nx/devkit';
import { addPlugin } from '@nx/devkit/src/utils/add-plugin';
import { createNodesV2 } from '../../plugins/plugin';
import { detoxVersion, nxVersion } from '../../utils/versions';
import { Schema } from './schema';
+4 -2
View File
@@ -1,3 +1,7 @@
import {
getNamedInputs,
calculateHashForCreateNodes,
} from '@nx/devkit/internal';
import {
CreateNodesContextV2,
createNodesFromFiles,
@@ -12,9 +16,7 @@ import {
} from '@nx/devkit';
import { dirname, join } from 'path';
import { getLockFileName } from '@nx/js';
import { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';
import { existsSync } from 'fs';
import { calculateHashForCreateNodes } from '@nx/devkit/src/utils/calculate-hash-for-create-nodes';
import { workspaceDataDirectory } from 'nx/src/utils/cache-directory';
import { hashObject } from 'nx/src/devkit-internals';
import { addBuildAndWatchDepsTargets } from '@nx/js/src/plugins/typescript/util';
+1 -1
View File
@@ -1,5 +1,5 @@
{
"outDir": "dist/packages/devkit",
"outDir": "packages/devkit/dist",
"assets": [
{
"glob": "**/files/**"
+3
View File
@@ -3,6 +3,9 @@ import * as jsoncEslintParser from 'jsonc-eslint-parser';
export default [
...baseConfig,
{
ignores: ['dist'],
},
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
+59
View File
@@ -4,3 +4,62 @@ export {
PluginCache,
safeWriteFileCache,
} from 'nx/src/devkit-internals';
// Generators
export {
determineArtifactNameAndDirectoryOptions,
getRelativeCwd,
type FileExtensionType,
} from './src/generators/artifact-name-and-directory-utils';
export {
getE2EWebServerInfo,
type E2EWebServerDetails,
} from './src/generators/e2e-web-server-info-utils';
export { forEachExecutorOptions } from './src/generators/executor-options-utils';
export { AggregatedLog } from './src/generators/plugin-migrations/aggregate-log-util';
export {
migrateProjectExecutorsToPlugin,
migrateProjectExecutorsToPluginV1,
NoTargetsToMigrateError,
type InferredTargetConfiguration,
} from './src/generators/plugin-migrations/executor-to-plugin-migrator';
export {
processTargetOutputs,
deleteMatchingProperties,
toProjectRelativePath,
} from './src/generators/plugin-migrations/plugin-migration-utils';
export {
determineProjectNameAndRootOptions,
ensureRootProjectName,
resolveImportPath,
} from './src/generators/project-name-and-root-utils';
export { promptWhenInteractive } from './src/generators/prompt';
export {
addBuildTargetDefaults,
addE2eCiTargetDefaults,
} from './src/generators/target-defaults-utils';
// Utils
export { addPlugin } from './src/utils/add-plugin';
export {
createAsyncIterable,
combineAsyncIterables,
mapAsyncIterable,
} from './src/utils/async-iterable';
export {
calculateHashForCreateNodes,
calculateHashesForCreateNodes,
} from './src/utils/calculate-hash-for-create-nodes';
export { getCatalogManager } from './src/utils/catalog';
export { loadConfigFile, clearRequireCache } from './src/utils/config-utils';
export { findPluginForConfigFile } from './src/utils/find-plugin-for-config-file';
export { getNamedInputs } from './src/utils/get-named-inputs';
export { logShowProjectCommand } from './src/utils/log-show-project-command';
export { eachValueFrom } from './src/utils/rxjs-for-await';
export { checkAndCleanWithSemver } from './src/utils/semver';
export {
camelize,
capitalize,
classify,
dasherize,
} from './src/utils/string-utils';
+54 -4
View File
@@ -2,6 +2,12 @@
"name": "@nx/devkit",
"version": "0.0.1",
"private": false,
"type": "commonjs",
"files": [
"dist",
"!dist/tsconfig.tsbuildinfo",
"migrations.json"
],
"description": "The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more. Learn more about [extending Nx by leveraging the Nx Devkit](https://nx.dev/extending-nx/intro/getting-started) on our docs.",
"repository": {
"type": "git",
@@ -19,9 +25,24 @@
"Cypress",
"CLI"
],
"main": "./index.js",
"type": "commonjs",
"types": "./index.d.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"testing": [
"dist/testing.d.ts"
],
"ngcli-adapter": [
"dist/ngcli-adapter.d.ts"
],
"internal": [
"dist/internal.d.ts"
],
"internal-testing-utils": [
"dist/internal-testing-utils.d.ts"
]
}
},
"author": "Victor Savkin",
"license": "MIT",
"bugs": {
@@ -42,12 +63,41 @@
"nx": "workspace:*"
},
"peerDependencies": {
"nx": ">= 21 <= 23 || ^22.0.0-0"
"nx": ">= 22 <= 24 || ^23.0.0-0"
},
"publishConfig": {
"access": "public"
},
"nx-migrations": {
"migrations": "./migrations.json"
},
"exports": {
".": {
"@nx/nx-source": "./index.ts",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./package.json": "./package.json",
"./migrations.json": "./migrations.json",
"./internal": {
"@nx/nx-source": "./internal.ts",
"types": "./dist/internal.d.ts",
"default": "./dist/internal.js"
},
"./internal-testing-utils": {
"@nx/nx-source": "./internal-testing-utils.ts",
"types": "./dist/internal-testing-utils.d.ts",
"default": "./dist/internal-testing-utils.js"
},
"./ngcli-adapter": {
"@nx/nx-source": "./ngcli-adapter.ts",
"types": "./dist/ngcli-adapter.d.ts",
"default": "./dist/ngcli-adapter.js"
},
"./testing": {
"@nx/nx-source": "./testing.ts",
"types": "./dist/testing.d.ts",
"default": "./dist/testing.js"
}
}
}
+21 -2
View File
@@ -3,10 +3,29 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/devkit",
"projectType": "library",
"release": {
"version": {
"generator": "@nx/js:release-version",
"preserveLocalDependencyProtocols": true,
"manifestRootsToUpdate": ["packages/{projectName}"]
}
},
"targets": {
"nx-release-publish": {
"options": {
"packageRoot": "packages/{projectName}"
}
},
"build-base": {
"outputs": [
"{projectRoot}/dist/**/*.{js,cjs,mjs,d.ts}",
"{projectRoot}/*.d.ts",
"{projectRoot}/src/**/*.d.ts"
]
},
"build": {
"outputs": ["{workspaceRoot}/dist/packages/devkit/README.md"],
"command": "node ./scripts/copy-readme.js devkit",
"outputs": ["{projectRoot}/README.md"],
"command": "node ./scripts/copy-readme.js devkit packages/devkit/readme-template.md packages/devkit/README.md",
"inputs": ["copyReadme"],
"dependsOn": ["^build", "build-base"]
}
+15 -5
View File
@@ -1,20 +1,30 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../../dist/packages/devkit",
"outDir": "dist",
"rootDir": ".",
"declarationDir": "dist",
"declarationMap": false,
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"types": ["node"],
"tsBuildInfoFile": "../../dist/packages/devkit/tsconfig.tsbuildinfo"
"composite": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"dist",
"**/*.spec.ts",
"**/*.test.ts",
"**/*_spec.ts",
"**/*_test.ts",
"internal-testing-utils.ts",
"jest.config.ts"
"jest.config.ts",
".eslintrc.json"
],
"include": ["**/*.ts", "*.json", "migrations.json"],
"include": ["*.ts", "src/**/*.ts"],
"references": [
{
"path": "../nx/tsconfig.lib.json"
+1 -1
View File
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/packages/devkit/spec",
"outDir": "dist/spec",
"module": "commonjs",
"types": ["jest", "node"],
"composite": true
+1 -1
View File
@@ -1,3 +1,4 @@
import { addPlugin } from '@nx/devkit/internal';
import {
type Tree,
type GeneratorCallback,
@@ -9,7 +10,6 @@ import {
logger,
updateNxJson,
} from '@nx/devkit';
import { addPlugin } from '@nx/devkit/src/utils/add-plugin';
import { InitGeneratorSchema } from './schema';
import { createNodesV2 } from '../../plugins/plugin';
import { nxVersion } from '../../utils/versions';
+4 -2
View File
@@ -1,3 +1,7 @@
import {
calculateHashesForCreateNodes,
getNamedInputs,
} from '@nx/devkit/internal';
import {
type CreateNodesV2,
type ProjectConfiguration,
@@ -8,12 +12,10 @@ import {
CreateNodesContextV2,
workspaceRoot,
} from '@nx/devkit';
import { calculateHashesForCreateNodes } from '@nx/devkit/src/utils/calculate-hash-for-create-nodes';
import { hashObject } from 'nx/src/hasher/file-hasher';
import { workspaceDataDirectory } from 'nx/src/utils/cache-directory';
import { existsSync } from 'fs';
import { dirname, join } from 'path';
import { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';
import { getLatestCommitSha } from 'nx/src/utils/git-utils';
import { interpolateObject } from '../utils/interpolate-pattern';
@@ -1,5 +1,6 @@
import * as pc from 'picocolors';
import type { ExecutorContext } from '@nx/devkit';
import { createAsyncIterable } from '@nx/devkit/internal';
import {
cacheDir,
joinPathFragments,
@@ -22,7 +23,6 @@ import {
EsBuildExecutorOptions,
NormalizedEsBuildExecutorOptions,
} from './schema';
import { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable';
import {
buildEsbuildOptions,
getOutExtension,
@@ -1,3 +1,4 @@
import { addBuildTargetDefaults } from '@nx/devkit/internal';
import {
formatFiles,
joinPathFragments,
@@ -8,7 +9,6 @@ import {
updateProjectConfiguration,
writeJson,
} from '@nx/devkit';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
import { getOutputDir, getUpdatedPackageJsonContent } from '@nx/js';
import { getImportPath } from '@nx/js/src/utils/get-import-path';
import {
@@ -1,5 +1,5 @@
import { workspaceRoot } from '@nx/devkit';
import { loadConfigFile } from '@nx/devkit/src/utils/config-utils';
import { loadConfigFile } from '@nx/devkit/internal';
import { registerTsProject } from '@nx/js/src/internal';
import type { TSESLint } from '@typescript-eslint/utils';
import { existsSync } from 'fs';
@@ -1,5 +1,5 @@
import { NX_VERSION, normalizePath, workspaceRoot } from '@nx/devkit';
import { getCatalogManager } from '@nx/devkit/src/utils/catalog';
import { getCatalogManager } from '@nx/devkit/internal';
import { findNpmDependencies } from '@nx/js/src/utils/find-npm-dependencies';
import { ESLintUtils } from '@typescript-eslint/utils';
import { AST } from 'jsonc-eslint-parser';
@@ -1,3 +1,8 @@
import {
migrateProjectExecutorsToPlugin,
NoTargetsToMigrateError,
processTargetOutputs,
} from '@nx/devkit/internal';
import {
createProjectGraphAsync,
formatFiles,
@@ -5,11 +10,6 @@ import {
type TargetConfiguration,
type Tree,
} from '@nx/devkit';
import {
migrateProjectExecutorsToPlugin,
NoTargetsToMigrateError,
} from '@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator';
import { processTargetOutputs } from '@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils';
import { basename, dirname, relative } from 'node:path/posix';
import { interpolate } from 'nx/src/tasks-runner/utils';
import { createNodesV2, type EslintPluginOptions } from '../../plugins/plugin';

Some files were not shown because too many files have changed in this diff Show More