@nx/js 16.4.0-beta.8 → 16.4.0

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 (45) hide show
  1. package/babel.js +3 -1
  2. package/migrations.json +12 -0
  3. package/package.json +6 -6
  4. package/plugins/jest/local-registry.d.ts +1 -0
  5. package/plugins/jest/local-registry.js +4 -0
  6. package/src/executors/node/node.impl.d.ts +1 -0
  7. package/src/executors/node/node.impl.js +27 -7
  8. package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.d.ts +2 -1
  9. package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +22 -17
  10. package/src/executors/tsc/lib/batch/index.d.ts +0 -4
  11. package/src/executors/tsc/lib/batch/index.js +0 -4
  12. package/src/executors/tsc/lib/batch/types.d.ts +5 -0
  13. package/src/executors/tsc/lib/get-task-options.d.ts +8 -0
  14. package/src/executors/tsc/lib/get-task-options.js +51 -0
  15. package/src/executors/tsc/lib/get-tsconfig.d.ts +4 -0
  16. package/src/executors/tsc/lib/get-tsconfig.js +138 -0
  17. package/src/executors/tsc/lib/index.d.ts +2 -0
  18. package/src/executors/tsc/lib/index.js +2 -0
  19. package/src/executors/tsc/lib/typescript-compilation.d.ts +29 -0
  20. package/src/executors/tsc/lib/typescript-compilation.js +206 -0
  21. package/src/executors/tsc/lib/{batch/typescript-diagnostic-reporters.d.ts → typescript-diagnostic-reporters.d.ts} +0 -1
  22. package/src/executors/tsc/lib/{batch/typescript-diagnostic-reporters.js → typescript-diagnostic-reporters.js} +1 -8
  23. package/src/executors/tsc/tsc.batch-impl.d.ts +3 -2
  24. package/src/executors/tsc/tsc.batch-impl.js +97 -7
  25. package/src/executors/verdaccio/verdaccio.impl.js +67 -39
  26. package/src/generators/setup-verdaccio/files/config.yml +5 -6
  27. package/src/generators/setup-verdaccio/generator.js +5 -1
  28. package/src/internal.d.ts +1 -0
  29. package/src/internal.js +4 -1
  30. package/src/plugins/jest/start-local-registry.d.ts +12 -0
  31. package/src/plugins/jest/start-local-registry.js +65 -0
  32. package/src/utils/add-local-registry-scripts.d.ts +5 -0
  33. package/src/utils/add-local-registry-scripts.js +57 -0
  34. package/src/utils/compiler-helper-dependency.d.ts +2 -1
  35. package/src/utils/compiler-helper-dependency.js +14 -4
  36. package/src/utils/minimal-publish-script.js +2 -5
  37. package/src/utils/versions.d.ts +1 -1
  38. package/src/utils/versions.js +1 -1
  39. package/src/executors/tsc/lib/batch/generate-temp-tsconfig.d.ts +0 -3
  40. package/src/executors/tsc/lib/batch/generate-temp-tsconfig.js +0 -52
  41. package/src/executors/tsc/lib/batch/get-task-options.d.ts +0 -3
  42. package/src/executors/tsc/lib/batch/get-task-options.js +0 -24
  43. package/src/executors/tsc/lib/batch/typescript-compilation.d.ts +0 -7
  44. package/src/executors/tsc/lib/batch/typescript-compilation.js +0 -195
  45. package/src/generators/setup-verdaccio/files/htpasswd +0 -1
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startLocalRegistry = void 0;
4
+ const child_process_1 = require("child_process");
5
+ /**
6
+ * This function is used to start a local registry for testing purposes.
7
+ * @param localRegistryTarget the target to run to start the local registry e.g. workspace:local-registry
8
+ * @param storage the storage location for the local registry
9
+ * @param verbose whether to log verbose output
10
+ */
11
+ function startLocalRegistry({ localRegistryTarget, storage, verbose, }) {
12
+ if (!localRegistryTarget) {
13
+ throw new Error(`localRegistryTarget is required`);
14
+ }
15
+ return new Promise((resolve, reject) => {
16
+ var _a, _b;
17
+ const childProcess = (0, child_process_1.fork)(require.resolve('nx'), [
18
+ ...`run ${localRegistryTarget} --location none --clear true`.split(' '),
19
+ ...(storage ? [`--storage`, storage] : []),
20
+ ], { stdio: 'pipe' });
21
+ const listener = (data) => {
22
+ var _a, _b, _c;
23
+ if (verbose) {
24
+ process.stdout.write(data);
25
+ }
26
+ if (data.toString().includes('http://localhost:')) {
27
+ const port = parseInt((_b = (_a = data.toString().match(/localhost:(?<port>\d+)/)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.port);
28
+ console.log('Local registry started on port ' + port);
29
+ const registry = `http://localhost:${port}`;
30
+ process.env.npm_config_registry = registry;
31
+ (0, child_process_1.execSync)(`npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"`);
32
+ // yarnv1
33
+ process.env.YARN_REGISTRY = registry;
34
+ // yarnv2
35
+ process.env.YARN_NPM_REGISTRY_SERVER = registry;
36
+ process.env.YARN_UNSAFE_HTTP_WHITELIST = 'localhost';
37
+ console.log('Set npm and yarn config registry to ' + registry);
38
+ resolve(() => {
39
+ childProcess.kill();
40
+ (0, child_process_1.execSync)(`npm config delete //localhost:${port}/:_authToken`);
41
+ });
42
+ (_c = childProcess === null || childProcess === void 0 ? void 0 : childProcess.stdout) === null || _c === void 0 ? void 0 : _c.off('data', listener);
43
+ }
44
+ };
45
+ (_a = childProcess === null || childProcess === void 0 ? void 0 : childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', listener);
46
+ (_b = childProcess === null || childProcess === void 0 ? void 0 : childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
47
+ process.stderr.write(data);
48
+ });
49
+ childProcess.on('error', (err) => {
50
+ console.log('local registry error', err);
51
+ reject(err);
52
+ });
53
+ childProcess.on('exit', (code) => {
54
+ console.log('local registry exit', code);
55
+ if (code !== 0) {
56
+ reject(code);
57
+ }
58
+ else {
59
+ resolve(() => { });
60
+ }
61
+ });
62
+ });
63
+ }
64
+ exports.startLocalRegistry = startLocalRegistry;
65
+ exports.default = startLocalRegistry;
@@ -0,0 +1,5 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare function addLocalRegistryScripts(tree: Tree): {
3
+ startLocalRegistryPath: string;
4
+ stopLocalRegistryPath: string;
5
+ };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addLocalRegistryScripts = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const startLocalRegistryScript = (localRegistryTarget) => `
6
+ /**
7
+ * This script starts a local registry for e2e testing purposes.
8
+ * It is meant to be called in jest's globalSetup.
9
+ */
10
+ import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
11
+ import { execFileSync } from 'child_process';
12
+
13
+ export default async () => {
14
+ // local registry target to run
15
+ const localRegistryTarget = '${localRegistryTarget}';
16
+ // storage folder for the local registry
17
+ const storage = './tmp/local-registry/storage';
18
+
19
+ global.stopLocalRegistry = await startLocalRegistry({
20
+ localRegistryTarget,
21
+ storage,
22
+ verbose: false,
23
+ });
24
+ const nx = require.resolve('nx');
25
+ execFileSync(
26
+ nx,
27
+ ['run-many', '--targets', 'publish', '--ver', '1.0.0', '--tag', 'e2e'],
28
+ { env: process.env, stdio: 'inherit' }
29
+ );
30
+ };
31
+ `;
32
+ const stopLocalRegistryScript = `
33
+ /**
34
+ * This script stops the local registry for e2e testing purposes.
35
+ * It is meant to be called in jest's globalTeardown.
36
+ */
37
+
38
+ export default () => {
39
+ if (global.stopLocalRegistry) {
40
+ global.stopLocalRegistry();
41
+ }
42
+ };
43
+ `;
44
+ function addLocalRegistryScripts(tree) {
45
+ const startLocalRegistryPath = 'tools/scripts/start-local-registry.ts';
46
+ const stopLocalRegistryPath = 'tools/scripts/stop-local-registry.ts';
47
+ const projectConfiguration = (0, devkit_1.readJson)(tree, 'project.json');
48
+ const localRegistryTarget = `${projectConfiguration.name}:local-registry`;
49
+ if (!tree.exists(startLocalRegistryPath)) {
50
+ tree.write(startLocalRegistryPath, startLocalRegistryScript(localRegistryTarget));
51
+ }
52
+ if (!tree.exists(stopLocalRegistryPath)) {
53
+ tree.write(stopLocalRegistryPath, stopLocalRegistryScript);
54
+ }
55
+ return { startLocalRegistryPath, stopLocalRegistryPath };
56
+ }
57
+ exports.addLocalRegistryScripts = addLocalRegistryScripts;
@@ -1,4 +1,4 @@
1
- import { ProjectGraph, ProjectGraphDependency } from '@nx/devkit';
1
+ import { type ProjectGraph, type ProjectGraphDependency } from '@nx/devkit';
2
2
  import { DependentBuildableProjectNode } from './buildable-libs-utils';
3
3
  export declare enum HelperDependency {
4
4
  tsc = "npm:tslib",
@@ -11,6 +11,7 @@ export declare enum HelperDependency {
11
11
  * @param {HelperDependency} helperDependency
12
12
  * @param {string} configPath
13
13
  * @param {DependentBuildableProjectNode[]} dependencies
14
+ * @param {ProjectGraph} projectGraph
14
15
  * @param {boolean=false} returnDependencyIfFound
15
16
  */
16
17
  export declare function getHelperDependency(helperDependency: HelperDependency, configPath: string, dependencies: DependentBuildableProjectNode[], projectGraph: ProjectGraph, returnDependencyIfFound?: boolean): DependentBuildableProjectNode | null;
@@ -9,7 +9,7 @@ var HelperDependency;
9
9
  (function (HelperDependency) {
10
10
  HelperDependency["tsc"] = "npm:tslib";
11
11
  HelperDependency["swc"] = "npm:@swc/helpers";
12
- })(HelperDependency = exports.HelperDependency || (exports.HelperDependency = {}));
12
+ })(HelperDependency || (exports.HelperDependency = HelperDependency = {}));
13
13
  const jsExecutors = {
14
14
  '@nx/js:tsc': {
15
15
  helperDependency: HelperDependency.tsc,
@@ -27,6 +27,7 @@ const jsExecutors = {
27
27
  * @param {HelperDependency} helperDependency
28
28
  * @param {string} configPath
29
29
  * @param {DependentBuildableProjectNode[]} dependencies
30
+ * @param {ProjectGraph} projectGraph
30
31
  * @param {boolean=false} returnDependencyIfFound
31
32
  */
32
33
  function getHelperDependency(helperDependency, configPath, dependencies, projectGraph, returnDependencyIfFound = false) {
@@ -50,7 +51,17 @@ function getHelperDependency(helperDependency, configPath, dependencies, project
50
51
  }
51
52
  if (!isHelperNeeded)
52
53
  return null;
53
- const libNode = projectGraph.externalNodes[helperDependency];
54
+ let libNode = projectGraph[helperDependency];
55
+ // If libNode is not found due to the version suffix from pnpm lockfile, try to match it by package name.
56
+ if (!libNode) {
57
+ for (const nodeName of Object.keys(projectGraph.externalNodes)) {
58
+ const node = projectGraph.externalNodes[nodeName];
59
+ if (`npm:${node.data.packageName}` === helperDependency) {
60
+ libNode = node;
61
+ break;
62
+ }
63
+ }
64
+ }
54
65
  if (!libNode) {
55
66
  devkit_1.logger.warn(`Your library compilation option specifies that the compiler external helper (${helperDependency.split(':')[1]}) is needed but it is not installed.`);
56
67
  return null;
@@ -74,8 +85,7 @@ function getHelperDependenciesFromProjectGraph(contextRoot, sourceProject, proje
74
85
  const internalDependencies = sourceDependencies.reduce((result, dependency) => {
75
86
  // we check if a dependency is part of the workspace and if it's a library
76
87
  // because we wouldn't want to include external dependencies (npm packages)
77
- if (!dependency.target.startsWith('npm:') &&
78
- !!projectGraph.nodes[dependency.target] &&
88
+ if (projectGraph.nodes[dependency.target] &&
79
89
  projectGraph.nodes[dependency.target].type === 'lib') {
80
90
  const targetData = projectGraph.nodes[dependency.target].data;
81
91
  // check if the dependency has a buildable target with one of the jsExecutors
@@ -13,14 +13,13 @@ const publishScriptContent = `
13
13
 
14
14
  import { execSync } from 'child_process';
15
15
  import { readFileSync, writeFileSync } from 'fs';
16
- import chalk from 'chalk';
17
16
 
18
17
  import devkit from '@nx/devkit';
19
18
  const { readCachedProjectGraph } = devkit;
20
19
 
21
20
  function invariant(condition, message) {
22
21
  if (!condition) {
23
- console.error(chalk.bold.red(message));
22
+ console.error(message);
24
23
  process.exit(1);
25
24
  }
26
25
  }
@@ -59,9 +58,7 @@ try {
59
58
  json.version = version;
60
59
  writeFileSync(\`package.json\`, JSON.stringify(json, null, 2));
61
60
  } catch (e) {
62
- console.error(
63
- chalk.bold.red(\`Error reading package.json file from library build output.\`)
64
- );
61
+ console.error(\`Error reading package.json file from library build output.\`);
65
62
  }
66
63
 
67
64
  // Execute "npm publish" to publish
@@ -8,7 +8,7 @@ export declare const swcNodeVersion = "~1.4.2";
8
8
  export declare const tsLibVersion = "^2.3.0";
9
9
  export declare const typesNodeVersion = "18.7.1";
10
10
  export declare const verdaccioVersion = "^5.0.4";
11
- export declare const typescriptVersion = "~5.0.2";
11
+ export declare const typescriptVersion = "~5.1.3";
12
12
  /**
13
13
  * The minimum version is currently determined from the lowest version
14
14
  * that's supported by the lowest Angular supported version, e.g.
@@ -12,7 +12,7 @@ exports.tsLibVersion = '^2.3.0';
12
12
  exports.typesNodeVersion = '18.7.1';
13
13
  exports.verdaccioVersion = '^5.0.4';
14
14
  // Typescript
15
- exports.typescriptVersion = '~5.0.2';
15
+ exports.typescriptVersion = '~5.1.3';
16
16
  /**
17
17
  * The minimum version is currently determined from the lowest version
18
18
  * that's supported by the lowest Angular supported version, e.g.
@@ -1,3 +0,0 @@
1
- import type { ExecutorContext } from '@nx/devkit';
2
- import type { NormalizedExecutorOptions } from '../../../../utils/schema';
3
- export declare function generateTempTsConfig(taskOptionsMap: Record<string, NormalizedExecutorOptions>, taskName: string, taskOptions: NormalizedExecutorOptions, context: ExecutorContext): string;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateTempTsConfig = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- const ts = require("typescript");
7
- const get_task_options_1 = require("./get-task-options");
8
- function generateTempTsConfig(taskOptionsMap, taskName, taskOptions, context) {
9
- const tmpDir = (0, path_1.join)(context.root, 'tmp');
10
- const originalTsConfigPath = taskOptions.tsConfig;
11
- const tmpTsConfigPath = (0, path_1.join)(tmpDir, (0, path_1.relative)(context.root, originalTsConfigPath));
12
- const projectReferences = [];
13
- for (const depTask of context.taskGraph.dependencies[taskName]) {
14
- // if included in the provided map, use it
15
- if (taskOptionsMap[depTask]) {
16
- projectReferences.push({
17
- path: (0, path_1.join)(tmpDir, (0, path_1.relative)(context.root, taskOptionsMap[depTask].tsConfig)),
18
- });
19
- continue;
20
- }
21
- // if it's not included in the provided map, it could be a cached task and
22
- // we need to pull the tsconfig from the relevant project graph node
23
- const options = (0, get_task_options_1.getTaskOptions)(depTask, context);
24
- if (options.tsConfig) {
25
- projectReferences.push({
26
- path: (0, path_1.join)(tmpDir, (0, path_1.relative)(context.root, options.tsConfig)),
27
- });
28
- }
29
- }
30
- (0, devkit_1.writeJsonFile)(tmpTsConfigPath, {
31
- extends: (0, devkit_1.normalizePath)((0, path_1.relative)((0, path_1.dirname)(tmpTsConfigPath), taskOptions.tsConfig)),
32
- compilerOptions: {
33
- rootDir: taskOptions.rootDir,
34
- outDir: taskOptions.outputPath,
35
- composite: true,
36
- declaration: true,
37
- declarationMap: true,
38
- tsBuildInfoFile: (0, devkit_1.joinPathFragments)(taskOptions.outputPath, 'tsconfig.tsbuildinfo'),
39
- },
40
- references: projectReferences,
41
- });
42
- /**
43
- * Ensure the temp tsconfig has the same modified date as the original.
44
- * Typescript compares this against the modified date of the tsbuildinfo
45
- * file. If the tsbuildinfo file is older, the cache is invalidated.
46
- * Since we always generate the temp tsconfig, any existing tsbuildinfo
47
- * file will be older even if they are not older than the original tsconfig.
48
- */
49
- ts.sys.setModifiedTime(tmpTsConfigPath, ts.sys.getModifiedTime(originalTsConfigPath));
50
- return tmpTsConfigPath;
51
- }
52
- exports.generateTempTsConfig = generateTempTsConfig;
@@ -1,3 +0,0 @@
1
- import type { ExecutorContext } from '@nx/devkit';
2
- import type { NormalizedExecutorOptions } from '../../../../utils/schema';
3
- export declare function getTaskOptions(taskName: string, context: ExecutorContext): NormalizedExecutorOptions;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTaskOptions = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const normalize_options_1 = require("../normalize-options");
6
- const tasksOptionsCache = new Map();
7
- function getTaskOptions(taskName, context) {
8
- var _a, _b;
9
- if (tasksOptionsCache.has(taskName)) {
10
- return tasksOptionsCache.get(taskName);
11
- }
12
- const target = context.taskGraph.tasks[taskName].target;
13
- const projectNode = context.projectGraph.nodes[target.project];
14
- const targetConfig = (_a = projectNode.data.targets) === null || _a === void 0 ? void 0 : _a[target.target];
15
- const taskOptions = Object.assign(Object.assign({}, targetConfig.options), (target.configuration
16
- ? (_b = targetConfig.configurations) === null || _b === void 0 ? void 0 : _b[target.configuration]
17
- : {}));
18
- const { project } = (0, devkit_1.parseTargetString)(taskName, context.projectGraph);
19
- const { sourceRoot, root } = context.projectsConfigurations.projects[project];
20
- const normalizedTaskOptions = (0, normalize_options_1.normalizeOptions)(taskOptions, context.root, sourceRoot, root);
21
- tasksOptionsCache.set(taskName, normalizedTaskOptions);
22
- return normalizedTaskOptions;
23
- }
24
- exports.getTaskOptions = getTaskOptions;
@@ -1,7 +0,0 @@
1
- import type { TaskGraph } from '@nx/devkit';
2
- import type { BatchResults } from 'nx/src/tasks-runner/batch/batch-messages';
3
- import type { TaskInfo } from './types';
4
- export declare function compileBatchTypescript(tsConfigTaskInfoMap: Record<string, TaskInfo>, taskGraph: TaskGraph, watch: boolean, postProjectCompilationCallback: (taskInfo: TaskInfo) => void): {
5
- iterator: AsyncIterable<BatchResults>;
6
- close: () => void | Promise<void>;
7
- };
@@ -1,195 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compileBatchTypescript = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
6
- const ts = require("typescript");
7
- const get_custom_transformers_factory_1 = require("../get-custom-transformers-factory");
8
- const typescript_diagnostic_reporters_1 = require("./typescript-diagnostic-reporters");
9
- // https://github.com/microsoft/TypeScript/blob/d45012c5e2ab122919ee4777a7887307c5f4a1e0/src/compiler/diagnosticMessages.json#L4050-L4053
10
- // Typescript diagnostic message for 5083: Cannot read file '{0}'.
11
- const TYPESCRIPT_CANNOT_READ_FILE = 5083;
12
- // https://github.com/microsoft/TypeScript/blob/d45012c5e2ab122919ee4777a7887307c5f4a1e0/src/compiler/diagnosticMessages.json#L4211-4214
13
- // Typescript diagnostic message for 6032: File change detected. Starting incremental compilation...
14
- const TYPESCRIPT_FILE_CHANGE_DETECTED_STARTING_INCREMENTAL_COMPILATION = 6032;
15
- function compileBatchTypescript(tsConfigTaskInfoMap, taskGraph, watch, postProjectCompilationCallback) {
16
- const timeNow = Date.now();
17
- const defaultResults = Object.keys(taskGraph.tasks).reduce((acc, task) => {
18
- acc[task] = { success: true, startTime: timeNow, terminalOutput: '' };
19
- return acc;
20
- }, {});
21
- let tearDown;
22
- return {
23
- iterator: (0, async_iterable_1.createAsyncIterable)(({ next, done }) => {
24
- if (watch) {
25
- compileTSWithWatch(tsConfigTaskInfoMap, postProjectCompilationCallback);
26
- tearDown = () => {
27
- done();
28
- };
29
- }
30
- else {
31
- const compilationResults = compileTS(tsConfigTaskInfoMap, postProjectCompilationCallback);
32
- next(Object.assign(Object.assign({}, defaultResults), compilationResults));
33
- done();
34
- }
35
- }),
36
- close: () => tearDown === null || tearDown === void 0 ? void 0 : tearDown(),
37
- };
38
- }
39
- exports.compileBatchTypescript = compileBatchTypescript;
40
- function compileTSWithWatch(tsConfigTaskInfoMap, postProjectCompilationCallback) {
41
- const formatDiagnosticsHost = {
42
- getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
43
- getNewLine: () => ts.sys.newLine,
44
- getCanonicalFileName: (filename) => ts.sys.useCaseSensitiveFileNames ? filename : filename.toLowerCase(),
45
- };
46
- const solutionHost = ts.createSolutionBuilderWithWatchHost(ts.sys,
47
- /*createProgram*/ undefined, (diagnostic) => {
48
- const formattedDiagnostic = (0, typescript_diagnostic_reporters_1.formatDiagnosticReport)(diagnostic, formatDiagnosticsHost);
49
- devkit_1.logger.info(formattedDiagnostic);
50
- }, (diagnostic) => {
51
- const formattedDiagnostic = (0, typescript_diagnostic_reporters_1.formatSolutionBuilderStatusReport)(diagnostic);
52
- devkit_1.logger.info(formattedDiagnostic);
53
- }, (diagnostic, newLine) => {
54
- const formattedDiagnostic = (0, typescript_diagnostic_reporters_1.formatWatchStatusReport)(diagnostic, newLine);
55
- devkit_1.logger.info(formattedDiagnostic);
56
- if (diagnostic.code ===
57
- TYPESCRIPT_FILE_CHANGE_DETECTED_STARTING_INCREMENTAL_COMPILATION) {
58
- // there's a change, build invalidated projects
59
- build();
60
- }
61
- });
62
- const rootNames = Object.keys(tsConfigTaskInfoMap);
63
- const solutionBuilder = ts.createSolutionBuilderWithWatch(solutionHost, rootNames, {});
64
- const build = () => {
65
- while (true) {
66
- const project = solutionBuilder.getNextInvalidatedProject();
67
- if (!project) {
68
- break;
69
- }
70
- const taskInfo = tsConfigTaskInfoMap[project.project];
71
- if (project.kind === ts.InvalidatedProjectKind.UpdateOutputFileStamps) {
72
- // update output timestamps and mark project as complete
73
- project.done();
74
- continue;
75
- }
76
- /**
77
- * This only applies when the deprecated `prepend` option is set to `true`.
78
- * Skip support.
79
- */
80
- if (project.kind === ts.InvalidatedProjectKind.UpdateBundle) {
81
- devkit_1.logger.warn(`The project ${taskInfo.context.projectName} ` +
82
- `is using the deprecated "prepend" Typescript compiler option. ` +
83
- `This option is not supported by the batch executor and it's ignored.`);
84
- continue;
85
- }
86
- // build and mark project as complete
87
- project.done(undefined, undefined, (0, get_custom_transformers_factory_1.getCustomTrasformersFactory)(taskInfo.options.transformers)(project.getProgram()));
88
- postProjectCompilationCallback(taskInfo);
89
- }
90
- };
91
- // initial build
92
- build();
93
- /**
94
- * This is a workaround to get the TS file watching to kick off. It won't
95
- * build twice since the `build` call above will mark invalidated projects
96
- * as completed and then, the implementation of the `solutionBuilder.build`
97
- * skips them.
98
- * We can't rely solely in `solutionBuilder.build()` because it doesn't
99
- * accept custom transformers.
100
- */
101
- solutionBuilder.build();
102
- return solutionHost;
103
- }
104
- function compileTS(tsConfigTaskInfoMap, postProjectCompilationCallback) {
105
- var _a;
106
- const results = {};
107
- let terminalOutput;
108
- const logInfo = (text) => {
109
- devkit_1.logger.info(text);
110
- terminalOutput += `${text}\n`;
111
- };
112
- const logWarn = (text) => {
113
- devkit_1.logger.warn(text);
114
- terminalOutput += `${text}\n`;
115
- };
116
- const formatDiagnosticsHost = {
117
- getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
118
- getNewLine: () => ts.sys.newLine,
119
- getCanonicalFileName: (filename) => ts.sys.useCaseSensitiveFileNames ? filename : filename.toLowerCase(),
120
- };
121
- const solutionBuilderHost = ts.createSolutionBuilderHost(ts.sys,
122
- /*createProgram*/ undefined, (diagnostic) => {
123
- const formattedDiagnostic = (0, typescript_diagnostic_reporters_1.formatDiagnosticReport)(diagnostic, formatDiagnosticsHost);
124
- // handles edge case where a wrong a project reference path can't be read
125
- if (diagnostic.code === TYPESCRIPT_CANNOT_READ_FILE) {
126
- Object.values(tsConfigTaskInfoMap).forEach((taskInfo) => {
127
- var _a, _b;
128
- var _c;
129
- (_a = results[_c = taskInfo.task]) !== null && _a !== void 0 ? _a : (results[_c] = { success: false, terminalOutput: '' });
130
- results[taskInfo.task].success = false;
131
- results[taskInfo.task].terminalOutput = `${(_b = results[taskInfo.task]) === null || _b === void 0 ? void 0 : _b.terminalOutput}${formattedDiagnostic}`;
132
- });
133
- }
134
- logInfo(formattedDiagnostic);
135
- }, (diagnostic) => {
136
- const formattedDiagnostic = (0, typescript_diagnostic_reporters_1.formatSolutionBuilderStatusReport)(diagnostic);
137
- logInfo(formattedDiagnostic);
138
- });
139
- const rootNames = Object.keys(tsConfigTaskInfoMap);
140
- const solutionBuilder = ts.createSolutionBuilder(solutionBuilderHost, rootNames, {});
141
- // eslint-disable-next-line no-constant-condition
142
- while (true) {
143
- const project = solutionBuilder.getNextInvalidatedProject();
144
- if (!project) {
145
- break;
146
- }
147
- const startTime = Date.now();
148
- terminalOutput = '';
149
- const taskInfo = tsConfigTaskInfoMap[project.project];
150
- const projectName = (_a = taskInfo === null || taskInfo === void 0 ? void 0 : taskInfo.context) === null || _a === void 0 ? void 0 : _a.projectName;
151
- if (project.kind === ts.InvalidatedProjectKind.UpdateOutputFileStamps) {
152
- if (projectName) {
153
- logInfo(`Updating output timestamps of project "${projectName}"...`);
154
- }
155
- // update output timestamps and mark project as complete
156
- const status = project.done();
157
- if (projectName && status === ts.ExitStatus.Success) {
158
- logInfo(`Done updating output timestamps of project "${projectName}"...`);
159
- }
160
- if (taskInfo) {
161
- results[taskInfo.task] = {
162
- success: status === ts.ExitStatus.Success,
163
- terminalOutput,
164
- startTime,
165
- endTime: Date.now(),
166
- };
167
- }
168
- continue;
169
- }
170
- /**
171
- * This only applies when the deprecated `prepend` option is set to `true`.
172
- * Skip support.
173
- */
174
- if (project.kind === ts.InvalidatedProjectKind.UpdateBundle) {
175
- logWarn(`The project ${taskInfo.context.projectName} ` +
176
- `is using the deprecated "prepend" Typescript compiler option. ` +
177
- `This option is not supported by the batch executor and it's ignored.`);
178
- continue;
179
- }
180
- logInfo(`Compiling TypeScript files for project "${projectName}"...`);
181
- // build and mark project as complete
182
- const status = project.done(undefined, undefined, (0, get_custom_transformers_factory_1.getCustomTrasformersFactory)(taskInfo.options.transformers)(project.getProgram()));
183
- postProjectCompilationCallback(taskInfo);
184
- if (status === ts.ExitStatus.Success) {
185
- logInfo(`Done compiling TypeScript files for project "${projectName}".`);
186
- }
187
- results[taskInfo.task] = {
188
- success: status === ts.ExitStatus.Success,
189
- terminalOutput,
190
- startTime,
191
- endTime: Date.now(),
192
- };
193
- }
194
- return results;
195
- }
@@ -1 +0,0 @@
1
- test:$6FrCaT/v0dwE:autocreated 2020-03-25T19:10:50.254Z