@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.
Files changed (49) hide show
  1. package/babel.js +7 -8
  2. package/package.json +5 -5
  3. package/src/executors/node/lib/kill-tree.js +42 -45
  4. package/src/executors/node/node.impl.js +190 -189
  5. package/src/executors/node/schema.json +1 -1
  6. package/src/executors/swc/swc.impl.js +82 -70
  7. package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +7 -4
  8. package/src/executors/tsc/lib/batch/watch.js +42 -49
  9. package/src/executors/tsc/lib/get-task-options.js +8 -6
  10. package/src/executors/tsc/lib/get-tsconfig.js +16 -5
  11. package/src/executors/tsc/lib/normalize-options.js +9 -2
  12. package/src/executors/tsc/lib/typescript-compilation.js +21 -24
  13. package/src/executors/tsc/tsc.batch-impl.js +133 -132
  14. package/src/executors/tsc/tsc.impl.js +54 -50
  15. package/src/executors/verdaccio/verdaccio.impl.js +64 -55
  16. package/src/generators/convert-to-swc/convert-to-swc.js +6 -9
  17. package/src/generators/init/init.js +86 -92
  18. package/src/generators/library/library.d.ts +1 -1
  19. package/src/generators/library/library.js +290 -203
  20. package/src/generators/setup-build/generator.js +120 -113
  21. package/src/generators/setup-verdaccio/generator.js +45 -50
  22. package/src/migrations/update-13-8-5/update-node-executor.js +17 -21
  23. package/src/migrations/update-13-8-5/update-swcrc.js +23 -27
  24. package/src/migrations/update-14-1-5/update-swcrc-path.js +17 -20
  25. package/src/migrations/update-15-8-0/rename-swcrc-config.js +57 -60
  26. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
  27. package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +19 -24
  28. package/src/plugins/jest/start-local-registry.js +4 -6
  29. package/src/plugins/rollup/type-definitions.js +21 -24
  30. package/src/utils/add-babel-inputs.js +1 -2
  31. package/src/utils/assets/assets.js +1 -2
  32. package/src/utils/assets/copy-assets-handler.js +48 -59
  33. package/src/utils/assets/index.js +20 -23
  34. package/src/utils/buildable-libs-utils.js +9 -13
  35. package/src/utils/find-npm-dependencies.d.ts +1 -0
  36. package/src/utils/find-npm-dependencies.js +25 -15
  37. package/src/utils/generate-globs.js +3 -3
  38. package/src/utils/inline.js +5 -10
  39. package/src/utils/package-json/get-npm-scope.js +2 -2
  40. package/src/utils/package-json/index.js +22 -25
  41. package/src/utils/package-json/update-package-json.js +26 -23
  42. package/src/utils/prettier.js +21 -24
  43. package/src/utils/swc/compile-swc.js +101 -106
  44. package/src/utils/typescript/compile-typescript-files.js +7 -8
  45. package/src/utils/typescript/print-diagnostics.js +13 -16
  46. package/src/utils/typescript/run-type-check.js +62 -59
  47. package/src/utils/typescript/ts-config.js +3 -5
  48. package/src/utils/typescript/tsnode-register.js +1 -1
  49. 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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
- devkit_1.logger.log(`Compiling with SWC for ${context.projectName}...`);
37
- if (normalizedOptions.clean) {
38
- (0, fs_extra_1.removeSync)(normalizedOptions.outputPath);
39
- }
40
- const swcCmdLog = (0, child_process_1.execSync)(getSwcCmd(normalizedOptions.swcCliOptions), {
41
- encoding: 'utf8',
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
- return tslib_1.__asyncGenerator(this, arguments, function* compileSwcWatch_1() {
66
- const getResult = (success) => ({
67
- success,
68
- outfile: normalizedOptions.mainOutputPath,
69
- });
70
- let typeCheckOptions;
71
- let initialPostCompile = true;
72
- if (normalizedOptions.clean) {
73
- (0, fs_extra_1.removeSync)(normalizedOptions.outputPath);
74
- }
75
- return yield tslib_1.__await(yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues((0, async_iterable_1.createAsyncIterable)(({ next, done }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
76
- let processOnExit;
77
- let stdoutOnData;
78
- let stderrOnData;
79
- let watcherOnExit;
80
- const swcWatcher = (0, child_process_1.exec)(getSwcCmd(normalizedOptions.swcCliOptions, true), { cwd: normalizedOptions.swcCliOptions.swcCwd });
81
- processOnExit = () => {
82
- swcWatcher.kill();
83
- done();
84
- process.off('SIGINT', processOnExit);
85
- process.off('SIGTERM', processOnExit);
86
- process.off('exit', processOnExit);
87
- };
88
- stdoutOnData = (data) => tslib_1.__awaiter(this, void 0, void 0, function* () {
89
- process.stdout.write(data);
90
- if (!data.startsWith('Watching')) {
91
- const swcStatus = data.includes('Successfully');
92
- if (initialPostCompile) {
93
- yield postCompilationCallback();
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
- stderrOnData = (err) => {
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
- next(getResult(false));
133
- };
134
- watcherOnExit = () => {
135
- done();
136
- swcWatcher.off('exit', watcherOnExit);
137
- };
138
- swcWatcher.stdout.on('data', stdoutOnData);
139
- swcWatcher.stderr.on('data', stderrOnData);
140
- process.on('SIGINT', processOnExit);
141
- process.on('SIGTERM', processOnExit);
142
- process.on('exit', processOnExit);
143
- swcWatcher.on('exit', watcherOnExit);
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 }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ iterator: (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
22
21
  if (normalizedOptions.watch) {
23
- const host = (0, compilation_1.compileTypeScriptWatcher)(tscOptions, (d) => tslib_1.__awaiter(this, void 0, void 0, function* () {
22
+ const host = (0, compilation_1.compileTypeScriptWatcher)(tscOptions, async (d) => {
24
23
  if (d.code === TYPESCRIPT_FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES) {
25
- yield postCompilationCallback();
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
- yield postCompilationCallback();
35
+ await postCompilationCallback();
37
36
  next(getResult(success));
38
37
  done();
39
38
  }
40
- })),
41
- close: () => tearDown === null || tearDown === void 0 ? void 0 : 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
- const tslib_1 = require("tslib");
5
- function printDiagnostics(errors = [], warnings = []) {
6
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
7
- if (errors.length > 0) {
8
- errors.forEach((err) => {
9
- console.log(`${err}\n`);
10
- });
11
- console.log(`Found ${errors.length} error${errors.length > 1 ? 's' : ''}.`);
12
- }
13
- else if (warnings.length > 0) {
14
- warnings.forEach((err) => {
15
- console.log(`${err}\n`);
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- const { ts, workspaceRoot, config, compilerOptions } = yield setupTypeScript(options);
13
- const host = ts.createWatchCompilerHost(config.fileNames, compilerOptions, ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram);
14
- const originalOnWatchStatusChange = host.onWatchStatusChange;
15
- host.onWatchStatusChange = (diagnostic, newLine, opts, errorCount) => {
16
- originalOnWatchStatusChange === null || originalOnWatchStatusChange === void 0 ? void 0 : originalOnWatchStatusChange(diagnostic, newLine, opts, errorCount);
17
- callback(diagnostic, getFormattedDiagnostic(ts, workspaceRoot, diagnostic), errorCount);
18
- };
19
- const watchProgram = ts.createWatchProgram(host);
20
- const program = watchProgram.getProgram().getProgram();
21
- const diagnostics = ts.getPreEmitDiagnostics(program);
22
- return {
23
- close: watchProgram.close.bind(watchProgram),
24
- preEmitErrors: diagnostics
25
- .filter((d) => d.category === ts.DiagnosticCategory.Error)
26
- .map((d) => getFormattedDiagnostic(ts, workspaceRoot, d)),
27
- preEmitWarnings: diagnostics
28
- .filter((d) => d.category === ts.DiagnosticCategory.Warning)
29
- .map((d) => getFormattedDiagnostic(ts, workspaceRoot, d)),
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
- const { ts, workspaceRoot, cacheDir, config, compilerOptions } = yield setupTypeScript(options);
37
- let program;
38
- let incremental = false;
39
- if (compilerOptions.incremental && cacheDir) {
40
- incremental = true;
41
- program = ts.createIncrementalProgram({
42
- rootNames: config.fileNames,
43
- options: Object.assign(Object.assign({}, compilerOptions), { incremental: true, tsBuildInfoFile: path.join(cacheDir, '.tsbuildinfo') }),
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);
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
59
- const ts = yield Promise.resolve().then(() => require('typescript'));
60
- const { workspaceRoot, tsConfigPath, cacheDir, incremental, rootDir } = options;
61
- const config = (0, ts_config_1.readTsConfig)(tsConfigPath);
62
- if (config.errors.length) {
63
- const errorMessages = config.errors.map((e) => e.messageText).join('\n');
64
- throw new Error(`Invalid config file due to following: ${errorMessages}`);
65
- }
66
- const emitOptions = options.mode === 'emitDeclarationOnly'
67
- ? { emitDeclarationOnly: true, declaration: true, outDir: options.outDir }
68
- : { noEmit: true };
69
- const compilerOptions = Object.assign(Object.assign(Object.assign(Object.assign({}, config.options), { skipLibCheck: true }), emitOptions), { incremental, rootDir: rootDir || config.options.rootDir });
70
- return { ts, workspaceRoot, cacheDir, config, compilerOptions };
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
- (_a = c.paths) !== null && _a !== void 0 ? _a : (c.paths = {});
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
- var _a;
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 ((_a = config.options) === null || _a === void 0 ? void 0 : _a.paths) {
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 (!(file === null || file === void 0 ? void 0 : file.endsWith('.ts')))
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- const unregisterFileWatcher = yield client_1.daemonClient.registerFileWatcher({ watchProjects: [projectName] }, (err, data) => {
11
- var _a;
12
- if (err === 'closed') {
13
- devkit_1.logger.error(`Watch error: Daemon closed the connection`);
14
- process.exit(1);
15
- }
16
- else if (err) {
17
- devkit_1.logger.error(`Watch error: ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown'}`);
18
- }
19
- else if (data.changedFiles.some((file) => file.path == (0, path_1.join)(projectRoot, relativeFilePath))) {
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;