Commit Graph
1657 Commits
Author SHA1 Message Date
Marvin Hagemeister 5c2b04bc2b chore: try vendor + parallel (#3628) 2025-11-18 13:58:36 +01:00
Marvin Hagemeister 45538532e8 chore: revert vendor: true (#3626)
This change was accidentally included in:
https://github.com/denoland/fresh/pull/3624
2025-11-18 12:49:53 +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
时瑶andAyaka 455b06e775 feat(docs): improve copy button appearance on light mode (#3620)
| Before| After |
| :---: | :---: |
|
![before](https://github.com/user-attachments/assets/6d485c89-79ec-485d-9897-de9db0a9b044)
|
![after](https://github.com/user-attachments/assets/5c134ea1-6dec-4da5-8a84-e7e7b7e062a7)
|

The appearance on dark mode doesn't change.

Co-authored-by: Ayaka <KiritaniAyaka@users.noreply.github.com>
2025-11-14 13:50:08 +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
Roy Revelt 45bb094bd6 docs: fix two typos (#3577)
fixes two tiny erros in the docs
2025-10-29 17:59:23 +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 76dfc65e63 chore: update @astral/astral (#3583) 2025-10-29 17:41:46 +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
PastelStoic 07f74ffa4a fix: link to Fresh documentation in README (#3569) 2025-10-23 12:29:49 +02:00
Marvin Hagemeister 41b9422dd1 fix: HEAD method not handled properly (#3563)
- It should never contain a response body
- It should be equivalent to `GET`
2025-10-21 15:43:17 +02:00
Brett Chalupa de1810e70d fix(vite): exclude test files from production builds (#3559)
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
2025-10-21 11:26:20 +02:00
Brett Chalupa 2a78005bc9 chore: update README Deno Deploy docs for EA (#3560)
Fixes #3537
2025-10-21 11:25:18 +02:00
Brett Chalupa 662f795ae8 feat: add @/ path alias to generated projects (#3562)
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
2025-10-21 11:24:36 +02:00
Brett Chalupa 34aa46aa35 fix: disable static file caching in development (#3561)
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.
2025-10-21 11:24:22 +02:00
Marvin Hagemeister 8b7caba444 chore: release 2.1.2 (#3542)
- @fresh/core@2.1.2
- @fresh/update@2.1.2
- @fresh/plugin-vite@1.0.5
2025-10-08 12:56:08 +02:00
Marvin Hagemeister efef51714b fix(vite): unable to load transpiled commonjs with node builtins (#3541) 2025-10-08 12:47:04 +02:00
Marvin Hagemeister 4b069ee0d0 fix(vite): empty commonjs files with only __esModule (#3540)
When modules only contain the `__esModule` flag, we still need to add
the `exports` and `module.exports` initializers.
2025-10-08 11:50:34 +02:00
Marvin Hagemeister 6c03a9bc26 fix(vite): support jsx namespaces (#3539)
Babel throws when encountering jsx namespaces by default. It needs a
setting to not throw.
2025-10-08 11:30:07 +02:00
Devon Wells a2c9350cc4 docs: typos in define helpers page (#3533)
## Summary

Minor typos in define docs page I noticed while onboarding to Fresh 2.
2025-10-07 12:48:29 +02:00
fry69 88de90704e test(init): fix address in use (#3532)
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.
2025-10-07 10:34:10 +02:00
Marvin Hagemeister 026889dbc2 chore: release @fresh/init@2.1.1 (#3531) 2025-10-06 17:58:32 +02:00
Marvin Hagemeister 41fba500de fix(init): revert init template to make init work again (#3530)
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.
2025-10-06 17:48:25 +02:00
fry69 b3c91bd008 chore: fix use free port in builder globals test (#3529)
Fix "port in use" problem re-introduced in builder globals test.
2025-10-06 07:54:44 +00:00
Marvin Hagemeister 909c2b3280 chore: remove old tests (#3528)
Not needed anymore
2025-10-06 09:31:36 +02:00
Marvin Hagemeister cc9946d105 chore: remove old tests (#3527) 2025-10-06 09:29:28 +02:00
fry69 198816b042 feat(init): template based init script (#3524)
Supersedes earlier attempt ->
https://github.com/denoland/fresh/pull/3517

This is now ready for review.

The major upside and motivation for this template based approach is that
it is now possible to view what gets generated in the repository as
actual valid files including syntax highlighting and formatting.

Previously those files where just strings inside the old `init` script,
which is IMHO a nightmare for maintainability.

The approach for this template system is loosely based on Vite's
`create-vite`, which also includes (redundant) templates inside the
repository, see here ->
https://github.com/vitejs/vite/tree/main/packages/create-vite

Included in the tests are compatibility checks against the current
`@fresh/init@2.0.9`, those can get removed at a later point when the
templates start to diverge. They are only included for demonstration
purposes, that this new implementation generates 100% identical output.

This means that the first PR after this got included, which modifies the
templates so the output differs from the old `init` script, also needs
to include:
```shell
rm packages/init/tests/compatibility_test.ts
```

Since this is a rather large PR, it may be more approachable to view the
branch directly ->
https://github.com/fry69/fresh/tree/fry69/refactor-init-template-rename/packages/init

Generated PR message below:

---

Replaces inline string-based project generation with file-based
templates for improved maintainability and extensibility.

### Architecture

**Template structure:**
- `assets/template/` - Complete project templates (vite, vite-tailwind,
builder, builder-tailwind)
- `assets/variants/` - Additive overlays (docker, vscode,
vscode-tailwind)
- `assets/base/` - Common files synced across template variants

Templates use `__VARIABLE__` syntax for substitution (project name,
dependency versions). Files with `__` prefix are renamed to `.` prefix
during generation (e.g., `__gitignore` → .gitignore).

**Template selection logic:**
```
Base: vite|vite-tailwind|builder|builder-tailwind
Variants: +docker, +vscode, +vscode-tailwind
```

### Maintenance workflow

Edit shared files in `assets/base/vite/` or `assets/base/builder/`, then
run `deno task sync` to propagate changes to template variants.
Template-specific files (deno.json, vite.config.ts, styles.css) are
never overwritten.

### Version resolution

Matches existing behavior: only Fresh core version is fetched from JSR,
all other dependencies use fixed versions updated by release scripts.

### Testing

55 tests covering:
- Unit tests for core functionality
- Integration tests (project generation, builds, dev servers)
- CLI argument parsing
- Compatibility tests verifying output matches v2.0.9 (pre-refactor
baseline)
- Template sync workflow

### Breaking changes

None. CLI interface and programmatic API remain identical. Package
publishes to same `@fresh/init` scope at JSR.

### Documentation

- README.md - User-facing usage documentation
- DESIGN.md - Maintainer documentation (architecture, template
maintenance, development setup)
2025-10-06 09:12:07 +02:00
fry69 317f1cb95f chore: make sure free ports get used in tests (#3497)
This fixes issues I have with running tests on one of my servers, where
port 8000 on `localhost` is occupied.

Note: The current `init` test will continue to fail, but that will
hopefully get replaced by #3524 which does not have this problem.

Before:
```
[
  "error: Uncaught (in promise) AddrInUse: Address already in use (os error 98)",
  "    at listen (ext:deno_net/01_net.js:594:35)",
  "    at serveInner (ext:deno_http/00_serve.ts:675:16)",
  "    at Object.serve (ext:deno_http/00_serve.ts:591:10)",
  "    at ext:deno_http/00_serve.ts:819:10",
  "    at ext:runtime_main/js/99_main.js:708:13",
  "    at eventLoopTick (ext:core/01_core.js:179:7)"
]
[...]
Builder - write prod routePattern => ./packages/fresh/src/dev/builder_test.ts:284:6
Builder - file:// islands => ./packages/fresh/src/dev/builder_test.ts:319:6
Builder - serves static files in subdir in prod => ./packages/fresh/src/dev/builder_test.ts:474:6
init - can start built project => ./packages/init/src/init_test.ts:237:6

FAILED | 471 passed (14 steps) | 4 failed | 18 ignored
```

After:
```
ok | 475 passed (14 steps) | 0 failed | 18 ignored
```
2025-10-06 09:10:25 +02:00
Christian 88781463da showcase: add Retro Ranker project to showcase.json (#3490)
Hello there,

Thought I would add my hobby project to the showcase, since it was built
with Fresh 1.0 and now ported to 2.0 (beta). Here's the link: [Retro
Ranker](https://retroranker.site) and the
[github](https://github.com/Nergy101/retro-ranker)

- [x] Ran `deno task ok` and passed.

If I missed anything, let me know.
Cheers!
2025-10-06 08:15:40 +02:00
Marvin Hagemeister c93e19dfbd docs: add Deno upgrade section (#3526) 2025-10-06 08:08:30 +02:00
fry69 84576bd848 fix: prevent island names from shadowing JavaScript globals (#3522)
fix #3521 

Generated PR message below

---

## Problem

Island files named after JavaScript global objects (e.g., Map.tsx,
`Set.tsx`, `Array.tsx`, `Promise.tsx`) cause runtime errors. The
generated boot code uses object shorthand syntax that resolves to the
global constructor instead of the imported component:

```javascript
import Map from "/islands/Map.tsx";
boot({Map}, props);  // {Map} resolves to global Map constructor
```

This results in `TypeError: Map is not a constructor` when the runtime
attempts to instantiate islands.

## Solution

Generate safe prefixed variable names (`__FRSH_ISLAND_N`) for island
imports and use explicit object property syntax to preserve the original
island names:

```javascript
import __FRSH_ISLAND_0 from "/islands/Map.tsx";
boot({"Map":__FRSH_ISLAND_0}, props);
```

This approach:
- Eliminates variable shadowing in all contexts (no scope collisions)
- Preserves original island names in HTML markers, error messages, and
runtime registry
- Allows any valid filename without restrictions
- Follows existing Fresh conventions for generated identifiers

## Changes

- preact_hooks.ts: Updated client-side boot script generation
- dev_build_cache.ts: Updated server-side snapshot generation
- Added integration tests for both Builder and Vite build systems
- Added documentation comment explaining why globals aren't in
`JS_RESERVED`

## Testing

Both tests verify that islands named after globals build successfully
and use safe variable names in generated code. Tests confirm the bug is
detected when fixes are reverted.
2025-10-05 10:53:55 +02:00
David Sherret a45cfe1ced fix(docs): export FreshViteConfig type (#3516)
For https://jsr.io/@fresh/plugin-vite/doc/~/fresh
2025-10-03 19:59:34 +02:00
fry69 8e9dcc087f docs: troubleshoot deploy error message (#3511)
This adds one sentence to the "My deployment won't start" section
mentioning the common `ISOLATE_INTERNAL_FAILURE` error message, so it
can get found via search.

See also discussion in Discord ->
https://discord.com/channels/684898665143206084/1422792167797166121
2025-10-02 23:47:48 +02:00
fry69 1e94e1c9c5 docs: troubleshoot VS Code extension (#3510)
This adds a short blurb how to install the VS Code extension to the
troubleshooting guide.

Possible concerns:
- maybe redundant as there are already official VS Code Deno docs
- could be shortened to just refer to the main docs or completely
removed
2025-10-01 13:20:47 +02:00
fry69 89ae0935b6 docs: troubleshoot dependency installation (#3508)
This adds:
- a short blurb about missing dependencies to the troubleshooting guide
- a hint to this guide in the getting starting page
2025-09-30 11:32:37 +02:00