create-pracht 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: migrate-nextjs
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.2.0
|
|
4
4
|
description: |
|
|
5
5
|
Migrate a Next.js application to Pracht. Converts App Router pages, layouts,
|
|
6
6
|
middleware, API routes, data fetching, and metadata to pracht equivalents.
|
|
@@ -83,7 +83,7 @@ For pages router projects, you can **skip manual manifest wiring entirely** (Pha
|
|
|
83
83
|
| `next/link` `<Link>` | `<Link route="...">` or plain `<a>` | Prefer typed `<Link>` for known app routes after `pracht typegen`; plain anchors still work |
|
|
84
84
|
| `next/link` `prefetch={false}` | `<Link prefetch="none">` | Pracht prefetches on hover/focus by default; also `"viewport"`, `"render"` |
|
|
85
85
|
| `useLinkStatus()` / pending UI | `useNavigation()` | `{ state, location, formData }` — powers progress bars and optimistic UI |
|
|
86
|
-
| `next/image` |
|
|
86
|
+
| `next/image` | `<Image>` from `@pracht/image` | Responsive srcsets plus Node, Cloudflare, Vercel, or passthrough loaders |
|
|
87
87
|
| `next/head` or Metadata API | `head()` export on route/shell | Per-route and per-shell head merging |
|
|
88
88
|
| `className` | `class` | Preact uses `class` attribute |
|
|
89
89
|
| `React.useState` etc. | `import { useState } from "preact/hooks"` | Preact hooks API is compatible |
|
|
@@ -117,6 +117,7 @@ For pages router projects, you can **skip manual manifest wiring entirely** (Pha
|
|
|
117
117
|
3. Update `package.json`:
|
|
118
118
|
- Replace `react`, `react-dom` → `preact`
|
|
119
119
|
- Replace `next` → `@pracht/core` (framework runtime), `@pracht/cli` (provides the `pracht` bin), `@pracht/vite-plugin`, and `@pracht/adapter-node` (or target adapter). There is no package named `pracht`.
|
|
120
|
+
- If the app imports `next/image`, add `@pracht/image`; add `sharp` only for the built-in Node optimization endpoint.
|
|
120
121
|
- Update scripts: `dev` → `pracht dev`, `build` → `pracht build`, `start` → `node dist/server/server.js` (Node.js) or a platform-specific deploy command; add `preview` → `pracht preview` to serve the production build locally
|
|
121
122
|
4. Remove Next.js config files: `next.config.*`, `next-env.d.ts`, `.next/`
|
|
122
123
|
5. If `tsconfig.json` has `"jsx": "preserve"`, change to `"jsx": "react-jsx"` and add `"jsxImportSource": "preact"`.
|
|
@@ -388,7 +389,7 @@ Plain anchors still work for simple, external, or user-provided URLs because the
|
|
|
388
389
|
|
|
389
390
|
`<Link>` also accepts navigation-behavior props: `prefetch` (`"none" | "intent" | "viewport" | "render"`, default `"intent"` on hover/focus — the equivalent of `next/link`'s `prefetch` tuning), `preserveScroll` (skip the scroll-to-top reset), and `viewTransition` (wrap the navigation in `document.startViewTransition()` where supported). Scroll restoration on back/forward works out of the box, like Next.js.
|
|
390
391
|
|
|
391
|
-
#### `next/image` →
|
|
392
|
+
#### `next/image` → `@pracht/image`
|
|
392
393
|
|
|
393
394
|
```tsx
|
|
394
395
|
// Next.js
|
|
@@ -396,9 +397,24 @@ import Image from "next/image";
|
|
|
396
397
|
<Image src="/photo.jpg" width={500} height={300} alt="Photo" />
|
|
397
398
|
|
|
398
399
|
// Pracht
|
|
399
|
-
|
|
400
|
+
import { Image } from "@pracht/image";
|
|
401
|
+
<Image src="/photo.jpg" width={500} height={300} alt="Photo" />
|
|
400
402
|
```
|
|
401
403
|
|
|
404
|
+
Choose the loader for the deployment target:
|
|
405
|
+
|
|
406
|
+
- Node: mount `createImageHandler()` from `@pracht/image/node`, install
|
|
407
|
+
`sharp`, and set its `localOrigin` to the same trusted value as
|
|
408
|
+
`nodeAdapter({ canonicalOrigin })`.
|
|
409
|
+
- Cloudflare Workers: configure `cloudflareLoader`; do not bundle the Node
|
|
410
|
+
handler because `sharp` does not run in Workers.
|
|
411
|
+
- Vercel Edge: configure `vercelLoader` and keep Vercel's allowed image sizes
|
|
412
|
+
aligned with the Pracht breakpoints.
|
|
413
|
+
- Static hosts: configure `passthroughLoader`.
|
|
414
|
+
|
|
415
|
+
Preserve the original `width`, `height`, `fill`, `sizes`, `quality`, and
|
|
416
|
+
priority intent. See `docs/IMAGES.md` for the endpoint and loader wiring.
|
|
417
|
+
|
|
402
418
|
#### `useRouter` → navigation
|
|
403
419
|
|
|
404
420
|
```tsx
|
|
@@ -483,6 +499,7 @@ export async function loader({ request }: LoaderArgs) {
|
|
|
483
499
|
| Next.js package | Pracht equivalent |
|
|
484
500
|
| --------------- | ---------------------------------------------------------------------------- |
|
|
485
501
|
| `next` | `@pracht/core` + `@pracht/cli` + `@pracht/vite-plugin` + `@pracht/adapter-node` (or target adapter) |
|
|
502
|
+
| `next/image` | `@pracht/image` |
|
|
486
503
|
| `react` | `preact` |
|
|
487
504
|
| `react-dom` | `preact` |
|
|
488
505
|
| `@next/font` | CSS `@font-face` or `fontsource` packages |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pre-deploy
|
|
3
|
-
version: 1.
|
|
3
|
+
version: 1.2.0
|
|
4
4
|
description: |
|
|
5
5
|
Adapter-aware pre-deployment checklist for pracht apps targeting Node,
|
|
6
6
|
Cloudflare Workers, or Vercel. Catches the issues that only surface in the
|
|
@@ -75,6 +75,10 @@ a markdown summary (graph diff + verify + budgets) worth attaching to it.
|
|
|
75
75
|
- Smoke test: `pracht preview --skip-build` (or `node dist/server/server.js`) boots and `curl localhost:3000` returns 200.
|
|
76
76
|
- Required env vars (grep `process.env.*` across `src/`) are set in the
|
|
77
77
|
deployment environment. List them for the user.
|
|
78
|
+
- If the app mounts `createImageHandler()` from `@pracht/image/node`, confirm
|
|
79
|
+
`sharp` is installed and `localOrigin` is the same trusted public origin as
|
|
80
|
+
`nodeAdapter({ canonicalOrigin })`. A production-relative image endpoint
|
|
81
|
+
without both values is an error.
|
|
78
82
|
- Reverse-proxy / TLS termination configured (out of scope for this skill —
|
|
79
83
|
flag for confirmation).
|
|
80
84
|
|
|
@@ -101,6 +105,9 @@ a markdown summary (graph diff + verify + budgets) worth attaching to it.
|
|
|
101
105
|
- Dev already runs inside workerd via `@cloudflare/vite-plugin`, so most
|
|
102
106
|
incompatibilities surface in dev; this check is the backstop for code
|
|
103
107
|
paths dev never hit.
|
|
108
|
+
- An API route importing `@pracht/image/node` is an error on Workers because
|
|
109
|
+
its optimizer requires `sharp`. Require `cloudflareLoader` (or
|
|
110
|
+
`passthroughLoader`) instead.
|
|
104
111
|
- ISG: worker-managed ISG via the per-colo Workers Cache API works out of the
|
|
105
112
|
box. If time-revalidated routes should use the edge-tier Workers Caching
|
|
106
113
|
upgrade instead, confirm both sides — `cloudflareAdapter({ cache: true })`
|
|
@@ -131,6 +138,9 @@ a markdown summary (graph diff + verify + budgets) worth attaching to it.
|
|
|
131
138
|
variant, so run the same Node-only API check as Cloudflare
|
|
132
139
|
**unconditionally** for Vercel builds. Do not skip it based on a runtime
|
|
133
140
|
probe.
|
|
141
|
+
- An API route importing `@pracht/image/node` is an error for the Vercel Edge
|
|
142
|
+
function. Require `vercelLoader` (with aligned allowed sizes) or
|
|
143
|
+
`passthroughLoader` instead.
|
|
134
144
|
- Build Output API v3 sanity: `config.json` has `version: 3`.
|
|
135
145
|
|
|
136
146
|
## Step 4: Cross-cutting checks
|
|
@@ -60,6 +60,10 @@ This writes:
|
|
|
60
60
|
- `src/pracht.d.ts` — module augmentation for route ids, params, loader data
|
|
61
61
|
types, and API route request/response types (consumed by `apiFetch()`).
|
|
62
62
|
- `src/pracht-routes.ts` — runtime `href()` helper backed by the same route map.
|
|
63
|
+
- `src/pracht-capabilities.d.ts` — only when the app registers capabilities:
|
|
64
|
+
input/output types from the capability schemas, so `invokeCapability()`,
|
|
65
|
+
`callCapability()`, and `<Form capability>`'s `onCapabilityResult` infer
|
|
66
|
+
types from the capability name.
|
|
63
67
|
|
|
64
68
|
Earlier versions wrote the declaration to `src/pracht-routes.d.ts`; typegen
|
|
65
69
|
removes that stale file automatically (TypeScript silently ignored it next to
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: upgrade-pracht
|
|
3
|
-
version: 1.0.
|
|
3
|
+
version: 1.0.1
|
|
4
4
|
description: |
|
|
5
5
|
Upgrade the @pracht/* packages in an app safely: inventory installed
|
|
6
6
|
versions, read the changelogs between installed and target, map breaking
|
|
@@ -33,8 +33,8 @@ pnpm list --depth 1 --json | grep -A2 '@pracht/' # or read package.json + lock
|
|
|
33
33
|
|
|
34
34
|
The family: `@pracht/core`, `@pracht/cli`, `@pracht/vite-plugin`,
|
|
35
35
|
`@pracht/adapter-node`, `@pracht/adapter-cloudflare`, `@pracht/adapter-vercel`,
|
|
36
|
-
`@pracht/preact-ssr-precompile`. Get the latest published
|
|
37
|
-
`npm view <pkg> version`.
|
|
36
|
+
`@pracht/preact-ssr-precompile`, `@pracht/image`. Get the latest published
|
|
37
|
+
versions with `npm view <pkg> version`.
|
|
38
38
|
|
|
39
39
|
## Step 2: Understand the versioning model
|
|
40
40
|
|
|
@@ -75,6 +75,7 @@ https://raw.githubusercontent.com/JoviDeCroock/pracht/main/packages/<dir>/CHANGE
|
|
|
75
75
|
| `@pracht/vite-plugin` | `packages/vite-plugin` |
|
|
76
76
|
| `@pracht/adapter-node` / `-cloudflare` / `-vercel` | `packages/adapter-*` |
|
|
77
77
|
| `@pracht/preact-ssr-precompile` | `packages/preact-ssr-precompile` |
|
|
78
|
+
| `@pracht/image` | `packages/image` |
|
|
78
79
|
|
|
79
80
|
Changelogs are changesets-generated: `## X.Y.Z` sections containing
|
|
80
81
|
`### Major Changes` / `### Minor Changes` / `### Patch Changes`. Read every
|
package/src/index.js
CHANGED
|
@@ -724,8 +724,8 @@ function createViteConfig(adapter, router, tailwind) {
|
|
|
724
724
|
|
|
725
725
|
const prachtOptions =
|
|
726
726
|
router === "pages"
|
|
727
|
-
? `{ pagesDir: "/src/pages", adapter: ${info.fn}() }`
|
|
728
|
-
: `{ adapter: ${info.fn}() }`;
|
|
727
|
+
? `{ pagesDir: "/src/pages", adapter: ${info.fn}(), llmsTxt: {} }`
|
|
728
|
+
: `{ adapter: ${info.fn}(), llmsTxt: {} }`;
|
|
729
729
|
|
|
730
730
|
const plugins = tailwind
|
|
731
731
|
? `[pracht(${prachtOptions}), tailwindcss()]`
|