Commit Graph
206 Commits
Author SHA1 Message Date
a79b155e79 fix: make <Head> work in client (#3252)
Closes #3310

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 21:21:39 +02:00
Sato Takayuki 19d3589b9b fix: apply basePath correctly in dev mode for root index (#3219)
## Summary
- Fixed an issue where basePath was not correctly applied in dev mode
for the root index route
- The dev server now uses root path "/" while preserving the configured
basePath for the main app
2026-03-29 21:17:17 +02:00
Bartek IwańczukandClaude Opus 4.6 ee9d1d04e7 fix: apply layout to index route with programmatic routing (#3725)
Closes #3553

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 21:14:34 +02:00
Bartek IwańczukandClaude Opus 4.6 9e7adc084b fix: middleware not matching routes with optional parameters in fs routing (#3726)
Closes #3545

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 21:11:55 +02:00
Bartek IwańczukandClaude Opus 4.6 dd1ecf3b16 fix: don't intercept forms without explicit f-partial inside f-client-nav (#3722)
Fixes #3473

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 19:07:54 +00:00
Bartek IwańczukandClaude Opus 4.6 caeebd88a5 fix: trailing slash mismatch causes 404 for static routes (#3721)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 21:06:18 +02:00
Bartek IwańczukandClaude Opus 4.6 e6b25a084c fix: add @types/babel__core to vite project template (#3723)
Closes #3605

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 19:04:07 +00:00
Bartek IwańczukandClaude Opus 4.6 075dfb73b2 feat: inject traceparent meta tag when OpenTelemetry is active (#3729)
Closes #2830

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 18:51:12 +00:00
Bartek IwańczukandClaude Opus 4.6 92e07f03b3 fix: resolve server entry filename from bundle chunks (#3719)
Closes #3655

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:45:32 +02:00
Bartek IwańczukandClaude Opus 4.6 be467d3cdb fix: warn when Partial with append/prepend mode is missing key prop (#3738)
## Summary
- Adds a `console.warn` during SSR when a `<Partial>` uses
`mode="append"` or `mode="prepend"` without a `key` prop
- Without a key, Preact cannot correctly reconcile prepended/appended
children, leading to subtle rendering bugs
- No warning for `mode="replace"` (default) since keys aren't required
there

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:33:14 +02:00
Bartek IwańczukandClaude Opus 4.6 103427f9da docs: comprehensive documentation audit, fixes, and website improvements (#3712)
## Summary

Full documentation audit and fixes for Fresh 2.x docs. Addresses every
issue identified in the [audit
report](https://gist.github.com/bartlomieju/91ddb08c23552f642d2073c0e9a36102).

### Critical fixes
- Remove 4 TODO placeholders (app.md, plugins/index.md)
- Fix 4 broken code examples (layouts syntax error, routing missing ctx,
csrf wrong import, getting-started unused prop)
- Fix 3 copy-pasted frontmatter descriptions (context, env-vars, app)
- Fix CSRF page describing CORS instead of CSRF

### New pages (8)
- **Architecture** — request lifecycle diagram, server-first rendering,
islands architecture
- **Data Fetching** — handlers, page(), type-safe data passing, async
components, PageProps reference
- **Signals** — useSignal, computed, props, shared state, serialization
- **Serialization** — supported types, what can't be serialized,
circular refs, pitfalls
- **API Routes** — handler-only routes, method-specific, catch-all,
programmatic
- **Common Patterns** — protected routes, redirects, cookies,
WebSockets, streaming, content negotiation, subdomain routing, proxying,
lazy-loading islands
- **API Reference** — all exports from fresh, fresh/runtime, fresh/dev
- **OpenTelemetry** — what's instrumented, enabling tracing, Deno Deploy

### Expanded pages (6)
- **Routing** — matching priority, HTTP methods, HEAD fallback,
file-based handlers
- **Vite plugin** — HMR, plugin composition, internals, debugging
- **Deno Deploy** — build config, env vars, custom domains,
troubleshooting
- **deno compile** — cross-compilation, limitations
- **Error handling** — expanded HttpError with message param, import
paths
- **Plugins index** — plugin authoring guidance, built-in plugin list

### Structural improvements
- Update all 3 index pages (concepts, advanced, examples) with links to
every sub-page
- Cross-link the two Layouts pages (file-based vs programmatic)
- Resolve contradictory build commands (remove legacy dev.ts references)
- Add "next steps" to Getting Started
- Explain `(_islands)` and `(_components)` directories in file routing
- Document `basePath`, `assetSrcSet()`, `IS_BROWSER`, route `css` option
- Add PR guidelines to Contributing page
- Add Deno version requirements to Introduction

### Docs fixes from issue triage
- **Docker deployment** — add missing `deno install --allow-scripts`
step, remove stale `deno cache`, fix CMD (#3500)
- **Deployment index** — add install step before build (#3500)
- **Static files** — add tip about root-relative URLs (#3482), add image
optimization section with vite-imagetools, CDN services, best practices
(#671)
- **main.ts vs main.tsx** — fix examples showing JSX in main.ts, add tip
about serverEntry config (#3476)
- **Head component** — clarify dedup precedence: last-rendered wins
(#2749)
- **Islands** — add custom elements / web components section (#2741)
- **Sharing state** — rewrite cart example to avoid shared module-level
signals (#2437, #1877)
- **Common patterns** — add subdomain routing (#603), proxying requests
(#361), lazy-loading islands (#565)

### Website fixes
- **Canary redirects** — catch-all `/docs/canary/...` → `/docs/...`
redirect (#3375)
- **Recipe partials** — redirect direct access to recipe routes to
homepage (#2559)
- **Homepage** — add progressive complexity code examples to Simple
section (#2755)

### Image reference fixes
- Rename `getting-started-3-cotuntdown.png` →
`getting-started-3-countdown.png`
- Fix 1.x partials image path

### Grammar/typos
- 11 corrections across 12 files

### CI
- Add `docs/check_images_test.ts` — verifies all markdown image
references resolve to existing files in `www/static/`

Closes #3514
Closes #3476
Closes #3591
Closes #2876
Closes #2075
Closes #1612
Closes #1535
Closes #527
Closes #3059
Closes #3695
Closes #3548
Closes #3500
Closes #3482
Closes #3375
Closes #2749
Closes #2741
Closes #2559
Closes #2437
Closes #671
Closes #361

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 18:22:33 +00:00
Bartek IwańczukandClaude Opus 4.6 059183b230 fix: improve error message for missing exports in file routes (#3718)
Closes #3652

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:18:07 +02:00
Bartek IwańczukandClaude Opus 4.6 4e0331b5c9 fix: preserve partial search param through redirects (#3715)
## Summary
- Fixes #2610 — "Partial + redirect breaks islands"
- When a partial request (`?fresh-partial=true`) hits a server-side
redirect via `ctx.redirect()`, the `fresh-partial` search param is now
preserved in the redirect `Location` header
- Previously the param was lost, so the redirect target rendered as a
full page instead of a partial response, breaking island hydration

The fix is in `ctx.redirect()` in `packages/fresh/src/context.ts` — when
`this.isPartial` is true, the partial param is appended to the redirect
location (handling existing query params and hash fragments correctly).

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 13:23:54 +02:00
0015710909 feat: allow passing Temporal objects to islands (#3701)
## Summary

- Add serialization/deserialization for all 8 Temporal types in the
jsonify module (used for island props): Instant, ZonedDateTime,
PlainDate, PlainTime, PlainDateTime, PlainYearMonth, PlainMonthDay,
Duration
- Stringify side guards with `typeof Temporal !== "undefined"` to avoid
ReferenceError when Temporal is unavailable
- Uses `.toString()` for serialization and `Type.from()` for
deserialization

Co-authored-by: Nano Miratus <nanomiratus@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 10:23:38 +02:00
Bartek IwańczukandClaude Opus 4.6 b790c804ee feat: support deno create for project initialization (#3706)
## Summary
- Add a `./create` export to `@fresh/init` so users can scaffold
projects with `deno create @fresh/init` (Deno 2.7+)
- The old `deno run -Ar jsr:@fresh/init` continues to work but now shows
a deprecation warning

**New way (Deno 2.7+):**
```sh
deno create @fresh/init
```

**Old way (still works, with warning):**
```sh
deno run -Ar jsr:@fresh/init
```

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 15:38:31 +00:00
Bartek Iwańczuk 25e6357e1a chore: release 2.2.2 (#3717) 2026-03-28 10:01:28 +01:00
Hong Minhee (洪 民憙)andBartek Iwańczuk b11d1d98f2 fix: handle invalid date objects in jsonify stringify (#2851)
## Summary
- Handles the case when `Date.toISOString()` throws for invalid dates by
catching the error and serializing as `"Invalid Date"`
- Round-trips correctly: `new Date("Invalid Date")` serializes to
`["Date","Invalid Date"]` and deserializes back to an invalid `Date`
object
- Adds test case and snapshot for invalid `Date`

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2026-03-26 08:31:27 +00:00
3822b4a21b test: add fresh_version_check test (#3029)
add a test file to auto check the fresh_version, based on deno.json
--version.

Close #3024 

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2026-03-26 08:20:01 +00:00
Marvin HagemeisterandBartek Iwańczuk 882b7829fd feat: expose HttpError for clients (#3080)
This PR exposes the `HttpError` class for clients. 

To do that I needed to make the error message optional to avoid bloating
up the bundle with lots of status strings.

Fixes https://github.com/denoland/fresh/issues/2995

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2026-03-26 09:10:21 +01:00
0fff2b04da chore: minor code cleanups (#3103)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 09:01:34 +01:00
022835cce6 perf: make updater faster by streaming instead of reading into memory (#3630)
Fix system crash (OOM) caused by updater spending time in folders like
docs/

- Skip hidden and vendor directories (node_modules, vendor, docs, etc.)
to avoid OOM
- free ASTs immediately
- ts-morph dependency bumped to ^27.0.2

Closes https://github.com/denoland/fresh/issues/3483

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 20:01:01 +01:00
c863097779 fix: handle paths with whitespaces in staticFiles (#3659)
Fix #3657

Static files with special characters in their names (spaces, `#`,
unicode, etc.) fail to load due to path encoding issues.

## Root cause

`prepareStaticFile()` uses `new URL(pathname, base)` to normalize paths,
but `new URL` doesn't properly encode characters that are already
percent-encoded in the filesystem path. For example, a file literally
named `test %20encodeUri` becomes `test%20%20encodeUri` (the space and
literal `%20` are indistinguishable), instead of the correct
`test%20%2520encodeUri`.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 20:00:48 +01:00
421e3394a2 fix(vite): use manifest entry filename for server entry import (#3595)
## Summary
When `rollupOptions.output.entryFileNames` is customized in vite config
(e.g. `[hash].mjs`), the generated `server.js` was hardcoding
`server-entry.mjs` as the import path, causing the server to fail to
start.

This fix reads the actual entry filename from the Vite manifest and uses
it in the generated `server.js` import, falling back to
`server-entry.mjs` when no custom naming is configured.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 18:47:02 +00:00
cdc14a0c6e Do not assign named exports into existing default export (#3494)
Fixes: https://github.com/denoland/fresh/issues/3492

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:40:46 +01:00
Marvin Hagemeister 4cc76aefed chore: release 2.2.1 (#3678) 2026-02-11 14:38:24 +01:00
Marvin Hagemeister 3d8091602c fix: .well-known static folder not working (#3676)
This folder is typically used for site metadata like `security.txt` and
other stuff.
2026-02-11 14:19:33 +01:00
Marvin Hagemeister 89ddbc4f4b chore: update preact version (#3664) 2026-01-07 14:17:59 +01:00
Eli ab14d1044c refactor(vite): replace old environment APIs (#3634)
I was perusing the code whilst investigating #3606 and noticed that,
despite the release post claiming that Fresh had ["fully
embrace[d]"](https://deno.com/blog/fresh-and-vite#:~:text=fully%20embraces)
the Vite Environment API, it was still using `ssrLoadModule`. Once I
started looking, I noticed a bunch of other code that wasn't
future-proof (env-wise, not rolldown-wise, which'll bring it's own swath
of deprecations[^1]), so I updated them as well.

The newly added source map tests from #3624 currently fail again because
the ModuleRunner API at the heart of the Environment API relies on
[`process.setSourceMapsEnabled`](https://docs.deno.com/api/node/process/~/Process.setSourceMapsEnabled),
which is [currently set to
no-op](https://github.com/denoland/deno/pull/22993) in Deno.

[^1]: Separately tried to try out rolldown-vite but it seems that Deno
doesn't support aliasing dependencies whatsoever? (I know there's not
official support, but I was going to try to edit the lockfile to hack
around it; however, it seems that there's not alias support in there at
all?)
2025-12-09 13:00:36 +01:00
eryue0220 0acebce0bb fix: update type & imports (#3638)
This pr is small fixed that update type declaration and import from
codebase.
2025-11-25 09:43:51 +01:00
David Sherret 18e47a86b0 fix(vite): force at least @deno/loader@0.3.10 (#3631)
Ref: https://github.com/denoland/deno-js-loader/pull/68
2025-11-19 23:05:45 +01:00
Marvin Hagemeister 2c36becff0 chore: release 2.2.0 (#3627)
- `@fresh/core@2.2.0`
- `@fresh/update@2.2.0`
- `@fresh/init@2.3.0`
- `@fresh/plugin-vite@1.0.8`
2025-11-18 14:09:19 +01:00
Marvin Hagemeister f5c0f16878 fix(vite): source mapping locations (#3624)
Mappings were wrong for a few reasons:
- Missing source map generation in one babel transform
- setting `compact: false` causes vite to generate incorrect mappings in
`vite:import-analysis`
- stack traces need to be mapped by vite

Fixes https://github.com/denoland/fresh/issues/3609
2025-11-18 11:40:52 +01:00
时瑶andAyaka 399dde767b feat(init): use recommended vscode settings for tailwind (#3621)
The recommended way to configure custom directives from Tailwind is to
use `files.associations`.

Check recommended settings from Tailwind CSS IntelliSense Extension:
https://github.com/tailwindlabs/tailwindcss-intellisense#recommended-vs-code-settings

This allows us to stop maintaining future changes to custom directives
from TailwindCSS, instead letting the TailwindCSS extension decide how
to handle them.

Co-authored-by: Ayaka <KiritaniAyaka@users.noreply.github.com>
2025-11-17 10:46:10 +01:00
Marvin Hagemeister 8de5b15799 feat: add .json()/.text()/.html()/.stream() context helpers (#3613)
Played around with Hono in the past days and the
`.text()/.json()/.html()` helpers are kinda neat, even if you can always
construct that yourself manually. Also added a `.stream()` helper to
create streams without having to deal with `ReadableStream` and
encodings yourself.
2025-11-11 17:25:02 +01:00
Christian Svensson fd7ecec5fa docs(core): add small usage & getting started example (#3598)
This PR just fills out the `README.md` with minimal usage example, such
that they can get a small taste of how the framework can be used. This
also helps improve the score in JSR.

Part of #3597
2025-11-11 15:34:22 +01:00
Christian Svensson 23734a00b2 docs(core): improve CORS example documentation on JSR (#3602)
Improves clarity of CORS JSDoc example for JSR:

<img width="1088" height="706" alt="image"
src="https://github.com/user-attachments/assets/8ea3b6f9-a5ee-41cc-9512-a3a0fb87a4c0"
/>

## Changes

- Split the example into two: Basic & Advances
- Uncomment "Advanced" example
2025-11-11 15:33:54 +01:00
Christian Svensson 6a1ce911d0 docs(examples): add module and public exports JSDoc for all entrypoints (#3603)
Addresses scoring of `@fresh/examples` of JSR for several metrics:

- ✅ Adds module doc for all entrypoints
- ✅ Adds descriptions to all public exports for `@fresh/examples` (0% ->
100%)

I could not find if `@fresh/examples` are part of any E2E tests to test
using JSR package as mounted app or Island, or if this is just a small
demo for users. So I just added small generic drescriptions.

Part of #3597
2025-11-11 15:33:28 +01:00
Christian Svensson 1dd8279075 docs(vite): add JSDoc and export public API (#3604)
Improves documentation of `@fresh/plugin-vite` related to public API,
and exports missing symbols/types that are part of public API
(`FreshViteConfig`).

- Adds `@module` JSDoc for the `@fresh/plugin-vite/client` entrypoint
  - Internal only, used for browser HMR
- Exports types `ImportCheck` & `ImportCheckDiagnostic`, as they are
part of the public API via `FreshViteConfig`
- Should make [`ImportCheck` link to correct
type](https://jsr.io/@fresh/plugin-vite/doc/~/FreshViteConfig#property_checkimports):
<img width="1053" height="285" alt="image"
src="https://github.com/user-attachments/assets/766c29f7-7f39-429e-bd81-234fed6b0820"
/>
- Adds JSDoc descriptions for all public exports; `fresh`,
`FreshViteConfig`, `ImportCheck` & `ImportCheckDiagnostic`
- Adds description for `FreshViteConfig.checkImports`

Part of #3597 & #3596
2025-11-11 15:33:03 +01:00
Christian Svensson ffa845ab0d docs(core): correct example code block formatting (#3601)
The example for the CSP middleware looks a bit broken currently on JSR,
due to the `@example` markdown is not wrapped in a code block.

<img width="1136" height="247" alt="image"
src="https://github.com/user-attachments/assets/57888033-aa9e-4701-87dc-4f4810365177"
/>

## Changes

- Improves formatting a bit, to be less compact
- Wraps the example in a code block ` ```ts `
- Adds a title to the `@example` - "Basic usage" - To avoid the example
being labeled as "Example1" on JSR
2025-11-04 16:03:51 +01:00
Christian Svensson a801686e9c docs(build-id): add code block example (#3600)
Adds a module doc and code block to help satisfy JSR's scoring.
Suggestions for alternatives or improvements very welcome.

Part of #3597
2025-11-04 16:02:53 +01:00
Marvin Hagemeister 42d7d9f23b chore: release 2.1.4 (#3586)
- @fresh/core@2.1.4
- @fresh/update@2.1.4
- @fresh/init@2.2.2
- @fresh/plugin-vite@1.0.7
2025-10-30 15:57:14 +01:00
Marvin Hagemeister 68e70858aa chore: improve init tests (#3590) 2025-10-30 15:49:02 +01:00
Marvin Hagemeister 5a220c6eea chore: tests add more logs for easier debugging (#3589) 2025-10-30 15:14:15 +01:00
Marvin Hagemeister 7fcae1d895 fix: HEAD when only GET is registered in .route() (#3587) 2025-10-30 14:59:12 +01:00
PastelStoic c7af11eb7c fix(vite): inherit top level outDir configuration for builds (#3570)
The Vite outDir setting is confusingly ignored, which is not documented
in the plugin documentation. This corrects that, while still preferring
the more specific environment settings.
2025-10-30 14:55:29 +01:00
Marvin Hagemeister 5e94dfe9fd fix: switch to nodeModulesDir: "manual" (#3588)
The `"auto"` value causes all kinds of race conditions between various
processes trying to auto install their view of dependencies.
2025-10-30 14:50:49 +01:00
Marvin Hagemeister 7db37d7ba1 fix(partial): buttons outside forms should not trigger navigation (#3584)
`<button>` elements that are not inside a form and have a `f-partial`
attribute should not trigger a history change.
2025-10-29 17:49:19 +01:00
Marvin Hagemeister 7b6d6315d1 fix(vite): mark transformed cjs with __esModule (#3575)
Fixes https://github.com/denoland/fresh/issues/3565
2025-10-24 19:54:37 +02:00
Marvin Hagemeister 5a228625ea chore: release 2.1.3 (#3572)
- @fresh/core@2.1.3
- @fresh/update@2.1.2
- @fresh/plugin-vite@1.0.6
- @fresh/init@2.2.1
2025-10-23 13:15:07 +02:00
Marvin Hagemeister 3681fb1c84 fix: .fsRoutes() pattern argument not working (#3571)
Fixes https://github.com/denoland/fresh/issues/3566
2025-10-23 13:05:11 +02:00