@nx/js 16.4.0-beta.1 → 16.4.0-beta.13
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/babel.js +3 -1
- package/executors.json +1 -0
- package/generators.json +12 -0
- package/migrations.json +12 -0
- package/package.json +6 -5
- package/plugins/jest/local-registry.d.ts +1 -0
- package/plugins/jest/local-registry.js +4 -0
- package/src/executors/node/node.impl.d.ts +1 -0
- package/src/executors/node/node.impl.js +59 -11
- 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 +59 -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 +63 -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 +8 -0
- package/src/executors/tsc/lib/get-task-options.js +51 -0
- package/src/executors/tsc/lib/get-tsconfig.d.ts +4 -0
- package/src/executors/tsc/lib/get-tsconfig.js +138 -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 +32 -0
- package/src/executors/tsc/lib/typescript-compilation.d.ts +29 -0
- package/src/executors/tsc/lib/typescript-compilation.js +206 -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/tsc.batch-impl.d.ts +5 -0
- package/src/executors/tsc/tsc.batch-impl.js +137 -0
- package/src/executors/tsc/tsc.impl.d.ts +0 -1
- package/src/executors/tsc/tsc.impl.js +4 -39
- package/src/executors/verdaccio/verdaccio.impl.d.ts +1 -0
- package/src/executors/verdaccio/verdaccio.impl.js +93 -45
- package/src/generators/library/library.js +2 -10
- package/src/generators/library/schema.json +7 -6
- package/src/generators/setup-build/generator.d.ts +5 -0
- package/src/generators/setup-build/generator.js +133 -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 +5 -6
- package/src/generators/setup-verdaccio/generator.js +5 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/plugins/jest/start-local-registry.d.ts +12 -0
- package/src/plugins/jest/start-local-registry.js +61 -0
- package/src/utils/add-babel-inputs.d.ts +1 -0
- package/src/utils/add-babel-inputs.js +2 -0
- package/src/utils/add-local-registry-scripts.d.ts +5 -0
- package/src/utils/add-local-registry-scripts.js +57 -0
- package/src/utils/assets/copy-assets-handler.d.ts +5 -1
- package/src/utils/assets/copy-assets-handler.js +34 -23
- package/src/utils/compiler-helper-dependency.d.ts +2 -1
- package/src/utils/compiler-helper-dependency.js +13 -2
- package/src/utils/inline.d.ts +1 -1
- package/src/utils/inline.js +3 -3
- package/src/utils/minimal-publish-script.js +2 -5
- package/src/utils/schema.d.ts +3 -2
- package/src/utils/swc/add-swc-config.d.ts +1 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/src/generators/setup-verdaccio/files/htpasswd +0 -1
package/babel.js
CHANGED
|
@@ -5,6 +5,8 @@ module.exports = function (api, options = {}) {
|
|
|
5
5
|
var _a, _b, _c;
|
|
6
6
|
api.assertVersion(7);
|
|
7
7
|
const isModern = api.caller((caller) => caller === null || caller === void 0 ? void 0 : caller.isModern);
|
|
8
|
+
// use by @nx/cypress react component testing to prevent core js build issues
|
|
9
|
+
const isTest = api.caller((caller) => caller === null || caller === void 0 ? void 0 : caller.isTest);
|
|
8
10
|
// This is set by `@nx/rollup:rollup` executor
|
|
9
11
|
const isNxPackage = api.caller((caller) => caller === null || caller === void 0 ? void 0 : caller.isNxPackage);
|
|
10
12
|
const emitDecoratorMetadata = api.caller((caller) => { var _a; return (_a = caller === null || caller === void 0 ? void 0 : caller.emitDecoratorMetadata) !== null && _a !== void 0 ? _a : true; });
|
|
@@ -19,7 +21,7 @@ module.exports = function (api, options = {}) {
|
|
|
19
21
|
// For Jest tests, NODE_ENV is set as 'test' and we only want to set target as Node.
|
|
20
22
|
// All other options will fail in Jest since Node does not support some ES features
|
|
21
23
|
// such as import syntax.
|
|
22
|
-
process.env.NODE_ENV === 'test'
|
|
24
|
+
isTest || process.env.NODE_ENV === 'test'
|
|
23
25
|
? { targets: { node: 'current' }, loose: true }
|
|
24
26
|
: {
|
|
25
27
|
// Allow importing core-js in entrypoint and use browserslist to select polyfills.
|
package/executors.json
CHANGED
package/generators.json
CHANGED
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
"schema": "./src/generators/setup-verdaccio/schema.json",
|
|
30
30
|
"alias": ["verdaccio"],
|
|
31
31
|
"description": "Setup Verdaccio for local package management."
|
|
32
|
+
},
|
|
33
|
+
"setup-build": {
|
|
34
|
+
"factory": "./src/generators/setup-build/generator#setupBuildSchematic",
|
|
35
|
+
"schema": "./src/generators/setup-build/schema.json",
|
|
36
|
+
"alias": ["build"],
|
|
37
|
+
"description": "setup-build generator"
|
|
32
38
|
}
|
|
33
39
|
},
|
|
34
40
|
"generators": {
|
|
@@ -59,6 +65,12 @@
|
|
|
59
65
|
"schema": "./src/generators/setup-verdaccio/schema.json",
|
|
60
66
|
"alias": ["verdaccio"],
|
|
61
67
|
"description": "Setup Verdaccio for local package management."
|
|
68
|
+
},
|
|
69
|
+
"setup-build": {
|
|
70
|
+
"factory": "./src/generators/setup-build/generator",
|
|
71
|
+
"schema": "./src/generators/setup-build/schema.json",
|
|
72
|
+
"alias": ["build"],
|
|
73
|
+
"description": "setup-build generator"
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
76
|
}
|
package/migrations.json
CHANGED
|
@@ -80,6 +80,18 @@
|
|
|
80
80
|
"version": "~5.0.2"
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
},
|
|
84
|
+
"16.4.0": {
|
|
85
|
+
"version": "16.4.0-beta.11",
|
|
86
|
+
"x-prompt": "Do you want to update to TypeScript v5.1?",
|
|
87
|
+
"requires": {
|
|
88
|
+
"typescript": ">=5.0.0 <5.1.0"
|
|
89
|
+
},
|
|
90
|
+
"packages": {
|
|
91
|
+
"typescript": {
|
|
92
|
+
"version": "~5.1.3"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
83
95
|
}
|
|
84
96
|
}
|
|
85
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "16.4.0-beta.
|
|
3
|
+
"version": "16.4.0-beta.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
|
|
6
6
|
"repository": {
|
|
@@ -39,14 +39,15 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.15.0",
|
|
40
40
|
"@babel/preset-typescript": "^7.15.0",
|
|
41
41
|
"@babel/runtime": "^7.14.8",
|
|
42
|
-
"@nrwl/js": "16.4.0-beta.
|
|
43
|
-
"@nx/devkit": "16.4.0-beta.
|
|
44
|
-
"@nx/workspace": "16.4.0-beta.
|
|
42
|
+
"@nrwl/js": "16.4.0-beta.13",
|
|
43
|
+
"@nx/devkit": "16.4.0-beta.13",
|
|
44
|
+
"@nx/workspace": "16.4.0-beta.13",
|
|
45
45
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
46
46
|
"babel-plugin-const-enum": "^1.0.1",
|
|
47
47
|
"babel-plugin-macros": "^2.8.0",
|
|
48
48
|
"babel-plugin-transform-typescript-metadata": "^0.3.1",
|
|
49
49
|
"chalk": "^4.1.0",
|
|
50
|
+
"detect-port": "^1.5.1",
|
|
50
51
|
"fast-glob": "3.2.7",
|
|
51
52
|
"fs-extra": "^11.1.0",
|
|
52
53
|
"ignore": "^5.0.4",
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"access": "public"
|
|
69
70
|
},
|
|
70
71
|
"types": "./src/index.d.ts",
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "d81afedfcc8d07db8cdb9b0e9286de0321ee184e"
|
|
72
73
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../src/plugins/jest/start-local-registry';
|
|
@@ -2,5 +2,6 @@ import { ExecutorContext } from '@nx/devkit';
|
|
|
2
2
|
import { NodeExecutorOptions } from './schema';
|
|
3
3
|
export declare function nodeExecutor(options: NodeExecutorOptions, context: ExecutorContext): AsyncGenerator<{
|
|
4
4
|
success: boolean;
|
|
5
|
+
options?: Record<string, any>;
|
|
5
6
|
}, void, undefined>;
|
|
6
7
|
export default nodeExecutor;
|
|
@@ -7,10 +7,12 @@ const child_process_1 = require("child_process");
|
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
const client_1 = require("nx/src/daemon/client/client");
|
|
9
9
|
const crypto_1 = require("crypto");
|
|
10
|
+
const path = require("path");
|
|
10
11
|
const path_1 = require("path");
|
|
11
12
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
12
13
|
const buildable_libs_utils_1 = require("../../utils/buildable-libs-utils");
|
|
13
14
|
const kill_tree_1 = require("./lib/kill-tree");
|
|
15
|
+
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
14
16
|
function debounce(fn, wait) {
|
|
15
17
|
let timeoutId;
|
|
16
18
|
return () => {
|
|
@@ -25,13 +27,25 @@ function nodeExecutor(options, context) {
|
|
|
25
27
|
(_a = (_e = process.env).NODE_ENV) !== null && _a !== void 0 ? _a : (_e.NODE_ENV = (_b = context === null || context === void 0 ? void 0 : context.configurationName) !== null && _b !== void 0 ? _b : 'development');
|
|
26
28
|
const project = context.projectGraph.nodes[context.projectName];
|
|
27
29
|
const buildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context.projectGraph);
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
+
let buildOptions;
|
|
31
|
+
if (project.data.targets[buildTarget.target]) {
|
|
32
|
+
buildOptions = Object.assign(Object.assign({}, (_c = project.data.targets[buildTarget.target]) === null || _c === void 0 ? void 0 : _c.options), options.buildTargetOptions);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
30
35
|
throw new Error(`Cannot find build target ${chalk.bold(options.buildTarget)} for project ${chalk.bold(context.projectName)}`);
|
|
31
36
|
}
|
|
37
|
+
if (options.waitUntilTargets && options.waitUntilTargets.length > 0) {
|
|
38
|
+
const results = yield tslib_1.__await(runWaitUntilTargets(options, context));
|
|
39
|
+
for (const [i, result] of results.entries()) {
|
|
40
|
+
if (!result.success) {
|
|
41
|
+
throw new Error(`Wait until target failed: ${options.waitUntilTargets[i]}.`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
32
45
|
// Re-map buildable workspace projects to their output directory.
|
|
33
46
|
const mappings = calculateResolveMappings(context, options);
|
|
34
|
-
const
|
|
47
|
+
const outputFileName = (_d = buildOptions.outputFileName) !== null && _d !== void 0 ? _d : `${path.parse(buildOptions.main).name}.js`;
|
|
48
|
+
const fileToRun = (0, path_1.join)(context.root, buildOptions.outputPath, outputFileName);
|
|
35
49
|
const tasks = [];
|
|
36
50
|
let currentTask = null;
|
|
37
51
|
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues((0, async_iterable_1.createAsyncIterable)(({ done, next, error }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -56,9 +70,7 @@ function nodeExecutor(options, context) {
|
|
|
56
70
|
let buildFailed = false;
|
|
57
71
|
// Run the build
|
|
58
72
|
task.promise = new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
task.childProcess = (0, child_process_1.exec)(`npx nx run ${context.projectName}:${buildTarget.target}${buildTarget.configuration
|
|
60
|
-
? `:${buildTarget.configuration}`
|
|
61
|
-
: ''}`, {
|
|
73
|
+
task.childProcess = (0, child_process_1.exec)(`npx nx run ${context.projectName}:${buildTarget.target}${buildTarget.configuration ? `:${buildTarget.configuration}` : ''}`, {
|
|
62
74
|
cwd: context.root,
|
|
63
75
|
}, (error, stdout, stderr) => {
|
|
64
76
|
if (
|
|
@@ -90,15 +102,16 @@ function nodeExecutor(options, context) {
|
|
|
90
102
|
// Run the program
|
|
91
103
|
task.promise = new Promise((resolve, reject) => {
|
|
92
104
|
var _a;
|
|
93
|
-
task.childProcess = (0, child_process_1.fork)((0, devkit_1.joinPathFragments)(__dirname, 'node-with-require-overrides'), (_a = options.
|
|
105
|
+
task.childProcess = (0, child_process_1.fork)((0, devkit_1.joinPathFragments)(__dirname, 'node-with-require-overrides'), (_a = options.args) !== null && _a !== void 0 ? _a : [], {
|
|
94
106
|
execArgv: getExecArgv(options),
|
|
95
107
|
stdio: [0, 1, 'pipe', 'ipc'],
|
|
96
|
-
env: Object.assign(Object.assign({}, process.env), { NX_FILE_TO_RUN: fileToRun, NX_MAPPINGS: JSON.stringify(mappings) }),
|
|
108
|
+
env: Object.assign(Object.assign({}, process.env), { NX_FILE_TO_RUN: fileToRunCorrectPath(fileToRun), NX_MAPPINGS: JSON.stringify(mappings) }),
|
|
97
109
|
});
|
|
98
110
|
task.childProcess.stderr.on('data', (data) => {
|
|
99
111
|
// Don't log out error if task is killed and new one has started.
|
|
100
112
|
// This could happen if a new build is triggered while new process is starting, since the operation is not atomic.
|
|
101
|
-
|
|
113
|
+
// Log the error in normal mode
|
|
114
|
+
if (!options.watch || !task.killed) {
|
|
102
115
|
devkit_1.logger.error(data.toString());
|
|
103
116
|
}
|
|
104
117
|
});
|
|
@@ -110,7 +123,7 @@ function nodeExecutor(options, context) {
|
|
|
110
123
|
done();
|
|
111
124
|
resolve();
|
|
112
125
|
});
|
|
113
|
-
next({ success: true });
|
|
126
|
+
next({ success: true, options: buildOptions });
|
|
114
127
|
});
|
|
115
128
|
}),
|
|
116
129
|
stop: (signal = 'SIGTERM') => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -171,7 +184,9 @@ function nodeExecutor(options, context) {
|
|
|
171
184
|
}
|
|
172
185
|
exports.nodeExecutor = nodeExecutor;
|
|
173
186
|
function getExecArgv(options) {
|
|
174
|
-
|
|
187
|
+
var _a;
|
|
188
|
+
const args = ((_a = options.runtimeArgs) !== null && _a !== void 0 ? _a : (options.runtimeArgs = []));
|
|
189
|
+
args.push('-r', require.resolve('source-map-support/register'));
|
|
175
190
|
if (options.inspect === true) {
|
|
176
191
|
options.inspect = "inspect" /* InspectType.Inspect */;
|
|
177
192
|
}
|
|
@@ -190,4 +205,37 @@ function calculateResolveMappings(context, options) {
|
|
|
190
205
|
return m;
|
|
191
206
|
}, {});
|
|
192
207
|
}
|
|
208
|
+
function runWaitUntilTargets(options, context) {
|
|
209
|
+
return Promise.all(options.waitUntilTargets.map((waitUntilTarget) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
const target = (0, devkit_1.parseTargetString)(waitUntilTarget, context.projectGraph);
|
|
211
|
+
const output = yield (0, devkit_1.runExecutor)(target, {}, context);
|
|
212
|
+
return new Promise((resolve) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
213
|
+
let event = yield output.next();
|
|
214
|
+
// Resolve after first event
|
|
215
|
+
resolve(event.value);
|
|
216
|
+
// Continue iterating
|
|
217
|
+
while (!event.done) {
|
|
218
|
+
event = yield output.next();
|
|
219
|
+
}
|
|
220
|
+
}));
|
|
221
|
+
})));
|
|
222
|
+
}
|
|
223
|
+
function fileToRunCorrectPath(fileToRun) {
|
|
224
|
+
if (!(0, fileutils_1.fileExists)(fileToRun)) {
|
|
225
|
+
const cjsFile = fileToRun.replace(/\.js$/, '.cjs');
|
|
226
|
+
if ((0, fileutils_1.fileExists)(cjsFile)) {
|
|
227
|
+
fileToRun = cjsFile;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
const mjsFile = fileToRun.replace(/\.js$/, '.mjs');
|
|
231
|
+
if ((0, fileutils_1.fileExists)(mjsFile)) {
|
|
232
|
+
fileToRun = mjsFile;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
throw new Error(`Could not find ${fileToRun}. Make sure your build succeeded.`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return fileToRun;
|
|
240
|
+
}
|
|
193
241
|
exports.default = nodeExecutor;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { NormalizedExecutorOptions } from '../../../../utils/schema';
|
|
3
|
+
import type { TypescriptInMemoryTsConfig } from '../typescript-compilation';
|
|
4
|
+
import type { TaskInfo } from './types';
|
|
5
|
+
export declare function createTaskInfoPerTsConfigMap(tasksOptions: Record<string, NormalizedExecutorOptions>, context: ExecutorContext, tasks: string[], taskInMemoryTsConfigMap: Record<string, TypescriptInMemoryTsConfig>): Record<string, TaskInfo>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTaskInfoPerTsConfigMap = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const copy_assets_handler_1 = require("../../../../utils/assets/copy-assets-handler");
|
|
7
|
+
const buildable_libs_utils_1 = require("../../../../utils/buildable-libs-utils");
|
|
8
|
+
const get_task_options_1 = require("../get-task-options");
|
|
9
|
+
const taskTsConfigCache = new Set();
|
|
10
|
+
function createTaskInfoPerTsConfigMap(tasksOptions, context, tasks, taskInMemoryTsConfigMap) {
|
|
11
|
+
const tsConfigTaskInfoMap = {};
|
|
12
|
+
processTasksAndPopulateTsConfigTaskInfoMap(tsConfigTaskInfoMap, tasksOptions, context, tasks, taskInMemoryTsConfigMap);
|
|
13
|
+
return tsConfigTaskInfoMap;
|
|
14
|
+
}
|
|
15
|
+
exports.createTaskInfoPerTsConfigMap = createTaskInfoPerTsConfigMap;
|
|
16
|
+
function processTasksAndPopulateTsConfigTaskInfoMap(tsConfigTaskInfoMap, tasksOptions, context, tasks, taskInMemoryTsConfigMap) {
|
|
17
|
+
var _a;
|
|
18
|
+
for (const taskName of tasks) {
|
|
19
|
+
if (taskTsConfigCache.has(taskName)) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const tsConfig = taskInMemoryTsConfigMap[taskName];
|
|
23
|
+
if (!tsConfig) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
let taskOptions = (_a = tasksOptions[taskName]) !== null && _a !== void 0 ? _a : (0, get_task_options_1.getTaskWithTscExecutorOptions)(taskName, context);
|
|
27
|
+
if (taskOptions) {
|
|
28
|
+
const taskInfo = createTaskInfo(taskName, taskOptions, context, tsConfig);
|
|
29
|
+
const tsConfigPath = (0, path_1.join)(context.root, (0, path_1.relative)(context.root, taskOptions.tsConfig));
|
|
30
|
+
tsConfigTaskInfoMap[tsConfigPath] = taskInfo;
|
|
31
|
+
taskTsConfigCache.add(taskName);
|
|
32
|
+
}
|
|
33
|
+
processTasksAndPopulateTsConfigTaskInfoMap(tsConfigTaskInfoMap, tasksOptions, context, context.taskGraph.dependencies[taskName], taskInMemoryTsConfigMap);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function createTaskInfo(taskName, taskOptions, context, tsConfig) {
|
|
37
|
+
const target = (0, devkit_1.parseTargetString)(taskName, context.projectGraph);
|
|
38
|
+
const taskContext = Object.assign(Object.assign({}, context), {
|
|
39
|
+
// batch executors don't get these in the context, we provide them
|
|
40
|
+
// here per task
|
|
41
|
+
projectName: target.project, targetName: target.target, configurationName: target.configuration });
|
|
42
|
+
const assetsHandler = new copy_assets_handler_1.CopyAssetsHandler({
|
|
43
|
+
projectDir: taskOptions.projectRoot,
|
|
44
|
+
rootDir: context.root,
|
|
45
|
+
outputDir: taskOptions.outputPath,
|
|
46
|
+
assets: taskOptions.assets,
|
|
47
|
+
});
|
|
48
|
+
const { target: projectGraphNode, dependencies: buildableProjectNodeDependencies, } = (0, buildable_libs_utils_1.calculateProjectDependencies)(context.projectGraph, context.root, context.taskGraph.tasks[taskName].target.project, context.taskGraph.tasks[taskName].target.target, context.taskGraph.tasks[taskName].target.configuration);
|
|
49
|
+
return {
|
|
50
|
+
task: taskName,
|
|
51
|
+
options: taskOptions,
|
|
52
|
+
context: taskContext,
|
|
53
|
+
assetsHandler,
|
|
54
|
+
buildableProjectNodeDependencies,
|
|
55
|
+
projectGraphNode,
|
|
56
|
+
tsConfig,
|
|
57
|
+
terminalOutput: '',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./build-task-info-per-tsconfig-map"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./normalize-tasks-options"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./watch"), exports);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { ExecutorOptions, NormalizedExecutorOptions } from '../../../../utils/schema';
|
|
3
|
+
export declare function normalizeTasksOptions(inputs: Record<string, ExecutorOptions>, context: ExecutorContext): Record<string, NormalizedExecutorOptions>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeTasksOptions = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const normalize_options_1 = require("../normalize-options");
|
|
6
|
+
function normalizeTasksOptions(inputs, context) {
|
|
7
|
+
return Object.entries(inputs).reduce((tasksOptions, [taskName, options]) => {
|
|
8
|
+
const { project } = (0, devkit_1.parseTargetString)(taskName, context.projectGraph);
|
|
9
|
+
const { sourceRoot, root } = context.projectsConfigurations.projects[project];
|
|
10
|
+
tasksOptions[taskName] = (0, normalize_options_1.normalizeOptions)(options, context.root, sourceRoot, root);
|
|
11
|
+
return tasksOptions;
|
|
12
|
+
}, {});
|
|
13
|
+
}
|
|
14
|
+
exports.normalizeTasksOptions = normalizeTasksOptions;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ExecutorContext, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
|
+
import type { CopyAssetsHandler } from '../../../../utils/assets/copy-assets-handler';
|
|
3
|
+
import type { DependentBuildableProjectNode } from '../../../../utils/buildable-libs-utils';
|
|
4
|
+
import type { NormalizedExecutorOptions } from '../../../../utils/schema';
|
|
5
|
+
import type { TypescriptInMemoryTsConfig } from '../typescript-compilation';
|
|
6
|
+
export interface TaskInfo {
|
|
7
|
+
task: string;
|
|
8
|
+
options: NormalizedExecutorOptions;
|
|
9
|
+
context: ExecutorContext;
|
|
10
|
+
assetsHandler: CopyAssetsHandler;
|
|
11
|
+
buildableProjectNodeDependencies: DependentBuildableProjectNode[];
|
|
12
|
+
projectGraphNode: ProjectGraphProjectNode;
|
|
13
|
+
tsConfig: TypescriptInMemoryTsConfig;
|
|
14
|
+
startTime?: number;
|
|
15
|
+
endTime?: number;
|
|
16
|
+
terminalOutput: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { TaskInfo } from './types';
|
|
2
|
+
export declare function watchTaskProjectsPackageJsonFileChanges(taskInfos: TaskInfo[], callback: (changedTaskInfos: TaskInfo[]) => void): Promise<() => void>;
|
|
3
|
+
export declare function watchTaskProjectsFileChangesForAssets(taskInfos: TaskInfo[]): Promise<() => void>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.watchTaskProjectsFileChangesForAssets = exports.watchTaskProjectsPackageJsonFileChanges = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const client_1 = require("nx/src/daemon/client/client");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
function watchTaskProjectsPackageJsonFileChanges(taskInfos, callback) {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
const projects = [];
|
|
11
|
+
const packageJsonTaskInfoMap = new Map();
|
|
12
|
+
taskInfos.forEach((t) => {
|
|
13
|
+
projects.push(t.context.projectName);
|
|
14
|
+
packageJsonTaskInfoMap.set((0, path_1.join)(t.options.projectRoot, 'package.json'), t);
|
|
15
|
+
});
|
|
16
|
+
const unregisterFileWatcher = yield client_1.daemonClient.registerFileWatcher({ watchProjects: projects }, (err, data) => {
|
|
17
|
+
var _a;
|
|
18
|
+
if (err === 'closed') {
|
|
19
|
+
devkit_1.logger.error(`Watch error: Daemon closed the connection`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
else if (err) {
|
|
23
|
+
devkit_1.logger.error(`Watch error: ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown'}`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const changedTasks = [];
|
|
27
|
+
data.changedFiles.forEach((file) => {
|
|
28
|
+
if (packageJsonTaskInfoMap.has(file.path)) {
|
|
29
|
+
changedTasks.push(packageJsonTaskInfoMap.get(file.path));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (changedTasks.length) {
|
|
33
|
+
callback(changedTasks);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return () => unregisterFileWatcher();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.watchTaskProjectsPackageJsonFileChanges = watchTaskProjectsPackageJsonFileChanges;
|
|
41
|
+
function watchTaskProjectsFileChangesForAssets(taskInfos) {
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const unregisterFileWatcher = yield client_1.daemonClient.registerFileWatcher({
|
|
44
|
+
watchProjects: taskInfos.map((t) => t.context.projectName),
|
|
45
|
+
includeDependentProjects: true,
|
|
46
|
+
includeGlobalWorkspaceFiles: true,
|
|
47
|
+
}, (err, data) => {
|
|
48
|
+
var _a;
|
|
49
|
+
if (err === 'closed') {
|
|
50
|
+
devkit_1.logger.error(`Watch error: Daemon closed the connection`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
else if (err) {
|
|
54
|
+
devkit_1.logger.error(`Watch error: ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown'}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
taskInfos.forEach((t) => t.assetsHandler.processWatchEvents(data.changedFiles));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return () => unregisterFileWatcher();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.watchTaskProjectsFileChangesForAssets = watchTaskProjectsFileChangesForAssets;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCustomTrasformersFactory = void 0;
|
|
4
|
+
const load_ts_transformers_1 = require("../../../utils/typescript/load-ts-transformers");
|
|
5
|
+
function getCustomTrasformersFactory(transformers) {
|
|
6
|
+
const { compilerPluginHooks } = (0, load_ts_transformers_1.loadTsTransformers)(transformers);
|
|
7
|
+
return (program) => ({
|
|
8
|
+
before: compilerPluginHooks.beforeHooks.map((hook) => hook(program)),
|
|
9
|
+
after: compilerPluginHooks.afterHooks.map((hook) => hook(program)),
|
|
10
|
+
afterDeclarations: compilerPluginHooks.afterDeclarationsHooks.map((hook) => hook(program)),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.getCustomTrasformersFactory = getCustomTrasformersFactory;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { NormalizedExecutorOptions } from '../../../utils/schema';
|
|
3
|
+
export declare function getTaskOptions(taskName: string, context: ExecutorContext): NormalizedExecutorOptions | {
|
|
4
|
+
tsConfig: string | null;
|
|
5
|
+
rootDir: string;
|
|
6
|
+
outputPath: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function getTaskWithTscExecutorOptions(taskName: string, context: ExecutorContext): NormalizedExecutorOptions | null;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTaskWithTscExecutorOptions = exports.getTaskOptions = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const normalize_options_1 = require("./normalize-options");
|
|
7
|
+
function getTaskOptions(taskName, context) {
|
|
8
|
+
const result = getTaskWithTscExecutorOptions(taskName, context);
|
|
9
|
+
if (result) {
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
const { taskOptions, root, projectNode, target } = parseTaskInfo(taskName, context);
|
|
13
|
+
const outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)({ overrides: context.taskGraph.tasks[taskName].overrides, target }, projectNode);
|
|
14
|
+
const outputPath = outputs.length
|
|
15
|
+
? (0, path_1.join)(context.root, outputs[0])
|
|
16
|
+
: (0, path_1.join)(context.root, 'dist', root);
|
|
17
|
+
const rootDir = (0, path_1.join)(context.root, root);
|
|
18
|
+
const tsConfig = taskOptions.tsConfig
|
|
19
|
+
? (0, path_1.join)(context.root, taskOptions.tsConfig)
|
|
20
|
+
: null;
|
|
21
|
+
return { tsConfig, rootDir, outputPath };
|
|
22
|
+
}
|
|
23
|
+
exports.getTaskOptions = getTaskOptions;
|
|
24
|
+
const tasksOptionsCache = new Map();
|
|
25
|
+
function getTaskWithTscExecutorOptions(taskName, context) {
|
|
26
|
+
if (tasksOptionsCache.has(taskName)) {
|
|
27
|
+
return tasksOptionsCache.get(taskName);
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const { taskOptions, sourceRoot, root } = parseTaskInfo(taskName, context);
|
|
31
|
+
const normalizedTaskOptions = (0, normalize_options_1.normalizeOptions)(taskOptions, context.root, sourceRoot, root);
|
|
32
|
+
tasksOptionsCache.set(taskName, normalizedTaskOptions);
|
|
33
|
+
return normalizedTaskOptions;
|
|
34
|
+
}
|
|
35
|
+
catch (_a) {
|
|
36
|
+
tasksOptionsCache.set(taskName, null);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.getTaskWithTscExecutorOptions = getTaskWithTscExecutorOptions;
|
|
41
|
+
function parseTaskInfo(taskName, context) {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const target = context.taskGraph.tasks[taskName].target;
|
|
44
|
+
const projectNode = context.projectGraph.nodes[target.project];
|
|
45
|
+
const targetConfig = (_a = projectNode.data.targets) === null || _a === void 0 ? void 0 : _a[target.target];
|
|
46
|
+
const { sourceRoot, root } = projectNode.data;
|
|
47
|
+
const taskOptions = Object.assign(Object.assign({}, targetConfig.options), (target.configuration
|
|
48
|
+
? (_b = targetConfig.configurations) === null || _b === void 0 ? void 0 : _b[target.configuration]
|
|
49
|
+
: {}));
|
|
50
|
+
return { taskOptions, root, sourceRoot, projectNode, target };
|
|
51
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { NormalizedExecutorOptions } from '../../../utils/schema';
|
|
3
|
+
import type { TypescriptInMemoryTsConfig } from './typescript-compilation';
|
|
4
|
+
export declare function getProcessedTaskTsConfigs(tasks: string[], tasksOptions: Record<string, NormalizedExecutorOptions>, context: ExecutorContext): Record<string, TypescriptInMemoryTsConfig>;
|