@nx/rsbuild 23.0.0-beta.18 → 23.0.0-beta.19
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 +4 -4
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +46 -11
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/rsbuild",
|
|
3
3
|
"description": "The Nx Plugin for Rsbuild contains an Nx plugin, executors and utilities that support building applications using Rsbuild.",
|
|
4
|
-
"version": "23.0.0-beta.
|
|
4
|
+
"version": "23.0.0-beta.19",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"executors": "./executors.json",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"tslib": "^2.3.0",
|
|
33
|
-
"@nx/devkit": "23.0.0-beta.
|
|
34
|
-
"@nx/js": "23.0.0-beta.
|
|
33
|
+
"@nx/devkit": "23.0.0-beta.19",
|
|
34
|
+
"@nx/js": "23.0.0-beta.19",
|
|
35
35
|
"minimatch": "10.2.5",
|
|
36
36
|
"semver": "^7.6.3",
|
|
37
37
|
"@phenomnomnominal/tsquery": "~6.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"nx": "23.0.0-beta.
|
|
40
|
+
"nx": "23.0.0-beta.19"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@rsbuild/core": "^1.0.0"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/plugins/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/plugins/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAKL,aAAa,EAMd,MAAM,YAAY,CAAC;AAYpB,MAAM,WAAW,oBAAoB;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAMD,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,oBAAoB,CAiE7D,CAAC"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -21,25 +21,37 @@ exports.createNodesV2 = [
|
|
|
21
21
|
const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
|
|
22
22
|
const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
23
23
|
const lockFileName = (0, js_1.getLockFileName)(packageManager);
|
|
24
|
+
const normalizedOptions = normalizeOptions(options);
|
|
24
25
|
try {
|
|
25
|
-
|
|
26
|
+
const { entries, preErrors } = await filterRsbuildConfigs(configFilePaths, context);
|
|
27
|
+
const projectHashes = await (0, internal_1.calculateHashesForCreateNodes)(entries.map((e) => e.projectRoot), { ...normalizedOptions, isUsingTsSolutionSetup }, context, entries.map(() => [lockFileName]));
|
|
28
|
+
let results = [];
|
|
29
|
+
let nodeErrors = [];
|
|
30
|
+
try {
|
|
31
|
+
results = await (0, devkit_1.createNodesFromFiles)((configFile, _, ctx, idx) => createNodesInternal(configFile, normalizedOptions, ctx, targetsCache, isUsingTsSolutionSetup, pmc, entries[idx].tsConfigFiles, projectHashes[idx]), entries.map((e) => e.configFile), options, context);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
if (e instanceof devkit_1.AggregateCreateNodesError) {
|
|
35
|
+
results = e.partialResults ?? [];
|
|
36
|
+
nodeErrors = e.errors;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const allErrors = [...preErrors, ...nodeErrors];
|
|
43
|
+
if (allErrors.length > 0) {
|
|
44
|
+
throw new devkit_1.AggregateCreateNodesError(allErrors, results);
|
|
45
|
+
}
|
|
46
|
+
return results;
|
|
26
47
|
}
|
|
27
48
|
finally {
|
|
28
49
|
targetsCache.writeToDisk();
|
|
29
50
|
}
|
|
30
51
|
},
|
|
31
52
|
];
|
|
32
|
-
async function createNodesInternal(configFilePath,
|
|
53
|
+
async function createNodesInternal(configFilePath, normalizedOptions, context, targetsCache, isUsingTsSolutionSetup, pmc, tsConfigFiles, hash) {
|
|
33
54
|
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
34
|
-
// Do not create a project if package.json and project.json isn't there.
|
|
35
|
-
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
36
|
-
if (!siblingFiles.includes('package.json') &&
|
|
37
|
-
!siblingFiles.includes('project.json')) {
|
|
38
|
-
return {};
|
|
39
|
-
}
|
|
40
|
-
const tsConfigFiles = siblingFiles.filter((p) => (0, minimatch_1.minimatch)(p, 'tsconfig*{.json,.*.json}')) ?? [];
|
|
41
|
-
const normalizedOptions = normalizeOptions(options);
|
|
42
|
-
const hash = await (0, internal_1.calculateHashForCreateNodes)(projectRoot, { ...normalizedOptions, isUsingTsSolutionSetup }, context, [lockFileName]);
|
|
43
55
|
if (!targetsCache.has(hash)) {
|
|
44
56
|
targetsCache.set(hash, await createRsbuildTargets(configFilePath, projectRoot, normalizedOptions, tsConfigFiles, isUsingTsSolutionSetup, context, pmc));
|
|
45
57
|
}
|
|
@@ -190,6 +202,29 @@ function normalizeOutputPath(outputPath, projectRoot, workspaceRoot, path) {
|
|
|
190
202
|
}
|
|
191
203
|
}
|
|
192
204
|
}
|
|
205
|
+
async function filterRsbuildConfigs(configFiles, context) {
|
|
206
|
+
const preErrors = [];
|
|
207
|
+
const candidates = await Promise.all(configFiles.map(async (configFile) => {
|
|
208
|
+
try {
|
|
209
|
+
const projectRoot = (0, path_1.dirname)(configFile);
|
|
210
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
211
|
+
if (!siblingFiles.includes('package.json') &&
|
|
212
|
+
!siblingFiles.includes('project.json')) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
const tsConfigFiles = siblingFiles.filter((p) => (0, minimatch_1.minimatch)(p, 'tsconfig*{.json,.*.json}')) ?? [];
|
|
216
|
+
return { configFile, projectRoot, tsConfigFiles };
|
|
217
|
+
}
|
|
218
|
+
catch (e) {
|
|
219
|
+
preErrors.push([configFile, e]);
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
}));
|
|
223
|
+
return {
|
|
224
|
+
entries: candidates.filter((c) => c !== null),
|
|
225
|
+
preErrors,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
193
228
|
function normalizeOptions(options) {
|
|
194
229
|
options ??= {};
|
|
195
230
|
options.buildTargetName ??= 'build';
|