@nx/js 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +68 -0
- package/babel.d.ts +13 -0
- package/babel.js +91 -0
- package/executors.json +32 -0
- package/generators.json +46 -0
- package/migrations.json +159 -0
- package/package.json +76 -0
- package/plugins/jest/local-registry.d.ts +1 -0
- package/plugins/jest/local-registry.js +4 -0
- package/src/executors/node/lib/kill-tree.d.ts +2 -0
- package/src/executors/node/lib/kill-tree.js +114 -0
- package/src/executors/node/node-with-require-overrides.d.ts +7 -0
- package/src/executors/node/node-with-require-overrides.js +21 -0
- package/src/executors/node/node.impl.d.ts +7 -0
- package/src/executors/node/node.impl.js +288 -0
- package/src/executors/node/schema.d.ts +18 -0
- package/src/executors/node/schema.json +92 -0
- package/src/executors/release-publish/format-bytes.d.ts +1 -0
- package/src/executors/release-publish/format-bytes.js +28 -0
- package/src/executors/release-publish/log-tar.d.ts +1 -0
- package/src/executors/release-publish/log-tar.js +68 -0
- package/src/executors/release-publish/release-publish.impl.d.ts +5 -0
- package/src/executors/release-publish/release-publish.impl.js +198 -0
- package/src/executors/release-publish/schema.d.ts +8 -0
- package/src/executors/release-publish/schema.json +26 -0
- package/src/executors/swc/schema.json +154 -0
- package/src/executors/swc/swc.impl.d.ts +10 -0
- package/src/executors/swc/swc.impl.js +149 -0
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.d.ts +5 -0
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +62 -0
- package/src/executors/tsc/lib/batch/index.d.ts +4 -0
- package/src/executors/tsc/lib/batch/index.js +7 -0
- package/src/executors/tsc/lib/batch/normalize-tasks-options.d.ts +3 -0
- package/src/executors/tsc/lib/batch/normalize-tasks-options.js +14 -0
- package/src/executors/tsc/lib/batch/types.d.ts +17 -0
- package/src/executors/tsc/lib/batch/types.js +2 -0
- package/src/executors/tsc/lib/batch/watch.d.ts +3 -0
- package/src/executors/tsc/lib/batch/watch.js +56 -0
- package/src/executors/tsc/lib/get-custom-transformers-factory.d.ts +3 -0
- package/src/executors/tsc/lib/get-custom-transformers-factory.js +13 -0
- package/src/executors/tsc/lib/get-task-options.d.ts +3 -0
- package/src/executors/tsc/lib/get-task-options.js +34 -0
- package/src/executors/tsc/lib/get-tsconfig.d.ts +4 -0
- package/src/executors/tsc/lib/get-tsconfig.js +86 -0
- package/src/executors/tsc/lib/index.d.ts +4 -0
- package/src/executors/tsc/lib/index.js +7 -0
- package/src/executors/tsc/lib/normalize-options.d.ts +2 -0
- package/src/executors/tsc/lib/normalize-options.js +39 -0
- package/src/executors/tsc/lib/typescript-compilation.d.ts +29 -0
- package/src/executors/tsc/lib/typescript-compilation.js +203 -0
- package/src/executors/tsc/lib/typescript-diagnostic-reporters.d.ts +3 -0
- package/src/executors/tsc/lib/typescript-diagnostic-reporters.js +37 -0
- package/src/executors/tsc/schema.json +163 -0
- package/src/executors/tsc/tsc.batch-impl.d.ts +5 -0
- package/src/executors/tsc/tsc.batch-impl.js +180 -0
- package/src/executors/tsc/tsc.impl.d.ts +7 -0
- package/src/executors/tsc/tsc.impl.js +97 -0
- package/src/executors/verdaccio/schema.d.ts +7 -0
- package/src/executors/verdaccio/schema.json +35 -0
- package/src/executors/verdaccio/verdaccio.impl.d.ts +12 -0
- package/src/executors/verdaccio/verdaccio.impl.js +220 -0
- package/src/generators/convert-to-swc/convert-to-swc.d.ts +4 -0
- package/src/generators/convert-to-swc/convert-to-swc.js +59 -0
- package/src/generators/convert-to-swc/schema.d.ts +4 -0
- package/src/generators/convert-to-swc/schema.json +36 -0
- package/src/generators/init/files/__fileName__ +20 -0
- package/src/generators/init/init.d.ts +4 -0
- package/src/generators/init/init.js +114 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +36 -0
- package/src/generators/library/files/jest-config/jest.config.__ext__ +30 -0
- package/src/generators/library/files/lib/src/index.ts__tmpl__ +1 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ +7 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.ts__tmpl__ +3 -0
- package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +14 -0
- package/src/generators/library/files/readme/README.md +19 -0
- package/src/generators/library/library.d.ts +16 -0
- package/src/generators/library/library.js +751 -0
- package/src/generators/library/schema.json +151 -0
- package/src/generators/release-version/release-version.d.ts +5 -0
- package/src/generators/release-version/release-version.js +390 -0
- package/src/generators/release-version/schema.d.ts +1 -0
- package/src/generators/release-version/schema.json +67 -0
- package/src/generators/release-version/test-utils/create-workspace-with-package-dependencies.d.ts +16 -0
- package/src/generators/release-version/test-utils/create-workspace-with-package-dependencies.js +40 -0
- package/src/generators/release-version/utils/package.d.ts +12 -0
- package/src/generators/release-version/utils/package.js +34 -0
- package/src/generators/release-version/utils/resolve-local-package-dependencies.d.ts +12 -0
- package/src/generators/release-version/utils/resolve-local-package-dependencies.js +78 -0
- package/src/generators/release-version/utils/resolve-version-spec.d.ts +1 -0
- package/src/generators/release-version/utils/resolve-version-spec.js +29 -0
- package/src/generators/release-version/utils/update-lock-file.d.ts +5 -0
- package/src/generators/release-version/utils/update-lock-file.js +105 -0
- package/src/generators/setup-build/generator.d.ts +4 -0
- package/src/generators/setup-build/generator.js +142 -0
- package/src/generators/setup-build/schema.d.ts +7 -0
- package/src/generators/setup-build/schema.json +42 -0
- package/src/generators/setup-verdaccio/files/config.yml +28 -0
- package/src/generators/setup-verdaccio/generator.d.ts +4 -0
- package/src/generators/setup-verdaccio/generator.js +56 -0
- package/src/generators/setup-verdaccio/schema.d.ts +3 -0
- package/src/generators/setup-verdaccio/schema.json +16 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +28 -0
- package/src/internal.d.ts +4 -0
- package/src/internal.js +15 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.d.ts +2 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.js +77 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.d.ts +2 -0
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +34 -0
- package/src/migrations/update-16-8-2/update-swcrc.d.ts +2 -0
- package/src/migrations/update-16-8-2/update-swcrc.js +23 -0
- package/src/migrations/update-17-0-0/remove-deprecated-build-options.d.ts +6 -0
- package/src/migrations/update-17-0-0/remove-deprecated-build-options.js +30 -0
- package/src/plugins/jest/start-local-registry.d.ts +12 -0
- package/src/plugins/jest/start-local-registry.js +63 -0
- package/src/plugins/rollup/type-definitions.d.ts +8 -0
- package/src/plugins/rollup/type-definitions.js +48 -0
- package/src/utils/add-babel-inputs.d.ts +3 -0
- package/src/utils/add-babel-inputs.js +23 -0
- package/src/utils/add-local-registry-scripts.d.ts +5 -0
- package/src/utils/add-local-registry-scripts.js +77 -0
- package/src/utils/assets/assets.d.ts +10 -0
- package/src/utils/assets/assets.js +36 -0
- package/src/utils/assets/copy-assets-handler.d.ts +32 -0
- package/src/utils/assets/copy-assets-handler.js +154 -0
- package/src/utils/assets/index.d.ts +16 -0
- package/src/utils/assets/index.js +27 -0
- package/src/utils/buildable-libs-utils.d.ts +43 -0
- package/src/utils/buildable-libs-utils.js +375 -0
- package/src/utils/check-dependencies.d.ts +8 -0
- package/src/utils/check-dependencies.js +23 -0
- package/src/utils/code-frames/highlight.d.ts +1 -0
- package/src/utils/code-frames/highlight.js +86 -0
- package/src/utils/code-frames/identifiers.d.ts +5 -0
- package/src/utils/code-frames/identifiers.js +52 -0
- package/src/utils/compiler-helper-dependency.d.ts +18 -0
- package/src/utils/compiler-helper-dependency.js +120 -0
- package/src/utils/find-npm-dependencies.d.ts +9 -0
- package/src/utils/find-npm-dependencies.js +140 -0
- package/src/utils/generate-globs.d.ts +6 -0
- package/src/utils/generate-globs.js +80 -0
- package/src/utils/get-import-path.d.ts +5 -0
- package/src/utils/get-import-path.js +14 -0
- package/src/utils/get-main-file-dir.d.ts +1 -0
- package/src/utils/get-main-file-dir.js +11 -0
- package/src/utils/inline.d.ts +19 -0
- package/src/utils/inline.js +210 -0
- package/src/utils/package-json/create-entry-points.d.ts +1 -0
- package/src/utils/package-json/create-entry-points.js +23 -0
- package/src/utils/package-json/get-npm-scope.d.ts +5 -0
- package/src/utils/package-json/get-npm-scope.js +16 -0
- package/src/utils/package-json/index.d.ts +13 -0
- package/src/utils/package-json/index.js +30 -0
- package/src/utils/package-json/update-package-json.d.ts +30 -0
- package/src/utils/package-json/update-package-json.js +179 -0
- package/src/utils/prettier.d.ts +6 -0
- package/src/utils/prettier.js +34 -0
- package/src/utils/schema.d.ts +87 -0
- package/src/utils/swc/add-swc-config.d.ts +3 -0
- package/src/utils/swc/add-swc-config.js +41 -0
- package/src/utils/swc/add-swc-dependencies.d.ts +3 -0
- package/src/utils/swc/add-swc-dependencies.js +18 -0
- package/src/utils/swc/compile-swc.d.ts +13 -0
- package/src/utils/swc/compile-swc.js +160 -0
- package/src/utils/swc/get-swcrc-path.d.ts +5 -0
- package/src/utils/swc/get-swcrc-path.js +15 -0
- package/src/utils/swc/inline.d.ts +2 -0
- package/src/utils/swc/inline.js +11 -0
- package/src/utils/typescript/__mocks__/plugin-a.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-a.js +5 -0
- package/src/utils/typescript/__mocks__/plugin-b.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-b.js +5 -0
- package/src/utils/typescript/add-tslib-dependencies.d.ts +2 -0
- package/src/utils/typescript/add-tslib-dependencies.js +11 -0
- package/src/utils/typescript/ast-utils.d.ts +32 -0
- package/src/utils/typescript/ast-utils.js +266 -0
- package/src/utils/typescript/compile-typescript-files.d.ts +10 -0
- package/src/utils/typescript/compile-typescript-files.js +43 -0
- package/src/utils/typescript/create-ts-config.d.ts +18 -0
- package/src/utils/typescript/create-ts-config.js +48 -0
- package/src/utils/typescript/ensure-typescript.d.ts +1 -0
- package/src/utils/typescript/ensure-typescript.js +9 -0
- package/src/utils/typescript/get-source-nodes.d.ts +2 -0
- package/src/utils/typescript/get-source-nodes.js +18 -0
- package/src/utils/typescript/load-ts-transformers.d.ts +5 -0
- package/src/utils/typescript/load-ts-transformers.js +62 -0
- package/src/utils/typescript/print-diagnostics.d.ts +1 -0
- package/src/utils/typescript/print-diagnostics.js +18 -0
- package/src/utils/typescript/run-type-check.d.ts +32 -0
- package/src/utils/typescript/run-type-check.js +128 -0
- package/src/utils/typescript/ts-config.d.ts +9 -0
- package/src/utils/typescript/ts-config.js +85 -0
- package/src/utils/typescript/tsnode-register.d.ts +1 -0
- package/src/utils/typescript/tsnode-register.js +24 -0
- package/src/utils/typescript/types.d.ts +18 -0
- package/src/utils/typescript/types.js +2 -0
- package/src/utils/versions.d.ts +17 -0
- package/src/utils/versions.js +21 -0
- package/src/utils/watch-for-single-file-changes.d.ts +1 -0
- package/src/utils/watch-for-single-file-changes.js +22 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Tree } from 'nx/src/generators/tree';
|
|
2
|
+
export declare const tsConfigBaseOptions: {
|
|
3
|
+
rootDir: string;
|
|
4
|
+
sourceMap: boolean;
|
|
5
|
+
declaration: boolean;
|
|
6
|
+
moduleResolution: string;
|
|
7
|
+
emitDecoratorMetadata: boolean;
|
|
8
|
+
experimentalDecorators: boolean;
|
|
9
|
+
importHelpers: boolean;
|
|
10
|
+
target: string;
|
|
11
|
+
module: string;
|
|
12
|
+
lib: string[];
|
|
13
|
+
skipLibCheck: boolean;
|
|
14
|
+
skipDefaultLibCheck: boolean;
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
paths: {};
|
|
17
|
+
};
|
|
18
|
+
export declare function extractTsConfigBase(host: Tree): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractTsConfigBase = exports.tsConfigBaseOptions = void 0;
|
|
4
|
+
const json_1 = require("nx/src/generators/utils/json");
|
|
5
|
+
exports.tsConfigBaseOptions = {
|
|
6
|
+
rootDir: '.',
|
|
7
|
+
sourceMap: true,
|
|
8
|
+
declaration: false,
|
|
9
|
+
moduleResolution: 'node',
|
|
10
|
+
emitDecoratorMetadata: true,
|
|
11
|
+
experimentalDecorators: true,
|
|
12
|
+
importHelpers: true,
|
|
13
|
+
target: 'es2015',
|
|
14
|
+
module: 'esnext',
|
|
15
|
+
lib: ['es2020', 'dom'],
|
|
16
|
+
skipLibCheck: true,
|
|
17
|
+
skipDefaultLibCheck: true,
|
|
18
|
+
baseUrl: '.',
|
|
19
|
+
paths: {},
|
|
20
|
+
};
|
|
21
|
+
function extractTsConfigBase(host) {
|
|
22
|
+
if (host.exists('tsconfig.base.json'))
|
|
23
|
+
return;
|
|
24
|
+
const tsconfig = (0, json_1.readJson)(host, 'tsconfig.json');
|
|
25
|
+
const baseCompilerOptions = {};
|
|
26
|
+
for (let compilerOption of Object.keys(exports.tsConfigBaseOptions)) {
|
|
27
|
+
baseCompilerOptions[compilerOption] =
|
|
28
|
+
tsconfig.compilerOptions[compilerOption];
|
|
29
|
+
delete tsconfig.compilerOptions[compilerOption];
|
|
30
|
+
}
|
|
31
|
+
(0, json_1.writeJson)(host, 'tsconfig.base.json', {
|
|
32
|
+
compileOnSave: false,
|
|
33
|
+
compilerOptions: baseCompilerOptions,
|
|
34
|
+
exclude: tsconfig.exclude,
|
|
35
|
+
});
|
|
36
|
+
tsconfig.extends = './tsconfig.base.json';
|
|
37
|
+
delete tsconfig.compileOnSave;
|
|
38
|
+
delete tsconfig.exclude;
|
|
39
|
+
(0, json_1.writeJson)(host, 'tsconfig.json', tsconfig);
|
|
40
|
+
// special case for updating e2e tests.
|
|
41
|
+
if (host.exists('e2e/tsconfig.json')) {
|
|
42
|
+
(0, json_1.updateJson)(host, 'e2e/tsconfig.json', (json) => {
|
|
43
|
+
json.extends = '../tsconfig.base.json';
|
|
44
|
+
return json;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.extractTsConfigBase = extractTsConfigBase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ensureTypescript(): typeof import("typescript");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureTypescript = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../versions");
|
|
6
|
+
function ensureTypescript() {
|
|
7
|
+
return (0, devkit_1.ensurePackage)('typescript', versions_1.typescriptVersion);
|
|
8
|
+
}
|
|
9
|
+
exports.ensureTypescript = ensureTypescript;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSourceNodes = void 0;
|
|
4
|
+
function getSourceNodes(sourceFile) {
|
|
5
|
+
const nodes = [sourceFile];
|
|
6
|
+
const result = [];
|
|
7
|
+
while (nodes.length > 0) {
|
|
8
|
+
const node = nodes.shift();
|
|
9
|
+
if (node) {
|
|
10
|
+
result.push(node);
|
|
11
|
+
if (node.getChildCount(sourceFile) >= 0) {
|
|
12
|
+
nodes.unshift(...node.getChildren());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
exports.getSourceNodes = getSourceNodes;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadTsTransformers = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
function loadTsTransformers(plugins, moduleResolver = require.resolve) {
|
|
7
|
+
const beforeHooks = [];
|
|
8
|
+
const afterHooks = [];
|
|
9
|
+
const afterDeclarationsHooks = [];
|
|
10
|
+
if (!plugins || !plugins.length)
|
|
11
|
+
return {
|
|
12
|
+
compilerPluginHooks: {
|
|
13
|
+
beforeHooks,
|
|
14
|
+
afterHooks,
|
|
15
|
+
afterDeclarationsHooks,
|
|
16
|
+
},
|
|
17
|
+
hasPlugin: false,
|
|
18
|
+
};
|
|
19
|
+
const normalizedPlugins = plugins.map((plugin) => typeof plugin === 'string' ? { name: plugin, options: {} } : plugin);
|
|
20
|
+
const nodeModulePaths = [
|
|
21
|
+
(0, path_1.join)(process.cwd(), 'node_modules'),
|
|
22
|
+
...module.paths,
|
|
23
|
+
];
|
|
24
|
+
const pluginRefs = normalizedPlugins.map(({ name }) => {
|
|
25
|
+
try {
|
|
26
|
+
const binaryPath = moduleResolver(name, {
|
|
27
|
+
paths: nodeModulePaths,
|
|
28
|
+
});
|
|
29
|
+
return require(binaryPath);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
devkit_1.logger.warn(`"${name}" plugin could not be found!`);
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
for (let i = 0; i < pluginRefs.length; i++) {
|
|
37
|
+
const { name: pluginName, options: pluginOptions } = normalizedPlugins[i];
|
|
38
|
+
const { before, after, afterDeclarations } = pluginRefs[i];
|
|
39
|
+
if (!before && !after && !afterDeclarations) {
|
|
40
|
+
devkit_1.logger.warn(`${pluginName} is not a Transformer Plugin. It does not provide neither before(), after(), nor afterDeclarations()`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (before) {
|
|
44
|
+
beforeHooks.push(before.bind(before, pluginOptions));
|
|
45
|
+
}
|
|
46
|
+
if (after) {
|
|
47
|
+
afterHooks.push(after.bind(after, pluginOptions));
|
|
48
|
+
}
|
|
49
|
+
if (afterDeclarations) {
|
|
50
|
+
afterDeclarationsHooks.push(afterDeclarations.bind(afterDeclarations, pluginOptions));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
compilerPluginHooks: {
|
|
55
|
+
beforeHooks,
|
|
56
|
+
afterHooks,
|
|
57
|
+
afterDeclarationsHooks,
|
|
58
|
+
},
|
|
59
|
+
hasPlugin: true,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
exports.loadTsTransformers = loadTsTransformers;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printDiagnostics(errors?: string[], warnings?: string[]): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printDiagnostics = void 0;
|
|
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
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.printDiagnostics = printDiagnostics;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Diagnostic } from 'typescript';
|
|
2
|
+
export interface TypeCheckResult {
|
|
3
|
+
warnings?: string[];
|
|
4
|
+
errors?: string[];
|
|
5
|
+
inputFilesCount: number;
|
|
6
|
+
totalFilesCount: number;
|
|
7
|
+
incremental: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type TypeCheckOptions = BaseTypeCheckOptions & Mode;
|
|
10
|
+
interface BaseTypeCheckOptions {
|
|
11
|
+
workspaceRoot: string;
|
|
12
|
+
tsConfigPath: string;
|
|
13
|
+
cacheDir?: string;
|
|
14
|
+
incremental?: boolean;
|
|
15
|
+
rootDir?: string;
|
|
16
|
+
}
|
|
17
|
+
type Mode = NoEmitMode | EmitDeclarationOnlyMode;
|
|
18
|
+
interface NoEmitMode {
|
|
19
|
+
mode: 'noEmit';
|
|
20
|
+
}
|
|
21
|
+
interface EmitDeclarationOnlyMode {
|
|
22
|
+
mode: 'emitDeclarationOnly';
|
|
23
|
+
outDir: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function runTypeCheckWatch(options: TypeCheckOptions, callback: (diagnostic: Diagnostic, formattedDiagnostic: string, errorCount?: number) => void | Promise<void>): Promise<{
|
|
26
|
+
close: any;
|
|
27
|
+
preEmitErrors: string[];
|
|
28
|
+
preEmitWarnings: string[];
|
|
29
|
+
}>;
|
|
30
|
+
export declare function runTypeCheck(options: TypeCheckOptions): Promise<TypeCheckResult>;
|
|
31
|
+
export declare function getFormattedDiagnostic(ts: typeof import('typescript'), workspaceRoot: string, diagnostic: Diagnostic): string;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFormattedDiagnostic = exports.runTypeCheck = exports.runTypeCheckWatch = void 0;
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const code_frames_1 = require("nx/src/utils/code-frames");
|
|
7
|
+
const highlight_1 = require("../code-frames/highlight");
|
|
8
|
+
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
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
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.runTypeCheckWatch = runTypeCheckWatch;
|
|
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);
|
|
54
|
+
}
|
|
55
|
+
exports.runTypeCheck = runTypeCheck;
|
|
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 };
|
|
75
|
+
}
|
|
76
|
+
function getTypeCheckResult(ts, allDiagnostics, workspaceRoot, inputFilesCount, totalFilesCount, incremental = false) {
|
|
77
|
+
const errors = allDiagnostics
|
|
78
|
+
.filter((d) => d.category === ts.DiagnosticCategory.Error)
|
|
79
|
+
.map((d) => getFormattedDiagnostic(ts, workspaceRoot, d));
|
|
80
|
+
const warnings = allDiagnostics
|
|
81
|
+
.filter((d) => d.category === ts.DiagnosticCategory.Warning)
|
|
82
|
+
.map((d) => getFormattedDiagnostic(ts, workspaceRoot, d));
|
|
83
|
+
return {
|
|
84
|
+
warnings,
|
|
85
|
+
errors,
|
|
86
|
+
inputFilesCount,
|
|
87
|
+
totalFilesCount,
|
|
88
|
+
incremental,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function getFormattedDiagnostic(ts, workspaceRoot, diagnostic) {
|
|
92
|
+
let message = '';
|
|
93
|
+
const reason = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
|
94
|
+
const category = diagnostic.category;
|
|
95
|
+
switch (category) {
|
|
96
|
+
case ts.DiagnosticCategory.Warning: {
|
|
97
|
+
message += `${chalk.yellow.bold('warning')} ${chalk.gray(`TS${diagnostic.code}`)}: `;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case ts.DiagnosticCategory.Error: {
|
|
101
|
+
message += `${chalk.red.bold('error')} ${chalk.gray(`TS${diagnostic.code}`)}: `;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case ts.DiagnosticCategory.Suggestion:
|
|
105
|
+
case ts.DiagnosticCategory.Message:
|
|
106
|
+
default: {
|
|
107
|
+
message += `${chalk.cyan.bold(category === 2 ? 'suggestion' : 'info')}: `;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
message += reason + '\n';
|
|
112
|
+
if (diagnostic.file) {
|
|
113
|
+
const pos = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
114
|
+
const line = pos.line + 1;
|
|
115
|
+
const column = pos.character + 1;
|
|
116
|
+
const fileName = path.relative(workspaceRoot, diagnostic.file.fileName);
|
|
117
|
+
message =
|
|
118
|
+
`${chalk.underline.blue(`${fileName}:${line}:${column}`)} - ` + message;
|
|
119
|
+
const code = diagnostic.file.getFullText(diagnostic.file.getSourceFile());
|
|
120
|
+
message +=
|
|
121
|
+
'\n' +
|
|
122
|
+
(0, code_frames_1.codeFrameColumns)(code, {
|
|
123
|
+
start: { line: line, column },
|
|
124
|
+
}, { highlight: highlight_1.highlight });
|
|
125
|
+
}
|
|
126
|
+
return message;
|
|
127
|
+
}
|
|
128
|
+
exports.getFormattedDiagnostic = getFormattedDiagnostic;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import * as ts from 'typescript';
|
|
3
|
+
export declare function readTsConfig(tsConfigPath: string): ts.ParsedCommandLine;
|
|
4
|
+
export declare function getRootTsConfigPathInTree(tree: Tree): string | null;
|
|
5
|
+
export declare function getRelativePathToRootTsConfig(tree: Tree, targetPath: string): string;
|
|
6
|
+
export declare function getRootTsConfigPath(): string | null;
|
|
7
|
+
export declare function getRootTsConfigFileName(tree?: Tree): string | null;
|
|
8
|
+
export declare function addTsConfigPath(tree: Tree, importPath: string, lookupPaths: string[]): void;
|
|
9
|
+
export declare function readTsConfigPaths(tsConfig?: string | ts.ParsedCommandLine): ts.MapLike<string[]>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readTsConfigPaths = exports.addTsConfigPath = exports.getRootTsConfigFileName = exports.getRootTsConfigPath = exports.getRelativePathToRootTsConfig = exports.getRootTsConfigPathInTree = exports.readTsConfig = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const ensure_typescript_1 = require("./ensure-typescript");
|
|
8
|
+
let tsModule;
|
|
9
|
+
function readTsConfig(tsConfigPath) {
|
|
10
|
+
if (!tsModule) {
|
|
11
|
+
tsModule = require('typescript');
|
|
12
|
+
}
|
|
13
|
+
const readResult = tsModule.readConfigFile(tsConfigPath, tsModule.sys.readFile);
|
|
14
|
+
return tsModule.parseJsonConfigFileContent(readResult.config, tsModule.sys, (0, path_1.dirname)(tsConfigPath));
|
|
15
|
+
}
|
|
16
|
+
exports.readTsConfig = readTsConfig;
|
|
17
|
+
function getRootTsConfigPathInTree(tree) {
|
|
18
|
+
for (const path of ['tsconfig.base.json', 'tsconfig.json']) {
|
|
19
|
+
if (tree.exists(path)) {
|
|
20
|
+
return path;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return 'tsconfig.base.json';
|
|
24
|
+
}
|
|
25
|
+
exports.getRootTsConfigPathInTree = getRootTsConfigPathInTree;
|
|
26
|
+
function getRelativePathToRootTsConfig(tree, targetPath) {
|
|
27
|
+
return (0, devkit_1.offsetFromRoot)(targetPath) + getRootTsConfigPathInTree(tree);
|
|
28
|
+
}
|
|
29
|
+
exports.getRelativePathToRootTsConfig = getRelativePathToRootTsConfig;
|
|
30
|
+
function getRootTsConfigPath() {
|
|
31
|
+
const tsConfigFileName = getRootTsConfigFileName();
|
|
32
|
+
return tsConfigFileName ? (0, path_1.join)(devkit_1.workspaceRoot, tsConfigFileName) : null;
|
|
33
|
+
}
|
|
34
|
+
exports.getRootTsConfigPath = getRootTsConfigPath;
|
|
35
|
+
function getRootTsConfigFileName(tree) {
|
|
36
|
+
for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
|
|
37
|
+
const pathExists = tree
|
|
38
|
+
? tree.exists(tsConfigName)
|
|
39
|
+
: (0, fs_1.existsSync)((0, path_1.join)(devkit_1.workspaceRoot, tsConfigName));
|
|
40
|
+
if (pathExists) {
|
|
41
|
+
return tsConfigName;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
exports.getRootTsConfigFileName = getRootTsConfigFileName;
|
|
47
|
+
function addTsConfigPath(tree, importPath, lookupPaths) {
|
|
48
|
+
(0, devkit_1.updateJson)(tree, getRootTsConfigPathInTree(tree), (json) => {
|
|
49
|
+
json.compilerOptions ??= {};
|
|
50
|
+
const c = json.compilerOptions;
|
|
51
|
+
c.paths ??= {};
|
|
52
|
+
if (c.paths[importPath]) {
|
|
53
|
+
throw new Error(`You already have a library using the import path "${importPath}". Make sure to specify a unique one.`);
|
|
54
|
+
}
|
|
55
|
+
c.paths[importPath] = lookupPaths;
|
|
56
|
+
return json;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.addTsConfigPath = addTsConfigPath;
|
|
60
|
+
function readTsConfigPaths(tsConfig) {
|
|
61
|
+
tsConfig ??= getRootTsConfigPath();
|
|
62
|
+
try {
|
|
63
|
+
if (!tsModule) {
|
|
64
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
65
|
+
}
|
|
66
|
+
let config;
|
|
67
|
+
if (typeof tsConfig === 'string') {
|
|
68
|
+
const configFile = tsModule.readConfigFile(tsConfig, tsModule.sys.readFile);
|
|
69
|
+
config = tsModule.parseJsonConfigFileContent(configFile.config, tsModule.sys, (0, path_1.dirname)(tsConfig));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
config = tsConfig;
|
|
73
|
+
}
|
|
74
|
+
if (config.options?.paths) {
|
|
75
|
+
return config.options.paths;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.readTsConfigPaths = readTsConfigPaths;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function tsNodeRegister(file: string, tsConfig?: string): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tsNodeRegister = void 0;
|
|
4
|
+
function tsNodeRegister(file, tsConfig) {
|
|
5
|
+
if (!file?.endsWith('.ts'))
|
|
6
|
+
return;
|
|
7
|
+
// Register TS compiler lazily
|
|
8
|
+
require('ts-node').register({
|
|
9
|
+
project: tsConfig,
|
|
10
|
+
compilerOptions: {
|
|
11
|
+
module: 'CommonJS',
|
|
12
|
+
types: ['node'],
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
if (!tsConfig)
|
|
16
|
+
return;
|
|
17
|
+
// Register paths in tsConfig
|
|
18
|
+
const tsconfigPaths = require('tsconfig-paths');
|
|
19
|
+
const { absoluteBaseUrl: baseUrl, paths } = tsconfigPaths.loadConfig(tsConfig);
|
|
20
|
+
if (baseUrl && paths) {
|
|
21
|
+
tsconfigPaths.register({ baseUrl, paths });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.tsNodeRegister = tsNodeRegister;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CustomTransformerFactory, Node, Program, TransformerFactory as TypescriptTransformerFactory } from 'typescript';
|
|
2
|
+
type TransformerFactory = TypescriptTransformerFactory<Node> | CustomTransformerFactory;
|
|
3
|
+
export interface TransformerPlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
options: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export type TransformerEntry = string | TransformerPlugin;
|
|
8
|
+
export interface CompilerPlugin {
|
|
9
|
+
before?: (options?: Record<string, unknown>, program?: Program) => TransformerFactory;
|
|
10
|
+
after?: (options?: Record<string, unknown>, program?: Program) => TransformerFactory;
|
|
11
|
+
afterDeclarations?: (options?: Record<string, unknown>, program?: Program) => TransformerFactory;
|
|
12
|
+
}
|
|
13
|
+
export interface CompilerPluginHooks {
|
|
14
|
+
beforeHooks: Array<(program?: Program) => TransformerFactory>;
|
|
15
|
+
afterHooks: Array<(program?: Program) => TransformerFactory>;
|
|
16
|
+
afterDeclarationsHooks: Array<(program?: Program) => TransformerFactory>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const nxVersion: any;
|
|
2
|
+
export declare const esbuildVersion = "^0.19.2";
|
|
3
|
+
export declare const prettierVersion = "^2.6.2";
|
|
4
|
+
export declare const swcCliVersion = "~0.1.62";
|
|
5
|
+
export declare const swcCoreVersion = "~1.3.85";
|
|
6
|
+
export declare const swcHelpersVersion = "~0.5.2";
|
|
7
|
+
export declare const swcNodeVersion = "~1.8.0";
|
|
8
|
+
export declare const tsLibVersion = "^2.3.0";
|
|
9
|
+
export declare const typesNodeVersion = "18.16.9";
|
|
10
|
+
export declare const verdaccioVersion = "^5.0.4";
|
|
11
|
+
export declare const typescriptVersion = "~5.3.2";
|
|
12
|
+
/**
|
|
13
|
+
* The minimum version is currently determined from the lowest version
|
|
14
|
+
* that's supported by the lowest Angular supported version, e.g.
|
|
15
|
+
* `npm view @angular/compiler-cli@14.0.0 peerDependencies.typescript`
|
|
16
|
+
*/
|
|
17
|
+
export declare const supportedTypescriptVersions = ">=4.8.2";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.supportedTypescriptVersions = exports.typescriptVersion = exports.verdaccioVersion = exports.typesNodeVersion = exports.tsLibVersion = exports.swcNodeVersion = exports.swcHelpersVersion = exports.swcCoreVersion = exports.swcCliVersion = exports.prettierVersion = exports.esbuildVersion = exports.nxVersion = void 0;
|
|
4
|
+
exports.nxVersion = require('../../package.json').version;
|
|
5
|
+
exports.esbuildVersion = '^0.19.2';
|
|
6
|
+
exports.prettierVersion = '^2.6.2';
|
|
7
|
+
exports.swcCliVersion = '~0.1.62';
|
|
8
|
+
exports.swcCoreVersion = '~1.3.85';
|
|
9
|
+
exports.swcHelpersVersion = '~0.5.2';
|
|
10
|
+
exports.swcNodeVersion = '~1.8.0';
|
|
11
|
+
exports.tsLibVersion = '^2.3.0';
|
|
12
|
+
exports.typesNodeVersion = '18.16.9';
|
|
13
|
+
exports.verdaccioVersion = '^5.0.4';
|
|
14
|
+
// Typescript
|
|
15
|
+
exports.typescriptVersion = '~5.3.2';
|
|
16
|
+
/**
|
|
17
|
+
* The minimum version is currently determined from the lowest version
|
|
18
|
+
* that's supported by the lowest Angular supported version, e.g.
|
|
19
|
+
* `npm view @angular/compiler-cli@14.0.0 peerDependencies.typescript`
|
|
20
|
+
*/
|
|
21
|
+
exports.supportedTypescriptVersions = '>=4.8.2';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function watchForSingleFileChanges(projectName: string, projectRoot: string, relativeFilePath: string, callback: () => void): Promise<() => void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.watchForSingleFileChanges = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const client_1 = require("nx/src/daemon/client/client");
|
|
6
|
+
const path_1 = require("path");
|
|
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
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return () => unregisterFileWatcher();
|
|
21
|
+
}
|
|
22
|
+
exports.watchForSingleFileChanges = watchForSingleFileChanges;
|