create-rsbuild 2.0.14 → 2.0.15
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/dist/index.js +106 -1
- package/package.json +8 -8
- package/template-lit-js/package.json +1 -1
- package/template-lit-ts/package.json +2 -2
- package/template-preact-js/package.json +1 -1
- package/template-preact-ts/package.json +2 -2
- package/template-react-js/package.json +1 -1
- package/template-react-ts/package.json +2 -2
- package/template-rstest/react-js/package.json +3 -3
- package/template-rstest/react-ts/package.json +3 -3
- package/template-rstest/vanilla-js/package.json +3 -3
- package/template-rstest/vanilla-ts/package.json +3 -3
- package/template-rstest/vue-js/package.json +3 -3
- package/template-rstest/vue-ts/package.json +3 -3
- package/template-solid-js/package.json +1 -1
- package/template-solid-ts/package.json +2 -2
- package/template-svelte-js/package.json +2 -2
- package/template-svelte-ts/package.json +3 -3
- package/template-tailwindcss/package.json +1 -1
- package/template-vanilla-js/package.json +1 -1
- package/template-vanilla-ts/package.json +2 -2
- package/template-vue-js/package.json +2 -2
- package/template-vue-ts/package.json +4 -4
- package/template-react-compiler/react-js/rsbuild.config.js +0 -18
- package/template-react-compiler/react-ts/rsbuild.config.ts +0 -17
- package/template-tailwindcss/postcss.config.mjs +0 -5
package/dist/index.js
CHANGED
|
@@ -1,6 +1,105 @@
|
|
|
1
1
|
import node_fs from "node:fs";
|
|
2
2
|
import node_path from "node:path";
|
|
3
3
|
import { checkCancel, copyFolder, create, select as external_create_rstack_select } from "create-rstack";
|
|
4
|
+
const tailwindcssPlugin = {
|
|
5
|
+
id: 'tailwindcss',
|
|
6
|
+
importName: 'pluginTailwindcss',
|
|
7
|
+
source: '@rsbuild/plugin-tailwindcss',
|
|
8
|
+
order: 20
|
|
9
|
+
};
|
|
10
|
+
const reactCompilerPlugin = {
|
|
11
|
+
id: 'react-compiler',
|
|
12
|
+
importName: 'pluginBabel',
|
|
13
|
+
source: '@rsbuild/plugin-babel',
|
|
14
|
+
call: `pluginBabel({
|
|
15
|
+
include: /\\.[jt]sx?$/,
|
|
16
|
+
exclude: [/[\\\\/]node_modules[\\\\/]/],
|
|
17
|
+
babelLoaderOptions(opts) {
|
|
18
|
+
opts.plugins?.unshift('babel-plugin-react-compiler');
|
|
19
|
+
},
|
|
20
|
+
})`,
|
|
21
|
+
order: 10
|
|
22
|
+
};
|
|
23
|
+
const cache = new Map();
|
|
24
|
+
const configFiles = [
|
|
25
|
+
'rsbuild.config.ts',
|
|
26
|
+
'rsbuild.config.js'
|
|
27
|
+
];
|
|
28
|
+
const indent = ' ';
|
|
29
|
+
const normalize = (code)=>code.replaceAll('\r\n', '\n');
|
|
30
|
+
const getCall = ({ importName, call })=>call ?? `${importName}()`;
|
|
31
|
+
const addImport = (code, plugin)=>{
|
|
32
|
+
if (code.includes(plugin.source)) return code;
|
|
33
|
+
const lines = code.split('\n');
|
|
34
|
+
const index = lines.findLastIndex((line)=>line.startsWith('import '));
|
|
35
|
+
lines.splice(index + 1, 0, plugin.importLine ?? `import { ${plugin.importName} } from '${plugin.source}';`);
|
|
36
|
+
return lines.join('\n');
|
|
37
|
+
};
|
|
38
|
+
const formatCall = (call)=>{
|
|
39
|
+
const lines = call.split('\n');
|
|
40
|
+
return lines.map((line, index)=>{
|
|
41
|
+
const comma = index === lines.length - 1 ? ',' : '';
|
|
42
|
+
return `${indent}${indent}${line}${comma}`;
|
|
43
|
+
}).join('\n');
|
|
44
|
+
};
|
|
45
|
+
const formatPlugins = (calls)=>{
|
|
46
|
+
if (calls.every((call)=>!call.includes('\n'))) return `${indent}plugins: [${calls.join(', ')}],`;
|
|
47
|
+
const lines = [
|
|
48
|
+
`${indent}plugins: [`,
|
|
49
|
+
...calls.map(formatCall),
|
|
50
|
+
`${indent}],`
|
|
51
|
+
];
|
|
52
|
+
return lines.join('\n');
|
|
53
|
+
};
|
|
54
|
+
const addPluginsField = (code, calls)=>{
|
|
55
|
+
if (code.includes('defineConfig({});')) return code.replace('defineConfig({});', `defineConfig({\n${formatPlugins(calls)}\n});`);
|
|
56
|
+
const next = code.replace('export default defineConfig({\n', `export default defineConfig({\n${formatPlugins(calls)}\n`);
|
|
57
|
+
if (next === code) throw new Error('Failed to update rsbuild.config: defineConfig object not found.');
|
|
58
|
+
return next;
|
|
59
|
+
};
|
|
60
|
+
const addCalls = (code, plugins)=>{
|
|
61
|
+
const calls = plugins.map(getCall);
|
|
62
|
+
const lines = code.split('\n');
|
|
63
|
+
const start = lines.findIndex((line)=>line.includes('plugins: ['));
|
|
64
|
+
if (-1 === start) return addPluginsField(code, calls);
|
|
65
|
+
const pluginsLine = lines[start].trim();
|
|
66
|
+
if (pluginsLine.endsWith('],')) {
|
|
67
|
+
const rawCalls = /^plugins: \[(.*)\],$/.exec(pluginsLine)?.[1]?.trim();
|
|
68
|
+
const oldCalls = rawCalls ? [
|
|
69
|
+
rawCalls
|
|
70
|
+
] : [];
|
|
71
|
+
lines[start] = formatPlugins([
|
|
72
|
+
...oldCalls,
|
|
73
|
+
...calls
|
|
74
|
+
]);
|
|
75
|
+
return lines.join('\n');
|
|
76
|
+
}
|
|
77
|
+
const end = lines.findIndex((line, index)=>index > start && '],' === line.trim());
|
|
78
|
+
if (-1 === end) throw new Error('Failed to update rsbuild.config: plugins array not found.');
|
|
79
|
+
lines.splice(end, 0, ...calls.map(formatCall));
|
|
80
|
+
return lines.join('\n');
|
|
81
|
+
};
|
|
82
|
+
const applyPlugins = (base, plugins)=>{
|
|
83
|
+
let code = base;
|
|
84
|
+
for (const plugin of plugins)code = addImport(code, plugin);
|
|
85
|
+
return addCalls(code, plugins);
|
|
86
|
+
};
|
|
87
|
+
const findConfig = (dir)=>configFiles.map((name)=>node_path.join(dir, name)).find((file)=>node_fs.existsSync(file));
|
|
88
|
+
const addPluginsToRsbuildConfig = async (dir, plugins)=>{
|
|
89
|
+
const file = findConfig(dir);
|
|
90
|
+
if (!file) return;
|
|
91
|
+
const state = cache.get(dir) ?? {
|
|
92
|
+
file,
|
|
93
|
+
base: normalize(await node_fs.promises.readFile(file, 'utf-8')),
|
|
94
|
+
plugins: new Map()
|
|
95
|
+
};
|
|
96
|
+
for (const plugin of plugins)state.plugins.set(plugin.id, plugin);
|
|
97
|
+
cache.set(dir, state);
|
|
98
|
+
const ordered = [
|
|
99
|
+
...state.plugins.values()
|
|
100
|
+
].sort((a, b)=>(a.order ?? 0) - (b.order ?? 0));
|
|
101
|
+
await node_fs.promises.writeFile(state.file, applyPlugins(state.base, ordered));
|
|
102
|
+
};
|
|
4
103
|
const frameworkAlias = {
|
|
5
104
|
vue3: 'vue',
|
|
6
105
|
'solid-js': 'solid'
|
|
@@ -150,13 +249,16 @@ create({
|
|
|
150
249
|
'react-js',
|
|
151
250
|
'react-ts'
|
|
152
251
|
].includes(templateName),
|
|
153
|
-
action: ({ templateName, distFolder })=>{
|
|
252
|
+
action: async ({ templateName, distFolder })=>{
|
|
154
253
|
const toolFolder = node_path.join(root, 'template-react-compiler');
|
|
155
254
|
copyFolder({
|
|
156
255
|
from: node_path.join(toolFolder, templateName),
|
|
157
256
|
to: distFolder,
|
|
158
257
|
isMergePackageJson: true
|
|
159
258
|
});
|
|
259
|
+
await addPluginsToRsbuildConfig(distFolder, [
|
|
260
|
+
reactCompilerPlugin
|
|
261
|
+
]);
|
|
160
262
|
}
|
|
161
263
|
},
|
|
162
264
|
{
|
|
@@ -181,6 +283,9 @@ create({
|
|
|
181
283
|
break;
|
|
182
284
|
}
|
|
183
285
|
}
|
|
286
|
+
await addPluginsToRsbuildConfig(distFolder, [
|
|
287
|
+
tailwindcssPlugin
|
|
288
|
+
]);
|
|
184
289
|
}
|
|
185
290
|
},
|
|
186
291
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-rsbuild",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.15",
|
|
4
4
|
"description": "Create a new Rsbuild project",
|
|
5
5
|
"homepage": "https://rsbuild.rs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"create-rstack": "2.1.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@rslib/core": "0.22.
|
|
33
|
-
"@types/node": "^24.13.
|
|
32
|
+
"@rslib/core": "0.22.1",
|
|
33
|
+
"@types/node": "^24.13.2",
|
|
34
34
|
"typescript": "^6.0.3",
|
|
35
|
-
"@rsbuild/
|
|
35
|
+
"@rsbuild/core": "2.0.15",
|
|
36
|
+
"@rsbuild/plugin-preact": "2.0.0",
|
|
36
37
|
"@rsbuild/plugin-react": "2.0.1",
|
|
38
|
+
"@rsbuild/plugin-babel": "1.2.1",
|
|
37
39
|
"@rsbuild/plugin-solid": "1.2.2",
|
|
38
|
-
"@rsbuild/plugin-
|
|
39
|
-
"@rsbuild/plugin-svelte": "2.0.0"
|
|
40
|
-
"@rsbuild/core": "2.0.14",
|
|
41
|
-
"@rsbuild/plugin-vue": "1.2.9"
|
|
40
|
+
"@rsbuild/plugin-vue": "1.2.9",
|
|
41
|
+
"@rsbuild/plugin-svelte": "2.0.0"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": "^20.19.0 || >=22.12.0"
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"react-dom": "^19.2.7"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@rsbuild/core": "^2.0.
|
|
16
|
+
"@rsbuild/core": "^2.0.14",
|
|
17
17
|
"@rsbuild/plugin-react": "^2.0.1",
|
|
18
|
-
"@types/node": "^24.13.
|
|
18
|
+
"@types/node": "^24.13.2",
|
|
19
19
|
"@types/react": "^19.2.17",
|
|
20
20
|
"@types/react-dom": "^19.2.3",
|
|
21
21
|
"typescript": "^6.0.3"
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"test:watch": "rstest --watch"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@rstest/adapter-rsbuild": "^0.10.
|
|
8
|
-
"@rstest/core": "^0.10.
|
|
7
|
+
"@rstest/adapter-rsbuild": "^0.10.4",
|
|
8
|
+
"@rstest/core": "^0.10.4",
|
|
9
9
|
"@testing-library/dom": "^10.4.1",
|
|
10
10
|
"@testing-library/jest-dom": "^6.9.1",
|
|
11
11
|
"@testing-library/react": "^16.3.2",
|
|
12
|
-
"happy-dom": "^20.10.
|
|
12
|
+
"happy-dom": "^20.10.3"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"test:watch": "rstest --watch"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@rstest/adapter-rsbuild": "^0.10.
|
|
8
|
-
"@rstest/core": "^0.10.
|
|
7
|
+
"@rstest/adapter-rsbuild": "^0.10.4",
|
|
8
|
+
"@rstest/core": "^0.10.4",
|
|
9
9
|
"@testing-library/dom": "^10.4.1",
|
|
10
10
|
"@testing-library/jest-dom": "^6.9.1",
|
|
11
11
|
"@testing-library/react": "^16.3.2",
|
|
12
|
-
"happy-dom": "^20.10.
|
|
12
|
+
"happy-dom": "^20.10.3"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"test:watch": "rstest --watch"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@rstest/adapter-rsbuild": "^0.10.
|
|
8
|
-
"@rstest/core": "^0.10.
|
|
7
|
+
"@rstest/adapter-rsbuild": "^0.10.4",
|
|
8
|
+
"@rstest/core": "^0.10.4",
|
|
9
9
|
"@testing-library/dom": "^10.4.1",
|
|
10
10
|
"@testing-library/jest-dom": "^6.9.1",
|
|
11
|
-
"happy-dom": "^20.10.
|
|
11
|
+
"happy-dom": "^20.10.3"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"test:watch": "rstest --watch"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@rstest/adapter-rsbuild": "^0.10.
|
|
8
|
-
"@rstest/core": "^0.10.
|
|
7
|
+
"@rstest/adapter-rsbuild": "^0.10.4",
|
|
8
|
+
"@rstest/core": "^0.10.4",
|
|
9
9
|
"@testing-library/dom": "^10.4.1",
|
|
10
10
|
"@testing-library/jest-dom": "^6.9.1",
|
|
11
|
-
"happy-dom": "^20.10.
|
|
11
|
+
"happy-dom": "^20.10.3"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"test:watch": "rstest --watch"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@rstest/adapter-rsbuild": "^0.10.
|
|
8
|
-
"@rstest/core": "^0.10.
|
|
7
|
+
"@rstest/adapter-rsbuild": "^0.10.4",
|
|
8
|
+
"@rstest/core": "^0.10.4",
|
|
9
9
|
"@testing-library/dom": "^10.4.1",
|
|
10
10
|
"@testing-library/jest-dom": "^6.9.1",
|
|
11
11
|
"@testing-library/vue": "^8.1.0",
|
|
12
|
-
"happy-dom": "^20.10.
|
|
12
|
+
"happy-dom": "^20.10.3"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"test:watch": "rstest --watch"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@rstest/adapter-rsbuild": "^0.10.
|
|
8
|
-
"@rstest/core": "^0.10.
|
|
7
|
+
"@rstest/adapter-rsbuild": "^0.10.4",
|
|
8
|
+
"@rstest/core": "^0.10.4",
|
|
9
9
|
"@testing-library/dom": "^10.4.1",
|
|
10
10
|
"@testing-library/jest-dom": "^6.9.1",
|
|
11
11
|
"@testing-library/vue": "^8.1.0",
|
|
12
|
-
"happy-dom": "^20.10.
|
|
12
|
+
"happy-dom": "^20.10.3"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"solid-js": "^1.9.13"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@rsbuild/core": "^2.0.
|
|
15
|
+
"@rsbuild/core": "^2.0.14",
|
|
16
16
|
"@rsbuild/plugin-babel": "^1.2.1",
|
|
17
17
|
"@rsbuild/plugin-solid": "^1.2.2",
|
|
18
|
-
"@types/node": "^24.13.
|
|
18
|
+
"@types/node": "^24.13.2",
|
|
19
19
|
"typescript": "^6.0.3"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"svelte-check": "svelte-check --tsconfig ./tsconfig.json"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"svelte": "^5.
|
|
13
|
+
"svelte": "^5.56.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@rsbuild/core": "^2.0.
|
|
16
|
+
"@rsbuild/core": "^2.0.14",
|
|
17
17
|
"@rsbuild/plugin-svelte": "^2.0.0",
|
|
18
|
-
"@types/node": "^24.13.
|
|
18
|
+
"@types/node": "^24.13.2",
|
|
19
19
|
"svelte-check": "^4.6.0",
|
|
20
20
|
"typescript": "^6.0.3"
|
|
21
21
|
}
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"preview": "rsbuild preview"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"vue": "^3.5.
|
|
12
|
+
"vue": "^3.5.38"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@rsbuild/core": "^2.0.
|
|
15
|
+
"@rsbuild/core": "^2.0.14",
|
|
16
16
|
"@rsbuild/plugin-vue": "^1.2.9",
|
|
17
|
-
"@types/node": "^24.13.
|
|
17
|
+
"@types/node": "^24.13.2",
|
|
18
18
|
"typescript": "^6.0.3",
|
|
19
|
-
"vue-tsc": "^3.3.
|
|
19
|
+
"vue-tsc": "^3.3.5"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import { defineConfig } from '@rsbuild/core';
|
|
3
|
-
import { pluginBabel } from '@rsbuild/plugin-babel';
|
|
4
|
-
import { pluginReact } from '@rsbuild/plugin-react';
|
|
5
|
-
|
|
6
|
-
// Docs: https://rsbuild.rs/config/
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
plugins: [
|
|
9
|
-
pluginReact(),
|
|
10
|
-
pluginBabel({
|
|
11
|
-
include: /\.[jt]sx?$/,
|
|
12
|
-
exclude: [/[\\/]node_modules[\\/]/],
|
|
13
|
-
babelLoaderOptions(opts) {
|
|
14
|
-
opts.plugins?.unshift('babel-plugin-react-compiler');
|
|
15
|
-
},
|
|
16
|
-
}),
|
|
17
|
-
],
|
|
18
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from '@rsbuild/core';
|
|
2
|
-
import { pluginBabel } from '@rsbuild/plugin-babel';
|
|
3
|
-
import { pluginReact } from '@rsbuild/plugin-react';
|
|
4
|
-
|
|
5
|
-
// Docs: https://rsbuild.rs/config/
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
plugins: [
|
|
8
|
-
pluginReact(),
|
|
9
|
-
pluginBabel({
|
|
10
|
-
include: /\.[jt]sx?$/,
|
|
11
|
-
exclude: [/[\\/]node_modules[\\/]/],
|
|
12
|
-
babelLoaderOptions(opts) {
|
|
13
|
-
opts.plugins?.unshift('babel-plugin-react-compiler');
|
|
14
|
-
},
|
|
15
|
-
}),
|
|
16
|
-
],
|
|
17
|
-
});
|