@nx/js 16.8.0-beta.3 → 16.8.0-beta.5
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 +7 -8
- package/package.json +5 -5
- package/src/executors/node/lib/kill-tree.js +42 -45
- package/src/executors/node/node.impl.js +190 -189
- package/src/executors/node/schema.json +1 -1
- package/src/executors/swc/swc.impl.js +82 -70
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +7 -4
- package/src/executors/tsc/lib/batch/watch.js +42 -49
- package/src/executors/tsc/lib/get-task-options.js +8 -6
- package/src/executors/tsc/lib/get-tsconfig.js +16 -5
- package/src/executors/tsc/lib/normalize-options.js +9 -2
- package/src/executors/tsc/lib/typescript-compilation.js +21 -24
- package/src/executors/tsc/tsc.batch-impl.js +133 -132
- package/src/executors/tsc/tsc.impl.js +54 -50
- package/src/executors/verdaccio/verdaccio.impl.js +64 -55
- package/src/generators/convert-to-swc/convert-to-swc.js +6 -9
- package/src/generators/init/init.js +86 -92
- package/src/generators/library/library.d.ts +1 -1
- package/src/generators/library/library.js +290 -203
- package/src/generators/setup-build/generator.js +120 -113
- package/src/generators/setup-verdaccio/generator.js +45 -50
- package/src/migrations/update-13-8-5/update-node-executor.js +17 -21
- package/src/migrations/update-13-8-5/update-swcrc.js +23 -27
- package/src/migrations/update-14-1-5/update-swcrc-path.js +17 -20
- package/src/migrations/update-15-8-0/rename-swcrc-config.js +57 -60
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +19 -24
- package/src/plugins/jest/start-local-registry.js +4 -6
- package/src/plugins/rollup/type-definitions.js +21 -24
- package/src/utils/add-babel-inputs.js +1 -2
- package/src/utils/assets/assets.js +1 -2
- package/src/utils/assets/copy-assets-handler.js +48 -59
- package/src/utils/assets/index.js +20 -23
- package/src/utils/buildable-libs-utils.js +9 -13
- package/src/utils/find-npm-dependencies.d.ts +1 -0
- package/src/utils/find-npm-dependencies.js +25 -15
- package/src/utils/generate-globs.js +3 -3
- package/src/utils/inline.js +5 -10
- package/src/utils/package-json/get-npm-scope.js +2 -2
- package/src/utils/package-json/index.js +22 -25
- package/src/utils/package-json/update-package-json.js +26 -23
- package/src/utils/prettier.js +21 -24
- package/src/utils/swc/compile-swc.js +101 -106
- package/src/utils/typescript/compile-typescript-files.js +7 -8
- package/src/utils/typescript/print-diagnostics.js +13 -16
- package/src/utils/typescript/run-type-check.js +62 -59
- package/src/utils/typescript/ts-config.js +3 -5
- package/src/utils/typescript/tsnode-register.js +1 -1
- package/src/utils/watch-for-single-file-changes.js +13 -17
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compileSwcWatch = exports.compileSwc = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const child_process_1 = require("child_process");
|
|
7
6
|
const fs_extra_1 = require("fs-extra");
|
|
@@ -31,117 +30,113 @@ function getTypeCheckOptions(normalizedOptions) {
|
|
|
31
30
|
}
|
|
32
31
|
return typeCheckOptions;
|
|
33
32
|
}
|
|
34
|
-
function compileSwc(context, normalizedOptions, postCompilationCallback) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
cwd: normalizedOptions.swcCliOptions.swcCwd,
|
|
43
|
-
});
|
|
44
|
-
devkit_1.logger.log(swcCmdLog.replace(/\n/, ''));
|
|
45
|
-
const isCompileSuccess = swcCmdLog.includes('Successfully compiled');
|
|
46
|
-
if (normalizedOptions.skipTypeCheck) {
|
|
47
|
-
yield postCompilationCallback();
|
|
48
|
-
return { success: isCompileSuccess };
|
|
49
|
-
}
|
|
50
|
-
const { errors, warnings } = yield (0, run_type_check_1.runTypeCheck)(getTypeCheckOptions(normalizedOptions));
|
|
51
|
-
const hasErrors = errors.length > 0;
|
|
52
|
-
const hasWarnings = warnings.length > 0;
|
|
53
|
-
if (hasErrors || hasWarnings) {
|
|
54
|
-
yield (0, print_diagnostics_1.printDiagnostics)(errors, warnings);
|
|
55
|
-
}
|
|
56
|
-
yield postCompilationCallback();
|
|
57
|
-
return {
|
|
58
|
-
success: !hasErrors && isCompileSuccess,
|
|
59
|
-
outfile: normalizedOptions.mainOutputPath,
|
|
60
|
-
};
|
|
33
|
+
async function compileSwc(context, normalizedOptions, postCompilationCallback) {
|
|
34
|
+
devkit_1.logger.log(`Compiling with SWC for ${context.projectName}...`);
|
|
35
|
+
if (normalizedOptions.clean) {
|
|
36
|
+
(0, fs_extra_1.removeSync)(normalizedOptions.outputPath);
|
|
37
|
+
}
|
|
38
|
+
const swcCmdLog = (0, child_process_1.execSync)(getSwcCmd(normalizedOptions.swcCliOptions), {
|
|
39
|
+
encoding: 'utf8',
|
|
40
|
+
cwd: normalizedOptions.swcCliOptions.swcCwd,
|
|
61
41
|
});
|
|
42
|
+
devkit_1.logger.log(swcCmdLog.replace(/\n/, ''));
|
|
43
|
+
const isCompileSuccess = swcCmdLog.includes('Successfully compiled');
|
|
44
|
+
if (normalizedOptions.skipTypeCheck) {
|
|
45
|
+
await postCompilationCallback();
|
|
46
|
+
return { success: isCompileSuccess };
|
|
47
|
+
}
|
|
48
|
+
const { errors, warnings } = await (0, run_type_check_1.runTypeCheck)(getTypeCheckOptions(normalizedOptions));
|
|
49
|
+
const hasErrors = errors.length > 0;
|
|
50
|
+
const hasWarnings = warnings.length > 0;
|
|
51
|
+
if (hasErrors || hasWarnings) {
|
|
52
|
+
await (0, print_diagnostics_1.printDiagnostics)(errors, warnings);
|
|
53
|
+
}
|
|
54
|
+
await postCompilationCallback();
|
|
55
|
+
return {
|
|
56
|
+
success: !hasErrors && isCompileSuccess,
|
|
57
|
+
outfile: normalizedOptions.mainOutputPath,
|
|
58
|
+
};
|
|
62
59
|
}
|
|
63
60
|
exports.compileSwc = compileSwc;
|
|
64
|
-
function compileSwcWatch(context, normalizedOptions, postCompilationCallback) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
initialPostCompile = false;
|
|
95
|
-
}
|
|
96
|
-
if (normalizedOptions.skipTypeCheck) {
|
|
97
|
-
next(getResult(swcStatus));
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (!typeCheckOptions) {
|
|
101
|
-
typeCheckOptions = getTypeCheckOptions(normalizedOptions);
|
|
102
|
-
}
|
|
103
|
-
const delayed = delay(5000);
|
|
104
|
-
next(getResult(yield Promise.race([
|
|
105
|
-
delayed
|
|
106
|
-
.start()
|
|
107
|
-
.then(() => ({ tscStatus: false, type: 'timeout' })),
|
|
108
|
-
(0, run_type_check_1.runTypeCheck)(typeCheckOptions).then(({ errors, warnings }) => {
|
|
109
|
-
const hasErrors = errors.length > 0;
|
|
110
|
-
if (hasErrors) {
|
|
111
|
-
(0, print_diagnostics_1.printDiagnostics)(errors, warnings);
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
tscStatus: !hasErrors,
|
|
115
|
-
type: 'tsc',
|
|
116
|
-
};
|
|
117
|
-
}),
|
|
118
|
-
]).then(({ type, tscStatus }) => {
|
|
119
|
-
if (type === 'tsc') {
|
|
120
|
-
delayed.cancel();
|
|
121
|
-
return tscStatus && swcStatus;
|
|
122
|
-
}
|
|
123
|
-
return swcStatus;
|
|
124
|
-
})));
|
|
61
|
+
async function* compileSwcWatch(context, normalizedOptions, postCompilationCallback) {
|
|
62
|
+
const getResult = (success) => ({
|
|
63
|
+
success,
|
|
64
|
+
outfile: normalizedOptions.mainOutputPath,
|
|
65
|
+
});
|
|
66
|
+
let typeCheckOptions;
|
|
67
|
+
let initialPostCompile = true;
|
|
68
|
+
if (normalizedOptions.clean) {
|
|
69
|
+
(0, fs_extra_1.removeSync)(normalizedOptions.outputPath);
|
|
70
|
+
}
|
|
71
|
+
return yield* (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
|
|
72
|
+
let processOnExit;
|
|
73
|
+
let stdoutOnData;
|
|
74
|
+
let stderrOnData;
|
|
75
|
+
let watcherOnExit;
|
|
76
|
+
const swcWatcher = (0, child_process_1.exec)(getSwcCmd(normalizedOptions.swcCliOptions, true), { cwd: normalizedOptions.swcCliOptions.swcCwd });
|
|
77
|
+
processOnExit = () => {
|
|
78
|
+
swcWatcher.kill();
|
|
79
|
+
done();
|
|
80
|
+
process.off('SIGINT', processOnExit);
|
|
81
|
+
process.off('SIGTERM', processOnExit);
|
|
82
|
+
process.off('exit', processOnExit);
|
|
83
|
+
};
|
|
84
|
+
stdoutOnData = async (data) => {
|
|
85
|
+
process.stdout.write(data);
|
|
86
|
+
if (!data.startsWith('Watching')) {
|
|
87
|
+
const swcStatus = data.includes('Successfully');
|
|
88
|
+
if (initialPostCompile) {
|
|
89
|
+
await postCompilationCallback();
|
|
90
|
+
initialPostCompile = false;
|
|
125
91
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
process.stderr.write(err);
|
|
129
|
-
if (err.includes('Debugger attached.')) {
|
|
92
|
+
if (normalizedOptions.skipTypeCheck) {
|
|
93
|
+
next(getResult(swcStatus));
|
|
130
94
|
return;
|
|
131
95
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
96
|
+
if (!typeCheckOptions) {
|
|
97
|
+
typeCheckOptions = getTypeCheckOptions(normalizedOptions);
|
|
98
|
+
}
|
|
99
|
+
const delayed = delay(5000);
|
|
100
|
+
next(getResult(await Promise.race([
|
|
101
|
+
delayed
|
|
102
|
+
.start()
|
|
103
|
+
.then(() => ({ tscStatus: false, type: 'timeout' })),
|
|
104
|
+
(0, run_type_check_1.runTypeCheck)(typeCheckOptions).then(({ errors, warnings }) => {
|
|
105
|
+
const hasErrors = errors.length > 0;
|
|
106
|
+
if (hasErrors) {
|
|
107
|
+
(0, print_diagnostics_1.printDiagnostics)(errors, warnings);
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
tscStatus: !hasErrors,
|
|
111
|
+
type: 'tsc',
|
|
112
|
+
};
|
|
113
|
+
}),
|
|
114
|
+
]).then(({ type, tscStatus }) => {
|
|
115
|
+
if (type === 'tsc') {
|
|
116
|
+
delayed.cancel();
|
|
117
|
+
return tscStatus && swcStatus;
|
|
118
|
+
}
|
|
119
|
+
return swcStatus;
|
|
120
|
+
})));
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
stderrOnData = (err) => {
|
|
124
|
+
process.stderr.write(err);
|
|
125
|
+
if (err.includes('Debugger attached.')) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
next(getResult(false));
|
|
129
|
+
};
|
|
130
|
+
watcherOnExit = () => {
|
|
131
|
+
done();
|
|
132
|
+
swcWatcher.off('exit', watcherOnExit);
|
|
133
|
+
};
|
|
134
|
+
swcWatcher.stdout.on('data', stdoutOnData);
|
|
135
|
+
swcWatcher.stderr.on('data', stderrOnData);
|
|
136
|
+
process.on('SIGINT', processOnExit);
|
|
137
|
+
process.on('SIGTERM', processOnExit);
|
|
138
|
+
process.on('exit', processOnExit);
|
|
139
|
+
swcWatcher.on('exit', watcherOnExit);
|
|
145
140
|
});
|
|
146
141
|
}
|
|
147
142
|
exports.compileSwcWatch = compileSwcWatch;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compileTypeScriptFiles = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const compilation_1 = require("@nx/workspace/src/utilities/typescript/compilation");
|
|
6
5
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
7
6
|
const TYPESCRIPT_FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES = 6194;
|
|
@@ -18,14 +17,14 @@ function compileTypeScriptFiles(normalizedOptions, tscOptions, postCompilationCa
|
|
|
18
17
|
});
|
|
19
18
|
let tearDown;
|
|
20
19
|
return {
|
|
21
|
-
iterator: (0, async_iterable_1.createAsyncIterable)(({ next, done }) =>
|
|
20
|
+
iterator: (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
|
|
22
21
|
if (normalizedOptions.watch) {
|
|
23
|
-
const host = (0, compilation_1.compileTypeScriptWatcher)(tscOptions, (d) =>
|
|
22
|
+
const host = (0, compilation_1.compileTypeScriptWatcher)(tscOptions, async (d) => {
|
|
24
23
|
if (d.code === TYPESCRIPT_FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES) {
|
|
25
|
-
|
|
24
|
+
await postCompilationCallback();
|
|
26
25
|
next(getResult(getErrorCountFromMessage(d.messageText) === 0));
|
|
27
26
|
}
|
|
28
|
-
})
|
|
27
|
+
});
|
|
29
28
|
tearDown = () => {
|
|
30
29
|
host.close();
|
|
31
30
|
done();
|
|
@@ -33,12 +32,12 @@ function compileTypeScriptFiles(normalizedOptions, tscOptions, postCompilationCa
|
|
|
33
32
|
}
|
|
34
33
|
else {
|
|
35
34
|
const { success } = (0, compilation_1.compileTypeScript)(tscOptions);
|
|
36
|
-
|
|
35
|
+
await postCompilationCallback();
|
|
37
36
|
next(getResult(success));
|
|
38
37
|
done();
|
|
39
38
|
}
|
|
40
|
-
})
|
|
41
|
-
close: () => tearDown
|
|
39
|
+
}),
|
|
40
|
+
close: () => tearDown?.(),
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
exports.compileTypeScriptFiles = compileTypeScriptFiles;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printDiagnostics = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.log(`Found ${warnings.length} warnings.`);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
4
|
+
async function printDiagnostics(errors = [], warnings = []) {
|
|
5
|
+
if (errors.length > 0) {
|
|
6
|
+
errors.forEach((err) => {
|
|
7
|
+
console.log(`${err}\n`);
|
|
8
|
+
});
|
|
9
|
+
console.log(`Found ${errors.length} error${errors.length > 1 ? 's' : ''}.`);
|
|
10
|
+
}
|
|
11
|
+
else if (warnings.length > 0) {
|
|
12
|
+
warnings.forEach((err) => {
|
|
13
|
+
console.log(`${err}\n`);
|
|
14
|
+
});
|
|
15
|
+
console.log(`Found ${warnings.length} warnings.`);
|
|
16
|
+
}
|
|
20
17
|
}
|
|
21
18
|
exports.printDiagnostics = printDiagnostics;
|
|
@@ -1,74 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFormattedDiagnostic = exports.runTypeCheck = exports.runTypeCheckWatch = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const chalk = require("chalk");
|
|
6
5
|
const path = require("path");
|
|
7
6
|
const code_frames_1 = require("nx/src/utils/code-frames");
|
|
8
7
|
const highlight_1 = require("../code-frames/highlight");
|
|
9
8
|
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
10
|
-
function runTypeCheckWatch(options, callback) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
});
|
|
9
|
+
async function runTypeCheckWatch(options, callback) {
|
|
10
|
+
const { ts, workspaceRoot, config, compilerOptions } = await setupTypeScript(options);
|
|
11
|
+
const host = ts.createWatchCompilerHost(config.fileNames, compilerOptions, ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram);
|
|
12
|
+
const originalOnWatchStatusChange = host.onWatchStatusChange;
|
|
13
|
+
host.onWatchStatusChange = (diagnostic, newLine, opts, errorCount) => {
|
|
14
|
+
originalOnWatchStatusChange?.(diagnostic, newLine, opts, errorCount);
|
|
15
|
+
callback(diagnostic, getFormattedDiagnostic(ts, workspaceRoot, diagnostic), errorCount);
|
|
16
|
+
};
|
|
17
|
+
const watchProgram = ts.createWatchProgram(host);
|
|
18
|
+
const program = watchProgram.getProgram().getProgram();
|
|
19
|
+
const diagnostics = ts.getPreEmitDiagnostics(program);
|
|
20
|
+
return {
|
|
21
|
+
close: watchProgram.close.bind(watchProgram),
|
|
22
|
+
preEmitErrors: diagnostics
|
|
23
|
+
.filter((d) => d.category === ts.DiagnosticCategory.Error)
|
|
24
|
+
.map((d) => getFormattedDiagnostic(ts, workspaceRoot, d)),
|
|
25
|
+
preEmitWarnings: diagnostics
|
|
26
|
+
.filter((d) => d.category === ts.DiagnosticCategory.Warning)
|
|
27
|
+
.map((d) => getFormattedDiagnostic(ts, workspaceRoot, d)),
|
|
28
|
+
};
|
|
32
29
|
}
|
|
33
30
|
exports.runTypeCheckWatch = runTypeCheckWatch;
|
|
34
|
-
function runTypeCheck(options) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
async function runTypeCheck(options) {
|
|
32
|
+
const { ts, workspaceRoot, cacheDir, config, compilerOptions } = await setupTypeScript(options);
|
|
33
|
+
let program;
|
|
34
|
+
let incremental = false;
|
|
35
|
+
if (compilerOptions.incremental && cacheDir) {
|
|
36
|
+
incremental = true;
|
|
37
|
+
program = ts.createIncrementalProgram({
|
|
38
|
+
rootNames: config.fileNames,
|
|
39
|
+
options: {
|
|
40
|
+
...compilerOptions,
|
|
41
|
+
incremental: true,
|
|
42
|
+
tsBuildInfoFile: path.join(cacheDir, '.tsbuildinfo'),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
program = ts.createProgram(config.fileNames, compilerOptions);
|
|
48
|
+
}
|
|
49
|
+
const result = program.emit();
|
|
50
|
+
const allDiagnostics = ts
|
|
51
|
+
.getPreEmitDiagnostics(program)
|
|
52
|
+
.concat(result.diagnostics);
|
|
53
|
+
return getTypeCheckResult(ts, allDiagnostics, workspaceRoot, config.fileNames.length, program.getSourceFiles().length, incremental);
|
|
55
54
|
}
|
|
56
55
|
exports.runTypeCheck = runTypeCheck;
|
|
57
|
-
function setupTypeScript(options) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
56
|
+
async function setupTypeScript(options) {
|
|
57
|
+
const ts = await Promise.resolve().then(() => require('typescript'));
|
|
58
|
+
const { workspaceRoot, tsConfigPath, cacheDir, incremental, rootDir } = options;
|
|
59
|
+
const config = (0, ts_config_1.readTsConfig)(tsConfigPath);
|
|
60
|
+
if (config.errors.length) {
|
|
61
|
+
const errorMessages = config.errors.map((e) => e.messageText).join('\n');
|
|
62
|
+
throw new Error(`Invalid config file due to following: ${errorMessages}`);
|
|
63
|
+
}
|
|
64
|
+
const emitOptions = options.mode === 'emitDeclarationOnly'
|
|
65
|
+
? { emitDeclarationOnly: true, declaration: true, outDir: options.outDir }
|
|
66
|
+
: { noEmit: true };
|
|
67
|
+
const compilerOptions = {
|
|
68
|
+
...config.options,
|
|
69
|
+
skipLibCheck: true,
|
|
70
|
+
...emitOptions,
|
|
71
|
+
incremental,
|
|
72
|
+
rootDir: rootDir || config.options.rootDir,
|
|
73
|
+
};
|
|
74
|
+
return { ts, workspaceRoot, cacheDir, config, compilerOptions };
|
|
72
75
|
}
|
|
73
76
|
function getTypeCheckResult(ts, allDiagnostics, workspaceRoot, inputFilesCount, totalFilesCount, incremental = false) {
|
|
74
77
|
const errors = allDiagnostics
|
|
@@ -46,9 +46,8 @@ function getRootTsConfigFileName(tree) {
|
|
|
46
46
|
exports.getRootTsConfigFileName = getRootTsConfigFileName;
|
|
47
47
|
function addTsConfigPath(tree, importPath, lookupPaths) {
|
|
48
48
|
(0, devkit_1.updateJson)(tree, getRootTsConfigPathInTree(tree), (json) => {
|
|
49
|
-
var _a;
|
|
50
49
|
const c = json.compilerOptions;
|
|
51
|
-
|
|
50
|
+
c.paths ??= {};
|
|
52
51
|
if (c.paths[importPath]) {
|
|
53
52
|
throw new Error(`You already have a library using the import path "${importPath}". Make sure to specify a unique one.`);
|
|
54
53
|
}
|
|
@@ -58,8 +57,7 @@ function addTsConfigPath(tree, importPath, lookupPaths) {
|
|
|
58
57
|
}
|
|
59
58
|
exports.addTsConfigPath = addTsConfigPath;
|
|
60
59
|
function readTsConfigPaths(tsConfig) {
|
|
61
|
-
|
|
62
|
-
tsConfig !== null && tsConfig !== void 0 ? tsConfig : (tsConfig = getRootTsConfigPath());
|
|
60
|
+
tsConfig ??= getRootTsConfigPath();
|
|
63
61
|
try {
|
|
64
62
|
if (!tsModule) {
|
|
65
63
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
@@ -72,7 +70,7 @@ function readTsConfigPaths(tsConfig) {
|
|
|
72
70
|
else {
|
|
73
71
|
config = tsConfig;
|
|
74
72
|
}
|
|
75
|
-
if (
|
|
73
|
+
if (config.options?.paths) {
|
|
76
74
|
return config.options.paths;
|
|
77
75
|
}
|
|
78
76
|
else {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tsNodeRegister = void 0;
|
|
4
4
|
function tsNodeRegister(file, tsConfig) {
|
|
5
|
-
if (!
|
|
5
|
+
if (!file?.endsWith('.ts'))
|
|
6
6
|
return;
|
|
7
7
|
// Register TS compiler lazily
|
|
8
8
|
require('ts-node').register({
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.watchForSingleFileChanges = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const client_1 = require("nx/src/daemon/client/client");
|
|
7
6
|
const path_1 = require("path");
|
|
8
|
-
function watchForSingleFileChanges(projectName, projectRoot, relativeFilePath, callback) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
callback();
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return () => unregisterFileWatcher();
|
|
7
|
+
async function watchForSingleFileChanges(projectName, projectRoot, relativeFilePath, callback) {
|
|
8
|
+
const unregisterFileWatcher = await client_1.daemonClient.registerFileWatcher({ watchProjects: [projectName] }, (err, data) => {
|
|
9
|
+
if (err === 'closed') {
|
|
10
|
+
devkit_1.logger.error(`Watch error: Daemon closed the connection`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
else if (err) {
|
|
14
|
+
devkit_1.logger.error(`Watch error: ${err?.message ?? 'Unknown'}`);
|
|
15
|
+
}
|
|
16
|
+
else if (data.changedFiles.some((file) => file.path == (0, path_1.join)(projectRoot, relativeFilePath))) {
|
|
17
|
+
callback();
|
|
18
|
+
}
|
|
24
19
|
});
|
|
20
|
+
return () => unregisterFileWatcher();
|
|
25
21
|
}
|
|
26
22
|
exports.watchForSingleFileChanges = watchForSingleFileChanges;
|