@nx/js 19.7.0-canary.20240905-ccda7f9 → 19.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "19.7.0-canary.20240905-ccda7f9",
3
+ "version": "19.7.0",
4
4
  "private": false,
5
5
  "description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
6
6
  "repository": {
@@ -39,8 +39,8 @@
39
39
  "@babel/preset-env": "^7.23.2",
40
40
  "@babel/preset-typescript": "^7.22.5",
41
41
  "@babel/runtime": "^7.22.6",
42
- "@nx/devkit": "19.7.0-canary.20240905-ccda7f9",
43
- "@nx/workspace": "19.7.0-canary.20240905-ccda7f9",
42
+ "@nx/devkit": "19.7.0",
43
+ "@nx/workspace": "19.7.0",
44
44
  "babel-plugin-const-enum": "^1.0.1",
45
45
  "babel-plugin-macros": "^2.8.0",
46
46
  "babel-plugin-transform-typescript-metadata": "^0.3.1",
@@ -61,7 +61,7 @@
61
61
  "ts-node": "10.9.1",
62
62
  "tsconfig-paths": "^4.1.2",
63
63
  "tslib": "^2.3.0",
64
- "@nrwl/js": "19.7.0-canary.20240905-ccda7f9"
64
+ "@nrwl/js": "19.7.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "verdaccio": "^5.0.4"
@@ -1,4 +1,7 @@
1
+ declare const Module: any;
1
2
  declare const url: any;
2
- declare const patchSigint: any;
3
- declare const patchRequire: any;
3
+ declare const originalLoader: any;
4
4
  declare const dynamicImport: Function;
5
+ declare const mappings: any;
6
+ declare const keys: string[];
7
+ declare const fileToRun: any;
@@ -1,7 +1,21 @@
1
+ const Module = require('module');
1
2
  const url = require('node:url');
2
- const { patchSigint } = require('./patch-sigint');
3
- const { patchRequire } = require('./patch-require');
4
- patchSigint();
5
- patchRequire();
3
+ const originalLoader = Module._load;
6
4
  const dynamicImport = new Function('specifier', 'return import(specifier)');
7
- dynamicImport(url.pathToFileURL(process.env.NX_FILE_TO_RUN));
5
+ const mappings = JSON.parse(process.env.NX_MAPPINGS);
6
+ const keys = Object.keys(mappings);
7
+ const fileToRun = url.pathToFileURL(process.env.NX_FILE_TO_RUN);
8
+ Module._load = function (request, parent) {
9
+ if (!parent)
10
+ return originalLoader.apply(this, arguments);
11
+ const match = keys.find((k) => request === k);
12
+ if (match) {
13
+ const newArguments = [...arguments];
14
+ newArguments[0] = mappings[match];
15
+ return originalLoader.apply(this, newArguments);
16
+ }
17
+ else {
18
+ return originalLoader.apply(this, arguments);
19
+ }
20
+ };
21
+ dynamicImport(fileToRun);
@@ -111,14 +111,11 @@ async function* nodeExecutor(options, context) {
111
111
  task.childProcess.stderr.on('data', handleStdErr);
112
112
  task.childProcess.once('exit', (code) => {
113
113
  task.childProcess.off('data', handleStdErr);
114
- if (options.watch &&
115
- !task.killed &&
116
- // SIGINT should exist the process rather than watch for changes.
117
- code !== 130) {
114
+ if (options.watch && !task.killed) {
118
115
  devkit_1.logger.info(`NX Process exited with code ${code}, waiting for changes to restart...`);
119
116
  }
120
- if (!options.watch || code === 130) {
121
- if (code !== 0 && code !== 130) {
117
+ if (!options.watch) {
118
+ if (code !== 0) {
122
119
  error(new Error(`Process exited with code ${code}`));
123
120
  }
124
121
  else {
@@ -12,6 +12,7 @@ const file_hasher_1 = require("nx/src/hasher/file-hasher");
12
12
  const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
13
13
  const cache_directory_1 = require("nx/src/utils/cache-directory");
14
14
  const ts_config_1 = require("../../utils/typescript/ts-config");
15
+ const pmc = (0, devkit_1.getPackageManagerCommand)();
15
16
  function readTargetsCache(cachePath) {
16
17
  return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, node_fs_1.existsSync)(cachePath)
17
18
  ? (0, devkit_1.readJsonFile)(cachePath)
@@ -110,6 +111,16 @@ function buildTscTargets(configFilePath, projectRoot, options, context) {
110
111
  inputs: getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
111
112
  outputs: getOutputs(configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
112
113
  syncGenerators: ['@nx/js:typescript-sync'],
114
+ metadata: {
115
+ technologies: ['typescript'],
116
+ description: 'Runs type-checking for the project.',
117
+ help: {
118
+ command: `${pmc.exec} tsc --build --help`,
119
+ example: {
120
+ args: ['--force'],
121
+ },
122
+ },
123
+ },
113
124
  };
114
125
  }
115
126
  }
@@ -125,6 +136,16 @@ function buildTscTargets(configFilePath, projectRoot, options, context) {
125
136
  inputs: getInputs(namedInputs, configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
126
137
  outputs: getOutputs(configFilePath, tsConfig, internalProjectReferences, context.workspaceRoot, projectRoot),
127
138
  syncGenerators: ['@nx/js:typescript-sync'],
139
+ metadata: {
140
+ technologies: ['typescript'],
141
+ description: 'Builds the project with `tsc`.',
142
+ help: {
143
+ command: `${pmc.exec} tsc --build --help`,
144
+ example: {
145
+ args: ['--force'],
146
+ },
147
+ },
148
+ },
128
149
  };
129
150
  }
130
151
  return { targets };
@@ -1,5 +0,0 @@
1
- /**
2
- * Overrides require calls to map buildable workspace libs to their output location.
3
- * This is useful for running programs compiled via TSC/SWC that aren't bundled.
4
- */
5
- export declare function patchRequire(): void;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.patchRequire = patchRequire;
4
- const Module = require('node:module');
5
- const originalLoader = Module._load;
6
- /**
7
- * Overrides require calls to map buildable workspace libs to their output location.
8
- * This is useful for running programs compiled via TSC/SWC that aren't bundled.
9
- */
10
- function patchRequire() {
11
- const mappings = JSON.parse(process.env.NX_MAPPINGS);
12
- const keys = Object.keys(mappings);
13
- Module._load = function (request, parent) {
14
- if (!parent)
15
- return originalLoader.apply(this, arguments);
16
- const match = keys.find((k) => request === k);
17
- if (match) {
18
- const newArguments = [...arguments];
19
- newArguments[0] = mappings[match];
20
- return originalLoader.apply(this, newArguments);
21
- }
22
- else {
23
- return originalLoader.apply(this, arguments);
24
- }
25
- };
26
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Patches the current process so that Ctrl+C is properly handled.
3
- * Without this patch, SIGINT or Ctrl+C does not wait for graceful shutdown and exits immediately.
4
- */
5
- export declare function patchSigint(): void;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.patchSigint = patchSigint;
4
- const readline = require('node:readline');
5
- /**
6
- * Patches the current process so that Ctrl+C is properly handled.
7
- * Without this patch, SIGINT or Ctrl+C does not wait for graceful shutdown and exits immediately.
8
- */
9
- function patchSigint() {
10
- readline.emitKeypressEvents(process.stdin);
11
- if (process.stdin.isTTY)
12
- process.stdin.setRawMode(true);
13
- process.stdin.on('keypress', async (chunk, key) => {
14
- if (key && key.ctrl && key.name === 'c') {
15
- process.stdin.setRawMode(false); // To ensure nx terminal is not stuck in raw mode
16
- const listeners = process.listeners('SIGINT');
17
- for (const listener of listeners) {
18
- await listener('SIGINT');
19
- }
20
- process.exit(130);
21
- }
22
- });
23
- console.log('To exit the process, press Ctrl+C');
24
- }