Skip to content

Commit 95ce815

Browse files
committed
Merge branch 'main' into feat_runtime_error_overlay
2 parents 075c2bb + 439a11d commit 95ce815

File tree

451 files changed

+7820
-10067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

451 files changed

+7820
-10067
lines changed

.github/workflows/test-ubuntu.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
changed:
4343
- "!**/*.md"
4444
- "!**/*.mdx"
45+
- "!**/_meta.json"
46+
- "!**/dictionary.txt"
4547
4648
- name: Setup Node.js ${{ matrix.node-version }}
4749
if: steps.changes.outputs.changed == 'true'
@@ -83,6 +85,8 @@ jobs:
8385
changed:
8486
- "!**/*.md"
8587
- "!**/*.mdx"
88+
- "!**/_meta.json"
89+
- "!**/dictionary.txt"
8690
8791
- name: Setup Node.js ${{ matrix.node-version }}
8892
if: steps.changes.outputs.changed == 'true'

.github/workflows/test-windows.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ jobs:
4646
changed:
4747
- "!**/*.md"
4848
- "!**/*.mdx"
49+
- "!**/_meta.json"
50+
- "!**/dictionary.txt"
4951
5052
- name: Setup Node.js ${{ matrix.node-version }}
5153
if: steps.changes.outputs.changed == 'true'
@@ -92,6 +94,8 @@ jobs:
9294
changed:
9395
- "!**/*.md"
9496
- "!**/*.mdx"
97+
- "!**/_meta.json"
98+
- "!**/dictionary.txt"
9599
96100
- name: Setup Node.js ${{ matrix.node-version }}
97101
if: steps.changes.outputs.changed == 'true'

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"search.exclude": {
44
"**/.git": true,
55
"**/dist": true,
6+
"**/dist-types": true,
67
"**/coverage": true,
78
"**/compiled": true,
89
"**/doc_build": true,

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ To get started with Rsbuild, see the [Quick Start](https://rsbuild.dev/guide/sta
9494
- [Modern.js](https://github.com/web-infra-dev/modern.js): A progressive React framework based on Rsbuild.
9595
- [awesome-rspack](https://github.com/web-infra-dev/awesome-rspack): A curated list of awesome things related to Rspack and Rsbuild.
9696
- [rspack-examples](https://github.com/rspack-contrib/rspack-examples): Examples for Rspack, Rsbuild, Rspress and Rsdoctor.
97+
- [storybook-rsbuild](https://github.com/rspack-contrib/storybook-rsbuild): Storybook builder powered by Rsbuild.
9798
- [rsbuild-plugin-template](https://github.com/rspack-contrib/rsbuild-plugin-template):Use this template to create your own Rsbuild plugin.
9899
- [rsfamily-design-resources](https://github.com/rspack-contrib/rsfamily-design-resources):Design resources for Rspack, Rsbuild, Rspress and Rsdoctor.
99100

README.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Rsbuild 具备以下特性:
9494
- [Modern.js](https://github.com/web-infra-dev/modern.js):基于 Rsbuild 的渐进式 React 框架。
9595
- [awesome-rspack](https://github.com/web-infra-dev/awesome-rspack):与 Rspack 和 Rsbuild 相关的精彩内容列表。
9696
- [rspack-examples](https://github.com/rspack-contrib/rspack-examples):Rspack、Rsbuild、Rspress 和 Rsdoctor 的示例项目。
97+
- [storybook-rsbuild](https://github.com/rspack-contrib/storybook-rsbuild): 基于 Rsbuild 构建的 Storybook。
9798
- [rsbuild-plugin-template](https://github.com/rspack-contrib/rsbuild-plugin-template):使用此模板创建你的 Rsbuild 插件。
9899
- [rsfamily-design-resources](https://github.com/rspack-contrib/rsfamily-design-resources):Rspack、Rsbuild、Rspress 和 Rsdoctor 的设计资源。
99100

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { build, rspackOnlyTest } from '@e2e/helper';
2+
import { expect } from '@playwright/test';
3+
4+
rspackOnlyTest(
5+
'should run babel with @rsbuild/babel-preset/node correctly',
6+
async () => {
7+
await build({
8+
cwd: __dirname,
9+
runServer: true,
10+
});
11+
12+
const { foo } = await import('./dist/server/index.js');
13+
expect(foo).toEqual(1);
14+
},
15+
);

e2e/cases/babel/preset/rsbuild.config.ts renamed to e2e/cases/babel/preset-node/rsbuild.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { pluginBabel } from '@rsbuild/plugin-babel';
22

33
export default {
4+
output: {
5+
targets: ['node'],
6+
},
47
plugins: [
58
pluginBabel({
69
babelLoaderOptions: (_, { addPresets }) => {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
console.log('hello');
2+
3+
export const foo = 1;

e2e/cases/babel/preset/index.test.ts renamed to e2e/cases/babel/preset-web/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { build, gotoPage, rspackOnlyTest } from '@e2e/helper';
22
import { expect } from '@playwright/test';
33

44
rspackOnlyTest(
5-
'should run babel with @rsbuild/babel-preset correctly',
5+
'should run babel with @rsbuild/babel-preset/web correctly',
66
async ({ page }) => {
77
const rsbuild = await build({
88
cwd: __dirname,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { pluginBabel } from '@rsbuild/plugin-babel';
2+
3+
export default {
4+
plugins: [
5+
pluginBabel({
6+
babelLoaderOptions: (_, { addPresets }) => {
7+
addPresets([require.resolve('@rsbuild/babel-preset/node')]);
8+
},
9+
}),
10+
],
11+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import path from 'node:path';
2+
import { build } from '@e2e/helper';
3+
import { globContentJSON } from '@e2e/helper';
4+
import { expect, test } from '@playwright/test';
5+
6+
test('should build CSS assets correctly', async () => {
7+
await expect(
8+
build({
9+
cwd: __dirname,
10+
rsbuildConfig: {},
11+
}),
12+
).resolves.toBeDefined();
13+
14+
const outputs = await globContentJSON(path.join(__dirname, 'dist'));
15+
const outputFiles = Object.keys(outputs);
16+
17+
expect(
18+
outputFiles.find(
19+
(item) => item.includes('static/image/image') && item.endsWith('.jpeg'),
20+
),
21+
).toBeTruthy();
22+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from '@rsbuild/core';
2+
import { pluginReact } from '@rsbuild/plugin-react';
3+
4+
export default defineConfig({
5+
plugins: [pluginReact()],
6+
output: {}
7+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function load(key: string) {
2+
import(`./test/${key}`).then(res => {
3+
console.log('res', res);
4+
})
5+
}
6+
7+
load('a');
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import styles from './index.module.less';
2+
3+
console.log('s', styles);
4+
5+
export const a = 1;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.header {
2+
background: url('@assets/image.jpeg') no-repeat;
3+
}

e2e/cases/css/css-modules-dom/index.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@ import { join, resolve } from 'node:path';
22
import { build, gotoPage } from '@e2e/helper';
33
import { expect, test } from '@playwright/test';
44
import { pluginReact } from '@rsbuild/plugin-react';
5+
import { pluginTypedCSSModules } from '@rsbuild/plugin-typed-css-modules';
56
import { fse } from '@rsbuild/shared';
67

78
const fixtures = resolve(__dirname);
89

9-
test('enableCssModuleTSDeclaration', async () => {
10+
test('plugin-typed-css-modules', async () => {
1011
fse.removeSync(join(fixtures, 'src/App.module.less.d.ts'));
1112
fse.removeSync(join(fixtures, 'src/App.module.scss.d.ts'));
1213

1314
await build({
1415
cwd: fixtures,
15-
plugins: [pluginReact()],
16-
rsbuildConfig: {
17-
output: {
18-
enableCssModuleTSDeclaration: true,
19-
},
20-
},
16+
plugins: [pluginReact(), pluginTypedCSSModules()],
2117
});
2218

2319
expect(

e2e/cases/css/css-modules-named-export/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ rspackOnlyTest(
77
const rsbuild = await build({
88
cwd: __dirname,
99
runServer: true,
10+
rsbuildConfig: {
11+
tools: {
12+
cssLoader: {
13+
modules: {
14+
// TODO: css-loader need support named export when namedExports: false.
15+
namedExport: true
16+
}
17+
}
18+
}
19+
}
1020
});
1121
const files = await rsbuild.unwrapOutputJSON();
1222

e2e/cases/css/css-modules-ts-declaration/index.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { join, resolve } from 'node:path';
22
import { build } from '@e2e/helper';
33
import { expect, test } from '@playwright/test';
4+
import { pluginTypedCSSModules } from '@rsbuild/plugin-typed-css-modules';
45
import { fse } from '@rsbuild/shared';
56

67
const fixtures = __dirname;
@@ -18,13 +19,11 @@ test('should generator ts declaration correctly for css modules auto true', asyn
1819

1920
await build({
2021
cwd: __dirname,
22+
plugins: [pluginTypedCSSModules()],
2123
rsbuildConfig: {
2224
source: {
2325
entry: { index: resolve(testDir, 'index.js') },
2426
},
25-
output: {
26-
enableCssModuleTSDeclaration: true,
27-
},
2827
},
2928
});
3029

@@ -51,12 +50,12 @@ test('should generator ts declaration correctly for css modules auto function',
5150

5251
await build({
5352
cwd: __dirname,
53+
plugins: [pluginTypedCSSModules()],
5454
rsbuildConfig: {
5555
source: {
5656
entry: { index: resolve(testDir, 'index.js') },
5757
},
5858
output: {
59-
enableCssModuleTSDeclaration: true,
6059
cssModules: {
6160
auto: (path) => {
6261
return path.endsWith('.less');
@@ -80,12 +79,12 @@ test('should generator ts declaration correctly for css modules auto Regexp', as
8079

8180
await build({
8281
cwd: __dirname,
82+
plugins: [pluginTypedCSSModules()],
8383
rsbuildConfig: {
8484
source: {
8585
entry: { index: resolve(testDir, 'index.js') },
8686
},
8787
output: {
88-
enableCssModuleTSDeclaration: true,
8988
cssModules: {
9089
auto: /\.module\./i,
9190
},
@@ -107,12 +106,12 @@ test('should generator ts declaration correctly for custom exportLocalsConventio
107106

108107
await build({
109108
cwd: __dirname,
109+
plugins: [pluginTypedCSSModules()],
110110
rsbuildConfig: {
111111
source: {
112112
entry: { index: resolve(testDir, 'index.js') },
113113
},
114114
output: {
115-
enableCssModuleTSDeclaration: true,
116115
cssModules: {
117116
auto: /\.module\./i,
118117
exportLocalsConvention: 'asIs',

e2e/cases/css/css-modules/index.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,45 @@ test('should compile CSS Modules follow by output.cssModules', async () => {
3737
/.the-a-class{color:red}.the-b-class-\w{6}{color:blue}.the-c-class{color:yellow}.the-d-class{color:green}/,
3838
);
3939
});
40+
41+
test('should compile CSS Modules follow by output.cssModules custom localIdentName', async () => {
42+
const rsbuild = await build({
43+
cwd: __dirname,
44+
rsbuildConfig: {
45+
output: {
46+
cssModules: {
47+
localIdentName: '[hash:base64:8]',
48+
},
49+
},
50+
},
51+
});
52+
const files = await rsbuild.unwrapOutputJSON();
53+
54+
const content =
55+
files[Object.keys(files).find((file) => file.endsWith('.css'))!];
56+
57+
expect(content).toMatch(
58+
/\.the-a-class{color:red}\.\w{8}{color:blue}\.\w{8}{color:yellow}\.the-d-class{color:green}/,
59+
);
60+
});
61+
62+
test('should compile CSS Modules follow by output.cssModules custom localIdentName - hashDigest', async () => {
63+
const rsbuild = await build({
64+
cwd: __dirname,
65+
rsbuildConfig: {
66+
output: {
67+
cssModules: {
68+
localIdentName: '[hash:hex:4]',
69+
},
70+
},
71+
},
72+
});
73+
const files = await rsbuild.unwrapOutputJSON();
74+
75+
const content =
76+
files[Object.keys(files).find((file) => file.endsWith('.css'))!];
77+
78+
expect(content).toMatch(
79+
/\.the-a-class{color:red}\.\w{4}{color:blue}\.\w{4}{color:yellow}\.the-d-class{color:green}/,
80+
);
81+
});
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
import { build } from '@e2e/helper';
2-
import { webpackOnlyTest } from '@e2e/helper';
3-
import { expect } from '@playwright/test';
2+
import { expect, test } from '@playwright/test';
43

5-
webpackOnlyTest(
6-
'should compile CSS Modules which depends on importLoaders correctly',
7-
async () => {
8-
const rsbuild = await build({
9-
cwd: __dirname,
10-
});
11-
const files = await rsbuild.unwrapOutputJSON();
4+
test('should compile CSS Modules which depends on importLoaders correctly', async () => {
5+
const rsbuild = await build({
6+
cwd: __dirname,
7+
});
8+
const files = await rsbuild.unwrapOutputJSON();
129

13-
const content =
14-
files[Object.keys(files).find((file) => file.endsWith('.css'))!];
10+
const content =
11+
files[Object.keys(files).find((file) => file.endsWith('.css'))!];
1512

16-
expect(content).toEqual(
17-
'.class-foo-yQ8Tl7+.hello-class-foo{background-color:red}.class-bar-TVH2T6 .hello-class-bar{background-color:blue}',
18-
);
19-
},
20-
);
13+
expect(content).toEqual(
14+
'.class-foo-yQ8Tl7+.hello-class-foo{background-color:red}.class-bar-TVH2T6 .hello-class-bar{background-color:blue}',
15+
);
16+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { build } from '@e2e/helper';
2+
import { expect, test } from '@playwright/test';
3+
4+
test('should load postcss.config.ts correctly', async () => {
5+
const rsbuild = await build({
6+
cwd: __dirname,
7+
});
8+
9+
const files = await rsbuild.unwrapOutputJSON();
10+
const indexCssFile = Object.keys(files).find(
11+
(file) => file.includes('index.') && file.endsWith('.css'),
12+
)!;
13+
14+
expect(files[indexCssFile]).toEqual(
15+
'.text-3xl{font-size:1.875rem;line-height:2.25rem}.font-bold{font-weight:700}.underline{text-decoration-line:underline}',
16+
);
17+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const path = require('node:path');
2+
3+
export default {
4+
plugins: {
5+
tailwindcss: {
6+
config: path.join(__dirname, './tailwind.config.cjs'),
7+
},
8+
},
9+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
html: {
3+
template: './src/index.html',
4+
},
5+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@tailwind utilities;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!doctype html>
2+
<html>
3+
<head></head>
4+
<body>
5+
<h1 class="text-3xl font-bold underline">Hello world!</h1>
6+
</body>
7+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './index.css';

0 commit comments

Comments
 (0)