Skip to content

Commit f8671d6

Browse files
authored
chore: add rsdoctor diff action in v2 branch (#7896)
1 parent 4ae7851 commit f8671d6

File tree

12 files changed

+2518
-143
lines changed

12 files changed

+2518
-143
lines changed

.github/workflows/diff.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Diff
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, closed]
6+
branches: [v2]
7+
8+
jobs:
9+
Build:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
issues: write
15+
pull-requests: write
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
19+
with:
20+
fetch-depth: 0
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Setup Pnpm
24+
run: |
25+
npm install -g corepack@latest --force
26+
corepack enable
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
30+
with:
31+
node-version: 22
32+
cache: 'pnpm'
33+
34+
- name: Install Dependencies and Build
35+
run: |
36+
pnpm install
37+
38+
- name: Build Demo Project
39+
run: |
40+
cd benchmark/bundle-diff
41+
RSDOCTOR=1 pnpm run build
42+
43+
- name: Report Compressed Size
44+
uses: web-infra-dev/rsdoctor-action@main
45+
with:
46+
github_token: ${{ secrets.GITHUB_TOKEN }}
47+
file_path: 'benchmark/bundle-diff/dist/rsdoctor-data.json'
48+
target_branch: 'v2'
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { appTools, defineConfig } from '@modern-js/app-tools';
2+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
3+
4+
const isCI = process.env.CI === 'true';
5+
6+
// https://modernjs.dev/en/configure/app/usage
7+
export default defineConfig({
8+
runtime: {
9+
router: true,
10+
},
11+
12+
tools: {
13+
bundlerChain: chain => {
14+
if (process.env.RSDOCTOR) {
15+
chain.plugin('rsdoctor').use(RsdoctorRspackPlugin, [
16+
{
17+
output: isCI
18+
? {
19+
mode: 'brief',
20+
options: {
21+
type: ['json'],
22+
},
23+
}
24+
: {},
25+
features: isCI ? ['bundle'] : ['bundle', 'loader', 'plugins'],
26+
},
27+
]);
28+
}
29+
},
30+
},
31+
plugins: [
32+
appTools({
33+
bundler: 'experimental-rspack',
34+
}),
35+
],
36+
});

benchmark/bundle-diff/package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "bundle-diff-benchmark",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "modern dev",
7+
"build": "modern build",
8+
"start": "modern start"
9+
},
10+
"engines": {
11+
"node": ">=16.18.1"
12+
},
13+
"eslintIgnore": [
14+
"node_modules/",
15+
"dist/"
16+
],
17+
"dependencies": {
18+
"@modern-js/runtime": "workspace:*",
19+
"react": "~18.2.0",
20+
"react-dom": "~18.2.0"
21+
},
22+
"devDependencies": {
23+
"@modern-js/app-tools": "workspace:*",
24+
"@modern-js/eslint-config": "2.59.0",
25+
"@modern-js/tsconfig": "workspace:*",
26+
"@rsdoctor/rspack-plugin": "^1.3.11",
27+
"@types/jest": "^29",
28+
"@types/node": "~16.11.7",
29+
"@types/react": "~18.0.26",
30+
"@types/react-dom": "~18.0.10",
31+
"prettier": "~2.8.1",
32+
"rimraf": "^6.0.1",
33+
"typescript": "~5.0.4"
34+
}
35+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// eslint-disable-next-line import/no-commonjs
2+
module.exports = {
3+
root: true,
4+
extends: ['@modern-js-app'],
5+
parserOptions: {
6+
tsconfigRootDir: __dirname,
7+
project: ['../tsconfig.json'],
8+
},
9+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference types='@modern-js/app-tools/types' />
2+
/// <reference types='@modern-js/runtime/types' />
3+
/// <reference types='@modern-js/runtime/types/router' />
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
html,
2+
body {
3+
padding: 0;
4+
margin: 0;
5+
background: linear-gradient(to bottom, transparent, #fff) #eceeef;
6+
}
7+
8+
p {
9+
margin: 0;
10+
}
11+
12+
* {
13+
-webkit-font-smoothing: antialiased;
14+
-moz-osx-font-smoothing: grayscale;
15+
box-sizing: border-box;
16+
}
17+
18+
.container-box {
19+
min-height: 100vh;
20+
max-width: 100%;
21+
display: flex;
22+
flex-direction: column;
23+
justify-content: center;
24+
align-items: center;
25+
padding-top: 10px;
26+
}
27+
28+
main {
29+
flex: 1;
30+
display: flex;
31+
flex-direction: column;
32+
justify-content: center;
33+
align-items: center;
34+
}
35+
36+
.title {
37+
display: flex;
38+
margin: 4rem 0 4rem;
39+
align-items: center;
40+
font-size: 4rem;
41+
font-weight: 600;
42+
}
43+
44+
.logo {
45+
width: 6rem;
46+
margin: 7px 0 0 1rem;
47+
}
48+
49+
.name {
50+
color: #4ecaff;
51+
}
52+
53+
.description {
54+
text-align: center;
55+
line-height: 1.5;
56+
font-size: 1.3rem;
57+
color: #1b3a42;
58+
margin-bottom: 5rem;
59+
}
60+
61+
.code {
62+
background: #fafafa;
63+
border-radius: 12px;
64+
padding: 0.6rem 0.9rem;
65+
font-size: 1.05rem;
66+
}
67+
68+
.container-box .grid {
69+
display: flex;
70+
align-items: center;
71+
justify-content: center;
72+
width: 1100px;
73+
margin-top: 3rem;
74+
}
75+
76+
.card {
77+
padding: 1.5rem;
78+
display: flex;
79+
flex-direction: column;
80+
justify-content: center;
81+
height: 100px;
82+
color: inherit;
83+
text-decoration: none;
84+
transition: 0.15s ease;
85+
width: 45%;
86+
}
87+
88+
.card:hover,
89+
.card:focus {
90+
transform: scale(1.05);
91+
}
92+
93+
.card h2 {
94+
display: flex;
95+
align-items: center;
96+
font-size: 1.5rem;
97+
margin: 0;
98+
padding: 0;
99+
}
100+
101+
.card p {
102+
opacity: 0.6;
103+
font-size: 0.9rem;
104+
line-height: 1.5;
105+
margin-top: 1rem;
106+
}
107+
108+
.arrow-right {
109+
width: 1.3rem;
110+
margin-left: 0.5rem;
111+
margin-top: 3px;
112+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Outlet } from '@modern-js/runtime/router';
2+
3+
export default function Layout() {
4+
return (
5+
<div>
6+
<Outlet />
7+
</div>
8+
);
9+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { Helmet } from '@modern-js/runtime/head';
2+
import './index.css';
3+
4+
const Index = () => (
5+
<div className="container-box">
6+
<Helmet>
7+
<link
8+
rel="icon"
9+
type="image/x-icon"
10+
href="https://lf3-static.bytednsdoc.com/obj/eden-cn/uhbfnupenuhf/favicon.ico"
11+
/>
12+
</Helmet>
13+
<main>
14+
<div className="title">
15+
Welcome to
16+
<img
17+
className="logo"
18+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/modern-js-logo.svg"
19+
alt="Modern.js Logo"
20+
/>
21+
<p className="name">Modern.js</p>
22+
</div>
23+
<p className="description">
24+
Get started by editing <code className="code">src/routes/page.tsx</code>
25+
</p>
26+
<div className="grid">
27+
<a
28+
href="https://modernjs.dev/guides/get-started/introduction.html"
29+
target="_blank"
30+
rel="noopener noreferrer"
31+
className="card"
32+
>
33+
<h2>
34+
Guide
35+
<img
36+
className="arrow-right"
37+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
38+
/>
39+
</h2>
40+
<p>Follow the guides to use all features of Modern.js.</p>
41+
</a>
42+
<a
43+
href="https://modernjs.dev/tutorials/foundations/introduction.html"
44+
target="_blank"
45+
className="card"
46+
rel="noreferrer"
47+
>
48+
<h2>
49+
Tutorials
50+
<img
51+
className="arrow-right"
52+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
53+
/>
54+
</h2>
55+
<p>Learn to use Modern.js to create your first application.</p>
56+
</a>
57+
<a
58+
href="https://modernjs.dev/configure/app/usage.html"
59+
target="_blank"
60+
className="card"
61+
rel="noreferrer"
62+
>
63+
<h2>
64+
Config
65+
<img
66+
className="arrow-right"
67+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
68+
/>
69+
</h2>
70+
<p>Find all configuration options provided by Modern.js.</p>
71+
</a>
72+
<a
73+
href="https://github.com/web-infra-dev/modern.js"
74+
target="_blank"
75+
rel="noopener noreferrer"
76+
className="card"
77+
>
78+
<h2>
79+
Github
80+
<img
81+
className="arrow-right"
82+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/arrow-right.svg"
83+
/>
84+
</h2>
85+
<p>View the source code of Github, feel free to contribute.</p>
86+
</a>
87+
</div>
88+
</main>
89+
</div>
90+
);
91+
92+
export default Index;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "@modern-js/tsconfig/base",
3+
"compilerOptions": {
4+
"declaration": false,
5+
"jsx": "preserve",
6+
"skipLibCheck": false,
7+
"baseUrl": "./",
8+
"paths": {
9+
"@/*": ["./src/*"],
10+
"@shared/*": ["./shared/*"]
11+
}
12+
},
13+
"include": ["src", "shared", "config", "modern.config.ts"],
14+
"exclude": ["**/node_modules"]
15+
}

0 commit comments

Comments
 (0)