@nx/rsbuild 22.0.0-beta.4 → 22.0.0-beta.5
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/config-utils.d.ts +1 -1
- package/config-utils.d.ts.map +1 -1
- package/config-utils.js +2 -1
- package/package.json +4 -4
- package/src/utils/ast-utils.d.ts +1 -0
- package/src/utils/ast-utils.d.ts.map +1 -1
- package/src/utils/ast-utils.js +29 -0
package/config-utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { addBuildPlugin } from './src/utils/add-build-plugin';
|
|
2
|
-
export { addCopyAssets, addHtmlTemplatePath, addExperimentalSwcPlugin, } from './src/utils/ast-utils';
|
|
2
|
+
export { addCopyAssets, addHtmlTemplatePath, addExperimentalSwcPlugin, addSourceDefine, } from './src/utils/ast-utils';
|
|
3
3
|
export * as versions from './src/utils/versions';
|
|
4
4
|
export { getRsbuildE2EWebServerInfo } from './src/utils/e2e-web-server-info-utils';
|
|
5
5
|
export { hasRsbuildPlugin } from './src/utils/has-rsbuild-plugin';
|
package/config-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-utils.d.ts","sourceRoot":"","sources":["../../../packages/rsbuild/config-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"config-utils.d.ts","sourceRoot":"","sources":["../../../packages/rsbuild/config-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
|
package/config-utils.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasRsbuildPlugin = exports.getRsbuildE2EWebServerInfo = exports.versions = exports.addExperimentalSwcPlugin = exports.addHtmlTemplatePath = exports.addCopyAssets = exports.addBuildPlugin = void 0;
|
|
3
|
+
exports.hasRsbuildPlugin = exports.getRsbuildE2EWebServerInfo = exports.versions = exports.addSourceDefine = exports.addExperimentalSwcPlugin = exports.addHtmlTemplatePath = exports.addCopyAssets = exports.addBuildPlugin = void 0;
|
|
4
4
|
var add_build_plugin_1 = require("./src/utils/add-build-plugin");
|
|
5
5
|
Object.defineProperty(exports, "addBuildPlugin", { enumerable: true, get: function () { return add_build_plugin_1.addBuildPlugin; } });
|
|
6
6
|
var ast_utils_1 = require("./src/utils/ast-utils");
|
|
7
7
|
Object.defineProperty(exports, "addCopyAssets", { enumerable: true, get: function () { return ast_utils_1.addCopyAssets; } });
|
|
8
8
|
Object.defineProperty(exports, "addHtmlTemplatePath", { enumerable: true, get: function () { return ast_utils_1.addHtmlTemplatePath; } });
|
|
9
9
|
Object.defineProperty(exports, "addExperimentalSwcPlugin", { enumerable: true, get: function () { return ast_utils_1.addExperimentalSwcPlugin; } });
|
|
10
|
+
Object.defineProperty(exports, "addSourceDefine", { enumerable: true, get: function () { return ast_utils_1.addSourceDefine; } });
|
|
10
11
|
exports.versions = require("./src/utils/versions");
|
|
11
12
|
var e2e_web_server_info_utils_1 = require("./src/utils/e2e-web-server-info-utils");
|
|
12
13
|
Object.defineProperty(exports, "getRsbuildE2EWebServerInfo", { enumerable: true, get: function () { return e2e_web_server_info_utils_1.getRsbuildE2EWebServerInfo; } });
|
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": "22.0.0-beta.
|
|
4
|
+
"version": "22.0.0-beta.5",
|
|
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": "22.0.0-beta.
|
|
34
|
-
"@nx/js": "22.0.0-beta.
|
|
33
|
+
"@nx/devkit": "22.0.0-beta.5",
|
|
34
|
+
"@nx/js": "22.0.0-beta.5",
|
|
35
35
|
"@rsbuild/core": "1.1.8",
|
|
36
36
|
"minimatch": "9.0.3",
|
|
37
37
|
"@phenomnomnominal/tsquery": "~5.0.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"nx": "22.0.0-beta.
|
|
40
|
+
"nx": "22.0.0-beta.5"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {},
|
|
43
43
|
"nx-migrations": {
|
package/src/utils/ast-utils.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import { type Tree } from '@nx/devkit';
|
|
|
2
2
|
export declare function addHtmlTemplatePath(tree: Tree, configFilePath: string, templatePath: string): void;
|
|
3
3
|
export declare function addCopyAssets(tree: Tree, configFilePath: string, from: string): void;
|
|
4
4
|
export declare function addExperimentalSwcPlugin(tree: Tree, configFilePath: string, pluginName: string): void;
|
|
5
|
+
export declare function addSourceDefine(tree: Tree, configFilePath: string, key: string, value: string): void;
|
|
5
6
|
//# sourceMappingURL=ast-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/utils/ast-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAOvC,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,QAgDrB;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,QAgDb;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,QAoGnB"}
|
|
1
|
+
{"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/rsbuild/src/utils/ast-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAOvC,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,QAgDrB;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,QAgDb;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,QAoGnB;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,QAmDd"}
|
package/src/utils/ast-utils.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addHtmlTemplatePath = addHtmlTemplatePath;
|
|
4
4
|
exports.addCopyAssets = addCopyAssets;
|
|
5
5
|
exports.addExperimentalSwcPlugin = addExperimentalSwcPlugin;
|
|
6
|
+
exports.addSourceDefine = addSourceDefine;
|
|
6
7
|
const indent_by_1 = require("./indent-by");
|
|
7
8
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
8
9
|
const DEFINE_CONFIG_SELECTOR = 'CallExpression:has(Identifier[name=defineConfig]) > ObjectLiteralExpression';
|
|
@@ -118,3 +119,31 @@ function addExperimentalSwcPlugin(tree, configFilePath, pluginName) {
|
|
|
118
119
|
}
|
|
119
120
|
tree.write(configFilePath, configContents);
|
|
120
121
|
}
|
|
122
|
+
function addSourceDefine(tree, configFilePath, key, value) {
|
|
123
|
+
const SOURCE_CONFIG_SELECTOR = 'CallExpression:has(Identifier[name=defineConfig]) ObjectLiteralExpression PropertyAssignment:has(Identifier[name=source]) > ObjectLiteralExpression';
|
|
124
|
+
const DEFINE_OBJECT_SELECTOR = 'CallExpression:has(Identifier[name=defineConfig]) ObjectLiteralExpression PropertyAssignment:has(Identifier[name=source]) ObjectLiteralExpression PropertyAssignment:has(Identifier[name=define]) > ObjectLiteralExpression';
|
|
125
|
+
let configContents = tree.read(configFilePath, 'utf-8');
|
|
126
|
+
const ast = tsquery_1.tsquery.ast(configContents);
|
|
127
|
+
const defineProperty = `'${key}': '${value}'`;
|
|
128
|
+
const sourceConfigNodes = (0, tsquery_1.tsquery)(ast, SOURCE_CONFIG_SELECTOR);
|
|
129
|
+
if (sourceConfigNodes.length === 0) {
|
|
130
|
+
const defineConfigNodes = (0, tsquery_1.tsquery)(ast, DEFINE_CONFIG_SELECTOR);
|
|
131
|
+
if (defineConfigNodes.length === 0) {
|
|
132
|
+
throw new Error(`Could not find 'defineConfig' in the config file at ${configFilePath}.`);
|
|
133
|
+
}
|
|
134
|
+
const defineConfigNode = defineConfigNodes[0];
|
|
135
|
+
configContents = `${configContents.slice(0, defineConfigNode.getStart() + 1)}\n${(0, indent_by_1.indentBy)(1)(`source: {\n${(0, indent_by_1.indentBy)(1)(`define: {\n${(0, indent_by_1.indentBy)(1)(defineProperty)},\n}`)},\n}`)},${configContents.slice(defineConfigNode.getStart() + 1)}`;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const sourceConfigNode = sourceConfigNodes[0];
|
|
139
|
+
const defineObjectNodes = (0, tsquery_1.tsquery)(ast, DEFINE_OBJECT_SELECTOR);
|
|
140
|
+
if (defineObjectNodes.length === 0) {
|
|
141
|
+
configContents = `${configContents.slice(0, sourceConfigNode.getStart() + 1)}\n${(0, indent_by_1.indentBy)(2)(`define: {\n${(0, indent_by_1.indentBy)(1)(defineProperty)},\n},`)}\n\t\t${configContents.slice(sourceConfigNode.getStart() + 1)}`;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const defineObjectNode = defineObjectNodes[0];
|
|
145
|
+
configContents = `${configContents.slice(0, defineObjectNode.getStart() + 1)}\n${(0, indent_by_1.indentBy)(3)(defineProperty)},\n\t\t\t${configContents.slice(defineObjectNode.getStart() + 1)}`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
tree.write(configFilePath, configContents);
|
|
149
|
+
}
|