Skip to content

Commit 3a90a3a

Browse files
Break up plugin (#10)
1 parent 92d4042 commit 3a90a3a

File tree

13 files changed

+605
-322
lines changed

13 files changed

+605
-322
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
e2e-tests:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version-file: '.nvmrc'
20+
21+
- name: Setup pnpm
22+
uses: pnpm/action-setup@v2
23+
with:
24+
version: 9.15.3
25+
run_install: false
26+
27+
- name: Get pnpm store directory
28+
id: pnpm-cache
29+
shell: bash
30+
run: |
31+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
32+
33+
- uses: actions/cache@v3
34+
name: Setup pnpm cache
35+
with:
36+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
37+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
38+
restore-keys: |
39+
${{ runner.os }}-pnpm-store-
40+
41+
- name: Install dependencies
42+
run: pnpm install
43+
44+
- name: Install Playwright browsers
45+
run: npx playwright install --with-deps chromium
46+
47+
- name: Run E2E tests
48+
run: pnpm e2e

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@
3333
],
3434
"scripts": {
3535
"build": "rslib build",
36+
"e2e": "pnpm build && cd examples/default-template; pnpm test:e2e",
3637
"dev": "rslib build --watch",
3738
"test": "vitest run",
3839
"test:watch": "vitest watch",
3940
"test:coverage": "vitest run --coverage",
4041
"test:core": "vitest run -c ./vitest.config.ts",
41-
"test:core:watch": "vitest watch -c ./vitest.config.ts"
42+
"test:core:watch": "vitest watch -c ./vitest.config.ts",
43+
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
44+
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\""
4245
},
4346
"dependencies": {
4447
"@babel/core": "^7.26.3",
@@ -75,6 +78,7 @@
7578
"@types/react-dom": "^19.0.1",
7679
"jiti": "^2.4.1",
7780
"playwright": "^1.50.1",
81+
"prettier": "3.4.2",
7882
"react": "^19.0.0",
7983
"react-dom": "^19.0.0",
8084
"react-router": "^7.4.0",

pnpm-lock.yaml

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/constants.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
export const PLUGIN_NAME = 'rsbuild:react-router';
22

3+
export const JS_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mjs'] as const;
4+
5+
export const JS_LOADERS = {
6+
'.ts': 'ts',
7+
'.tsx': 'tsx',
8+
'.js': 'js',
9+
'.jsx': 'jsx',
10+
} as const;
11+
312
export const SERVER_ONLY_ROUTE_EXPORTS = [
413
'loader',
514
'action',
@@ -41,4 +50,4 @@ export const CLIENT_EXPORTS = {
4150
links: 'links',
4251
meta: 'meta',
4352
shouldRevalidate: 'shouldRevalidate',
44-
} as const;
53+
} as const;

src/dev-server.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ export type DevServerMiddleware = (
88
) => Promise<void>;
99

1010
export const createDevServerMiddleware = (server: any): DevServerMiddleware => {
11-
return async (req: IncomingMessage, res: ServerResponse, next: (err?: any) => void): Promise<void> => {
11+
return async (
12+
req: IncomingMessage,
13+
res: ServerResponse,
14+
next: (err?: any) => void
15+
): Promise<void> => {
1216
try {
13-
const bundle = (await server.environments.node.loadBundle(
14-
'app',
15-
));
17+
const bundle = await server.environments.node.loadBundle('app');
1618

1719
if (!bundle || !bundle.routes) {
1820
throw new Error('Server bundle not found or invalid');

0 commit comments

Comments
 (0)