@nx/js 0.0.0-pr-22179-271588f
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/LICENSE +22 -0
- package/README.md +68 -0
- package/babel.d.ts +13 -0
- package/babel.js +91 -0
- package/executors.json +32 -0
- package/generators.json +46 -0
- package/migrations.json +159 -0
- package/package.json +76 -0
- package/plugins/jest/local-registry.d.ts +1 -0
- package/plugins/jest/local-registry.js +4 -0
- package/src/executors/node/lib/kill-tree.d.ts +2 -0
- package/src/executors/node/lib/kill-tree.js +114 -0
- package/src/executors/node/node-with-require-overrides.d.ts +7 -0
- package/src/executors/node/node-with-require-overrides.js +21 -0
- package/src/executors/node/node.impl.d.ts +7 -0
- package/src/executors/node/node.impl.js +288 -0
- package/src/executors/node/schema.d.ts +18 -0
- package/src/executors/node/schema.json +92 -0
- package/src/executors/release-publish/format-bytes.d.ts +1 -0
- package/src/executors/release-publish/format-bytes.js +28 -0
- package/src/executors/release-publish/log-tar.d.ts +1 -0
- package/src/executors/release-publish/log-tar.js +68 -0
- package/src/executors/release-publish/release-publish.impl.d.ts +5 -0
- package/src/executors/release-publish/release-publish.impl.js +198 -0
- package/src/executors/release-publish/schema.d.ts +8 -0
- package/src/executors/release-publish/schema.json +26 -0
- package/src/executors/swc/schema.json +154 -0
- package/src/executors/swc/swc.impl.d.ts +10 -0
- package/src/executors/swc/swc.impl.js +149 -0
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.d.ts +5 -0
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +62 -0
- package/src/executors/tsc/lib/batch/index.d.ts +4 -0
- package/src/executors/tsc/lib/batch/index.js +7 -0
- package/src/executors/tsc/lib/batch/normalize-tasks-options.d.ts +3 -0
- package/src/executors/tsc/lib/batch/normalize-tasks-options.js +14 -0
- package/src/executors/tsc/lib/batch/types.d.ts +17 -0
- package/src/executors/tsc/lib/batch/types.js +2 -0
- package/src/executors/tsc/lib/batch/watch.d.ts +3 -0
- package/src/executors/tsc/lib/batch/watch.js +56 -0
- package/src/executors/tsc/lib/get-custom-transformers-factory.d.ts +3 -0
- package/src/executors/tsc/lib/get-custom-transformers-factory.js +13 -0
- package/src/executors/tsc/lib/get-task-options.d.ts +3 -0
- package/src/executors/tsc/lib/get-task-options.js +34 -0
- package/src/executors/tsc/lib/get-tsconfig.d.ts +4 -0
- package/src/executors/tsc/lib/get-tsconfig.js +86 -0
- package/src/executors/tsc/lib/index.d.ts +4 -0
- package/src/executors/tsc/lib/index.js +7 -0
- package/src/executors/tsc/lib/normalize-options.d.ts +2 -0
- package/src/executors/tsc/lib/normalize-options.js +39 -0
- package/src/executors/tsc/lib/typescript-compilation.d.ts +29 -0
- package/src/executors/tsc/lib/typescript-compilation.js +203 -0
- package/src/executors/tsc/lib/typescript-diagnostic-reporters.d.ts +3 -0
- package/src/executors/tsc/lib/typescript-diagnostic-reporters.js +37 -0
- package/src/executors/tsc/schema.json +163 -0
- package/src/executors/tsc/tsc.batch-impl.d.ts +5 -0
- package/src/executors/tsc/tsc.batch-impl.js +180 -0
- package/src/executors/tsc/tsc.impl.d.ts +7 -0
- package/src/executors/tsc/tsc.impl.js +97 -0
- package/src/executors/verdaccio/schema.d.ts +7 -0
- package/src/executors/verdaccio/schema.json +35 -0
- package/src/executors/verdaccio/verdaccio.impl.d.ts +12 -0
- package/src/executors/verdaccio/verdaccio.impl.js +220 -0
- package/src/generators/convert-to-swc/convert-to-swc.d.ts +4 -0
- package/src/generators/convert-to-swc/convert-to-swc.js +59 -0
- package/src/generators/convert-to-swc/schema.d.ts +4 -0
- package/src/generators/convert-to-swc/schema.json +36 -0
- package/src/generators/init/files/__fileName__ +20 -0
- package/src/generators/init/init.d.ts +4 -0
- package/src/generators/init/init.js +114 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +36 -0
- package/src/generators/library/files/jest-config/jest.config.__ext__ +30 -0
- package/src/generators/library/files/lib/src/index.ts__tmpl__ +1 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ +7 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.ts__tmpl__ +3 -0
- package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +14 -0
- package/src/generators/library/files/readme/README.md +19 -0
- package/src/generators/library/library.d.ts +16 -0
- package/src/generators/library/library.js +751 -0
- package/src/generators/library/schema.json +151 -0
- package/src/generators/release-version/release-version.d.ts +5 -0
- package/src/generators/release-version/release-version.js +390 -0
- package/src/generators/release-version/schema.d.ts +1 -0
- package/src/generators/release-version/schema.json +67 -0
- package/src/generators/release-version/test-utils/create-workspace-with-package-dependencies.d.ts +16 -0
- package/src/generators/release-version/test-utils/create-workspace-with-package-dependencies.js +40 -0
- package/src/generators/release-version/utils/package.d.ts +12 -0
- package/src/generators/release-version/utils/package.js +34 -0
- package/src/generators/release-version/utils/resolve-local-package-dependencies.d.ts +12 -0
- package/src/generators/release-version/utils/resolve-local-package-dependencies.js +78 -0
- package/src/generators/release-version/utils/resolve-version-spec.d.ts +1 -0
- package/src/generators/release-version/utils/resolve-version-spec.js +29 -0
- package/src/generators/release-version/utils/update-lock-file.d.ts +5 -0
- package/src/generators/release-version/utils/update-lock-file.js +105 -0
- package/src/generators/setup-build/generator.d.ts +4 -0
- package/src/generators/setup-build/generator.js +142 -0
- package/src/generators/setup-build/schema.d.ts +7 -0
- package/src/generators/setup-build/schema.json +42 -0
- package/src/generators/setup-verdaccio/files/config.yml +28 -0
- package/src/generators/setup-verdaccio/generator.d.ts +4 -0
- package/src/generators/setup-verdaccio/generator.js +56 -0
- package/src/generators/setup-verdaccio/schema.d.ts +3 -0
- package/src/generators/setup-verdaccio/schema.json +16 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +28 -0
- package/src/internal.d.ts +4 -0
- package/src/internal.js +15 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.d.ts +2 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.js +77 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.d.ts +2 -0
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +34 -0
- package/src/migrations/update-16-8-2/update-swcrc.d.ts +2 -0
- package/src/migrations/update-16-8-2/update-swcrc.js +23 -0
- package/src/migrations/update-17-0-0/remove-deprecated-build-options.d.ts +6 -0
- package/src/migrations/update-17-0-0/remove-deprecated-build-options.js +30 -0
- package/src/plugins/jest/start-local-registry.d.ts +12 -0
- package/src/plugins/jest/start-local-registry.js +63 -0
- package/src/plugins/rollup/type-definitions.d.ts +8 -0
- package/src/plugins/rollup/type-definitions.js +48 -0
- package/src/utils/add-babel-inputs.d.ts +3 -0
- package/src/utils/add-babel-inputs.js +23 -0
- package/src/utils/add-local-registry-scripts.d.ts +5 -0
- package/src/utils/add-local-registry-scripts.js +77 -0
- package/src/utils/assets/assets.d.ts +10 -0
- package/src/utils/assets/assets.js +36 -0
- package/src/utils/assets/copy-assets-handler.d.ts +32 -0
- package/src/utils/assets/copy-assets-handler.js +154 -0
- package/src/utils/assets/index.d.ts +16 -0
- package/src/utils/assets/index.js +27 -0
- package/src/utils/buildable-libs-utils.d.ts +43 -0
- package/src/utils/buildable-libs-utils.js +375 -0
- package/src/utils/check-dependencies.d.ts +8 -0
- package/src/utils/check-dependencies.js +23 -0
- package/src/utils/code-frames/highlight.d.ts +1 -0
- package/src/utils/code-frames/highlight.js +86 -0
- package/src/utils/code-frames/identifiers.d.ts +5 -0
- package/src/utils/code-frames/identifiers.js +52 -0
- package/src/utils/compiler-helper-dependency.d.ts +18 -0
- package/src/utils/compiler-helper-dependency.js +120 -0
- package/src/utils/find-npm-dependencies.d.ts +9 -0
- package/src/utils/find-npm-dependencies.js +140 -0
- package/src/utils/generate-globs.d.ts +6 -0
- package/src/utils/generate-globs.js +80 -0
- package/src/utils/get-import-path.d.ts +5 -0
- package/src/utils/get-import-path.js +14 -0
- package/src/utils/get-main-file-dir.d.ts +1 -0
- package/src/utils/get-main-file-dir.js +11 -0
- package/src/utils/inline.d.ts +19 -0
- package/src/utils/inline.js +210 -0
- package/src/utils/package-json/create-entry-points.d.ts +1 -0
- package/src/utils/package-json/create-entry-points.js +23 -0
- package/src/utils/package-json/get-npm-scope.d.ts +5 -0
- package/src/utils/package-json/get-npm-scope.js +16 -0
- package/src/utils/package-json/index.d.ts +13 -0
- package/src/utils/package-json/index.js +30 -0
- package/src/utils/package-json/update-package-json.d.ts +30 -0
- package/src/utils/package-json/update-package-json.js +179 -0
- package/src/utils/prettier.d.ts +6 -0
- package/src/utils/prettier.js +34 -0
- package/src/utils/schema.d.ts +87 -0
- package/src/utils/swc/add-swc-config.d.ts +3 -0
- package/src/utils/swc/add-swc-config.js +41 -0
- package/src/utils/swc/add-swc-dependencies.d.ts +3 -0
- package/src/utils/swc/add-swc-dependencies.js +18 -0
- package/src/utils/swc/compile-swc.d.ts +13 -0
- package/src/utils/swc/compile-swc.js +160 -0
- package/src/utils/swc/get-swcrc-path.d.ts +5 -0
- package/src/utils/swc/get-swcrc-path.js +15 -0
- package/src/utils/swc/inline.d.ts +2 -0
- package/src/utils/swc/inline.js +11 -0
- package/src/utils/typescript/__mocks__/plugin-a.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-a.js +5 -0
- package/src/utils/typescript/__mocks__/plugin-b.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-b.js +5 -0
- package/src/utils/typescript/add-tslib-dependencies.d.ts +2 -0
- package/src/utils/typescript/add-tslib-dependencies.js +11 -0
- package/src/utils/typescript/ast-utils.d.ts +32 -0
- package/src/utils/typescript/ast-utils.js +266 -0
- package/src/utils/typescript/compile-typescript-files.d.ts +10 -0
- package/src/utils/typescript/compile-typescript-files.js +43 -0
- package/src/utils/typescript/create-ts-config.d.ts +18 -0
- package/src/utils/typescript/create-ts-config.js +48 -0
- package/src/utils/typescript/ensure-typescript.d.ts +1 -0
- package/src/utils/typescript/ensure-typescript.js +9 -0
- package/src/utils/typescript/get-source-nodes.d.ts +2 -0
- package/src/utils/typescript/get-source-nodes.js +18 -0
- package/src/utils/typescript/load-ts-transformers.d.ts +5 -0
- package/src/utils/typescript/load-ts-transformers.js +62 -0
- package/src/utils/typescript/print-diagnostics.d.ts +1 -0
- package/src/utils/typescript/print-diagnostics.js +18 -0
- package/src/utils/typescript/run-type-check.d.ts +32 -0
- package/src/utils/typescript/run-type-check.js +128 -0
- package/src/utils/typescript/ts-config.d.ts +9 -0
- package/src/utils/typescript/ts-config.js +85 -0
- package/src/utils/typescript/tsnode-register.d.ts +1 -0
- package/src/utils/typescript/tsnode-register.js +24 -0
- package/src/utils/typescript/types.d.ts +18 -0
- package/src/utils/typescript/types.js +2 -0
- package/src/utils/versions.d.ts +17 -0
- package/src/utils/versions.js +21 -0
- package/src/utils/watch-for-single-file-changes.d.ts +1 -0
- package/src/utils/watch-for-single-file-changes.js +22 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"outputCapture": "direct-nodejs",
|
|
4
|
+
"title": "Typescript Build Target",
|
|
5
|
+
"description": "Builds using TypeScript.",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"main": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The name of the main entry-point file.",
|
|
12
|
+
"x-completion-type": "file",
|
|
13
|
+
"x-completion-glob": "main@(.js|.ts|.jsx|.tsx)",
|
|
14
|
+
"x-priority": "important"
|
|
15
|
+
},
|
|
16
|
+
"generateExportsField": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"alias": "exports",
|
|
19
|
+
"description": "Update the output package.json file's 'exports' field. This field is used by Node and bundles.",
|
|
20
|
+
"default": false,
|
|
21
|
+
"x-priority": "important"
|
|
22
|
+
},
|
|
23
|
+
"additionalEntryPoints": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"description": "Additional entry-points to add to exports field in the package.json file.",
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "string"
|
|
28
|
+
},
|
|
29
|
+
"x-priority": "important"
|
|
30
|
+
},
|
|
31
|
+
"rootDir": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "Sets the rootDir for TypeScript compilation. When not defined, it uses the root of project."
|
|
34
|
+
},
|
|
35
|
+
"outputPath": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "The output path of the generated files.",
|
|
38
|
+
"x-completion-type": "directory",
|
|
39
|
+
"x-priority": "important"
|
|
40
|
+
},
|
|
41
|
+
"tsConfig": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "The path to the Typescript configuration file.",
|
|
44
|
+
"x-completion-type": "file",
|
|
45
|
+
"x-completion-glob": "tsconfig.*.json",
|
|
46
|
+
"x-priority": "important"
|
|
47
|
+
},
|
|
48
|
+
"assets": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"description": "List of static assets.",
|
|
51
|
+
"default": [],
|
|
52
|
+
"items": {
|
|
53
|
+
"$ref": "#/definitions/assetPattern"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"watch": {
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"description": "Enable re-building when files change.",
|
|
59
|
+
"default": false
|
|
60
|
+
},
|
|
61
|
+
"clean": {
|
|
62
|
+
"type": "boolean",
|
|
63
|
+
"description": "Remove previous output before build.",
|
|
64
|
+
"default": true
|
|
65
|
+
},
|
|
66
|
+
"transformers": {
|
|
67
|
+
"type": "array",
|
|
68
|
+
"description": "List of TypeScript Transformer Plugins.",
|
|
69
|
+
"default": [],
|
|
70
|
+
"items": {
|
|
71
|
+
"$ref": "#/definitions/transformerPattern"
|
|
72
|
+
},
|
|
73
|
+
"x-priority": "important"
|
|
74
|
+
},
|
|
75
|
+
"external": {
|
|
76
|
+
"description": "A list projects to be treated as external. This feature is experimental",
|
|
77
|
+
"oneOf": [
|
|
78
|
+
{
|
|
79
|
+
"type": "string",
|
|
80
|
+
"enum": ["all", "none"]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"type": "array",
|
|
84
|
+
"items": {
|
|
85
|
+
"type": "string"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"externalBuildTargets": {
|
|
91
|
+
"type": "array",
|
|
92
|
+
"items": {
|
|
93
|
+
"type": "string"
|
|
94
|
+
},
|
|
95
|
+
"description": "List of target names that annotate a build target for a project",
|
|
96
|
+
"default": ["build"]
|
|
97
|
+
},
|
|
98
|
+
"generateLockfile": {
|
|
99
|
+
"type": "boolean",
|
|
100
|
+
"description": "Generate a lockfile (e.g. package-lock.json) that matches the workspace lockfile to ensure package versions match.",
|
|
101
|
+
"default": false,
|
|
102
|
+
"x-priority": "internal"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"required": ["main", "outputPath", "tsConfig"],
|
|
106
|
+
"definitions": {
|
|
107
|
+
"assetPattern": {
|
|
108
|
+
"oneOf": [
|
|
109
|
+
{
|
|
110
|
+
"type": "object",
|
|
111
|
+
"properties": {
|
|
112
|
+
"glob": {
|
|
113
|
+
"type": "string",
|
|
114
|
+
"description": "The pattern to match."
|
|
115
|
+
},
|
|
116
|
+
"input": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"description": "The input directory path in which to apply 'glob'. Defaults to the project root."
|
|
119
|
+
},
|
|
120
|
+
"ignore": {
|
|
121
|
+
"description": "An array of globs to ignore.",
|
|
122
|
+
"type": "array",
|
|
123
|
+
"items": {
|
|
124
|
+
"type": "string"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"output": {
|
|
128
|
+
"type": "string",
|
|
129
|
+
"description": "Absolute path within the output."
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"additionalProperties": false,
|
|
133
|
+
"required": ["glob", "input", "output"]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"type": "string"
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
"transformerPattern": {
|
|
141
|
+
"oneOf": [
|
|
142
|
+
{
|
|
143
|
+
"type": "string"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"type": "object",
|
|
147
|
+
"properties": {
|
|
148
|
+
"name": {
|
|
149
|
+
"type": "string"
|
|
150
|
+
},
|
|
151
|
+
"options": {
|
|
152
|
+
"type": "object",
|
|
153
|
+
"additionalProperties": true
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"additionalProperties": false,
|
|
157
|
+
"required": ["name"]
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"examplesFile": "../../../docs/tsc-examples.md"
|
|
163
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ExecutorContext, TaskGraph } from '@nx/devkit';
|
|
2
|
+
import type { BatchExecutorTaskResult } from 'nx/src/config/misc-interfaces';
|
|
3
|
+
import type { ExecutorOptions } from '../../utils/schema';
|
|
4
|
+
export declare function tscBatchExecutor(taskGraph: TaskGraph, inputs: Record<string, ExecutorOptions>, overrides: ExecutorOptions, context: ExecutorContext): AsyncGenerator<BatchExecutorTaskResult, any, unknown>;
|
|
5
|
+
export default tscBatchExecutor;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tscBatchExecutor = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const async_iterator_1 = require("nx/src/utils/async-iterator");
|
|
7
|
+
const update_package_json_1 = require("../../utils/package-json/update-package-json");
|
|
8
|
+
const tsc_impl_1 = require("./tsc.impl");
|
|
9
|
+
const lib_1 = require("./lib");
|
|
10
|
+
const batch_1 = require("./lib/batch");
|
|
11
|
+
const create_entry_points_1 = require("../../utils/package-json/create-entry-points");
|
|
12
|
+
async function* tscBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
13
|
+
const tasksOptions = (0, batch_1.normalizeTasksOptions)(inputs, context);
|
|
14
|
+
let shouldWatch = false;
|
|
15
|
+
Object.values(tasksOptions).forEach((taskOptions) => {
|
|
16
|
+
if (taskOptions.clean) {
|
|
17
|
+
(0, fs_1.rmSync)(taskOptions.outputPath, { force: true, recursive: true });
|
|
18
|
+
}
|
|
19
|
+
if (taskOptions.watch) {
|
|
20
|
+
shouldWatch = true;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const taskInMemoryTsConfigMap = (0, lib_1.getProcessedTaskTsConfigs)(Object.keys(taskGraph.tasks), tasksOptions, context);
|
|
24
|
+
const tsConfigTaskInfoMap = (0, batch_1.createTaskInfoPerTsConfigMap)(tasksOptions, context, Object.keys(taskGraph.tasks), taskInMemoryTsConfigMap);
|
|
25
|
+
const tsCompilationContext = createTypescriptCompilationContext(tsConfigTaskInfoMap, taskInMemoryTsConfigMap, context);
|
|
26
|
+
const logger = {
|
|
27
|
+
error: (message, tsConfig) => {
|
|
28
|
+
process.stderr.write(message);
|
|
29
|
+
if (tsConfig) {
|
|
30
|
+
tsConfigTaskInfoMap[tsConfig].terminalOutput += message;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
info: (message, tsConfig) => {
|
|
34
|
+
process.stdout.write(message);
|
|
35
|
+
if (tsConfig) {
|
|
36
|
+
tsConfigTaskInfoMap[tsConfig].terminalOutput += message;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
warn: (message, tsConfig) => {
|
|
40
|
+
process.stdout.write(message);
|
|
41
|
+
if (tsConfig) {
|
|
42
|
+
tsConfigTaskInfoMap[tsConfig].terminalOutput += message;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
const processTaskPostCompilation = (tsConfig) => {
|
|
47
|
+
if (tsConfigTaskInfoMap[tsConfig]) {
|
|
48
|
+
const taskInfo = tsConfigTaskInfoMap[tsConfig];
|
|
49
|
+
taskInfo.assetsHandler.processAllAssetsOnceSync();
|
|
50
|
+
(0, update_package_json_1.updatePackageJson)({
|
|
51
|
+
...taskInfo.options,
|
|
52
|
+
additionalEntryPoints: (0, create_entry_points_1.createEntryPoints)(taskInfo.options.additionalEntryPoints, context.root),
|
|
53
|
+
format: [(0, tsc_impl_1.determineModuleFormatFromTsConfig)(tsConfig)],
|
|
54
|
+
// As long as d.ts files match their .js counterparts, we don't need to emit them.
|
|
55
|
+
// TSC can match them correctly based on file names.
|
|
56
|
+
skipTypings: true,
|
|
57
|
+
}, taskInfo.context, taskInfo.projectGraphNode, taskInfo.buildableProjectNodeDependencies);
|
|
58
|
+
taskInfo.endTime = Date.now();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const typescriptCompilation = (0, lib_1.compileTypescriptSolution)(tsCompilationContext, shouldWatch, logger, {
|
|
62
|
+
beforeProjectCompilationCallback: (tsConfig) => {
|
|
63
|
+
if (tsConfigTaskInfoMap[tsConfig]) {
|
|
64
|
+
tsConfigTaskInfoMap[tsConfig].startTime = Date.now();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
afterProjectCompilationCallback: processTaskPostCompilation,
|
|
68
|
+
});
|
|
69
|
+
if (shouldWatch) {
|
|
70
|
+
const taskInfos = Object.values(tsConfigTaskInfoMap);
|
|
71
|
+
const watchAssetsChangesDisposer = await (0, batch_1.watchTaskProjectsFileChangesForAssets)(taskInfos);
|
|
72
|
+
const watchProjectsChangesDisposer = await (0, batch_1.watchTaskProjectsPackageJsonFileChanges)(taskInfos, (changedTaskInfos) => {
|
|
73
|
+
for (const t of changedTaskInfos) {
|
|
74
|
+
(0, update_package_json_1.updatePackageJson)({
|
|
75
|
+
...t.options,
|
|
76
|
+
additionalEntryPoints: (0, create_entry_points_1.createEntryPoints)(t.options.additionalEntryPoints, context.root),
|
|
77
|
+
format: [(0, tsc_impl_1.determineModuleFormatFromTsConfig)(t.options.tsConfig)],
|
|
78
|
+
// As long as d.ts files match their .js counterparts, we don't need to emit them.
|
|
79
|
+
// TSC can match them correctly based on file names.
|
|
80
|
+
skipTypings: true,
|
|
81
|
+
}, t.context, t.projectGraphNode, t.buildableProjectNodeDependencies);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const handleTermination = async (exitCode) => {
|
|
85
|
+
watchAssetsChangesDisposer();
|
|
86
|
+
watchProjectsChangesDisposer();
|
|
87
|
+
process.exit(exitCode);
|
|
88
|
+
};
|
|
89
|
+
process.on('SIGINT', () => handleTermination(128 + 2));
|
|
90
|
+
process.on('SIGTERM', () => handleTermination(128 + 15));
|
|
91
|
+
return yield* mapAsyncIterable(typescriptCompilation, async (iterator) => {
|
|
92
|
+
// drain the iterator, we don't use the results
|
|
93
|
+
await (0, async_iterator_1.getLastValueFromAsyncIterableIterator)(iterator);
|
|
94
|
+
return { value: undefined, done: true };
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const toBatchExecutorTaskResult = (tsConfig, success) => ({
|
|
98
|
+
task: tsConfigTaskInfoMap[tsConfig].task,
|
|
99
|
+
result: {
|
|
100
|
+
success: success,
|
|
101
|
+
terminalOutput: tsConfigTaskInfoMap[tsConfig].terminalOutput,
|
|
102
|
+
startTime: tsConfigTaskInfoMap[tsConfig].startTime,
|
|
103
|
+
endTime: tsConfigTaskInfoMap[tsConfig].endTime,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
let isCompilationDone = false;
|
|
107
|
+
const taskTsConfigsToReport = new Set(Object.keys(taskGraph.tasks).map((t) => taskInMemoryTsConfigMap[t].path));
|
|
108
|
+
let tasksToReportIterator;
|
|
109
|
+
const processSkippedTasks = () => {
|
|
110
|
+
const { value: tsConfig, done } = tasksToReportIterator.next();
|
|
111
|
+
if (done) {
|
|
112
|
+
return { value: undefined, done: true };
|
|
113
|
+
}
|
|
114
|
+
tsConfigTaskInfoMap[tsConfig].startTime = Date.now();
|
|
115
|
+
processTaskPostCompilation(tsConfig);
|
|
116
|
+
return { value: toBatchExecutorTaskResult(tsConfig, true), done: false };
|
|
117
|
+
};
|
|
118
|
+
return yield* mapAsyncIterable(typescriptCompilation, async (iterator) => {
|
|
119
|
+
if (isCompilationDone) {
|
|
120
|
+
return processSkippedTasks();
|
|
121
|
+
}
|
|
122
|
+
const { value, done } = await iterator.next();
|
|
123
|
+
if (done) {
|
|
124
|
+
if (taskTsConfigsToReport.size > 0) {
|
|
125
|
+
/**
|
|
126
|
+
* TS compilation is done but we still have tasks to report. This can
|
|
127
|
+
* happen if, for example, a project is identified as affected, but
|
|
128
|
+
* no file in the TS project is actually changed or if running a
|
|
129
|
+
* task with `--skip-nx-cache` and the outputs are already there. There
|
|
130
|
+
* can still be changes to assets or other files we need to process.
|
|
131
|
+
*
|
|
132
|
+
* Switch to handle the iterator for the tasks we still need to report.
|
|
133
|
+
*/
|
|
134
|
+
isCompilationDone = true;
|
|
135
|
+
tasksToReportIterator = taskTsConfigsToReport.values();
|
|
136
|
+
return processSkippedTasks();
|
|
137
|
+
}
|
|
138
|
+
return { value: undefined, done: true };
|
|
139
|
+
}
|
|
140
|
+
taskTsConfigsToReport.delete(value.tsConfig);
|
|
141
|
+
return {
|
|
142
|
+
value: toBatchExecutorTaskResult(value.tsConfig, value.success),
|
|
143
|
+
done: false,
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
exports.tscBatchExecutor = tscBatchExecutor;
|
|
148
|
+
exports.default = tscBatchExecutor;
|
|
149
|
+
async function* mapAsyncIterable(iterable, nextFn) {
|
|
150
|
+
return yield* {
|
|
151
|
+
[Symbol.asyncIterator]() {
|
|
152
|
+
const iterator = iterable[Symbol.asyncIterator].call(iterable);
|
|
153
|
+
return {
|
|
154
|
+
async next() {
|
|
155
|
+
return await nextFn(iterator);
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function createTypescriptCompilationContext(tsConfigTaskInfoMap, taskInMemoryTsConfigMap, context) {
|
|
162
|
+
const tsCompilationContext = Object.entries(tsConfigTaskInfoMap).reduce((acc, [tsConfig, taskInfo]) => {
|
|
163
|
+
acc[tsConfig] = {
|
|
164
|
+
project: taskInfo.context.projectName,
|
|
165
|
+
tsConfig: taskInfo.tsConfig,
|
|
166
|
+
transformers: taskInfo.options.transformers,
|
|
167
|
+
};
|
|
168
|
+
return acc;
|
|
169
|
+
}, {});
|
|
170
|
+
Object.entries(taskInMemoryTsConfigMap).forEach(([task, tsConfig]) => {
|
|
171
|
+
if (!tsCompilationContext[tsConfig.path]) {
|
|
172
|
+
tsCompilationContext[tsConfig.path] = {
|
|
173
|
+
project: (0, devkit_1.parseTargetString)(task, context).project,
|
|
174
|
+
transformers: [],
|
|
175
|
+
tsConfig: tsConfig,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return tsCompilationContext;
|
|
180
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { TypeScriptCompilationOptions } from '@nx/workspace/src/utilities/typescript/compilation';
|
|
3
|
+
import { ExecutorOptions, NormalizedExecutorOptions } from '../../utils/schema';
|
|
4
|
+
export declare function determineModuleFormatFromTsConfig(absolutePathToTsConfig: string): 'cjs' | 'esm';
|
|
5
|
+
export declare function createTypeScriptCompilationOptions(normalizedOptions: NormalizedExecutorOptions, context: ExecutorContext): TypeScriptCompilationOptions;
|
|
6
|
+
export declare function tscExecutor(_options: ExecutorOptions, context: ExecutorContext): AsyncGenerator<import("../../utils/typescript/compile-typescript-files").TypescriptCompilationResult, any, undefined>;
|
|
7
|
+
export default tscExecutor;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tscExecutor = exports.createTypeScriptCompilationOptions = exports.determineModuleFormatFromTsConfig = void 0;
|
|
4
|
+
const ts = require("typescript");
|
|
5
|
+
const copy_assets_handler_1 = require("../../utils/assets/copy-assets-handler");
|
|
6
|
+
const check_dependencies_1 = require("../../utils/check-dependencies");
|
|
7
|
+
const compiler_helper_dependency_1 = require("../../utils/compiler-helper-dependency");
|
|
8
|
+
const inline_1 = require("../../utils/inline");
|
|
9
|
+
const update_package_json_1 = require("../../utils/package-json/update-package-json");
|
|
10
|
+
const compile_typescript_files_1 = require("../../utils/typescript/compile-typescript-files");
|
|
11
|
+
const watch_for_single_file_changes_1 = require("../../utils/watch-for-single-file-changes");
|
|
12
|
+
const lib_1 = require("./lib");
|
|
13
|
+
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
14
|
+
const create_entry_points_1 = require("../../utils/package-json/create-entry-points");
|
|
15
|
+
function determineModuleFormatFromTsConfig(absolutePathToTsConfig) {
|
|
16
|
+
const tsConfig = (0, ts_config_1.readTsConfig)(absolutePathToTsConfig);
|
|
17
|
+
if (tsConfig.options.module === ts.ModuleKind.ES2015 ||
|
|
18
|
+
tsConfig.options.module === ts.ModuleKind.ES2020 ||
|
|
19
|
+
tsConfig.options.module === ts.ModuleKind.ES2022 ||
|
|
20
|
+
tsConfig.options.module === ts.ModuleKind.ESNext) {
|
|
21
|
+
return 'esm';
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return 'cjs';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.determineModuleFormatFromTsConfig = determineModuleFormatFromTsConfig;
|
|
28
|
+
function createTypeScriptCompilationOptions(normalizedOptions, context) {
|
|
29
|
+
return {
|
|
30
|
+
outputPath: normalizedOptions.outputPath,
|
|
31
|
+
projectName: context.projectName,
|
|
32
|
+
projectRoot: normalizedOptions.projectRoot,
|
|
33
|
+
rootDir: normalizedOptions.rootDir,
|
|
34
|
+
tsConfig: normalizedOptions.tsConfig,
|
|
35
|
+
watch: normalizedOptions.watch,
|
|
36
|
+
deleteOutputPath: normalizedOptions.clean,
|
|
37
|
+
getCustomTransformers: (0, lib_1.getCustomTrasformersFactory)(normalizedOptions.transformers),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.createTypeScriptCompilationOptions = createTypeScriptCompilationOptions;
|
|
41
|
+
async function* tscExecutor(_options, context) {
|
|
42
|
+
const { sourceRoot, root } = context.projectsConfigurations.projects[context.projectName];
|
|
43
|
+
const options = (0, lib_1.normalizeOptions)(_options, context.root, sourceRoot, root);
|
|
44
|
+
const { projectRoot, tmpTsConfig, target, dependencies } = (0, check_dependencies_1.checkDependencies)(context, options.tsConfig);
|
|
45
|
+
if (tmpTsConfig) {
|
|
46
|
+
options.tsConfig = tmpTsConfig;
|
|
47
|
+
}
|
|
48
|
+
const tsLibDependency = (0, compiler_helper_dependency_1.getHelperDependency)(compiler_helper_dependency_1.HelperDependency.tsc, options.tsConfig, dependencies, context.projectGraph);
|
|
49
|
+
if (tsLibDependency) {
|
|
50
|
+
dependencies.push(tsLibDependency);
|
|
51
|
+
}
|
|
52
|
+
const assetHandler = new copy_assets_handler_1.CopyAssetsHandler({
|
|
53
|
+
projectDir: projectRoot,
|
|
54
|
+
rootDir: context.root,
|
|
55
|
+
outputDir: _options.outputPath,
|
|
56
|
+
assets: _options.assets,
|
|
57
|
+
});
|
|
58
|
+
const tsCompilationOptions = createTypeScriptCompilationOptions(options, context);
|
|
59
|
+
const inlineProjectGraph = (0, inline_1.handleInliningBuild)(context, options, tsCompilationOptions.tsConfig);
|
|
60
|
+
if (!(0, inline_1.isInlineGraphEmpty)(inlineProjectGraph)) {
|
|
61
|
+
tsCompilationOptions.rootDir = '.';
|
|
62
|
+
}
|
|
63
|
+
const typescriptCompilation = (0, compile_typescript_files_1.compileTypeScriptFiles)(options, tsCompilationOptions, async () => {
|
|
64
|
+
await assetHandler.processAllAssetsOnce();
|
|
65
|
+
(0, update_package_json_1.updatePackageJson)({
|
|
66
|
+
...options,
|
|
67
|
+
additionalEntryPoints: (0, create_entry_points_1.createEntryPoints)(options.additionalEntryPoints, context.root),
|
|
68
|
+
format: [determineModuleFormatFromTsConfig(options.tsConfig)],
|
|
69
|
+
// As long as d.ts files match their .js counterparts, we don't need to emit them.
|
|
70
|
+
// TSC can match them correctly based on file names.
|
|
71
|
+
skipTypings: true,
|
|
72
|
+
}, context, target, dependencies);
|
|
73
|
+
(0, inline_1.postProcessInlinedDependencies)(tsCompilationOptions.outputPath, tsCompilationOptions.projectRoot, inlineProjectGraph);
|
|
74
|
+
});
|
|
75
|
+
if (options.watch) {
|
|
76
|
+
const disposeWatchAssetChanges = await assetHandler.watchAndProcessOnAssetChange();
|
|
77
|
+
const disposePackageJsonChanges = await (0, watch_for_single_file_changes_1.watchForSingleFileChanges)(context.projectName, options.projectRoot, 'package.json', () => (0, update_package_json_1.updatePackageJson)({
|
|
78
|
+
...options,
|
|
79
|
+
additionalEntryPoints: (0, create_entry_points_1.createEntryPoints)(options.additionalEntryPoints, context.root),
|
|
80
|
+
// As long as d.ts files match their .js counterparts, we don't need to emit them.
|
|
81
|
+
// TSC can match them correctly based on file names.
|
|
82
|
+
skipTypings: true,
|
|
83
|
+
format: [determineModuleFormatFromTsConfig(options.tsConfig)],
|
|
84
|
+
}, context, target, dependencies));
|
|
85
|
+
const handleTermination = async (exitCode) => {
|
|
86
|
+
await typescriptCompilation.close();
|
|
87
|
+
disposeWatchAssetChanges();
|
|
88
|
+
disposePackageJsonChanges();
|
|
89
|
+
process.exit(exitCode);
|
|
90
|
+
};
|
|
91
|
+
process.on('SIGINT', () => handleTermination(128 + 2));
|
|
92
|
+
process.on('SIGTERM', () => handleTermination(128 + 15));
|
|
93
|
+
}
|
|
94
|
+
return yield* typescriptCompilation.iterator;
|
|
95
|
+
}
|
|
96
|
+
exports.tscExecutor = tscExecutor;
|
|
97
|
+
exports.default = tscExecutor;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"title": "Verdaccio Local Registry",
|
|
5
|
+
"description": "Start a local registry with Verdaccio.",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"location": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Location option for npm config",
|
|
12
|
+
"default": "user",
|
|
13
|
+
"enum": ["global", "user", "project", "none"]
|
|
14
|
+
},
|
|
15
|
+
"storage": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Path to the custom storage directory for Verdaccio"
|
|
18
|
+
},
|
|
19
|
+
"port": {
|
|
20
|
+
"type": "number",
|
|
21
|
+
"description": "Port of local registry that Verdaccio should listen to",
|
|
22
|
+
"default": 4873
|
|
23
|
+
},
|
|
24
|
+
"config": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Path to the custom Verdaccio config file"
|
|
27
|
+
},
|
|
28
|
+
"clear": {
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"description": "Clear local registry storage before starting Verdaccio",
|
|
31
|
+
"default": true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"required": ["port"]
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { VerdaccioExecutorSchema } from './schema';
|
|
3
|
+
/**
|
|
4
|
+
* - set npm and yarn to use local registry
|
|
5
|
+
* - start verdaccio
|
|
6
|
+
* - stop local registry when done
|
|
7
|
+
*/
|
|
8
|
+
export declare function verdaccioExecutor(options: VerdaccioExecutorSchema, context: ExecutorContext): Promise<{
|
|
9
|
+
success: boolean;
|
|
10
|
+
port: number;
|
|
11
|
+
}>;
|
|
12
|
+
export default verdaccioExecutor;
|