@nx/js 0.0.0-pr-28808-ae8ea8d → 0.0.0-pr-28808-41aa4e0
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": "0.0.0-pr-28808-
|
|
3
|
+
"version": "0.0.0-pr-28808-41aa4e0",
|
|
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": "0.0.0-pr-28808-
|
|
43
|
-
"@nx/workspace": "0.0.0-pr-28808-
|
|
42
|
+
"@nx/devkit": "0.0.0-pr-28808-41aa4e0",
|
|
43
|
+
"@nx/workspace": "0.0.0-pr-28808-41aa4e0",
|
|
44
44
|
"@zkochan/js-yaml": "0.0.7",
|
|
45
45
|
"babel-plugin-const-enum": "^1.0.1",
|
|
46
46
|
"babel-plugin-macros": "^2.8.0",
|
|
@@ -76,7 +76,8 @@ async function createNodesInternal(configFilePath, options, context, lockFileNam
|
|
|
76
76
|
// project references and typecheck will fail.
|
|
77
77
|
if (siblingFiles.includes('next.config.js') ||
|
|
78
78
|
siblingFiles.includes('next.config.cjs') ||
|
|
79
|
-
siblingFiles.includes('next.config.mjs')
|
|
79
|
+
siblingFiles.includes('next.config.mjs') ||
|
|
80
|
+
siblingFiles.includes('next.config.ts')) {
|
|
80
81
|
return {};
|
|
81
82
|
}
|
|
82
83
|
/**
|
|
@@ -84,7 +85,7 @@ async function createNodesInternal(configFilePath, options, context, lockFileNam
|
|
|
84
85
|
* - hashes of the content of the relevant files that can affect what's inferred by the plugin:
|
|
85
86
|
* - current config file
|
|
86
87
|
* - config files extended by the current config file (recursively up to the root config file)
|
|
87
|
-
* - referenced config files that are internal to the owning Nx project of the current config file
|
|
88
|
+
* - referenced config files that are internal to the owning Nx project of the current config file, or is a shallow external reference of the owning Nx project
|
|
88
89
|
* - lock file
|
|
89
90
|
* - hash of the plugin options
|
|
90
91
|
* - current config file path
|
|
@@ -92,11 +93,13 @@ async function createNodesInternal(configFilePath, options, context, lockFileNam
|
|
|
92
93
|
const tsConfig = readCachedTsConfig(fullConfigPath);
|
|
93
94
|
const extendedConfigFiles = getExtendedConfigFiles(fullConfigPath, tsConfig);
|
|
94
95
|
const internalReferencedFiles = resolveInternalProjectReferences(tsConfig, context.workspaceRoot, projectRoot);
|
|
96
|
+
const externalProjectReferences = resolveShallowExternalProjectReferences(tsConfig, context.workspaceRoot, projectRoot);
|
|
95
97
|
const nodeHash = (0, file_hasher_1.hashArray)([
|
|
96
98
|
...[
|
|
97
99
|
fullConfigPath,
|
|
98
100
|
...extendedConfigFiles.files,
|
|
99
101
|
...Object.keys(internalReferencedFiles),
|
|
102
|
+
...Object.keys(externalProjectReferences),
|
|
100
103
|
(0, node_path_1.join)(context.workspaceRoot, lockFileName),
|
|
101
104
|
].map(file_hasher_1.hashFile),
|
|
102
105
|
(0, file_hasher_1.hashObject)(options),
|
|
@@ -126,14 +129,15 @@ function buildTscTargets(configFilePath, projectRoot, options, context) {
|
|
|
126
129
|
// Typecheck target
|
|
127
130
|
if ((0, node_path_1.basename)(configFilePath) === 'tsconfig.json' && options.typecheck) {
|
|
128
131
|
internalProjectReferences = resolveInternalProjectReferences(tsConfig, context.workspaceRoot, projectRoot);
|
|
132
|
+
const externalProjectReferences = resolveShallowExternalProjectReferences(tsConfig, context.workspaceRoot, projectRoot);
|
|
129
133
|
const targetName = options.typecheck.targetName;
|
|
130
134
|
if (!targets[targetName]) {
|
|
131
135
|
let command = `tsc --build --emitDeclarationOnly --pretty --verbose`;
|
|
132
136
|
if (tsConfig.options.noEmit ||
|
|
133
|
-
Object.values(internalProjectReferences).some((ref) => ref.options.noEmit)
|
|
134
|
-
|
|
135
|
-
//
|
|
136
|
-
command = `
|
|
137
|
+
Object.values(internalProjectReferences).some((ref) => ref.options.noEmit) ||
|
|
138
|
+
Object.values(externalProjectReferences).some((ref) => ref.options.noEmit)) {
|
|
139
|
+
// `tsc --build` does not work with `noEmit: true`
|
|
140
|
+
command = `echo "The 'typecheck' target is disabled because one or more project references set 'noEmit: true' in their tsconfig. Remove this property to resolve this issue."`;
|
|
137
141
|
}
|
|
138
142
|
targets[targetName] = {
|
|
139
143
|
dependsOn: [`^${targetName}`],
|
|
@@ -328,6 +332,27 @@ function getExtendedConfigFiles(tsConfigPath, tsConfig) {
|
|
|
328
332
|
};
|
|
329
333
|
}
|
|
330
334
|
function resolveInternalProjectReferences(tsConfig, workspaceRoot, projectRoot, projectReferences = {}) {
|
|
335
|
+
walkProjectReferences(tsConfig, workspaceRoot, projectRoot, (configPath, config) => {
|
|
336
|
+
if (isExternalProjectReference(configPath, workspaceRoot, projectRoot)) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
projectReferences[configPath] = config;
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
return projectReferences;
|
|
344
|
+
}
|
|
345
|
+
function resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, projectRoot, projectReferences = {}) {
|
|
346
|
+
walkProjectReferences(tsConfig, workspaceRoot, projectRoot, (configPath, config) => {
|
|
347
|
+
if (isExternalProjectReference(configPath, workspaceRoot, projectRoot)) {
|
|
348
|
+
projectReferences[configPath] = config;
|
|
349
|
+
}
|
|
350
|
+
return false;
|
|
351
|
+
});
|
|
352
|
+
return projectReferences;
|
|
353
|
+
}
|
|
354
|
+
function walkProjectReferences(tsConfig, workspaceRoot, projectRoot, visitor, // false stops recursion
|
|
355
|
+
projectReferences = {}) {
|
|
331
356
|
if (!tsConfig.projectReferences?.length) {
|
|
332
357
|
return projectReferences;
|
|
333
358
|
}
|
|
@@ -341,15 +366,14 @@ function resolveInternalProjectReferences(tsConfig, workspaceRoot, projectRoot,
|
|
|
341
366
|
// the referenced tsconfig doesn't exist, ignore it
|
|
342
367
|
continue;
|
|
343
368
|
}
|
|
344
|
-
if (isExternalProjectReference(refConfigPath, workspaceRoot, projectRoot)) {
|
|
345
|
-
continue;
|
|
346
|
-
}
|
|
347
369
|
if (!refConfigPath.endsWith('.json')) {
|
|
348
370
|
refConfigPath = (0, node_path_1.join)(refConfigPath, 'tsconfig.json');
|
|
349
371
|
}
|
|
350
372
|
const refTsConfig = readCachedTsConfig(refConfigPath);
|
|
351
|
-
|
|
352
|
-
|
|
373
|
+
const result = visitor(refConfigPath, refTsConfig);
|
|
374
|
+
if (result !== false) {
|
|
375
|
+
walkProjectReferences(refTsConfig, workspaceRoot, projectRoot, visitor);
|
|
376
|
+
}
|
|
353
377
|
}
|
|
354
378
|
return projectReferences;
|
|
355
379
|
}
|
|
@@ -7,6 +7,7 @@ exports.updateTsconfigFiles = updateTsconfigFiles;
|
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
const tree_1 = require("nx/src/generators/tree");
|
|
9
9
|
const package_manager_workspaces_1 = require("../package-manager-workspaces");
|
|
10
|
+
const posix_1 = require("node:path/posix");
|
|
10
11
|
function isUsingTypeScriptPlugin(tree) {
|
|
11
12
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
12
13
|
return (nxJson?.plugins?.some((p) => typeof p === 'string'
|
|
@@ -110,6 +111,9 @@ function updateTsconfigFiles(tree, projectRoot, runtimeTsconfigFileName, compile
|
|
|
110
111
|
// tsconfig.json for e2e projects need to have references array
|
|
111
112
|
(0, devkit_1.updateJson)(tree, tsconfigE2E, (json) => {
|
|
112
113
|
json.references ??= [];
|
|
114
|
+
const projectPath = (0, posix_1.relative)(e2eRoot, projectRoot);
|
|
115
|
+
if (!json.references.some((x) => x.path === projectPath))
|
|
116
|
+
json.references.push({ path: projectPath });
|
|
113
117
|
return json;
|
|
114
118
|
});
|
|
115
119
|
}
|