@nx/js 16.4.0-beta.9 → 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 (38) hide show
  1. package/babel.js +3 -1
  2. package/migrations.json +12 -0
  3. package/package.json +6 -6
  4. package/src/executors/node/node.impl.d.ts +1 -0
  5. package/src/executors/node/node.impl.js +27 -7
  6. package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.d.ts +2 -1
  7. package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +22 -17
  8. package/src/executors/tsc/lib/batch/index.d.ts +0 -4
  9. package/src/executors/tsc/lib/batch/index.js +0 -4
  10. package/src/executors/tsc/lib/batch/types.d.ts +5 -0
  11. package/src/executors/tsc/lib/get-task-options.d.ts +8 -0
  12. package/src/executors/tsc/lib/get-task-options.js +51 -0
  13. package/src/executors/tsc/lib/get-tsconfig.d.ts +4 -0
  14. package/src/executors/tsc/lib/get-tsconfig.js +138 -0
  15. package/src/executors/tsc/lib/index.d.ts +2 -0
  16. package/src/executors/tsc/lib/index.js +2 -0
  17. package/src/executors/tsc/lib/typescript-compilation.d.ts +29 -0
  18. package/src/executors/tsc/lib/typescript-compilation.js +206 -0
  19. package/src/executors/tsc/lib/{batch/typescript-diagnostic-reporters.d.ts → typescript-diagnostic-reporters.d.ts} +0 -1
  20. package/src/executors/tsc/lib/{batch/typescript-diagnostic-reporters.js → typescript-diagnostic-reporters.js} +1 -8
  21. package/src/executors/tsc/tsc.batch-impl.d.ts +3 -2
  22. package/src/executors/tsc/tsc.batch-impl.js +97 -7
  23. package/src/executors/verdaccio/verdaccio.impl.js +60 -24
  24. package/src/generators/setup-verdaccio/files/config.yml +4 -5
  25. package/src/internal.d.ts +1 -0
  26. package/src/internal.js +4 -1
  27. package/src/plugins/jest/start-local-registry.js +5 -1
  28. package/src/utils/compiler-helper-dependency.d.ts +2 -1
  29. package/src/utils/compiler-helper-dependency.js +14 -4
  30. package/src/utils/versions.d.ts +1 -1
  31. package/src/utils/versions.js +1 -1
  32. package/src/executors/tsc/lib/batch/generate-temp-tsconfig.d.ts +0 -3
  33. package/src/executors/tsc/lib/batch/generate-temp-tsconfig.js +0 -52
  34. package/src/executors/tsc/lib/batch/get-task-options.d.ts +0 -3
  35. package/src/executors/tsc/lib/batch/get-task-options.js +0 -24
  36. package/src/executors/tsc/lib/batch/typescript-compilation.d.ts +0 -7
  37. package/src/executors/tsc/lib/batch/typescript-compilation.js +0 -195
  38. package/src/generators/setup-verdaccio/files/htpasswd +0 -1
@@ -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