## 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>
## 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>
## 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>
## 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>
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>
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>
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>
## 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>
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?)
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
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.
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
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
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
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
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.
The Vite plugin was not filtering out test files from route discovery,
causing test files in routes/ (e.g., routes/api/counter_test.ts) to be
bundled into production builds, inflating bundle sizes by ~20KB per test
file and including unnecessary test dependencies.
Root cause: Vite plugin defaulted ignore patterns to [] while Builder
correctly defaults to [TEST_FILE_PATTERN].
This fix:
- Defines TEST_FILE_PATTERN in shared constants.ts for reusability
- Exports TEST_FILE_PATTERN from internals_dev.ts for Vite plugin access
- Updates Vite plugin default from [] to [TEST_FILE_PATTERN]
- Updates Builder to import TEST_FILE_PATTERN from constants.ts
- Ensures test files matching /[._]test\.(?:[tj]sx?|[mc][tj]s)$/ are
excluded
- Adds integration test to prevent regression
- Allows Deno best practice of colocating test files without bundling
them
Test coverage (prevents regression):
- Unit test: walkDir respects skip patterns
- Unit test: crawlRouteDir excludes test files
- Integration test: Vite builds exclude test files from output
Fixes#3558
Sets up `@/` as the default path alias in newly generated Fresh
projects, following the official Deno documentation guidelines. This
allows developers to use `@/` for absolute imports from the project root
instead of relative paths. This is especially convenient to remove
import that require deeply traversing up the directory tree.
The `@/` alias is now included in the imports section of deno.json for
all new projects, enabling cleaner import statements like:
```
import { Button } from "@/components/Button.tsx";
```
Fixes#3485
When running Fresh 2 in development, the ETag caching was leading to
incorrect assets being served. I'd often get stale assets from days ago
or separate apps. This problem was especially bad with multiple apps
that run on the same port. For example, I may work on App A on the
default port 5173. Then boot up App B. I'd get assets from App A when I
wouldn't want them, leading to a frustrating dev experience.
Reverting back to the old init script also re-introduced the "address in
use" problem.
This does not have any effect: `env: { PORT: "0" }`
Adding arguments to `deno task start` also have no effect.
The only solution I can come up with is to ignore the task and call
`deno serve` with proper arguments directly for the build tests.
https://github.com/denoland/fresh/pull/3524 unfortunately introduced a
regression in the init script which breaks it. This was caused by two
independent problems:
1. Only files reachable in the module graph are published, meaning the
templates itself weren't published to JSR
2. When publishing to JSR all specifiers become `https://` internally
which breaks doing path operations like `path.resolve()`,
`path.relative()` and all others. This is something that cannot be
tested locally in advance
Addressing these is going to require a bit of work. The quickest way to
get init working again is to revert it.