@nx/rsbuild 23.0.0-beta.2 → 23.0.0-beta.21
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 +15 -8
- package/src/generators/configuration/configuration.d.ts.map +1 -1
- package/src/generators/configuration/configuration.js +5 -2
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +8 -4
- package/src/generators/init/schema.json +1 -1
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +68 -33
- package/src/utils/assert-supported-rsbuild-version.d.ts +3 -0
- package/src/utils/assert-supported-rsbuild-version.d.ts.map +1 -0
- package/src/utils/assert-supported-rsbuild-version.js +8 -0
- package/src/utils/e2e-web-server-info-utils.d.ts +1 -1
- package/src/utils/e2e-web-server-info-utils.d.ts.map +1 -1
- package/src/utils/e2e-web-server-info-utils.js +6 -5
- package/src/utils/version-utils.d.ts +28 -0
- package/src/utils/version-utils.d.ts.map +1 -0
- package/src/utils/version-utils.js +53 -0
- package/src/utils/versions.d.ts +20 -4
- package/src/utils/versions.d.ts.map +1 -1
- package/src/utils/versions.js +23 -5
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.21",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -30,16 +30,23 @@
|
|
|
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.
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"@phenomnomnominal/tsquery": "~6.
|
|
33
|
+
"@nx/devkit": "23.0.0-beta.21",
|
|
34
|
+
"@nx/js": "23.0.0-beta.21",
|
|
35
|
+
"minimatch": "10.2.5",
|
|
36
|
+
"semver": "^7.6.3",
|
|
37
|
+
"@phenomnomnominal/tsquery": "~6.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"nx": "23.0.0-beta.
|
|
40
|
+
"nx": "23.0.0-beta.21"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@rsbuild/core": "^1.0.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"@rsbuild/core": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
41
49
|
},
|
|
42
|
-
"peerDependencies": {},
|
|
43
50
|
"nx-migrations": {
|
|
44
51
|
"migrations": "./migrations.json"
|
|
45
52
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/rsbuild/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAIjB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/rsbuild/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAIjB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAQvC,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,8BA0DtE;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -5,9 +5,11 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const lib_1 = require("./lib");
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
7
7
|
const init_1 = require("../init/init");
|
|
8
|
-
const
|
|
8
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
9
|
+
const assert_supported_rsbuild_version_1 = require("../../utils/assert-supported-rsbuild-version");
|
|
9
10
|
const path_1 = require("path");
|
|
10
11
|
async function configurationGenerator(tree, schema) {
|
|
12
|
+
(0, assert_supported_rsbuild_version_1.assertSupportedRsbuildVersion)(tree);
|
|
11
13
|
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
12
14
|
const projects = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
13
15
|
let project = projects.projects[schema.project];
|
|
@@ -39,7 +41,8 @@ async function configurationGenerator(tree, schema) {
|
|
|
39
41
|
delete projectJson.targets['dev'];
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
|
-
|
|
44
|
+
const rsbuildVersions = (0, version_utils_1.getRsbuildVersionsForInstalledMajor)(tree);
|
|
45
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@rsbuild/core': rsbuildVersions.rsbuildVersion }, undefined, true));
|
|
43
46
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), options.projectRoot, {
|
|
44
47
|
...options,
|
|
45
48
|
tpl: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/rsbuild/src/generators/init/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/rsbuild/src/generators/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,iBAAiB,EAMvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAM/C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,qBAazE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,8BAEpE;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,mBAAmB,8BAoD5B;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -3,26 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateDependencies = updateDependencies;
|
|
4
4
|
exports.initGenerator = initGenerator;
|
|
5
5
|
exports.initGeneratorInternal = initGeneratorInternal;
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
7
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
8
8
|
const plugin_1 = require("../../plugins/plugin");
|
|
9
9
|
const versions_1 = require("../../utils/versions");
|
|
10
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
11
|
+
const assert_supported_rsbuild_version_1 = require("../../utils/assert-supported-rsbuild-version");
|
|
10
12
|
function updateDependencies(tree, schema) {
|
|
13
|
+
const rsbuildVersions = (0, version_utils_1.getRsbuildVersionsForInstalledMajor)(tree);
|
|
11
14
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
12
15
|
'@nx/rsbuild': versions_1.nxVersion,
|
|
13
|
-
'@rsbuild/core':
|
|
14
|
-
}, undefined, schema.keepExistingVersions);
|
|
16
|
+
'@rsbuild/core': rsbuildVersions.rsbuildVersion,
|
|
17
|
+
}, undefined, schema.keepExistingVersions ?? true);
|
|
15
18
|
}
|
|
16
19
|
function initGenerator(tree, schema) {
|
|
17
20
|
return initGeneratorInternal(tree, { addPlugin: false, ...schema });
|
|
18
21
|
}
|
|
19
22
|
async function initGeneratorInternal(tree, schema) {
|
|
23
|
+
(0, assert_supported_rsbuild_version_1.assertSupportedRsbuildVersion)(tree);
|
|
20
24
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
21
25
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
22
26
|
nxJson.useInferencePlugins !== false;
|
|
23
27
|
schema.addPlugin ??= addPluginDefault;
|
|
24
28
|
if (schema.addPlugin) {
|
|
25
|
-
await (0,
|
|
29
|
+
await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rsbuild', plugin_1.createNodesV2, {
|
|
26
30
|
buildTargetName: ['build', 'rsbuild:build', 'rsbuild-build'],
|
|
27
31
|
devTargetName: ['dev', 'rsbuild:dev', 'rsbuild-dev'],
|
|
28
32
|
previewTargetName: ['preview', 'rsbuild:preview', 'rsbuild-preview'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/plugins/plugin.ts"],"names":[],"mappings":"
|
|
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
|
@@ -1,54 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesV2 = void 0;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
6
6
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
7
7
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
8
|
-
const
|
|
9
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
8
|
+
const internal_2 = require("@nx/js/internal");
|
|
10
9
|
const js_1 = require("@nx/js");
|
|
11
10
|
const fs_1 = require("fs");
|
|
12
11
|
const path_1 = require("path");
|
|
13
12
|
const minimatch_1 = require("minimatch");
|
|
14
|
-
const core_1 = require("@rsbuild/core");
|
|
15
|
-
const util_1 = require("@nx/js/src/plugins/typescript/util");
|
|
16
|
-
function readTargetsCache(cachePath) {
|
|
17
|
-
return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
|
|
18
|
-
}
|
|
19
|
-
function writeTargetsCache(cachePath, results) {
|
|
20
|
-
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
21
|
-
}
|
|
22
13
|
const rsbuildConfigGlob = '**/rsbuild.config.{js,ts,mjs,mts,cjs,cts}';
|
|
23
14
|
exports.createNodesV2 = [
|
|
24
15
|
rsbuildConfigGlob,
|
|
25
16
|
async (configFilePaths, options, context) => {
|
|
26
17
|
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
27
18
|
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `rsbuild-${optionsHash}.hash`);
|
|
28
|
-
const targetsCache =
|
|
29
|
-
const isUsingTsSolutionSetup = (0,
|
|
30
|
-
const
|
|
19
|
+
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
20
|
+
const isUsingTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)();
|
|
21
|
+
const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
|
|
22
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
23
|
+
const lockFileName = (0, js_1.getLockFileName)(packageManager);
|
|
24
|
+
const normalizedOptions = normalizeOptions(options);
|
|
31
25
|
try {
|
|
32
|
-
|
|
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;
|
|
33
47
|
}
|
|
34
48
|
finally {
|
|
35
|
-
|
|
49
|
+
targetsCache.writeToDisk();
|
|
36
50
|
}
|
|
37
51
|
},
|
|
38
52
|
];
|
|
39
|
-
async function createNodesInternal(configFilePath,
|
|
53
|
+
async function createNodesInternal(configFilePath, normalizedOptions, context, targetsCache, isUsingTsSolutionSetup, pmc, tsConfigFiles, hash) {
|
|
40
54
|
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (!siblingFiles.includes('package.json') &&
|
|
44
|
-
!siblingFiles.includes('project.json')) {
|
|
45
|
-
return {};
|
|
55
|
+
if (!targetsCache.has(hash)) {
|
|
56
|
+
targetsCache.set(hash, await createRsbuildTargets(configFilePath, projectRoot, normalizedOptions, tsConfigFiles, isUsingTsSolutionSetup, context, pmc));
|
|
46
57
|
}
|
|
47
|
-
const
|
|
48
|
-
const normalizedOptions = normalizeOptions(options);
|
|
49
|
-
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, { ...normalizedOptions, isUsingTsSolutionSetup }, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
|
|
50
|
-
targetsCache[hash] ??= await createRsbuildTargets(configFilePath, projectRoot, normalizedOptions, tsConfigFiles, isUsingTsSolutionSetup, context, pmc);
|
|
51
|
-
const { targets, metadata } = targetsCache[hash];
|
|
58
|
+
const { targets, metadata } = targetsCache.get(hash);
|
|
52
59
|
return {
|
|
53
60
|
projects: {
|
|
54
61
|
[projectRoot]: {
|
|
@@ -61,13 +68,17 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
|
|
|
61
68
|
}
|
|
62
69
|
async function createRsbuildTargets(configFilePath, projectRoot, options, tsConfigFiles, isUsingTsSolutionSetup, context, pmc) {
|
|
63
70
|
const absoluteConfigFilePath = (0, devkit_1.joinPathFragments)(context.workspaceRoot, configFilePath);
|
|
64
|
-
|
|
71
|
+
// Required lazily: `@rsbuild/core` is an optional peer dependency, so it
|
|
72
|
+
// may be absent when the plugin is loaded in a workspace that doesn't use
|
|
73
|
+
// Rsbuild yet (e.g. before a generator installs it).
|
|
74
|
+
const { loadConfig } = require('@rsbuild/core');
|
|
75
|
+
const rsbuildConfig = await loadConfig({
|
|
65
76
|
path: absoluteConfigFilePath,
|
|
66
77
|
});
|
|
67
78
|
if (!rsbuildConfig.filePath) {
|
|
68
79
|
return { targets: {}, metadata: {} };
|
|
69
80
|
}
|
|
70
|
-
const namedInputs = (0,
|
|
81
|
+
const namedInputs = (0, internal_1.getNamedInputs)(projectRoot, context);
|
|
71
82
|
const { buildOutputs } = getOutputs(rsbuildConfig.content, projectRoot, context.workspaceRoot);
|
|
72
83
|
const targets = {};
|
|
73
84
|
targets[options.buildTargetName] = {
|
|
@@ -156,13 +167,14 @@ async function createRsbuildTargets(configFilePath, projectRoot, options, tsConf
|
|
|
156
167
|
];
|
|
157
168
|
}
|
|
158
169
|
}
|
|
159
|
-
(0,
|
|
170
|
+
(0, internal_2.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmc);
|
|
160
171
|
return { targets, metadata: {} };
|
|
161
172
|
}
|
|
162
173
|
function getOutputs(rsbuildConfig, projectRoot, workspaceRoot) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
174
|
+
// `output.distPath.root` is the directory Rsbuild emits the build into, so
|
|
175
|
+
// it is the build output as-is. (Don't take its `dirname` - that points at
|
|
176
|
+
// the parent directory, which can capture sibling projects' outputs.)
|
|
177
|
+
const buildOutputPath = normalizeOutputPath(rsbuildConfig?.output?.distPath?.root, projectRoot, workspaceRoot, 'dist');
|
|
166
178
|
return {
|
|
167
179
|
buildOutputs: [buildOutputPath],
|
|
168
180
|
};
|
|
@@ -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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-supported-rsbuild-version.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/utils/assert-supported-rsbuild-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAIvC,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAM9D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertSupportedRsbuildVersion = assertSupportedRsbuildVersion;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
|
+
const versions_1 = require("./versions");
|
|
6
|
+
function assertSupportedRsbuildVersion(tree) {
|
|
7
|
+
(0, internal_1.assertSupportedPackageVersion)(tree, '@rsbuild/core', versions_1.minSupportedRsbuildVersion);
|
|
8
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
|
-
export declare function getRsbuildE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number): Promise<import("@nx/devkit/
|
|
2
|
+
export declare function getRsbuildE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number): Promise<import("@nx/devkit/internal").E2EWebServerDetails>;
|
|
3
3
|
//# sourceMappingURL=e2e-web-server-info-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e2e-web-server-info-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/utils/e2e-web-server-info-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"e2e-web-server-info-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/utils/e2e-web-server-info-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,YAAY,CAAC;AAMnD,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,OAAO,EAC3B,eAAe,CAAC,EAAE,MAAM,8DA6BzB"}
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRsbuildE2EWebServerInfo = getRsbuildE2EWebServerInfo;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
async function getRsbuildE2EWebServerInfo(tree, projectName, configFilePath, isPluginBeingAdded, e2ePortOverride) {
|
|
7
7
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
8
8
|
let e2ePort = e2ePortOverride ?? 4200;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const devPort = (0, internal_1.readTargetDefaultsForTarget)('dev', nxJson.targetDefaults)
|
|
10
|
+
?.options?.port;
|
|
11
|
+
if (devPort) {
|
|
12
|
+
e2ePort = devPort;
|
|
12
13
|
}
|
|
13
|
-
return (0,
|
|
14
|
+
return (0, internal_1.getE2EWebServerInfo)(tree, projectName, {
|
|
14
15
|
plugin: '@nx/rsbuild',
|
|
15
16
|
serveTargetName: 'devTargetName',
|
|
16
17
|
serveStaticTargetName: 'previewTargetName',
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import { type SupportedRsbuildMajorVersion } from './versions';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the declared @rsbuild/core major version from the workspace's
|
|
5
|
+
* package.json when it matches a supported major, or `undefined` otherwise
|
|
6
|
+
* (fresh install, dist tag, unknown major). Below-floor enforcement is
|
|
7
|
+
* handled at generator entry points via `assertSupportedRsbuildVersion`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getInstalledRsbuildMajorVersion(tree: Tree): SupportedRsbuildMajorVersion | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the installed @rsbuild/core major version resolved at runtime from
|
|
12
|
+
* node_modules. For use in executors and runtime code where no Tree is
|
|
13
|
+
* available. Returns `null` when @rsbuild/core can't be resolved or the
|
|
14
|
+
* installed major isn't supported.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getInstalledRsbuildVersionRuntime(): SupportedRsbuildMajorVersion | null;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the version-map entry for the installed major, falling back to the
|
|
19
|
+
* latest supported map when no installed version is detected (fresh install)
|
|
20
|
+
* or the detected major is outside the supported window.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getRsbuildVersionsForInstalledMajor(tree: Tree): {
|
|
23
|
+
rsbuildVersion: string;
|
|
24
|
+
rsbuildPluginReactVersion: string;
|
|
25
|
+
rsbuildPluginVueVersion: string;
|
|
26
|
+
rsbuildPluginSassVersion: string;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=version-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/utils/version-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAMvC,OAAO,EAGL,KAAK,4BAA4B,EAClC,MAAM,YAAY,CAAC;AAIpB;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,IAAI,GACT,4BAA4B,GAAG,SAAS,CAS1C;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,IAAI,4BAA4B,GAAG,IAAI,CASvF;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,IAAI;;;;;EAM7D"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInstalledRsbuildMajorVersion = getInstalledRsbuildMajorVersion;
|
|
4
|
+
exports.getInstalledRsbuildVersionRuntime = getInstalledRsbuildVersionRuntime;
|
|
5
|
+
exports.getRsbuildVersionsForInstalledMajor = getRsbuildVersionsForInstalledMajor;
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
7
|
+
const semver_1 = require("semver");
|
|
8
|
+
const versions_1 = require("./versions");
|
|
9
|
+
const RSBUILD_CORE_PACKAGE = '@rsbuild/core';
|
|
10
|
+
/**
|
|
11
|
+
* Returns the declared @rsbuild/core major version from the workspace's
|
|
12
|
+
* package.json when it matches a supported major, or `undefined` otherwise
|
|
13
|
+
* (fresh install, dist tag, unknown major). Below-floor enforcement is
|
|
14
|
+
* handled at generator entry points via `assertSupportedRsbuildVersion`.
|
|
15
|
+
*/
|
|
16
|
+
function getInstalledRsbuildMajorVersion(tree) {
|
|
17
|
+
const declared = (0, internal_1.getDeclaredPackageVersion)(tree, RSBUILD_CORE_PACKAGE);
|
|
18
|
+
if (!declared) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const installedMajor = (0, semver_1.major)(declared);
|
|
22
|
+
return installedMajor in versions_1.backwardCompatibleRsbuildVersions
|
|
23
|
+
? installedMajor
|
|
24
|
+
: undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the installed @rsbuild/core major version resolved at runtime from
|
|
28
|
+
* node_modules. For use in executors and runtime code where no Tree is
|
|
29
|
+
* available. Returns `null` when @rsbuild/core can't be resolved or the
|
|
30
|
+
* installed major isn't supported.
|
|
31
|
+
*/
|
|
32
|
+
function getInstalledRsbuildVersionRuntime() {
|
|
33
|
+
const version = (0, internal_1.getInstalledPackageVersion)(RSBUILD_CORE_PACKAGE);
|
|
34
|
+
if (!version) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const installedMajor = (0, semver_1.major)(version);
|
|
38
|
+
return installedMajor in versions_1.backwardCompatibleRsbuildVersions
|
|
39
|
+
? installedMajor
|
|
40
|
+
: null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the version-map entry for the installed major, falling back to the
|
|
44
|
+
* latest supported map when no installed version is detected (fresh install)
|
|
45
|
+
* or the detected major is outside the supported window.
|
|
46
|
+
*/
|
|
47
|
+
function getRsbuildVersionsForInstalledMajor(tree) {
|
|
48
|
+
const installed = getInstalledRsbuildMajorVersion(tree);
|
|
49
|
+
if (installed === undefined) {
|
|
50
|
+
return versions_1.latestRsbuildVersions;
|
|
51
|
+
}
|
|
52
|
+
return versions_1.backwardCompatibleRsbuildVersions[installed];
|
|
53
|
+
}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export
|
|
5
|
-
|
|
2
|
+
export declare const minSupportedRsbuildVersion = "1.0.0";
|
|
3
|
+
export declare const supportedRsbuildMajorVersions: readonly [1];
|
|
4
|
+
export type SupportedRsbuildMajorVersion = (typeof supportedRsbuildMajorVersions)[number];
|
|
5
|
+
type RsbuildVersionMap = {
|
|
6
|
+
rsbuildVersion: string;
|
|
7
|
+
rsbuildPluginReactVersion: string;
|
|
8
|
+
rsbuildPluginVueVersion: string;
|
|
9
|
+
rsbuildPluginSassVersion: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const latestRsbuildVersions: RsbuildVersionMap;
|
|
12
|
+
export declare const backwardCompatibleRsbuildVersions: Record<SupportedRsbuildMajorVersion, RsbuildVersionMap>;
|
|
13
|
+
/**
|
|
14
|
+
* Kept for backward compatibility with code paths that don't yet branch on
|
|
15
|
+
* the detected installed major. Points at the latest supported major.
|
|
16
|
+
*/
|
|
17
|
+
export declare const rsbuildVersion: string;
|
|
18
|
+
export declare const rsbuildPluginReactVersion: string;
|
|
19
|
+
export declare const rsbuildPluginVueVersion: string;
|
|
20
|
+
export declare const rsbuildPluginSassVersion: string;
|
|
21
|
+
export {};
|
|
6
22
|
//# sourceMappingURL=versions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAE/D,eAAO,MAAM,0BAA0B,UAAU,CAAC;AAKlD,eAAO,MAAM,6BAA6B,cAAe,CAAC;AAC1D,MAAM,MAAM,4BAA4B,GACtC,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjD,KAAK,iBAAiB,GAAG;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,yBAAyB,EAAE,MAAM,CAAC;IAClC,uBAAuB,EAAE,MAAM,CAAC;IAChC,wBAAwB,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,iBAKnC,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,MAAM,CACpD,4BAA4B,EAC5B,iBAAiB,CAGlB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,QAAuC,CAAC;AACnE,eAAO,MAAM,yBAAyB,QACW,CAAC;AAClD,eAAO,MAAM,uBAAuB,QACW,CAAC;AAChD,eAAO,MAAM,wBAAwB,QACW,CAAC"}
|
package/src/utils/versions.js
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rsbuildPluginSassVersion = exports.rsbuildPluginVueVersion = exports.rsbuildPluginReactVersion = exports.rsbuildVersion = exports.nxVersion = void 0;
|
|
3
|
+
exports.rsbuildPluginSassVersion = exports.rsbuildPluginVueVersion = exports.rsbuildPluginReactVersion = exports.rsbuildVersion = exports.backwardCompatibleRsbuildVersions = exports.latestRsbuildVersions = exports.supportedRsbuildMajorVersions = exports.minSupportedRsbuildVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
|
-
exports.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
exports.minSupportedRsbuildVersion = '1.0.0';
|
|
6
|
+
// Supported `@rsbuild/core` majors. Currently v1 only — v2 ships as pure
|
|
7
|
+
// ESM, which @nx/rsbuild (CommonJS) cannot consume without a deeper
|
|
8
|
+
// refactor; tracked separately.
|
|
9
|
+
exports.supportedRsbuildMajorVersions = [1];
|
|
10
|
+
exports.latestRsbuildVersions = {
|
|
11
|
+
rsbuildVersion: '1.1.10',
|
|
12
|
+
rsbuildPluginReactVersion: '1.1.0',
|
|
13
|
+
rsbuildPluginVueVersion: '1.0.5',
|
|
14
|
+
rsbuildPluginSassVersion: '1.1.2',
|
|
15
|
+
};
|
|
16
|
+
exports.backwardCompatibleRsbuildVersions = {
|
|
17
|
+
1: exports.latestRsbuildVersions,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Kept for backward compatibility with code paths that don't yet branch on
|
|
21
|
+
* the detected installed major. Points at the latest supported major.
|
|
22
|
+
*/
|
|
23
|
+
exports.rsbuildVersion = exports.latestRsbuildVersions.rsbuildVersion;
|
|
24
|
+
exports.rsbuildPluginReactVersion = exports.latestRsbuildVersions.rsbuildPluginReactVersion;
|
|
25
|
+
exports.rsbuildPluginVueVersion = exports.latestRsbuildVersions.rsbuildPluginVueVersion;
|
|
26
|
+
exports.rsbuildPluginSassVersion = exports.latestRsbuildVersions.rsbuildPluginSassVersion;
|