@nx/rsbuild 22.4.0-canary.20260113-246d4fd → 22.4.0-canary.20260114-45f2ae3
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,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.4.0-canary.
|
|
4
|
+
"version": "22.4.0-canary.20260114-45f2ae3",
|
|
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.4.0-canary.
|
|
34
|
-
"@nx/js": "22.4.0-canary.
|
|
33
|
+
"@nx/devkit": "22.4.0-canary.20260114-45f2ae3",
|
|
34
|
+
"@nx/js": "22.4.0-canary.20260114-45f2ae3",
|
|
35
35
|
"@rsbuild/core": "1.1.8",
|
|
36
|
-
"minimatch": "
|
|
37
|
-
"@phenomnomnominal/tsquery": "~
|
|
36
|
+
"minimatch": "10.1.1",
|
|
37
|
+
"@phenomnomnominal/tsquery": "~6.1.4"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"nx": "22.4.0-canary.
|
|
40
|
+
"nx": "22.4.0-canary.20260114-45f2ae3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {},
|
|
43
43
|
"nx-migrations": {
|
|
@@ -17,10 +17,10 @@ function addBuildPlugin(tree, pathToConfigFile, importPath, pluginName, options)
|
|
|
17
17
|
let configContents = tree.read(pathToConfigFile, 'utf-8');
|
|
18
18
|
configContents = `import { ${pluginName} } from '${importPath}';
|
|
19
19
|
${configContents}`;
|
|
20
|
-
const
|
|
21
|
-
const pluginsArrayNodes = (0, tsquery_1.
|
|
20
|
+
const sourceFile = (0, tsquery_1.ast)(configContents);
|
|
21
|
+
const pluginsArrayNodes = (0, tsquery_1.query)(sourceFile, PLUGINS_ARRAY_SELECTOR);
|
|
22
22
|
if (pluginsArrayNodes.length === 0) {
|
|
23
|
-
const defineConfigNodes = (0, tsquery_1.
|
|
23
|
+
const defineConfigNodes = (0, tsquery_1.query)(sourceFile, DEFINE_CONFIG_SELECTOR);
|
|
24
24
|
if (defineConfigNodes.length === 0) {
|
|
25
25
|
throw new Error(`Could not find defineConfig in the config file at ${pathToConfigFile}.`);
|
|
26
26
|
}
|
|
@@ -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,
|
|
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,QA6CrB;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,QAuGnB;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
|
@@ -11,10 +11,10 @@ function addHtmlTemplatePath(tree, configFilePath, templatePath) {
|
|
|
11
11
|
const HTML_CONFIG_SELECTOR = 'CallExpression:has(Identifier[name=defineConfig]) ObjectLiteralExpression PropertyAssignment:has(Identifier[name=html]) > ObjectLiteralExpression';
|
|
12
12
|
const TEMPLATE_STRING_SELECTOR = 'PropertyAssignment:has(Identifier[name=template]) > StringLiteral';
|
|
13
13
|
let configContents = tree.read(configFilePath, 'utf-8');
|
|
14
|
-
const
|
|
15
|
-
const htmlConfigNodes = (0, tsquery_1.
|
|
14
|
+
const sourceFile = (0, tsquery_1.ast)(configContents);
|
|
15
|
+
const htmlConfigNodes = (0, tsquery_1.query)(sourceFile, HTML_CONFIG_SELECTOR);
|
|
16
16
|
if (htmlConfigNodes.length === 0) {
|
|
17
|
-
const defineConfigNodes = (0, tsquery_1.
|
|
17
|
+
const defineConfigNodes = (0, tsquery_1.query)(sourceFile, DEFINE_CONFIG_SELECTOR);
|
|
18
18
|
if (defineConfigNodes.length === 0) {
|
|
19
19
|
throw new Error(`Could not find 'defineConfig' in the config file at ${configFilePath}.`);
|
|
20
20
|
}
|
|
@@ -23,7 +23,7 @@ function addHtmlTemplatePath(tree, configFilePath, templatePath) {
|
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
const htmlConfigNode = htmlConfigNodes[0];
|
|
26
|
-
const templateStringNodes = (0, tsquery_1.
|
|
26
|
+
const templateStringNodes = (0, tsquery_1.query)(htmlConfigNode, TEMPLATE_STRING_SELECTOR);
|
|
27
27
|
if (templateStringNodes.length === 0) {
|
|
28
28
|
configContents = `${configContents.slice(0, htmlConfigNode.getStart() + 1)}\n${(0, indent_by_1.indentBy)(2)(`template: '${templatePath}',`)}\n\t\t${configContents.slice(htmlConfigNode.getStart() + 1)}`;
|
|
29
29
|
}
|
|
@@ -39,10 +39,10 @@ function addCopyAssets(tree, configFilePath, from) {
|
|
|
39
39
|
const COPY_ARRAY_SELECTOR = 'PropertyAssignment:has(Identifier[name=copy]) > ArrayLiteralExpression';
|
|
40
40
|
const copyAssetArrayElement = `{ from: '${from}' }`;
|
|
41
41
|
let configContents = tree.read(configFilePath, 'utf-8');
|
|
42
|
-
const
|
|
43
|
-
const outputConfigNodes = (0, tsquery_1.
|
|
42
|
+
const sourceFile = (0, tsquery_1.ast)(configContents);
|
|
43
|
+
const outputConfigNodes = (0, tsquery_1.query)(sourceFile, OUTPUT_CONFIG_SELECTOR);
|
|
44
44
|
if (outputConfigNodes.length === 0) {
|
|
45
|
-
const defineConfigNodes = (0, tsquery_1.
|
|
45
|
+
const defineConfigNodes = (0, tsquery_1.query)(sourceFile, DEFINE_CONFIG_SELECTOR);
|
|
46
46
|
if (defineConfigNodes.length === 0) {
|
|
47
47
|
throw new Error(`Could not find 'defineConfig' in the config file at ${configFilePath}.`);
|
|
48
48
|
}
|
|
@@ -51,7 +51,7 @@ function addCopyAssets(tree, configFilePath, from) {
|
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
53
|
const outputConfigNode = outputConfigNodes[0];
|
|
54
|
-
const copyAssetsArrayNodes = (0, tsquery_1.
|
|
54
|
+
const copyAssetsArrayNodes = (0, tsquery_1.query)(outputConfigNode, COPY_ARRAY_SELECTOR);
|
|
55
55
|
if (copyAssetsArrayNodes.length === 0) {
|
|
56
56
|
configContents = `${configContents.slice(0, outputConfigNode.getStart() + 1)}\n${(0, indent_by_1.indentBy)(2)(`copy: [${copyAssetArrayElement}],`)}\n\t${configContents.slice(outputConfigNode.getStart() + 1)}`;
|
|
57
57
|
}
|
|
@@ -69,16 +69,16 @@ function addExperimentalSwcPlugin(tree, configFilePath, pluginName) {
|
|
|
69
69
|
const SWC_SELECTOR = 'CallExpression:has(Identifier[name=defineConfig]) ObjectLiteralExpression PropertyAssignment:has(Identifier[name=tools]) PropertyAssignment:has(Identifier[name=swc]) > ObjectLiteralExpression';
|
|
70
70
|
const TOOLS_SELECTOR = 'CallExpression:has(Identifier[name=defineConfig]) ObjectLiteralExpression PropertyAssignment:has(Identifier[name=tools]) > ObjectLiteralExpression';
|
|
71
71
|
let configContents = tree.read(configFilePath, 'utf-8');
|
|
72
|
-
const
|
|
72
|
+
const sourceFile = (0, tsquery_1.ast)(configContents);
|
|
73
73
|
const pluginToAdd = (0, indent_by_1.indentBy)(1)(`['${pluginName}', {}],`);
|
|
74
74
|
const pluginsArrayToAdd = (0, indent_by_1.indentBy)(1)(`plugins: [\n${pluginToAdd}\n],`);
|
|
75
75
|
const experimentalObjectToAdd = (0, indent_by_1.indentBy)(1)(`experimental: {\n${pluginsArrayToAdd} \n},`);
|
|
76
76
|
const jscObjectToAdd = (0, indent_by_1.indentBy)(1)(`jsc: {\n${experimentalObjectToAdd}\n},`);
|
|
77
77
|
const swcObjectToAdd = (0, indent_by_1.indentBy)(1)(`swc: {\n${jscObjectToAdd}\n},`);
|
|
78
78
|
const toolsObjectToAdd = (0, indent_by_1.indentBy)(1)(`tools: {\n${swcObjectToAdd}\n},`);
|
|
79
|
-
const toolsNodes = (0, tsquery_1.
|
|
79
|
+
const toolsNodes = (0, tsquery_1.query)(sourceFile, TOOLS_SELECTOR);
|
|
80
80
|
if (toolsNodes.length === 0) {
|
|
81
|
-
const defineConfigNodes = (0, tsquery_1.
|
|
81
|
+
const defineConfigNodes = (0, tsquery_1.query)(sourceFile, DEFINE_CONFIG_SELECTOR);
|
|
82
82
|
if (defineConfigNodes.length === 0) {
|
|
83
83
|
throw new Error(`Could not find 'defineConfig' in the config file at ${configFilePath}.`);
|
|
84
84
|
}
|
|
@@ -86,25 +86,25 @@ function addExperimentalSwcPlugin(tree, configFilePath, pluginName) {
|
|
|
86
86
|
configContents = `${configContents.slice(0, defineConfigNode.getStart() + 1)}\n${toolsObjectToAdd}${configContents.slice(defineConfigNode.getStart() + 1)}`;
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
|
-
const swcNodes = (0, tsquery_1.
|
|
89
|
+
const swcNodes = (0, tsquery_1.query)(sourceFile, SWC_SELECTOR);
|
|
90
90
|
if (swcNodes.length === 0) {
|
|
91
91
|
const toolsNode = toolsNodes[0];
|
|
92
92
|
configContents = `${configContents.slice(0, toolsNode.getStart() + 1)}\n${(0, indent_by_1.indentBy)(1)(swcObjectToAdd)}\n\t${configContents.slice(toolsNode.getStart() + 1)}`;
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
|
-
const jscNodes = (0, tsquery_1.
|
|
95
|
+
const jscNodes = (0, tsquery_1.query)(sourceFile, SWC_JSC_SELECTOR);
|
|
96
96
|
if (jscNodes.length === 0) {
|
|
97
97
|
const swcNode = swcNodes[0];
|
|
98
98
|
configContents = `${configContents.slice(0, swcNode.getStart() + 1)}\n${(0, indent_by_1.indentBy)(2)(jscObjectToAdd)}\n\t\t${configContents.slice(swcNode.getStart() + 1)}`;
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
|
-
const experimentalNodes = (0, tsquery_1.
|
|
101
|
+
const experimentalNodes = (0, tsquery_1.query)(sourceFile, SWC_JSC_EXPERIMENTAL_SELECTOR);
|
|
102
102
|
if (experimentalNodes.length === 0) {
|
|
103
103
|
const jscNode = jscNodes[0];
|
|
104
104
|
configContents = `${configContents.slice(0, jscNode.getStart() + 1)}\n${(0, indent_by_1.indentBy)(3)(experimentalObjectToAdd)}\n\t\t\t${configContents.slice(jscNode.getStart() + 1)}`;
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
107
|
-
const pluginsArrayNodes = (0, tsquery_1.
|
|
107
|
+
const pluginsArrayNodes = (0, tsquery_1.query)(sourceFile, SWC_JSC_EXPERIMENTAL_PLUGIN_ARRAY_SELECTOR);
|
|
108
108
|
if (pluginsArrayNodes.length === 0) {
|
|
109
109
|
const experimentalNode = experimentalNodes[0];
|
|
110
110
|
configContents = `${configContents.slice(0, experimentalNode.getStart() + 1)}\n${(0, indent_by_1.indentBy)(4)(pluginsArrayToAdd)}\n\t\t\t\t${configContents.slice(experimentalNode.getStart() + 1)}`;
|
|
@@ -123,11 +123,11 @@ function addSourceDefine(tree, configFilePath, key, value) {
|
|
|
123
123
|
const SOURCE_CONFIG_SELECTOR = 'CallExpression:has(Identifier[name=defineConfig]) ObjectLiteralExpression PropertyAssignment:has(Identifier[name=source]) > ObjectLiteralExpression';
|
|
124
124
|
const DEFINE_OBJECT_SELECTOR = 'CallExpression:has(Identifier[name=defineConfig]) ObjectLiteralExpression PropertyAssignment:has(Identifier[name=source]) ObjectLiteralExpression PropertyAssignment:has(Identifier[name=define]) > ObjectLiteralExpression';
|
|
125
125
|
let configContents = tree.read(configFilePath, 'utf-8');
|
|
126
|
-
const
|
|
126
|
+
const sourceFile = (0, tsquery_1.ast)(configContents);
|
|
127
127
|
const defineProperty = `'${key}': '${value}'`;
|
|
128
|
-
const sourceConfigNodes = (0, tsquery_1.
|
|
128
|
+
const sourceConfigNodes = (0, tsquery_1.query)(sourceFile, SOURCE_CONFIG_SELECTOR);
|
|
129
129
|
if (sourceConfigNodes.length === 0) {
|
|
130
|
-
const defineConfigNodes = (0, tsquery_1.
|
|
130
|
+
const defineConfigNodes = (0, tsquery_1.query)(sourceFile, DEFINE_CONFIG_SELECTOR);
|
|
131
131
|
if (defineConfigNodes.length === 0) {
|
|
132
132
|
throw new Error(`Could not find 'defineConfig' in the config file at ${configFilePath}.`);
|
|
133
133
|
}
|
|
@@ -136,7 +136,7 @@ function addSourceDefine(tree, configFilePath, key, value) {
|
|
|
136
136
|
}
|
|
137
137
|
else {
|
|
138
138
|
const sourceConfigNode = sourceConfigNodes[0];
|
|
139
|
-
const defineObjectNodes = (0, tsquery_1.
|
|
139
|
+
const defineObjectNodes = (0, tsquery_1.query)(sourceFile, DEFINE_OBJECT_SELECTOR);
|
|
140
140
|
if (defineObjectNodes.length === 0) {
|
|
141
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
142
|
}
|