@nx/js 16.8.0-beta.4 → 16.8.0-beta.6
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/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.js +289 -245
- package/src/generators/setup-build/generator.js +119 -123
- 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.js +9 -11
- 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 +23 -21
- 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.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;
|