Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/witty-squids-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@pizzajsdev/react-router-hono': minor
'@pizzajsdev/app-router-fs': minor
'@pizzajsdev/utils': minor
'@pizzajsdev/i18n': minor
---

upgrade dependencies and migrate to tsdown
7 changes: 6 additions & 1 deletion .github/actions/setup-project/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: 'Setup project'
description: 'Sets up project and its dependencies'
env:
APP_CI: true
APP_ENV: development
NODE_VERSION: 24.5.0
PNPM_VERSION: 10.14.0
runs:
using: 'composite'
steps:
Expand All @@ -17,6 +22,6 @@ runs:

- shell: bash
run: |
pnpm env use --global 22
pnpm env use --global 24
pnpm install -g bun@latest
pnpm install --frozen-lockfile
6 changes: 0 additions & 6 deletions .github/workflows/quality-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ on:
branches:
- main

env:
APP_CI: true
APP_ENV: development
NODE_VERSION: 22.15.0
PNPM_VERSION: 10.9.0

concurrency:
group: qualityCheck-${{ github.ref }}
cancel-in-progress: true
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ on:
branches:
- main

env:
APP_CI: true
APP_ENV: development
NODE_VERSION: 22.15.0
PNPM_VERSION: 10.9.0

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
Expand Down
25 changes: 16 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
"private": true,
"type": "module",
"scripts": {
"build": "pnpm -r run build",
"build": "pnpm build:libs && pnpm build:apps",
"build:libs": "pnpm -r --filter '!pizzajs-playground' run build",
"build:apps": "pnpm --filter pizzajs-playground run build",
"changelog": "changeset",
"changeset:add": "changeset",
"changeset:commit": "git add ./.changeset && git commit -m 'chore(docs): add changesets'",
"changeset:release": "pnpm run build && changeset publish",
"changeset:version-packages": "changeset version && pnpm format",
"cleanup": "rm -rf packages/*/.react-router packages/*/dist",
"cleanup:modules": "rm -rf node_modules packages/*/node_modules",
"dev": "pnpm -r --parallel run dev",
"dev": "pnpm -r --parallel --filter '!pizzajs-playground' run dev",
"dev:apps": "pnpm --filter pizzajs-playground run dev",
"format": "pnpm format:prettier && pnpm format:pkg",
"format:pkg": "bun run --bun sort-package-json package.json packages/*/package.json",
"format:prettier": "bun run --bun prettier --write README.md .github/ ./packages",
Expand All @@ -27,18 +30,22 @@
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.1",
"@changesets/cli": "^2.29.3",
"@changesets/cli": "^2.29.5",
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1",
"@oxc-project/runtime": "^0.80.0",
"@types/node": "^24.2.0",
"husky": "^9.1.7",
"madge": "^8.0.0",
"prettier": "^3.5.3",
"sort-package-json": "^3.2.1",
"typescript": "^5.8.3",
"vitest": "^3.1.3"
"prettier": "^3.6.2",
"publint": "^0.3.12",
"sort-package-json": "^3.4.0",
"tsdown": "^0.13.3",
"typescript": "^5.9.2",
"vitest": "^3.2.4"
},
"packageManager": "pnpm@10.9.0",
"packageManager": "pnpm@10.14.0",
"engines": {
"node": ">=20.19.0"
"node": ">=22.15.0"
}
}
4 changes: 3 additions & 1 deletion packages/app-router-fs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ Edit the `app/routes.ts` file to use the generated routes.
```ts
import { collectRoutes } from '@pizzajsdev/app-router-fs'
import { createRouterConfig } from '@pizzajsdev/app-router-fs/adapters/react-router'
import path from 'node:path'

export const collectedRoutes = collectRoutes('routes', ['.tsx', '.ts'], process.cwd() + '/app')
const __dirname = path.dirname(new URL(import.meta.url).pathname)
export const collectedRoutes = collectRoutes('routes', ['.tsx', '.ts'], __dirname)
const routes = createRouterConfig(collectedRoutes)

export default routes
Expand Down
15 changes: 7 additions & 8 deletions packages/app-router-fs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,17 @@
"dist"
],
"scripts": {
"build": "rm -rf dist && tsup --clean",
"build": "rm -rf dist && tsdown --clean",
"postbuild": "publint",
"dev": "tsup --watch",
"dev": "tsdown --watch",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@types/node": "^22.15.17",
"@oxc-project/runtime": "^0.80.0",
"@react-router/dev": "^7.7.1",
"@types/node": "^24.2.0",
"publint": "^0.3.12",
"tsup": "^8.4.0",
"typescript": "^5.8.3"
},
"peerDependencies": {
"@react-router/dev": "^7.6.0"
"tsdown": "^0.13.3",
"typescript": "^5.9.2"
}
}
4 changes: 4 additions & 0 deletions packages/app-router-fs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export class FileSystemRouter {
parentLayoutFile: string | null = null,
): RouteDefinition[] {
const routesDir = path.join(this.cwd, dir)
if (!fs.existsSync(routesDir)) {
throw new Error(`[app-router-fs] Routes directory not found: ${routesDir}`)
}

const entries = fs.readdirSync(routesDir, { withFileTypes: true })
const routes: RouteDefinition[] = []
let layoutFile: string | null = parentLayoutFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Options, defineConfig } from 'tsup'
import { type Options, defineConfig } from 'tsdown'

const config: Options = {
entry: ['./src/**/!(*.test).ts'],
Expand All @@ -11,10 +11,11 @@ const config: Options = {
bundle: false,
dts: true,
sourcemap: true,
splitting: true,
treeshake: true,
skipNodeModulesBundle: true,
external: ['node_modules'],
// @ts-expect-error - splitting is not supported by tsdown yet, but it's WIP
splitting: true,
}

export default defineConfig([config])
23 changes: 10 additions & 13 deletions packages/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,23 @@
"dist"
],
"scripts": {
"build": "rm -rf dist && tsup --clean",
"build": "rm -rf dist && tsdown --clean",
"postbuild": "publint",
"dev": "tsup --watch",
"dev": "tsdown --watch",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@pizzajsdev/utils": "workspace:*"
},
"devDependencies": {
"@types/node": "^22.15.17",
"@types/react": "^19.1.3",
"@types/react-dom": "^19.1.3",
"@oxc-project/runtime": "^0.80.0",
"@types/node": "^24.2.0",
"@types/react": "^19.1.9",
"@types/react-dom": "^19.1.7",
"publint": "^0.3.12",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"tsup": "^8.4.0",
"typescript": "^5.8.3"
},
"peerDependencies": {
"react": "^19.1.0",
"react-dom": "^19.1.0"
"react": "^19.1.1",
"react-dom": "^19.1.1",
"tsdown": "^0.13.3",
"typescript": "^5.9.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Options, defineConfig } from 'tsup'
import { type Options, defineConfig } from 'tsdown'

const config: Options = {
entry: ['./src/**/!(*.test).ts', './src/**/!(*.test).tsx'],
Expand All @@ -11,10 +11,11 @@ const config: Options = {
bundle: false,
dts: true,
sourcemap: true,
splitting: true,
treeshake: true,
skipNodeModulesBundle: true,
external: ['node_modules'],
// @ts-expect-error - splitting is not supported by tsdown yet, but it's WIP
splitting: true,
}

export default defineConfig([config])
10 changes: 10 additions & 0 deletions packages/playground/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
*.local

node_modules/
.local/
dist/

# React Router
.react-router/
build/
3 changes: 3 additions & 0 deletions packages/playground/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PizzaJS Playground

A playground to integrate all PizzaJS libraries.
16 changes: 16 additions & 0 deletions packages/playground/app/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@import 'tailwindcss';

@theme {
--font-sans:
'Inter', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji';
}

html,
body {
@apply bg-white dark:bg-gray-950;

@media (prefers-color-scheme: dark) {
color-scheme: dark;
}
}
28 changes: 28 additions & 0 deletions packages/playground/app/context.server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { HttpBindings } from '@hono/node-server'
import type { Context } from 'hono'
import type { ActionFunctionArgs, LoaderFunctionArgs } from 'react-router'

export const getLoadContext = async (ctx: Context<{ Bindings: HttpBindings }>) => {
const req = ctx.req.raw
const url = new URL(req.url)
const cookie = req.headers.get('Cookie') ?? ''
const userAgent = req.headers.get('User-Agent')

return {
url,
userAgent,
cookie,
// other data, e.g.:
// lang,
// session
}
}

export interface LoadContext extends Awaited<ReturnType<typeof getLoadContext>> {}
export type LoaderFunctionArgsWithContext = LoaderFunctionArgs<LoadContext>
export type ActionFunctionArgsWithContext = ActionFunctionArgs<LoadContext>
export type ServerFunctionArgsWithContext = LoaderFunctionArgsWithContext | ActionFunctionArgsWithContext

declare module 'react-router' {
interface AppLoadContext extends LoadContext {}
}
3 changes: 3 additions & 0 deletions packages/playground/app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { handleRequest } from '@pizzajsdev/react-router-hono/server-entry'

export default handleRequest
67 changes: 67 additions & 0 deletions packages/playground/app/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { isRouteErrorResponse, Links, Meta, Outlet, Scripts, ScrollRestoration } from 'react-router'

import type { Route } from './+types/root'
import appInlineCss from './app.css?inline'

export const links: Route.LinksFunction = () => [
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
{
rel: 'preconnect',
href: 'https://fonts.gstatic.com',
crossOrigin: 'anonymous',
},
{
as: 'style',
rel: 'preload',
href: 'https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap',
},
]

export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
<style id="app_css" dangerouslySetInnerHTML={{ __html: appInlineCss }} />
</head>
<body>
{children}
<ScrollRestoration />
<Scripts />
</body>
</html>
)
}

export default function App() {
return <Outlet />
}

export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
let message = 'Oops!'
let details = 'An unexpected error occurred.'
let stack: string | undefined

if (isRouteErrorResponse(error)) {
message = error.status === 404 ? '404' : 'Error'
details = error.status === 404 ? 'The requested page could not be found.' : error.statusText || details
} else if (import.meta.env.DEV && error && error instanceof Error) {
details = error.message
stack = error.stack
}

return (
<main className="pt-16 p-4 container mx-auto">
<h1>{message}</h1>
<p>{details}</p>
{stack && (
<pre className="w-full p-4 overflow-x-auto">
<code>{stack}</code>
</pre>
)}
</main>
)
}
9 changes: 9 additions & 0 deletions packages/playground/app/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { collectRoutes } from '@pizzajsdev/app-router-fs'
import { createRouterConfig } from '@pizzajsdev/app-router-fs/adapters/react-router'
import path from 'node:path'

const __dirname = path.dirname(new URL(import.meta.url).pathname)
export const collectedRoutes = collectRoutes('routes', ['.tsx', '.ts'], __dirname)
const routes = createRouterConfig(collectedRoutes)

export default routes
22 changes: 22 additions & 0 deletions packages/playground/app/routes/demos/[slug].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Link } from 'react-router'
import type { Route } from './+types/[slug]'

export function loader({ params }: Route.LoaderArgs) {
return {
slug: params.slug,
}
}

export default function Demo({ loaderData }: Route.ComponentProps) {
return (
<div>
<Link
to="/demos"
className="inline-block mb-4 text-blue-600 hover:text-blue-800 font-medium transition-colors duration-200"
>
← Back to Demos
</Link>
<div className="p-4 rounded-lg bg-blue-600 text-white border border-blue-700">Content for {loaderData.slug}</div>
</div>
)
}
Loading