nx 23.0.0-beta.2 → 23.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/init-local.js +11 -20
- package/dist/bin/nx.d.ts +1 -0
- package/dist/bin/nx.js +28 -2
- package/dist/plugins/package-json.js +4 -2
- package/dist/src/adapter/ngcli-adapter.d.ts +2 -1
- package/dist/src/adapter/ngcli-adapter.js +25 -2
- package/dist/src/ai/clone-ai-config-repo.js +20 -3
- package/dist/src/analytics/analytics.js +10 -1
- package/dist/src/command-line/add/completion.d.ts +1 -0
- package/dist/src/command-line/add/completion.js +15 -0
- package/dist/src/command-line/affected/completion.d.ts +1 -0
- package/dist/src/command-line/affected/completion.js +15 -0
- package/dist/src/command-line/completion/argv-layout.d.ts +6 -0
- package/dist/src/command-line/completion/argv-layout.js +19 -0
- package/dist/src/command-line/completion/command-completions.d.ts +19 -0
- package/dist/src/command-line/completion/command-completions.js +120 -0
- package/dist/src/command-line/completion/command-handlers.d.ts +30 -0
- package/dist/src/command-line/completion/command-handlers.js +69 -0
- package/dist/src/command-line/completion/command-object.d.ts +10 -0
- package/dist/src/command-line/completion/command-object.js +95 -0
- package/dist/src/command-line/completion/completion-providers.d.ts +21 -0
- package/dist/src/command-line/completion/completion-providers.js +194 -0
- package/dist/src/command-line/completion/infix-targets.d.ts +1 -0
- package/dist/src/command-line/completion/infix-targets.js +48 -0
- package/dist/src/command-line/completion/metadata.d.ts +22 -0
- package/dist/src/command-line/completion/metadata.js +71 -0
- package/dist/src/command-line/completion/registrations.d.ts +9 -0
- package/dist/src/command-line/completion/registrations.js +16 -0
- package/dist/src/command-line/completion/scripts/bash.sh +51 -0
- package/dist/src/command-line/completion/scripts/fish.fish +47 -0
- package/dist/src/command-line/completion/scripts/powershell.ps1 +52 -0
- package/dist/src/command-line/completion/scripts/zsh.zsh +69 -0
- package/dist/src/command-line/completion/scripts.d.ts +18 -0
- package/dist/src/command-line/completion/scripts.js +140 -0
- package/dist/src/command-line/completion/trigger.d.ts +3 -0
- package/dist/src/command-line/completion/trigger.js +21 -0
- package/dist/src/command-line/completion/value-completions.d.ts +3 -0
- package/dist/src/command-line/completion/value-completions.js +21 -0
- package/dist/src/command-line/examples.js +1 -1
- package/dist/src/command-line/format/format.js +15 -5
- package/dist/src/command-line/generate/completion.d.ts +1 -0
- package/dist/src/command-line/generate/completion.js +9 -0
- package/dist/src/command-line/graph/completion.d.ts +1 -0
- package/dist/src/command-line/graph/completion.js +13 -0
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +14 -18
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +1 -0
- package/dist/src/command-line/init/implementation/utils.d.ts +7 -1
- package/dist/src/command-line/init/implementation/utils.js +51 -14
- package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +22 -0
- package/dist/src/command-line/migrate/agentic/capture-generator-output.js +100 -0
- package/dist/src/command-line/migrate/agentic/cli-args.d.ts +12 -0
- package/dist/src/command-line/migrate/agentic/cli-args.js +38 -0
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +6 -0
- package/dist/src/command-line/migrate/agentic/definitions.js +98 -0
- package/dist/src/command-line/migrate/agentic/detect-installed.d.ts +10 -0
- package/dist/src/command-line/migrate/agentic/detect-installed.js +68 -0
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +46 -0
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +87 -0
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +63 -0
- package/dist/src/command-line/migrate/agentic/handoff.js +183 -0
- package/dist/src/command-line/migrate/agentic/inception.d.ts +9 -0
- package/dist/src/command-line/migrate/agentic/inception.js +15 -0
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +22 -0
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +50 -0
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +51 -0
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +65 -0
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +44 -0
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +52 -0
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +21 -0
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +26 -0
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +18 -0
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +130 -0
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +46 -0
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +88 -0
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +51 -0
- package/dist/src/command-line/migrate/agentic/run-step.js +121 -0
- package/dist/src/command-line/migrate/agentic/runner.d.ts +33 -0
- package/dist/src/command-line/migrate/agentic/runner.js +442 -0
- package/dist/src/command-line/migrate/agentic/select.d.ts +14 -0
- package/dist/src/command-line/migrate/agentic/select.js +150 -0
- package/dist/src/command-line/migrate/agentic/types.d.ts +102 -0
- package/dist/src/command-line/migrate/agentic/types.js +2 -0
- package/dist/src/command-line/migrate/command-object.d.ts +1 -0
- package/dist/src/command-line/migrate/command-object.js +32 -7
- package/dist/src/command-line/migrate/migrate-commits.d.ts +50 -0
- package/dist/src/command-line/migrate/migrate-commits.js +102 -0
- package/dist/src/command-line/migrate/migrate-output.d.ts +180 -0
- package/dist/src/command-line/migrate/migrate-output.js +258 -0
- package/dist/src/command-line/migrate/migrate.d.ts +122 -12
- package/dist/src/command-line/migrate/migrate.js +1036 -217
- package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
- package/dist/src/command-line/migrate/migration-shape.js +13 -0
- package/dist/src/command-line/migrate/multi-major.d.ts +30 -0
- package/dist/src/command-line/migrate/multi-major.js +185 -0
- package/dist/src/command-line/migrate/prompt-files.d.ts +31 -0
- package/dist/src/command-line/migrate/prompt-files.js +141 -0
- package/dist/src/command-line/migrate/run-migration-process.js +28 -6
- package/dist/src/command-line/migrate/safe-prompt.d.ts +28 -0
- package/dist/src/command-line/migrate/safe-prompt.js +49 -0
- package/dist/src/command-line/migrate/update-filters.d.ts +11 -0
- package/dist/src/command-line/migrate/update-filters.js +44 -0
- package/dist/src/command-line/migrate/version-utils.d.ts +6 -0
- package/dist/src/command-line/migrate/version-utils.js +59 -0
- package/dist/src/command-line/nx-commands.js +9 -0
- package/dist/src/command-line/release/config/config.d.ts +3 -6
- package/dist/src/command-line/release/config/config.js +77 -45
- package/dist/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
- package/dist/src/command-line/release/config/use-legacy-versioning.js +8 -0
- package/dist/src/command-line/release/utils/release-graph.js +2 -3
- package/dist/src/command-line/release/utils/repository-git-tags.js +1 -1
- package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +7 -19
- package/dist/src/command-line/release/version/resolve-current-version.js +1 -1
- package/dist/src/command-line/release/version/version-actions.js +3 -7
- package/dist/src/command-line/report/report.js +2 -2
- package/dist/src/command-line/run/completion.d.ts +1 -0
- package/dist/src/command-line/run/completion.js +7 -0
- package/dist/src/command-line/run-many/completion.d.ts +1 -0
- package/dist/src/command-line/run-many/completion.js +13 -0
- package/dist/src/command-line/show/completion.d.ts +1 -0
- package/dist/src/command-line/show/completion.js +27 -0
- package/dist/src/command-line/show/show-target/info.d.ts +1 -0
- package/dist/src/command-line/show/show-target/info.js +100 -19
- package/dist/src/command-line/watch/command-object.js +24 -4
- package/dist/src/command-line/watch/completion.d.ts +1 -0
- package/dist/src/command-line/watch/completion.js +10 -0
- package/dist/src/command-line/watch/watch.d.ts +7 -0
- package/dist/src/command-line/watch/watch.js +1 -1
- package/dist/src/config/misc-interfaces.d.ts +25 -2
- package/dist/src/config/nx-json.d.ts +43 -56
- package/dist/src/config/schema-utils.d.ts +21 -0
- package/dist/src/config/schema-utils.js +92 -18
- package/dist/src/config/task-graph.d.ts +4 -107
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.css +2 -3
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +1 -1
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +1 -1
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +1 -1
- package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +9 -0
- package/dist/src/daemon/server/file-watching/route-workspace-changes.js +76 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +45 -11
- package/dist/src/daemon/server/server.js +4 -43
- package/dist/src/daemon/server/start.d.ts +1 -1
- package/dist/src/daemon/server/start.js +2 -0
- package/dist/src/devkit-exports.d.ts +2 -2
- package/dist/src/devkit-internals.d.ts +5 -1
- package/dist/src/devkit-internals.js +17 -1
- package/dist/src/executors/run-commands/running-tasks.d.ts +7 -0
- package/dist/src/executors/run-commands/running-tasks.js +178 -105
- package/dist/src/executors/run-script/run-script.impl.js +3 -10
- package/dist/src/executors/utils/convert-nx-executor.js +1 -1
- package/dist/src/hasher/hash-plan-inspector.d.ts +1 -1
- package/dist/src/hasher/task-hasher.js +6 -4
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +0 -3
- package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +6 -2
- package/dist/src/migrations/update-17-0-0/move-cache-directory.md +31 -0
- package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +20 -4
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.md +27 -0
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.md +24 -0
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.md +49 -0
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.md +54 -0
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.md +28 -0
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.md +22 -0
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.md +11 -0
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.d.ts +2 -0
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +16 -0
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +9 -0
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +18 -0
- package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.d.ts +35 -0
- package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.js +139 -0
- package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.md +66 -0
- package/dist/src/native/index.d.ts +79 -2
- package/dist/src/native/native-bindings.js +3 -0
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/plugins/js/lock-file/npm-parser.js +37 -19
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +51 -4
- package/dist/src/plugins/js/lock-file/project-graph-pruning.js +12 -4
- package/dist/src/plugins/js/utils/packages.js +1 -1
- package/dist/src/plugins/js/utils/register.d.ts +103 -14
- package/dist/src/plugins/js/utils/register.js +434 -39
- package/dist/src/plugins/js/utils/typescript.d.ts +7 -0
- package/dist/src/plugins/js/utils/typescript.js +39 -0
- package/dist/src/plugins/package-json/create-nodes.d.ts +3 -2
- package/dist/src/plugins/package-json/create-nodes.js +7 -5
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +2 -1
- package/dist/src/project-graph/build-project-graph.d.ts +5 -0
- package/dist/src/project-graph/build-project-graph.js +6 -2
- package/dist/src/project-graph/file-map-utils.d.ts +5 -0
- package/dist/src/project-graph/file-map-utils.js +10 -1
- package/dist/src/project-graph/plugins/get-plugins.d.ts +7 -2
- package/dist/src/project-graph/plugins/get-plugins.js +8 -5
- package/dist/src/project-graph/plugins/isolation/plugin-worker.d.ts +1 -0
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +2 -0
- package/dist/src/project-graph/plugins/resolve-plugin.d.ts +7 -4
- package/dist/src/project-graph/plugins/resolve-plugin.js +152 -33
- package/dist/src/project-graph/plugins/tasks-execution-hooks.js +4 -2
- package/dist/src/project-graph/plugins/transpiler.d.ts +12 -0
- package/dist/src/project-graph/plugins/transpiler.js +37 -0
- package/dist/src/project-graph/plugins/utils.js +13 -7
- package/dist/src/project-graph/project-graph.js +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +95 -4
- package/dist/src/project-graph/utils/project-configuration/target-defaults.js +515 -68
- package/dist/src/project-graph/utils/project-configuration-utils.d.ts +13 -5
- package/dist/src/project-graph/utils/project-configuration-utils.js +14 -6
- package/dist/src/project-graph/utils/retrieve-workspace-files.js +1 -1
- package/dist/src/tasks-runner/create-task-graph.d.ts +4 -4
- package/dist/src/tasks-runner/create-task-graph.js +1 -1
- package/dist/src/tasks-runner/default-tasks-runner.d.ts +0 -2
- package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.js +11 -6
- package/dist/src/tasks-runner/init-tasks-runner.d.ts +0 -15
- package/dist/src/tasks-runner/init-tasks-runner.js +0 -63
- package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +18 -0
- package/dist/src/tasks-runner/legacy-depends-on-warning.js +109 -0
- package/dist/src/tasks-runner/life-cycle.d.ts +7 -8
- package/dist/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +6 -6
- package/dist/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +13 -2
- package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.js +16 -5
- package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +11 -2
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
- package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
- package/dist/src/tasks-runner/run-command.js +8 -11
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +1 -1
- package/dist/src/tasks-runner/running-tasks/batch-process.js +3 -5
- package/dist/src/tasks-runner/running-tasks/node-child-process.d.ts +2 -2
- package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -7
- package/dist/src/tasks-runner/task-env.d.ts +1 -1
- package/dist/src/tasks-runner/task-env.js +6 -1
- package/dist/src/tasks-runner/task-orchestrator.d.ts +11 -1
- package/dist/src/tasks-runner/task-orchestrator.js +112 -38
- package/dist/src/tasks-runner/tasks-schedule.js +3 -3
- package/dist/src/tasks-runner/utils.d.ts +7 -8
- package/dist/src/tasks-runner/utils.js +23 -27
- package/dist/src/utils/child-process.js +2 -2
- package/dist/src/utils/compile-cache.d.ts +24 -0
- package/dist/src/utils/compile-cache.js +49 -0
- package/dist/src/utils/enable-compile-cache.d.ts +1 -0
- package/dist/src/utils/enable-compile-cache.js +7 -0
- package/dist/src/utils/fileutils.d.ts +0 -8
- package/dist/src/utils/fileutils.js +0 -40
- package/dist/src/utils/git-utils.d.ts +15 -0
- package/dist/src/utils/git-utils.js +138 -0
- package/dist/src/utils/handle-import.d.ts +4 -1
- package/dist/src/utils/handle-import.js +56 -2
- package/dist/src/utils/has-nx-js-plugin.d.ts +9 -0
- package/dist/src/utils/has-nx-js-plugin.js +24 -0
- package/dist/src/utils/installed-nx-version.d.ts +14 -4
- package/dist/src/utils/installed-nx-version.js +54 -7
- package/dist/src/utils/logger.d.ts +12 -1
- package/dist/src/utils/logger.js +57 -36
- package/dist/src/utils/nx-key.d.ts +0 -1
- package/dist/src/utils/nx-key.js +20 -23
- package/dist/src/utils/nx-package-group.d.ts +8 -0
- package/dist/src/utils/nx-package-group.js +15 -0
- package/dist/src/utils/output.d.ts +3 -2
- package/dist/src/utils/output.js +29 -28
- package/dist/src/utils/package-json.d.ts +14 -1
- package/dist/src/utils/package-json.js +20 -21
- package/dist/src/utils/perf-logging.js +3 -1
- package/dist/src/utils/plugin-cache-utils.d.ts +13 -4
- package/dist/src/utils/plugin-cache-utils.js +23 -13
- package/dist/src/utils/plugins/local-plugins.d.ts +18 -0
- package/dist/src/utils/plugins/local-plugins.js +30 -0
- package/dist/src/utils/tar.d.ts +8 -0
- package/dist/src/utils/tar.js +44 -0
- package/migrations.json +16 -0
- package/package.json +28 -28
- package/schemas/nx-schema.json +114 -80
- package/dist/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +0 -7
- package/dist/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +0 -155
- package/dist/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +0 -16
- package/dist/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +0 -121
|
@@ -16,6 +16,7 @@ const globs_1 = require("../../utils/globs");
|
|
|
16
16
|
const logger_1 = require("../../utils/logger");
|
|
17
17
|
const output_1 = require("../../utils/output");
|
|
18
18
|
const package_json_1 = require("../../utils/package-json");
|
|
19
|
+
const package_manager_1 = require("../../utils/package-manager");
|
|
19
20
|
const path_1 = require("../../utils/path");
|
|
20
21
|
const versions_1 = require("../../utils/versions");
|
|
21
22
|
const plugins_1 = require("../../project-graph/plugins");
|
|
@@ -38,6 +39,7 @@ exports.createNodesV2 = [
|
|
|
38
39
|
return projectJsonRoots.has((0, node_path_1.dirname)(packageJsonPath));
|
|
39
40
|
};
|
|
40
41
|
const cache = (0, package_json_2.readPackageJsonConfigurationCache)();
|
|
42
|
+
const packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)((0, package_manager_1.detectPackageManager)(context.workspaceRoot), context.workspaceRoot);
|
|
41
43
|
return (0, plugins_1.createNodesFromFiles)((packageJsonPath, options, context) => {
|
|
42
44
|
const isInPackageManagerWorkspaces = isInPackageJsonWorkspaces(packageJsonPath);
|
|
43
45
|
if (!isInPackageManagerWorkspaces &&
|
|
@@ -45,7 +47,7 @@ exports.createNodesV2 = [
|
|
|
45
47
|
// Skip if package.json is not part of the package.json workspaces and not next to a project.json.
|
|
46
48
|
return null;
|
|
47
49
|
}
|
|
48
|
-
return createNodeFromPackageJson(packageJsonPath, context.workspaceRoot, cache, isInPackageManagerWorkspaces);
|
|
50
|
+
return createNodeFromPackageJson(packageJsonPath, context.workspaceRoot, cache, isInPackageManagerWorkspaces, packageManagerCommand);
|
|
49
51
|
}, packageJsons, _, context);
|
|
50
52
|
},
|
|
51
53
|
];
|
|
@@ -111,7 +113,7 @@ function buildPackageJsonWorkspacesMatcher(patterns) {
|
|
|
111
113
|
!patterns.negativeLookup[p] &&
|
|
112
114
|
patterns.negative.every((negative) => (0, minimatch_1.minimatch)(p, negative));
|
|
113
115
|
}
|
|
114
|
-
function createNodeFromPackageJson(pkgJsonPath, workspaceRoot, cache, isInPackageManagerWorkspaces) {
|
|
116
|
+
function createNodeFromPackageJson(pkgJsonPath, workspaceRoot, cache, isInPackageManagerWorkspaces, packageManagerCommand) {
|
|
115
117
|
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspaceRoot, pkgJsonPath));
|
|
116
118
|
const projectRoot = (0, node_path_1.dirname)(pkgJsonPath);
|
|
117
119
|
const hash = (0, file_hasher_1.hashObject)({
|
|
@@ -128,7 +130,7 @@ function createNodeFromPackageJson(pkgJsonPath, workspaceRoot, cache, isInPackag
|
|
|
128
130
|
},
|
|
129
131
|
};
|
|
130
132
|
}
|
|
131
|
-
const project = buildProjectConfigurationFromPackageJson(json, workspaceRoot, pkgJsonPath, (0, nx_json_1.readNxJson)(workspaceRoot), isInPackageManagerWorkspaces);
|
|
133
|
+
const project = buildProjectConfigurationFromPackageJson(json, workspaceRoot, pkgJsonPath, (0, nx_json_1.readNxJson)(workspaceRoot), isInPackageManagerWorkspaces, packageManagerCommand);
|
|
132
134
|
cache.set(hash, project);
|
|
133
135
|
return {
|
|
134
136
|
projects: {
|
|
@@ -136,7 +138,7 @@ function createNodeFromPackageJson(pkgJsonPath, workspaceRoot, cache, isInPackag
|
|
|
136
138
|
},
|
|
137
139
|
};
|
|
138
140
|
}
|
|
139
|
-
function buildProjectConfigurationFromPackageJson(packageJson, workspaceRoot, packageJsonPath, nxJson, isInPackageManagerWorkspaces) {
|
|
141
|
+
function buildProjectConfigurationFromPackageJson(packageJson, workspaceRoot, packageJsonPath, nxJson, isInPackageManagerWorkspaces, packageManagerCommand) {
|
|
140
142
|
const normalizedPath = packageJsonPath.split('\\').join('/');
|
|
141
143
|
const projectRoot = (0, node_path_1.dirname)(normalizedPath);
|
|
142
144
|
const siblingProjectJson = tryReadJson((0, node_path_1.join)(workspaceRoot, projectRoot, 'project.json'));
|
|
@@ -161,7 +163,7 @@ function buildProjectConfigurationFromPackageJson(packageJson, workspaceRoot, pa
|
|
|
161
163
|
root: projectRoot,
|
|
162
164
|
name,
|
|
163
165
|
...packageJson.nx,
|
|
164
|
-
targets: (0, package_json_1.readTargetsFromPackageJson)(packageJson, nxJson, projectRoot, workspaceRoot),
|
|
166
|
+
targets: (0, package_json_1.readTargetsFromPackageJson)(packageJson, nxJson, projectRoot, workspaceRoot, packageManagerCommand),
|
|
165
167
|
tags: (0, package_json_1.getTagsFromPackageJson)(packageJson),
|
|
166
168
|
metadata: (0, package_json_1.getMetadataFromPackageJson)(packageJson, isInPackageManagerWorkspaces),
|
|
167
169
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTouchedProjectsFromProjectGlobChanges = void 0;
|
|
4
4
|
const minimatch_1 = require("minimatch");
|
|
5
|
+
const nx_json_1 = require("../../../config/nx-json");
|
|
5
6
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
6
7
|
const path_1 = require("path");
|
|
7
8
|
const fs_1 = require("fs");
|
|
@@ -20,7 +21,7 @@ const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGra
|
|
|
20
21
|
'package.json',
|
|
21
22
|
]);
|
|
22
23
|
}
|
|
23
|
-
const plugins = (await (0, get_plugins_1.getPlugins)()).filter((p) => !!p.createNodes);
|
|
24
|
+
const plugins = (await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot))).filter((p) => !!p.createNodes);
|
|
24
25
|
return (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.getGlobPatternsOfPlugins)(plugins));
|
|
25
26
|
})();
|
|
26
27
|
const touchedProjects = new Set();
|
|
@@ -2,6 +2,7 @@ import { FileMap, ProjectGraph, ProjectGraphExternalNode } from '../config/proje
|
|
|
2
2
|
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
|
3
3
|
import { NxWorkspaceFilesExternals } from '../native';
|
|
4
4
|
import { CreateMetadataError } from './error-types';
|
|
5
|
+
import { FileData } from './file-utils';
|
|
5
6
|
import { FileMapCache } from './nx-deps-cache';
|
|
6
7
|
import { CreateMetadataContext } from './plugins';
|
|
7
8
|
import type { LoadedNxPlugin } from './plugins/loaded-nx-plugin';
|
|
@@ -9,8 +10,12 @@ import type { ConfigurationSourceMaps } from './utils/project-configuration/sour
|
|
|
9
10
|
export declare function getFileMap(): {
|
|
10
11
|
fileMap: FileMap;
|
|
11
12
|
rustReferences: NxWorkspaceFilesExternals | null;
|
|
13
|
+
/** @deprecated always `[]`; kept so cached nx-cloud workers that destructure it don't see `undefined`. */
|
|
14
|
+
allWorkspaceFiles: FileData[];
|
|
12
15
|
};
|
|
13
16
|
export declare function hydrateFileMap(fileMap: FileMap, rustReferences: NxWorkspaceFilesExternals): void;
|
|
17
|
+
/** @deprecated pass `(fileMap, rustReferences)`. Kept for cached nx-cloud workers still on the 3-arg form. */
|
|
18
|
+
export declare function hydrateFileMap(fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals): void;
|
|
14
19
|
export declare function buildProjectGraphUsingProjectFileMap(projectRootMap: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null, plugins: LoadedNxPlugin[], sourceMap: ConfigurationSourceMaps): Promise<{
|
|
15
20
|
projectGraph: ProjectGraph;
|
|
16
21
|
projectFileMapCache: FileMapCache;
|
|
@@ -29,6 +29,7 @@ function getFileMap() {
|
|
|
29
29
|
return {
|
|
30
30
|
fileMap: storedFileMap,
|
|
31
31
|
rustReferences: storedRustReferences,
|
|
32
|
+
allWorkspaceFiles: [],
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
@@ -38,12 +39,15 @@ function getFileMap() {
|
|
|
38
39
|
projectFileMap: {},
|
|
39
40
|
},
|
|
40
41
|
rustReferences: null,
|
|
42
|
+
allWorkspaceFiles: [],
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
|
-
function hydrateFileMap(fileMap,
|
|
46
|
+
function hydrateFileMap(fileMap, rustReferencesOrAllFiles, maybeRustReferences) {
|
|
45
47
|
storedFileMap = fileMap;
|
|
46
|
-
storedRustReferences =
|
|
48
|
+
storedRustReferences = Array.isArray(rustReferencesOrAllFiles)
|
|
49
|
+
? (maybeRustReferences ?? null)
|
|
50
|
+
: rustReferencesOrAllFiles;
|
|
47
51
|
}
|
|
48
52
|
async function buildProjectGraphUsingProjectFileMap(projectRootMap, externalNodes, fileMap, rustReferences, fileMapCache, plugins, sourceMap) {
|
|
49
53
|
storedFileMap = fileMap;
|
|
@@ -3,6 +3,11 @@ import type { ProjectConfiguration, ProjectsConfigurations } from '../config/wor
|
|
|
3
3
|
import { NxWorkspaceFilesExternals } from '../native';
|
|
4
4
|
export interface WorkspaceFileMap {
|
|
5
5
|
fileMap: FileMap;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Derived from `fileMap.projectFileMap` + `fileMap.nonProjectFiles`.
|
|
8
|
+
* Will be removed in a future major. Compute it locally if needed.
|
|
9
|
+
*/
|
|
10
|
+
allWorkspaceFiles?: FileData[];
|
|
6
11
|
}
|
|
7
12
|
export declare function createProjectFileMapUsingProjectGraph(graph: ProjectGraph): Promise<ProjectFileMap>;
|
|
8
13
|
export declare function createFileMapUsingProjectGraph(graph: ProjectGraph): Promise<WorkspaceFileMap>;
|
|
@@ -7,6 +7,7 @@ exports.updateFileMap = updateFileMap;
|
|
|
7
7
|
const workspace_context_1 = require("../utils/workspace-context");
|
|
8
8
|
const workspace_root_1 = require("../utils/workspace-root");
|
|
9
9
|
const project_graph_1 = require("./project-graph");
|
|
10
|
+
const build_all_workspace_files_1 = require("./utils/build-all-workspace-files");
|
|
10
11
|
const find_project_for_path_1 = require("./utils/find-project-for-path");
|
|
11
12
|
async function createProjectFileMapUsingProjectGraph(graph) {
|
|
12
13
|
return (await createFileMapUsingProjectGraph(graph)).fileMap.projectFileMap;
|
|
@@ -36,12 +37,20 @@ function createFileMap(projectsConfigurations, allWorkspaceFiles) {
|
|
|
36
37
|
nonProjectFiles.push(f);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
const result = {
|
|
40
41
|
fileMap: {
|
|
41
42
|
projectFileMap,
|
|
42
43
|
nonProjectFiles,
|
|
43
44
|
},
|
|
44
45
|
};
|
|
46
|
+
Object.defineProperty(result, 'allWorkspaceFiles', {
|
|
47
|
+
enumerable: false,
|
|
48
|
+
configurable: true,
|
|
49
|
+
get() {
|
|
50
|
+
return (0, build_all_workspace_files_1.buildAllWorkspaceFiles)(result.fileMap.projectFileMap, result.fileMap.nonProjectFiles);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
return result;
|
|
45
54
|
}
|
|
46
55
|
function updateFileMap(projectsConfigurations, rustReferences, updatedFiles, deletedFiles) {
|
|
47
56
|
const updates = (0, workspace_context_1.updateProjectFiles)(Object.fromEntries((0, find_project_for_path_1.createProjectRootMappingsFromProjectConfigurations)(projectsConfigurations)), rustReferences, updatedFiles, deletedFiles);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NxJsonConfiguration } from '../../config/nx-json';
|
|
1
2
|
import type { LoadedNxPlugin } from './loaded-nx-plugin';
|
|
2
3
|
export interface SeparatedPlugins {
|
|
3
4
|
specifiedPlugins: LoadedNxPlugin[];
|
|
@@ -7,14 +8,18 @@ export interface SeparatedPlugins {
|
|
|
7
8
|
* Returns all plugins (specified + default) as a flat list.
|
|
8
9
|
* Specified plugins come first, followed by default plugins.
|
|
9
10
|
*/
|
|
10
|
-
export declare function getPlugins(root?: string): Promise<LoadedNxPlugin[]>;
|
|
11
|
+
export declare function getPlugins(nxJson: NxJsonConfiguration, root?: string): Promise<LoadedNxPlugin[]>;
|
|
11
12
|
/**
|
|
12
13
|
* Returns specified plugins (from nx.json) and default plugins (project.json,
|
|
13
14
|
* package.json, etc.) as separate arrays. This separation is needed for
|
|
14
15
|
* two-phase project configuration processing where target defaults are
|
|
15
16
|
* applied between specified and default plugin results.
|
|
17
|
+
*
|
|
18
|
+
* `nxJson` is required so callers control the snapshot of nx.json the plugin
|
|
19
|
+
* loader uses. This matters for the daemon's freshness-gated recompute, where
|
|
20
|
+
* the snap hash and the plugin set must reflect the same disk state.
|
|
16
21
|
*/
|
|
17
|
-
export declare function getPluginsSeparated(root?: string): Promise<SeparatedPlugins>;
|
|
22
|
+
export declare function getPluginsSeparated(nxJson: NxJsonConfiguration, root?: string): Promise<SeparatedPlugins>;
|
|
18
23
|
export declare function getOnlyDefaultPlugins(root?: string): Promise<LoadedNxPlugin[]>;
|
|
19
24
|
export declare function cleanupPlugins(): void;
|
|
20
25
|
export declare function reasonToError(reason: unknown): Error;
|
|
@@ -7,7 +7,6 @@ exports.cleanupPlugins = cleanupPlugins;
|
|
|
7
7
|
exports.reasonToError = reasonToError;
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
9
|
const angular_json_1 = require("../../adapter/angular-json");
|
|
10
|
-
const nx_json_1 = require("../../config/nx-json");
|
|
11
10
|
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
12
11
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
13
12
|
const in_process_loader_1 = require("./in-process-loader");
|
|
@@ -29,8 +28,8 @@ const loadingMethod = (plugin, root, index) => (0, enabled_1.isIsolationEnabled)
|
|
|
29
28
|
* Returns all plugins (specified + default) as a flat list.
|
|
30
29
|
* Specified plugins come first, followed by default plugins.
|
|
31
30
|
*/
|
|
32
|
-
async function getPlugins(root = workspace_root_1.workspaceRoot) {
|
|
33
|
-
const { specifiedPlugins, defaultPlugins } = await getPluginsSeparated(root);
|
|
31
|
+
async function getPlugins(nxJson, root = workspace_root_1.workspaceRoot) {
|
|
32
|
+
const { specifiedPlugins, defaultPlugins } = await getPluginsSeparated(nxJson, root);
|
|
34
33
|
return specifiedPlugins.concat(defaultPlugins);
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
@@ -38,9 +37,13 @@ async function getPlugins(root = workspace_root_1.workspaceRoot) {
|
|
|
38
37
|
* package.json, etc.) as separate arrays. This separation is needed for
|
|
39
38
|
* two-phase project configuration processing where target defaults are
|
|
40
39
|
* applied between specified and default plugin results.
|
|
40
|
+
*
|
|
41
|
+
* `nxJson` is required so callers control the snapshot of nx.json the plugin
|
|
42
|
+
* loader uses. This matters for the daemon's freshness-gated recompute, where
|
|
43
|
+
* the snap hash and the plugin set must reflect the same disk state.
|
|
41
44
|
*/
|
|
42
|
-
async function getPluginsSeparated(root = workspace_root_1.workspaceRoot) {
|
|
43
|
-
const pluginsConfiguration =
|
|
45
|
+
async function getPluginsSeparated(nxJson, root = workspace_root_1.workspaceRoot) {
|
|
46
|
+
const pluginsConfiguration = nxJson.plugins ?? [];
|
|
44
47
|
const pluginsConfigurationHash = (0, file_hasher_1.hashObject)(pluginsConfiguration);
|
|
45
48
|
// If the plugins configuration has not changed, reuse the current plugins
|
|
46
49
|
if (cachedSeparatedPlugins &&
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Must be the first import — see enable-compile-cache.ts.
|
|
4
|
+
require("../../../utils/enable-compile-cache");
|
|
3
5
|
const node_perf_hooks_1 = require("node:perf_hooks");
|
|
4
6
|
node_perf_hooks_1.performance.mark(`plugin worker ${process.pid} code loading -- start`);
|
|
5
7
|
const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
|
2
|
+
type LocalPluginMatch = {
|
|
3
|
+
path: string;
|
|
4
|
+
projectConfig: ProjectConfiguration;
|
|
5
|
+
resolvedFile?: string;
|
|
6
|
+
};
|
|
2
7
|
export declare function resolveNxPlugin(moduleName: string, root: string, paths: string[]): Promise<{
|
|
3
8
|
pluginPath: string;
|
|
4
9
|
name: any;
|
|
5
10
|
shouldRegisterTSTranspiler: boolean;
|
|
6
11
|
}>;
|
|
7
|
-
export declare function resolveLocalNxPlugin(importPath: string, projects: Record<string, ProjectConfiguration>, root?: string):
|
|
8
|
-
path: string;
|
|
9
|
-
projectConfig: ProjectConfiguration;
|
|
10
|
-
} | null;
|
|
12
|
+
export declare function resolveLocalNxPlugin(importPath: string, projects: Record<string, ProjectConfiguration>, root?: string): LocalPluginMatch | null;
|
|
11
13
|
export declare function getPluginPathAndName(moduleName: string, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): {
|
|
12
14
|
pluginPath: string;
|
|
13
15
|
name: any;
|
|
14
16
|
shouldRegisterTSTranspiler: boolean;
|
|
15
17
|
};
|
|
18
|
+
export {};
|
|
@@ -6,28 +6,59 @@ exports.getPluginPathAndName = getPluginPathAndName;
|
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const path = tslib_1.__importStar(require("node:path"));
|
|
8
8
|
const node_fs_1 = require("node:fs");
|
|
9
|
+
const resolve_exports_1 = require("resolve.exports");
|
|
9
10
|
const packages_1 = require("../../plugins/js/utils/packages");
|
|
11
|
+
const typescript_1 = require("../../plugins/js/utils/typescript");
|
|
10
12
|
const fileutils_1 = require("../../utils/fileutils");
|
|
11
13
|
const logger_1 = require("../../utils/logger");
|
|
12
14
|
const path_1 = require("../../utils/path");
|
|
13
15
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
14
16
|
const find_project_for_path_1 = require("../utils/find-project-for-path");
|
|
15
17
|
const retrieve_workspace_files_1 = require("../utils/retrieve-workspace-files");
|
|
18
|
+
const TS_SOURCE_EXTENSIONS = new Set(['.ts', '.tsx', '.cts', '.mts']);
|
|
16
19
|
let projectsWithoutInference;
|
|
17
20
|
let projectsWithoutInferencePromise = null;
|
|
18
21
|
async function resolveNxPlugin(moduleName, root, paths) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
// Default plugins (see `getDefaultPlugins` in `get-plugins.ts`) are passed
|
|
23
|
+
// as absolute file paths to compiled bundles inside `nx` itself; they are
|
|
24
|
+
// never workspace-local. Skip the project load entirely for them to avoid
|
|
25
|
+
// recursing through `retrieveProjectConfigurationsWithoutPluginInference`,
|
|
26
|
+
// which itself triggers default-plugin loading.
|
|
27
|
+
if (!path.isAbsolute(moduleName)) {
|
|
28
|
+
let resolvedFromNode;
|
|
29
|
+
try {
|
|
30
|
+
resolvedFromNode = require.resolve(moduleName, { paths });
|
|
31
|
+
}
|
|
32
|
+
catch { }
|
|
33
|
+
// Load projects if Node couldn't resolve (so the local fallback can run)
|
|
34
|
+
// OR if Node resolved to a workspace-internal path (a symlinked workspace
|
|
35
|
+
// package whose source-first lookup should win over the symlinked dist).
|
|
36
|
+
if (!resolvedFromNode ||
|
|
37
|
+
isWorkspaceLocalResolution(resolvedFromNode, root)) {
|
|
38
|
+
projectsWithoutInferencePromise ??=
|
|
39
|
+
(0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
|
40
|
+
projectsWithoutInference ??= await projectsWithoutInferencePromise;
|
|
41
|
+
}
|
|
27
42
|
}
|
|
28
43
|
const { pluginPath, name, shouldRegisterTSTranspiler } = getPluginPathAndName(moduleName, paths, projectsWithoutInference, root);
|
|
29
44
|
return { pluginPath, name, shouldRegisterTSTranspiler };
|
|
30
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Distinguishes a symlinked workspace package (where `require.resolve`
|
|
48
|
+
* follows the package-manager symlink into the workspace source tree) from
|
|
49
|
+
* a truly-installed dependency under `node_modules/`. The former needs the
|
|
50
|
+
* source-first lookup to bypass the dist that Node would otherwise return.
|
|
51
|
+
*/
|
|
52
|
+
function isWorkspaceLocalResolution(resolvedPath, root) {
|
|
53
|
+
const normalizedRoot = path.normalize(root);
|
|
54
|
+
const normalizedPath = path.normalize(resolvedPath);
|
|
55
|
+
return (normalizedPath.startsWith(normalizedRoot + path.sep) &&
|
|
56
|
+
!normalizedPath.includes(path.sep + 'node_modules' + path.sep));
|
|
57
|
+
}
|
|
58
|
+
function isPackageResolutionError(e) {
|
|
59
|
+
const code = e.code;
|
|
60
|
+
return (code === 'MODULE_NOT_FOUND' || code === 'ERR_PACKAGE_PATH_NOT_EXPORTED');
|
|
61
|
+
}
|
|
31
62
|
function readPluginMainFromProjectConfiguration(plugin) {
|
|
32
63
|
const { main } = Object.values(plugin.targets).find((x) => [
|
|
33
64
|
'@nx/js:tsc',
|
|
@@ -46,31 +77,44 @@ function resolveLocalNxPlugin(importPath, projects, root = workspace_root_1.work
|
|
|
46
77
|
}
|
|
47
78
|
function getPluginPathAndName(moduleName, paths, projects, root) {
|
|
48
79
|
let pluginPath;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
80
|
+
// Resolve local workspace plugins from source first so the workspace's
|
|
81
|
+
// `customConditions`/`development` exports condition wins over the built
|
|
82
|
+
// `dist` artifact that Node's resolver would otherwise pick up via the
|
|
83
|
+
// `default` condition (Node ignores TypeScript custom conditions). Skipped
|
|
84
|
+
// when `projects` weren't loaded — the caller already determined that the
|
|
85
|
+
// import isn't a workspace package.
|
|
86
|
+
const localPlugin = projects
|
|
87
|
+
? resolveLocalNxPlugin(moduleName, projects, root)
|
|
88
|
+
: null;
|
|
89
|
+
if (localPlugin) {
|
|
90
|
+
pluginPath = tryResolveLocalPluginFromSource(moduleName, localPlugin, root);
|
|
91
|
+
if (!pluginPath && getSubpathOfLocalPackage(moduleName, localPlugin)) {
|
|
92
|
+
throwUnresolvableLocalPluginError(moduleName, localPlugin, root);
|
|
93
|
+
}
|
|
56
94
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
95
|
+
if (!pluginPath) {
|
|
96
|
+
try {
|
|
97
|
+
pluginPath = require.resolve(moduleName, { paths });
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
if (localPlugin && isPackageResolutionError(e)) {
|
|
101
|
+
throwUnresolvableLocalPluginError(moduleName, localPlugin, root);
|
|
64
102
|
}
|
|
65
|
-
|
|
66
|
-
logger_1.logger.error(`Plugin listed in \`nx.json\` not found: ${moduleName}`);
|
|
103
|
+
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
67
104
|
throw e;
|
|
68
105
|
}
|
|
69
|
-
|
|
70
|
-
|
|
106
|
+
if (localPlugin) {
|
|
107
|
+
throwUnresolvableLocalPluginError(moduleName, localPlugin, root);
|
|
108
|
+
}
|
|
109
|
+
logger_1.logger.error(`Plugin listed in \`nx.json\` not found: ${moduleName}`);
|
|
71
110
|
throw e;
|
|
72
111
|
}
|
|
73
112
|
}
|
|
113
|
+
const ext = path.extname(pluginPath);
|
|
114
|
+
// Directory paths fall through to Node's `package.json` `main` resolution
|
|
115
|
+
// which may land on a TS file; only opt out of TS transpiler registration
|
|
116
|
+
// when the resolved path is unambiguously JS.
|
|
117
|
+
const shouldRegisterTSTranspiler = ext === '' || TS_SOURCE_EXTENSIONS.has(ext);
|
|
74
118
|
const packageJsonPath = path.join(pluginPath, 'package.json');
|
|
75
119
|
const { name } = !['.ts', '.js'].some((x) => path.extname(moduleName) === x) && // Not trying to point to a ts or js file
|
|
76
120
|
(0, node_fs_1.existsSync)(packageJsonPath) // plugin has a package.json
|
|
@@ -78,12 +122,84 @@ function getPluginPathAndName(moduleName, paths, projects, root) {
|
|
|
78
122
|
: { name: moduleName };
|
|
79
123
|
return { pluginPath, name, shouldRegisterTSTranspiler };
|
|
80
124
|
}
|
|
125
|
+
function getSubpathOfLocalPackage(moduleName, plugin) {
|
|
126
|
+
const packageName = plugin.projectConfig.metadata?.js?.packageName;
|
|
127
|
+
if (!packageName || !moduleName.startsWith(packageName + '/')) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return '.' + moduleName.slice(packageName.length);
|
|
131
|
+
}
|
|
132
|
+
function tryResolveLocalPluginFromSource(moduleName, plugin, root) {
|
|
133
|
+
if (plugin.resolvedFile) {
|
|
134
|
+
return plugin.resolvedFile;
|
|
135
|
+
}
|
|
136
|
+
const subpath = getSubpathOfLocalPackage(moduleName, plugin);
|
|
137
|
+
if (subpath) {
|
|
138
|
+
return resolveSubpathFromExports(plugin.projectConfig, plugin.path, subpath, root);
|
|
139
|
+
}
|
|
140
|
+
const main = readPluginMainFromProjectConfiguration(plugin.projectConfig);
|
|
141
|
+
return main ? path.join(root, main) : null;
|
|
142
|
+
}
|
|
143
|
+
function throwUnresolvableLocalPluginError(moduleName, plugin, root) {
|
|
144
|
+
const subpath = getSubpathOfLocalPackage(moduleName, plugin);
|
|
145
|
+
const packageName = plugin.projectConfig.metadata?.js?.packageName;
|
|
146
|
+
if (subpath) {
|
|
147
|
+
throw new Error(`Unable to resolve local plugin "${moduleName}". The import targets ` +
|
|
148
|
+
`the subpath "${subpath}" of the local package "${packageName}", but ` +
|
|
149
|
+
`the package's "exports" map has no resolvable entry for "${subpath}", ` +
|
|
150
|
+
`or none of the matched paths exist on disk. Check the "exports" field ` +
|
|
151
|
+
`in "${path.relative(root, path.join(plugin.path, 'package.json'))}" ` +
|
|
152
|
+
`and ensure the source file referenced by "${subpath}" exists.`);
|
|
153
|
+
}
|
|
154
|
+
throw new Error(`Unable to resolve local plugin "${moduleName}". The local package ` +
|
|
155
|
+
`"${packageName ?? moduleName}" does not declare a build target with ` +
|
|
156
|
+
`a "main" source path, and Node could not resolve it either.`);
|
|
157
|
+
}
|
|
158
|
+
function resolveSubpathFromExports(projectConfig, projectPath, subpath, root) {
|
|
159
|
+
const packageExports = projectConfig.metadata?.js?.packageExports;
|
|
160
|
+
if (!packageExports) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
const pkg = {
|
|
164
|
+
name: projectConfig.metadata.js.packageName,
|
|
165
|
+
exports: packageExports,
|
|
166
|
+
};
|
|
167
|
+
try {
|
|
168
|
+
const matches = (0, resolve_exports_1.resolve)(pkg, subpath, {
|
|
169
|
+
conditions: (0, typescript_1.getRootTsConfigResolveExportsConditions)(root),
|
|
170
|
+
});
|
|
171
|
+
if (!matches || !matches.length) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
for (const match of matches) {
|
|
175
|
+
const candidate = path.join(projectPath, match);
|
|
176
|
+
if ((0, node_fs_1.existsSync)(candidate)) {
|
|
177
|
+
return candidate;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
logger_1.logger.verbose(`Failed to resolve subpath "${subpath}" of local plugin via package.json exports`, e);
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
81
186
|
function lookupLocalPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
187
|
+
const match = findNxProjectForImportPath(importPath, projects, root);
|
|
188
|
+
if (!match) {
|
|
84
189
|
return null;
|
|
85
190
|
}
|
|
86
|
-
|
|
191
|
+
let resolvedFile;
|
|
192
|
+
if (match.tsPathFile) {
|
|
193
|
+
const candidate = path.join(root, match.tsPathFile);
|
|
194
|
+
if (path.extname(candidate) && (0, node_fs_1.existsSync)(candidate)) {
|
|
195
|
+
resolvedFile = candidate;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
path: path.join(root, match.projectConfig.root),
|
|
200
|
+
projectConfig: match.projectConfig,
|
|
201
|
+
resolvedFile,
|
|
202
|
+
};
|
|
87
203
|
}
|
|
88
204
|
let packageEntryPointsToProjectMap;
|
|
89
205
|
let wildcardEntryPointsToProjectMap;
|
|
@@ -101,7 +217,10 @@ function findNxProjectForImportPath(importPath, projects, root = workspace_root_
|
|
|
101
217
|
for (const tsConfigPath of possibleTsPaths) {
|
|
102
218
|
const nxProject = (0, find_project_for_path_1.findProjectForPath)(tsConfigPath, projectRootMappings);
|
|
103
219
|
if (nxProject) {
|
|
104
|
-
return
|
|
220
|
+
return {
|
|
221
|
+
projectConfig: projectNameMap.get(nxProject),
|
|
222
|
+
tsPathFile: tsConfigPath,
|
|
223
|
+
};
|
|
105
224
|
}
|
|
106
225
|
}
|
|
107
226
|
}
|
|
@@ -112,14 +231,14 @@ function findNxProjectForImportPath(importPath, projects, root = workspace_root_
|
|
|
112
231
|
} = (0, packages_1.getWorkspacePackagesMetadata)(projects));
|
|
113
232
|
}
|
|
114
233
|
if (packageEntryPointsToProjectMap[importPath]) {
|
|
115
|
-
return packageEntryPointsToProjectMap[importPath];
|
|
234
|
+
return { projectConfig: packageEntryPointsToProjectMap[importPath] };
|
|
116
235
|
}
|
|
117
236
|
const project = (0, packages_1.matchImportToWildcardEntryPointsToProjectMap)(wildcardEntryPointsToProjectMap, importPath);
|
|
118
237
|
if (project) {
|
|
119
|
-
return project;
|
|
238
|
+
return { projectConfig: project };
|
|
120
239
|
}
|
|
121
240
|
logger_1.logger.verbose('Unable to find local plugin', possibleTsPaths, projectRootMappings);
|
|
122
|
-
|
|
241
|
+
return null;
|
|
123
242
|
}
|
|
124
243
|
let tsconfigPaths;
|
|
125
244
|
function readTsConfigPaths(root = workspace_root_1.workspaceRoot) {
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runPreTasksExecution = runPreTasksExecution;
|
|
4
4
|
exports.runPostTasksExecution = runPostTasksExecution;
|
|
5
|
+
const nx_json_1 = require("../../config/nx-json");
|
|
5
6
|
const get_plugins_1 = require("./get-plugins");
|
|
6
7
|
const is_on_daemon_1 = require("../../daemon/is-on-daemon");
|
|
7
8
|
const client_1 = require("../../daemon/client/client");
|
|
9
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
8
10
|
async function runPreTasksExecution(pluginContext) {
|
|
9
11
|
if ((0, is_on_daemon_1.isOnDaemon)() || !(0, client_1.isDaemonEnabled)()) {
|
|
10
12
|
performance.mark(`preTasksExecution:start`);
|
|
11
|
-
const plugins = await (0, get_plugins_1.getPlugins)(pluginContext.workspaceRoot);
|
|
13
|
+
const plugins = await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(pluginContext.workspaceRoot), pluginContext.workspaceRoot);
|
|
12
14
|
const envs = await Promise.all(plugins
|
|
13
15
|
.filter((p) => p.preTasksExecution)
|
|
14
16
|
.map(async (plugin) => {
|
|
@@ -43,7 +45,7 @@ function applyProcessEnvs(envs) {
|
|
|
43
45
|
async function runPostTasksExecution(context) {
|
|
44
46
|
if ((0, is_on_daemon_1.isOnDaemon)() || !(0, client_1.isDaemonEnabled)()) {
|
|
45
47
|
performance.mark(`postTasksExecution:start`);
|
|
46
|
-
const plugins = await (0, get_plugins_1.getPlugins)();
|
|
48
|
+
const plugins = await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot));
|
|
47
49
|
await Promise.all(plugins
|
|
48
50
|
.filter((p) => p.postTasksExecution)
|
|
49
51
|
.map(async (plugin) => {
|
|
@@ -2,7 +2,19 @@ export declare let unregisterPluginTSTranspiler: (() => void) | null;
|
|
|
2
2
|
/**
|
|
3
3
|
* Register swc-node or ts-node if they are not currently registered
|
|
4
4
|
* with some default settings which work well for Nx plugins.
|
|
5
|
+
*
|
|
6
|
+
* When the runtime supports native TypeScript stripping and the user hasn't
|
|
7
|
+
* opted out, this is a noop - Node loads plugin `.ts` files directly. The
|
|
8
|
+
* lazy fallback in `handleImport` will call `forceRegisterPluginTSTranspiler`
|
|
9
|
+
* if a plugin uses unsupported syntax (enum, runtime namespace, etc.).
|
|
5
10
|
*/
|
|
6
11
|
export declare function registerPluginTSTranspiler(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Always register swc-node or ts-node + tsconfig-paths, ignoring the native
|
|
14
|
+
* strip preference. Called from the fallback path in `handleImport` when a
|
|
15
|
+
* plugin `.ts` file throws `ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX` under native
|
|
16
|
+
* stripping.
|
|
17
|
+
*/
|
|
18
|
+
export declare function forceRegisterPluginTSTranspiler(): void;
|
|
7
19
|
export declare function pluginTranspilerIsRegistered(): boolean;
|
|
8
20
|
export declare function cleanupPluginTSTranspiler(): void;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unregisterPluginTSTranspiler = void 0;
|
|
4
4
|
exports.registerPluginTSTranspiler = registerPluginTSTranspiler;
|
|
5
|
+
exports.forceRegisterPluginTSTranspiler = forceRegisterPluginTSTranspiler;
|
|
5
6
|
exports.pluginTranspilerIsRegistered = pluginTranspilerIsRegistered;
|
|
6
7
|
exports.cleanupPluginTSTranspiler = cleanupPluginTSTranspiler;
|
|
7
8
|
const node_fs_1 = require("node:fs");
|
|
@@ -10,11 +11,47 @@ const register_1 = require("../../plugins/js/utils/register");
|
|
|
10
11
|
const typescript_1 = require("../../plugins/js/utils/typescript");
|
|
11
12
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
12
13
|
exports.unregisterPluginTSTranspiler = null;
|
|
14
|
+
const NOOP = () => { };
|
|
13
15
|
/**
|
|
14
16
|
* Register swc-node or ts-node if they are not currently registered
|
|
15
17
|
* with some default settings which work well for Nx plugins.
|
|
18
|
+
*
|
|
19
|
+
* When the runtime supports native TypeScript stripping and the user hasn't
|
|
20
|
+
* opted out, this is a noop - Node loads plugin `.ts` files directly. The
|
|
21
|
+
* lazy fallback in `handleImport` will call `forceRegisterPluginTSTranspiler`
|
|
22
|
+
* if a plugin uses unsupported syntax (enum, runtime namespace, etc.).
|
|
16
23
|
*/
|
|
17
24
|
function registerPluginTSTranspiler() {
|
|
25
|
+
if (exports.unregisterPluginTSTranspiler !== null) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if ((0, register_1.isNativeStripPreferred)()) {
|
|
29
|
+
// Sentinel so pluginTranspilerIsRegistered() reports true and callers
|
|
30
|
+
// don't keep retrying. The actual transpiler stays unregistered until
|
|
31
|
+
// a fallback forces it.
|
|
32
|
+
exports.unregisterPluginTSTranspiler = NOOP;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
doRegisterPluginTSTranspiler();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Always register swc-node or ts-node + tsconfig-paths, ignoring the native
|
|
39
|
+
* strip preference. Called from the fallback path in `handleImport` when a
|
|
40
|
+
* plugin `.ts` file throws `ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX` under native
|
|
41
|
+
* stripping.
|
|
42
|
+
*/
|
|
43
|
+
function forceRegisterPluginTSTranspiler() {
|
|
44
|
+
// If the previous registration was the native-strip sentinel, throw it
|
|
45
|
+
// out so we actually wire up swc/ts-node.
|
|
46
|
+
if (exports.unregisterPluginTSTranspiler === NOOP) {
|
|
47
|
+
exports.unregisterPluginTSTranspiler = null;
|
|
48
|
+
}
|
|
49
|
+
if (exports.unregisterPluginTSTranspiler !== null) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
doRegisterPluginTSTranspiler();
|
|
53
|
+
}
|
|
54
|
+
function doRegisterPluginTSTranspiler() {
|
|
18
55
|
// Get the first tsconfig that matches the allowed set
|
|
19
56
|
const tsConfigName = [
|
|
20
57
|
(0, posix_1.join)(workspace_root_1.workspaceRoot, 'tsconfig.base.json'),
|