@nx/node 21.4.0-canary.20250809-014e775 → 21.4.0-canary.20250813-811d184
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 +7 -7
- package/src/generators/application/files/common/webpack.config.js__tmpl__ +11 -0
- package/src/generators/application/lib/create-files.d.ts.map +1 -1
- package/src/generators/application/lib/create-files.js +6 -0
- package/src/utils/vscode-debug-config.d.ts +8 -0
- package/src/utils/vscode-debug-config.d.ts.map +1 -0
- package/src/utils/vscode-debug-config.js +82 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/node",
|
3
|
-
"version": "21.4.0-canary.
|
3
|
+
"version": "21.4.0-canary.20250813-811d184",
|
4
4
|
"private": false,
|
5
5
|
"description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.",
|
6
6
|
"repository": {
|
@@ -32,16 +32,16 @@
|
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
34
|
"tslib": "^2.3.0",
|
35
|
-
"@nx/devkit": "21.4.0-canary.
|
36
|
-
"@nx/jest": "21.4.0-canary.
|
37
|
-
"@nx/js": "21.4.0-canary.
|
38
|
-
"@nx/eslint": "21.4.0-canary.
|
39
|
-
"@nx/docker": "21.4.0-canary.
|
35
|
+
"@nx/devkit": "21.4.0-canary.20250813-811d184",
|
36
|
+
"@nx/jest": "21.4.0-canary.20250813-811d184",
|
37
|
+
"@nx/js": "21.4.0-canary.20250813-811d184",
|
38
|
+
"@nx/eslint": "21.4.0-canary.20250813-811d184",
|
39
|
+
"@nx/docker": "21.4.0-canary.20250813-811d184",
|
40
40
|
"tcp-port-used": "^1.0.2",
|
41
41
|
"kill-port": "^1.6.1"
|
42
42
|
},
|
43
43
|
"devDependencies": {
|
44
|
-
"nx": "21.4.0-canary.
|
44
|
+
"nx": "21.4.0-canary.20250813-811d184"
|
45
45
|
},
|
46
46
|
"publishConfig": {
|
47
47
|
"access": "public"
|
@@ -5,6 +5,9 @@ const { join } = require('path');
|
|
5
5
|
module.exports = {
|
6
6
|
output: {
|
7
7
|
path: join(__dirname, '<%= webpackPluginOptions.outputPath %>'),
|
8
|
+
...(process.env.NODE_ENV !== 'production' && {
|
9
|
+
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
|
10
|
+
}),
|
8
11
|
},
|
9
12
|
plugins: [
|
10
13
|
new NxAppWebpackPlugin({
|
@@ -16,6 +19,7 @@ module.exports = {
|
|
16
19
|
optimization: false,
|
17
20
|
outputHashing: 'none',
|
18
21
|
generatePackageJson: true,
|
22
|
+
sourceMaps: true,
|
19
23
|
})
|
20
24
|
],
|
21
25
|
};
|
@@ -28,6 +32,13 @@ module.exports = composePlugins(
|
|
28
32
|
target: 'node',
|
29
33
|
}),
|
30
34
|
(config) => {
|
35
|
+
config.output = {
|
36
|
+
...config.output,
|
37
|
+
...(process.env.NODE_ENV !== 'production' && {
|
38
|
+
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
|
39
|
+
}),
|
40
|
+
};
|
41
|
+
config.devtool = 'source-map';
|
31
42
|
// Update the webpack config as needed here.
|
32
43
|
// e.g. `config.plugins.push(new MyPlugin())`
|
33
44
|
return config;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"create-files.d.ts","sourceRoot":"","sources":["../../../../../../../packages/node/src/generators/application/lib/create-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,IAAI,EACL,MAAM,YAAY,CAAC;
|
1
|
+
{"version":3,"file":"create-files.d.ts","sourceRoot":"","sources":["../../../../../../../packages/node/src/generators/application/lib/create-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,IAAI,EACL,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,QAgEhE"}
|
@@ -5,6 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const js_1 = require("@nx/js");
|
6
6
|
const path_1 = require("path");
|
7
7
|
const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
8
|
+
const vscode_debug_config_1 = require("../../../utils/vscode-debug-config");
|
8
9
|
function addAppFiles(tree, options) {
|
9
10
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common'), options.appProjectRoot, {
|
10
11
|
...options,
|
@@ -40,4 +41,9 @@ function addAppFiles(tree, options) {
|
|
40
41
|
if (options.js) {
|
41
42
|
(0, devkit_1.toJS)(tree);
|
42
43
|
}
|
44
|
+
// Generate a debug config for VS Code so that users can easily debug their application
|
45
|
+
(0, vscode_debug_config_1.addVSCodeDebugConfiguration)(tree, {
|
46
|
+
projectName: options.name,
|
47
|
+
projectRoot: options.appProjectRoot,
|
48
|
+
});
|
43
49
|
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
2
|
+
export interface VSCodeDebugConfigOptions {
|
3
|
+
projectName: string;
|
4
|
+
projectRoot: string;
|
5
|
+
packageManager?: string;
|
6
|
+
}
|
7
|
+
export declare function addVSCodeDebugConfiguration(tree: Tree, options: VSCodeDebugConfigOptions): void;
|
8
|
+
//# sourceMappingURL=vscode-debug-config.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"vscode-debug-config.d.ts","sourceRoot":"","sources":["../../../../../packages/node/src/utils/vscode-debug-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAKL,MAAM,YAAY,CAAC;AA+BpB,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,wBAAwB,GAChC,IAAI,CAwDN"}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.addVSCodeDebugConfiguration = addVSCodeDebugConfiguration;
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
5
|
+
function findFreeDebugPort(tree) {
|
6
|
+
let highestPort = 0;
|
7
|
+
// Check existing launch.json configurations for used debug ports
|
8
|
+
if (tree.exists('.vscode/launch.json')) {
|
9
|
+
try {
|
10
|
+
const launchConfig = JSON.parse(tree.read('.vscode/launch.json', 'utf-8'));
|
11
|
+
if (launchConfig.configurations) {
|
12
|
+
for (const config of launchConfig.configurations) {
|
13
|
+
if (config.env && config.env.NODE_OPTIONS) {
|
14
|
+
const match = config.env.NODE_OPTIONS.match(/--inspect=(\d+)/);
|
15
|
+
if (match) {
|
16
|
+
const currentPort = parseInt(match[1]);
|
17
|
+
highestPort = Math.max(highestPort, currentPort);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
catch {
|
24
|
+
// Ignore parsing errors
|
25
|
+
}
|
26
|
+
}
|
27
|
+
// Return the next available port after the highest used port, or 9229 if none are used
|
28
|
+
return highestPort > 0 ? highestPort + 1 : 9229;
|
29
|
+
}
|
30
|
+
function addVSCodeDebugConfiguration(tree, options) {
|
31
|
+
const pmCommand = (0, devkit_1.getPackageManagerCommand)().exec;
|
32
|
+
// Determine the output path based on project configuration
|
33
|
+
let outputPath;
|
34
|
+
try {
|
35
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
36
|
+
outputPath = projectConfig.targets?.build?.options?.outputPath;
|
37
|
+
}
|
38
|
+
catch {
|
39
|
+
outputPath = undefined;
|
40
|
+
}
|
41
|
+
// If no outputPath is configured, assume it's in the project directory
|
42
|
+
if (!outputPath) {
|
43
|
+
outputPath = `${options.projectRoot}/dist`;
|
44
|
+
}
|
45
|
+
// Find a free debug port to avoid conflicts
|
46
|
+
const debugPort = findFreeDebugPort(tree);
|
47
|
+
const debugConfig = {
|
48
|
+
type: 'node',
|
49
|
+
request: 'launch',
|
50
|
+
name: `Debug ${options.projectName} with Nx`,
|
51
|
+
runtimeExecutable: pmCommand,
|
52
|
+
runtimeArgs: ['nx', 'serve', options.projectName],
|
53
|
+
env: {
|
54
|
+
NODE_OPTIONS: `--inspect=${debugPort}`,
|
55
|
+
},
|
56
|
+
console: 'integratedTerminal',
|
57
|
+
internalConsoleOptions: 'neverOpen',
|
58
|
+
skipFiles: ['<node_internals>/**'],
|
59
|
+
sourceMaps: true,
|
60
|
+
outFiles: [
|
61
|
+
`\${workspaceFolder}/${outputPath}/**/*.(m|c|)js`,
|
62
|
+
'!**/node_modules/**',
|
63
|
+
],
|
64
|
+
};
|
65
|
+
if (!tree.exists('.vscode/launch.json')) {
|
66
|
+
// Create launch.json with the configuration
|
67
|
+
(0, devkit_1.writeJson)(tree, '.vscode/launch.json', {
|
68
|
+
version: '0.2.0',
|
69
|
+
configurations: [debugConfig],
|
70
|
+
});
|
71
|
+
}
|
72
|
+
else {
|
73
|
+
// Add configuration to existing launch.json
|
74
|
+
(0, devkit_1.updateJson)(tree, '.vscode/launch.json', (json) => {
|
75
|
+
if (!json.configurations) {
|
76
|
+
json.configurations = [];
|
77
|
+
}
|
78
|
+
json.configurations.push(debugConfig);
|
79
|
+
return json;
|
80
|
+
});
|
81
|
+
}
|
82
|
+
}
|