nx 19.4.1 → 19.5.0-beta.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.
@@ -65,3 +65,4 @@ export declare class DaemonClient {
65
65
  stop(): Promise<void>;
66
66
  }
67
67
  export declare const daemonClient: DaemonClient;
68
+ export declare function isDaemonEnabled(): boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.daemonClient = exports.DaemonClient = void 0;
3
+ exports.isDaemonEnabled = exports.daemonClient = exports.DaemonClient = void 0;
4
4
  const workspace_root_1 = require("../../utils/workspace-root");
5
5
  const child_process_1 = require("child_process");
6
6
  const fs_1 = require("fs");
@@ -13,12 +13,13 @@ const output_1 = require("../../utils/output");
13
13
  const socket_utils_1 = require("../socket-utils");
14
14
  const tmp_dir_1 = require("../tmp-dir");
15
15
  const is_ci_1 = require("../../utils/is-ci");
16
+ const nx_json_1 = require("../../config/nx-json");
16
17
  const configuration_1 = require("../../config/configuration");
17
18
  const promised_based_queue_1 = require("../../utils/promised-based-queue");
18
- const nx_json_1 = require("../../config/nx-json");
19
19
  const daemon_socket_messenger_1 = require("./daemon-socket-messenger");
20
20
  const cache_1 = require("../cache");
21
21
  const error_types_1 = require("../../project-graph/error-types");
22
+ const native_1 = require("../../native");
22
23
  const get_nx_workspace_files_1 = require("../message-types/get-nx-workspace-files");
23
24
  const get_context_file_data_1 = require("../message-types/get-context-file-data");
24
25
  const get_files_in_directory_1 = require("../message-types/get-files-in-directory");
@@ -64,6 +65,7 @@ class DaemonClient {
64
65
  // CI=true,env=undefined => no daemon
65
66
  // CI=true,env=false => no daemon
66
67
  // CI=true,env=true => daemon
68
+ // WASM => no daemon because file watching does not work
67
69
  if (((0, is_ci_1.isCI)() && env !== 'true') ||
68
70
  isDocker() ||
69
71
  (0, tmp_dir_1.isDaemonDisabled)() ||
@@ -74,6 +76,12 @@ class DaemonClient {
74
76
  (useDaemonProcessOption === false && env === 'false')) {
75
77
  this._enabled = false;
76
78
  }
79
+ else if (native_1.IS_WASM) {
80
+ output_1.output.warn({
81
+ title: 'The Nx Daemon is unsupported in WebAssembly environments. Some things may be slower than or not function as expected.',
82
+ });
83
+ this._enabled = false;
84
+ }
77
85
  else {
78
86
  this._enabled = true;
79
87
  }
@@ -402,6 +410,10 @@ class DaemonClient {
402
410
  }
403
411
  exports.DaemonClient = DaemonClient;
404
412
  exports.daemonClient = new DaemonClient();
413
+ function isDaemonEnabled() {
414
+ return exports.daemonClient.enabled();
415
+ }
416
+ exports.isDaemonEnabled = isDaemonEnabled;
405
417
  function isDocker() {
406
418
  try {
407
419
  (0, fs_1.statSync)('/.dockerenv');
@@ -132,3 +132,4 @@ export { cacheDir } from './utils/cache-directory';
132
132
  * @category Utils
133
133
  */
134
134
  export { createProjectFileMapUsingProjectGraph } from './project-graph/file-map-utils';
135
+ export { isDaemonEnabled } from './daemon/client/client';
@@ -4,7 +4,7 @@
4
4
  * Try hard to not add to this API to reduce the surface area we need to maintain.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.globAsync = exports.glob = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.isWorkspacesEnabled = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.createNodesFromFiles = exports.AggregateCreateNodesError = exports.workspaceLayout = void 0;
7
+ exports.isDaemonEnabled = exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.globAsync = exports.glob = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.isWorkspacesEnabled = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.createNodesFromFiles = exports.AggregateCreateNodesError = exports.workspaceLayout = void 0;
8
8
  var configuration_1 = require("./config/configuration");
9
9
  Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return configuration_1.workspaceLayout; } });
10
10
  var error_types_1 = require("./project-graph/error-types");
@@ -138,3 +138,5 @@ Object.defineProperty(exports, "cacheDir", { enumerable: true, get: function ()
138
138
  */
139
139
  var file_map_utils_1 = require("./project-graph/file-map-utils");
140
140
  Object.defineProperty(exports, "createProjectFileMapUsingProjectGraph", { enumerable: true, get: function () { return file_map_utils_1.createProjectFileMapUsingProjectGraph; } });
141
+ var client_1 = require("./daemon/client/client");
142
+ Object.defineProperty(exports, "isDaemonEnabled", { enumerable: true, get: function () { return client_1.isDaemonEnabled; } });
@@ -0,0 +1 @@
1
+ export * from '@nx/nx-wasm32-wasi'
@@ -1,192 +1,232 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
1
  /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
5
3
 
6
- export class ExternalObject<T> {
4
+ export declare class ExternalObject<T> {
7
5
  readonly '': {
8
6
  readonly '': unique symbol
9
7
  [K: symbol]: T
10
8
  }
11
9
  }
10
+ export declare class ChildProcess {
11
+ kill(): void
12
+ onExit(callback: (message: string) => void): void
13
+ onOutput(callback: (message: string) => void): void
14
+ }
15
+
16
+ export declare class HashPlanner {
17
+ constructor(nxJson: NxJson, projectGraph: ExternalObject<ProjectGraph>)
18
+ getPlans(taskIds: Array<string>, taskGraph: TaskGraph): Record<string, string[]>
19
+ getPlansReference(taskIds: Array<string>, taskGraph: TaskGraph): JsExternal
20
+ }
21
+
22
+ export declare class ImportResult {
23
+ file: string
24
+ sourceProject: string
25
+ dynamicImportExpressions: Array<string>
26
+ staticImportExpressions: Array<string>
27
+ }
28
+
29
+ export declare class RustPseudoTerminal {
30
+ constructor()
31
+ runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, execArgv?: Array<string> | undefined | null, quiet?: boolean | undefined | null, tty?: boolean | undefined | null): ChildProcess
32
+ /**
33
+ * This allows us to run a pseudoterminal with a fake node ipc channel
34
+ * this makes it possible to be backwards compatible with the old implementation
35
+ */
36
+ fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, execArgv: Array<string> | undefined | null, quiet: boolean): ChildProcess
37
+ }
38
+
39
+ export declare class TaskHasher {
40
+ constructor(workspaceRoot: string, projectGraph: ExternalObject<ProjectGraph>, projectFileMap: ExternalObject<ProjectFiles>, allWorkspaceFiles: ExternalObject<Array<FileData>>, tsConfig: Buffer, tsConfigPaths: Record<string, Array<string>>, options?: HasherOptions | undefined | null)
41
+ hashPlans(hashPlans: ExternalObject<Record<string, Array<HashInstruction>>>, jsEnv: Record<string, string>): NapiDashMap
42
+ }
43
+
44
+ export declare class Watcher {
45
+ origin: string
46
+ /**
47
+ * Creates a new Watcher instance.
48
+ * Will always ignore the following directories:
49
+ * * .git/
50
+ * * node_modules/
51
+ * * .nx/
52
+ */
53
+ constructor(origin: string, additionalGlobs?: Array<string> | undefined | null, useIgnore?: boolean | undefined | null)
54
+ watch(callback: (err: string | null, events: WatchEvent[]) => void): void
55
+ stop(): Promise<void>
56
+ }
57
+
58
+ export declare class WorkspaceContext {
59
+ workspaceRoot: string
60
+ constructor(workspaceRoot: string, cacheDir: string)
61
+ getWorkspaceFiles(projectRootMap: Record<string, string>): NxWorkspaceFiles
62
+ glob(globs: Array<string>, exclude?: Array<string> | undefined | null): Array<string>
63
+ hashFilesMatchingGlob(globs: Array<string>, exclude?: Array<string> | undefined | null): string
64
+ incrementalUpdate(updatedFiles: Array<string>, deletedFiles: Array<string>): Record<string, string>
65
+ updateProjectFiles(projectRootMappings: ProjectRootMappings, projectFiles: ExternalObject<ProjectFiles>, globalFiles: ExternalObject<Array<FileData>>, updatedFiles: Record<string, string>, deletedFiles: Array<string>): UpdatedWorkspaceFiles
66
+ allFileData(): Array<FileData>
67
+ getFilesInDirectory(directory: string): Array<string>
68
+ }
69
+
70
+ export declare export function copy(src: string, dest: string): void
71
+
72
+ export interface DepsOutputsInput {
73
+ dependentTasksOutputFiles: string
74
+ transitive?: boolean
75
+ }
76
+
77
+ export interface EnvironmentInput {
78
+ env: string
79
+ }
80
+
81
+ export declare const enum EventType {
82
+ delete = 'delete',
83
+ update = 'update',
84
+ create = 'create'
85
+ }
86
+
12
87
  /**
13
88
  * Expands the given entries into a list of existing directories and files.
14
89
  * This is used for copying outputs to and from the cache
15
90
  */
16
- export function expandOutputs(directory: string, entries: Array<string>): Array<string>
17
- /**
18
- * Expands the given outputs into a list of existing files.
19
- * This is used when hashing outputs
20
- */
21
- export function getFilesForOutputs(directory: string, entries: Array<string>): Array<string>
22
- export function remove(src: string): void
23
- export function copy(src: string, dest: string): void
24
- export function hashArray(input: Array<string>): string
25
- export function hashFile(file: string): string | null
26
- export function findImports(projectFileMap: Record<string, Array<string>>): Array<ImportResult>
27
- /**
28
- * Transfer the project graph from the JS world to the Rust world, so that we can pass the project graph via memory quicker
29
- * This wont be needed once the project graph is created in Rust
30
- */
31
- export function transferProjectGraph(projectGraph: ProjectGraph): ExternalObject<ProjectGraph>
91
+ export declare export function expandOutputs(directory: string, entries: Array<string>): Array<string>
92
+
93
+ export interface ExternalDependenciesInput {
94
+ externalDependencies: Array<string>
95
+ }
96
+
32
97
  export interface ExternalNode {
33
98
  packageName?: string
34
99
  version: string
35
100
  hash?: string
36
101
  }
37
- export interface Target {
38
- executor?: string
39
- inputs?: Array<JsInputs>
40
- outputs?: Array<string>
41
- options?: string
42
- configurations?: string
102
+
103
+ export interface FileData {
104
+ file: string
105
+ hash: string
43
106
  }
44
- export interface Project {
45
- root: string
46
- namedInputs?: Record<string, Array<JsInputs>>
47
- tags?: Array<string>
48
- targets: Record<string, Target>
107
+
108
+ export interface FileMap {
109
+ projectFileMap: ProjectFiles
110
+ nonProjectFiles: Array<FileData>
49
111
  }
50
- export interface ProjectGraph {
51
- nodes: Record<string, Project>
52
- dependencies: Record<string, Array<string>>
53
- externalNodes: Record<string, ExternalNode>
112
+
113
+ export interface FileSetInput {
114
+ fileset: string
54
115
  }
116
+
117
+ export declare export function findImports(projectFileMap: Record<string, Array<string>>): Array<ImportResult>
118
+
119
+ /**
120
+ * Expands the given outputs into a list of existing files.
121
+ * This is used when hashing outputs
122
+ */
123
+ export declare export function getFilesForOutputs(directory: string, entries: Array<string>): Array<string>
124
+
125
+ export declare export function hashArray(input: Array<string>): string
126
+
55
127
  export interface HashDetails {
56
128
  value: string
57
129
  details: Record<string, string>
58
130
  }
131
+
59
132
  export interface HasherOptions {
60
133
  selectivelyHashTsConfig: boolean
61
134
  }
62
- export interface Task {
63
- id: string
64
- target: TaskTarget
65
- outputs: Array<string>
66
- projectRoot?: string
67
- }
68
- export interface TaskTarget {
69
- project: string
70
- target: string
71
- configuration?: string
72
- }
73
- export interface TaskGraph {
74
- roots: Array<string>
75
- tasks: Record<string, Task>
76
- dependencies: Record<string, Array<string>>
77
- }
78
- export interface FileData {
79
- file: string
80
- hash: string
81
- }
135
+
136
+ export declare export function hashFile(file: string): string | null
137
+
82
138
  export interface InputsInput {
83
139
  input: string
84
140
  dependencies?: boolean
85
141
  projects?: string | Array<string>
86
142
  }
87
- export interface FileSetInput {
88
- fileset: string
89
- }
90
- export interface RuntimeInput {
91
- runtime: string
92
- }
93
- export interface EnvironmentInput {
94
- env: string
95
- }
96
- export interface ExternalDependenciesInput {
97
- externalDependencies: Array<string>
98
- }
99
- export interface DepsOutputsInput {
100
- dependentTasksOutputFiles: string
101
- transitive?: boolean
102
- }
143
+
144
+ export const IS_WASM: boolean
145
+
103
146
  /** Stripped version of the NxJson interface for use in rust */
104
147
  export interface NxJson {
105
148
  namedInputs?: Record<string, Array<JsInputs>>
106
149
  }
107
- export const enum EventType {
108
- delete = 'delete',
109
- update = 'update',
110
- create = 'create'
111
- }
112
- export interface WatchEvent {
113
- path: string
114
- type: EventType
115
- }
116
- /** Public NAPI error codes that are for Node */
117
- export const enum WorkspaceErrors {
118
- ParseError = 'ParseError',
119
- Generic = 'Generic'
120
- }
150
+
121
151
  export interface NxWorkspaceFiles {
122
152
  projectFileMap: ProjectFiles
123
153
  globalFiles: Array<FileData>
124
154
  externalReferences?: NxWorkspaceFilesExternals
125
155
  }
156
+
126
157
  export interface NxWorkspaceFilesExternals {
127
158
  projectFiles: ExternalObject<ProjectFiles>
128
159
  globalFiles: ExternalObject<Array<FileData>>
129
160
  allWorkspaceFiles: ExternalObject<Array<FileData>>
130
161
  }
131
- export interface UpdatedWorkspaceFiles {
132
- fileMap: FileMap
133
- externalReferences: NxWorkspaceFilesExternals
162
+
163
+ export interface Project {
164
+ root: string
165
+ namedInputs?: Record<string, Array<JsInputs>>
166
+ tags?: Array<string>
167
+ targets: Record<string, Target>
134
168
  }
135
- export interface FileMap {
136
- projectFileMap: ProjectFiles
137
- nonProjectFiles: Array<FileData>
169
+
170
+ export interface ProjectGraph {
171
+ nodes: Record<string, Project>
172
+ dependencies: Record<string, Array<string>>
173
+ externalNodes: Record<string, ExternalNode>
138
174
  }
139
- export function testOnlyTransferFileMap(projectFiles: Record<string, Array<FileData>>, nonProjectFiles: Array<FileData>): NxWorkspaceFilesExternals
140
- export class ImportResult {
141
- file: string
142
- sourceProject: string
143
- dynamicImportExpressions: Array<string>
144
- staticImportExpressions: Array<string>
175
+
176
+ export declare export function remove(src: string): void
177
+
178
+ export interface RuntimeInput {
179
+ runtime: string
145
180
  }
146
- export class ChildProcess {
147
- kill(): void
148
- onExit(callback: (message: string) => void): void
149
- onOutput(callback: (message: string) => void): void
181
+
182
+ export interface Target {
183
+ executor?: string
184
+ inputs?: Array<JsInputs>
185
+ outputs?: Array<string>
186
+ options?: string
187
+ configurations?: string
150
188
  }
151
- export class RustPseudoTerminal {
152
- constructor()
153
- runCommand(command: string, commandDir?: string | undefined | null, jsEnv?: Record<string, string> | undefined | null, execArgv?: Array<string> | undefined | null, quiet?: boolean | undefined | null, tty?: boolean | undefined | null): ChildProcess
154
- /**
155
- * This allows us to run a pseudoterminal with a fake node ipc channel
156
- * this makes it possible to be backwards compatible with the old implementation
157
- */
158
- fork(id: string, forkScript: string, pseudoIpcPath: string, commandDir: string | undefined | null, jsEnv: Record<string, string> | undefined | null, execArgv: Array<string> | undefined | null, quiet: boolean): ChildProcess
189
+
190
+ export interface Task {
191
+ id: string
192
+ target: TaskTarget
193
+ outputs: Array<string>
194
+ projectRoot?: string
159
195
  }
160
- export class HashPlanner {
161
- constructor(nxJson: NxJson, projectGraph: ExternalObject<ProjectGraph>)
162
- getPlans(taskIds: Array<string>, taskGraph: TaskGraph): Record<string, string[]>
163
- getPlansReference(taskIds: Array<string>, taskGraph: TaskGraph): JsExternal
196
+
197
+ export interface TaskGraph {
198
+ roots: Array<string>
199
+ tasks: Record<string, Task>
200
+ dependencies: Record<string, Array<string>>
164
201
  }
165
- export class TaskHasher {
166
- constructor(workspaceRoot: string, projectGraph: ExternalObject<ProjectGraph>, projectFileMap: ExternalObject<ProjectFiles>, allWorkspaceFiles: ExternalObject<Array<FileData>>, tsConfig: Buffer, tsConfigPaths: Record<string, Array<string>>, options?: HasherOptions | undefined | null)
167
- hashPlans(hashPlans: ExternalObject<Record<string, Array<HashInstruction>>>, jsEnv: Record<string, string>): NapiDashMap
202
+
203
+ export interface TaskTarget {
204
+ project: string
205
+ target: string
206
+ configuration?: string
168
207
  }
169
- export class Watcher {
170
- origin: string
171
- /**
172
- * Creates a new Watcher instance.
173
- * Will always ignore the following directories:
174
- * * .git/
175
- * * node_modules/
176
- * * .nx/
177
- */
178
- constructor(origin: string, additionalGlobs?: Array<string> | undefined | null, useIgnore?: boolean | undefined | null)
179
- watch(callback: (err: string | null, events: WatchEvent[]) => void): void
180
- stop(): Promise<void>
208
+
209
+ export declare export function testOnlyTransferFileMap(projectFiles: Record<string, Array<FileData>>, nonProjectFiles: Array<FileData>): NxWorkspaceFilesExternals
210
+
211
+ /**
212
+ * Transfer the project graph from the JS world to the Rust world, so that we can pass the project graph via memory quicker
213
+ * This wont be needed once the project graph is created in Rust
214
+ */
215
+ export declare export function transferProjectGraph(projectGraph: ProjectGraph): ExternalObject<ProjectGraph>
216
+
217
+ export interface UpdatedWorkspaceFiles {
218
+ fileMap: FileMap
219
+ externalReferences: NxWorkspaceFilesExternals
181
220
  }
182
- export class WorkspaceContext {
183
- workspaceRoot: string
184
- constructor(workspaceRoot: string, cacheDir: string)
185
- getWorkspaceFiles(projectRootMap: Record<string, string>): NxWorkspaceFiles
186
- glob(globs: Array<string>, exclude?: Array<string> | undefined | null): Array<string>
187
- hashFilesMatchingGlob(globs: Array<string>, exclude?: Array<string> | undefined | null): string
188
- incrementalUpdate(updatedFiles: Array<string>, deletedFiles: Array<string>): Record<string, string>
189
- updateProjectFiles(projectRootMappings: ProjectRootMappings, projectFiles: ExternalObject<ProjectFiles>, globalFiles: ExternalObject<Array<FileData>>, updatedFiles: Record<string, string>, deletedFiles: Array<string>): UpdatedWorkspaceFiles
190
- allFileData(): Array<FileData>
191
- getFilesInDirectory(directory: string): Array<string>
221
+
222
+ export interface WatchEvent {
223
+ path: string
224
+ type: EventType
225
+ }
226
+
227
+ /** Public NAPI error codes that are for Node */
228
+ export declare const enum WorkspaceErrors {
229
+ ParseError = 'ParseError',
230
+ Generic = 'Generic'
192
231
  }
232
+
@@ -4,6 +4,22 @@ const Module = require('module');
4
4
  const { nxVersion } = require('../utils/versions');
5
5
  const { getNativeFileCacheLocation } = require('./native-file-cache-location');
6
6
 
7
+ // WASI is still experimental and throws a warning when used
8
+ // We spawn many many processes so the warning gets printed a lot
9
+ // We have a different warning elsewhere to warn people using WASI
10
+ const originalEmit = process.emit;
11
+ process.emit = function (eventName, eventData) {
12
+ if (
13
+ eventName === `warning` &&
14
+ typeof eventData === `object` &&
15
+ eventData?.name === `ExperimentalWarning` &&
16
+ eventData?.message?.includes(`WASI`)
17
+ ) {
18
+ return false;
19
+ }
20
+ return originalEmit.apply(process, arguments);
21
+ };
22
+
7
23
  const nxPackages = new Set([
8
24
  '@nx/nx-android-arm64',
9
25
  '@nx/nx-android-arm-eabi',