Skip to content

Commit 05e6b37

Browse files
authored
test: add treeshaking, improve CI (#1750)
1 parent 00c6d33 commit 05e6b37

41 files changed

Lines changed: 1307 additions & 574 deletions

Some content is hidden

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

.github/workflows/server-function.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 103 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 🧪 Tests
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [main]
7+
push:
8+
branches: [main]
9+
10+
jobs:
11+
tests:
12+
name: "🧪 Tests"
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: pnpm/action-setup@v4
17+
with:
18+
# https://github.com/pnpm/pnpm/issues/8953
19+
version: 9.15.3
20+
21+
- name: Install project dependencies
22+
run: pnpm i
23+
24+
- name: Build SolidStart
25+
run: pnpm --filter @solidjs/start build
26+
27+
- name: Build Test Project
28+
run: pnpm --filter tests build
29+
30+
- name: Run unit tests
31+
run: pnpm --filter tests unit:ci
32+
33+
- name: Install Cypress dependencies
34+
uses: cypress-io/github-action@v6
35+
with:
36+
working-directory: .
37+
runTests: false
38+
39+
- name: E2E Firefox
40+
uses: cypress-io/github-action@v6
41+
with:
42+
install: false
43+
working-directory: packages/tests
44+
start: pnpm start
45+
browser: firefox
46+
47+
- name: E2E Chromium
48+
uses: cypress-io/github-action@v6
49+
with:
50+
install: false
51+
working-directory: packages/tests
52+
start: pnpm start
53+
browser: chromium

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ vite.config.ts.timestamp*
4949

5050
.nitro
5151
.output
52+
53+
# ignore cypress screenshots
54+
**/cypress/screenshots

packages/start/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"dependencies": {
6666
"@vinxi/plugin-directives": "^0.5.0",
6767
"@vinxi/server-components": "^0.5.0",
68-
"@tanstack/server-functions-plugin": "^1.97.2",
68+
"@tanstack/server-functions-plugin": "^1.97.19",
6969
"defu": "^6.1.2",
7070
"error-stack-parser": "^2.1.4",
7171
"html-to-image": "^1.11.11",

packages/start/src/router/routes.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Route {
77
children?: Route[];
88
page?: boolean;
99
$component?: any;
10-
$HEAD?: any;
10+
$HEAD?: any;
1111
$GET?: any;
1212
$POST?: any;
1313
$PUT?: any;
@@ -24,9 +24,7 @@ declare module "vinxi/routes" {
2424
}
2525
}
2626

27-
export const pageRoutes = defineRoutes(
28-
(fileRoutes as unknown as Route[]).filter(o => o.page)
29-
);
27+
export const pageRoutes = defineRoutes((fileRoutes as unknown as Route[]).filter(o => o.page));
3028

3129
function defineRoutes(fileRoutes: Route[]) {
3230
function processRoute(routes: Route[], route: Route, id: string, full: string) {
@@ -35,7 +33,11 @@ function defineRoutes(fileRoutes: Route[]) {
3533
});
3634

3735
if (!parentRoute) {
38-
routes.push({ ...route, id, path: id.replace(/\/\([^)/]+\)/g, "").replace(/\([^)/]+\)/g, "") });
36+
routes.push({
37+
...route,
38+
id,
39+
path: id.replace(/\/\([^)/]+\)/g, "").replace(/\([^)/]+\)/g, "")
40+
});
3941
return routes;
4042
}
4143
processRoute(
@@ -58,7 +60,8 @@ function defineRoutes(fileRoutes: Route[]) {
5860
export function matchAPIRoute(path: string, method: string) {
5961
const match = router.lookup(path);
6062
if (match && match.route) {
61-
const handler = method === "HEAD" ? match.route["$HEAD"] || match.route["$GET"] : match.route[`$${method}`];
63+
const handler =
64+
method === "HEAD" ? match.route["$HEAD"] || match.route["$GET"] : match.route[`$${method}`];
6265
if (handler === undefined) return;
6366
return {
6467
handler,
@@ -68,19 +71,34 @@ export function matchAPIRoute(path: string, method: string) {
6871
}
6972

7073
function containsHTTP(route: Route) {
71-
return route["$HEAD"] || route["$GET"] || route["$POST"] || route["$PUT"] || route["$PATCH"] || route["$DELETE"];
74+
return (
75+
route["$HEAD"] ||
76+
route["$GET"] ||
77+
route["$POST"] ||
78+
route["$PUT"] ||
79+
route["$PATCH"] ||
80+
route["$DELETE"]
81+
);
7282
}
7383

7484
const router = createRouter({
7585
routes: (fileRoutes as unknown as Route[]).reduce((memo, route) => {
7686
if (!containsHTTP(route)) return memo;
77-
let path = route.path.replace(/\/\([^)/]+\)/g, "").replace(/\([^)/]+\)/g, "").replace(/\*([^/]*)/g, (_, m) => `**:${m}`).split('/').map(s => (s.startsWith(':') || s.startsWith('*')) ? s : encodeURIComponent(s)).join('/');
87+
let path = route.path
88+
.replace(/\/\([^)/]+\)/g, "")
89+
.replace(/\([^)/]+\)/g, "")
90+
.replace(/\*([^/]*)/g, (_, m) => `**:${m}`)
91+
.split("/")
92+
.map(s => (s.startsWith(":") || s.startsWith("*") ? s : encodeURIComponent(s)))
93+
.join("/");
7894
if (/:[^/]*\?/g.test(path)) {
7995
throw new Error(`Optional parameters are not supported in API routes: ${path}`);
8096
}
8197
if (memo[path]) {
8298
throw new Error(
83-
`Duplicate API routes for "${path}" found at "${memo[path]!.route.path}" and "${route.path}"`
99+
`Duplicate API routes for "${path}" found at "${memo[path]!.route.path}" and "${
100+
route.path
101+
}"`
84102
);
85103
}
86104
memo[path] = { route };
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)