## Summary
- Refresh `deno.lock` to pick up latest dependency resolutions (notably
preact 10.28.2 → 10.29.0, new `@deno/graph` and `@std/json` entries)
- Fix stale integrity hashes for `raw.githubusercontent.com` remote
specifiers (`check_docs.ts`, `utils.ts`) that point to branch HEAD
- Run `deno fmt` on `www/static/docsearch.css` and
`www/static/markdown.css`
- Remove `deploy.yml` workflow — Deno Deploy now uses its built-in
GitHub integration
---------
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?)
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.
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)
The tests for the `init` package were failing with a `PermissionDenied`
error in Jules container environment when creating temporary
directories. This was because the tests were attempting to create the
temporary directories in the root of the project, where permissions are
often restricted.
This change corrects the issue by removing the local `withTmpDir` helper
function in `packages/init/src/init_test.ts` and instead using the one
from `../../fresh/src/test_utils.ts`. The shared helper function
correctly creates temporary directories in the operating system's
default temporary directory, which resolves the permission issue.
Sample error message from Jules before this fix:
```
ERRORS
init - new project => ./packages/init/src/init_test.ts:99:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
at file:///app/packages/init/src/init_test.ts:100:27
init - create project dir => ./packages/init/src/init_test.ts:107:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async file:///app/packages/init/src/init_test.ts:108:21
init - with tailwind => ./packages/init/src/init_test.ts:122:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
at file:///app/packages/init/src/init_test.ts:123:27
init - with vscode => ./packages/init/src/init_test.ts:140:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async file:///app/packages/init/src/init_test.ts:141:21
init - fmt, lint, and type check project => ./packages/init/src/init_test.ts:153:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async fn (file:///app/packages/init/src/init_test.ts:159:23)
init with tailwind - fmt, lint, and type check project => ./packages/init/src/init_test.ts:179:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async file:///app/packages/init/src/init_test.ts:182:23
init - can start dev server => ./packages/init/src/init_test.ts:205:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async fn (file:///app/packages/init/src/init_test.ts:211:23)
init - can start built project => ./packages/init/src/init_test.ts:233:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
at async file:///app/packages/init/src/init_test.ts:234:21
init - errors on missing build cache in prod => ./packages/init/src/init_test.ts:265:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
at file:///app/packages/init/src/init_test.ts:266:27
init - with vite => ./packages/init/src/init_test.ts:348:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
const dir = await Deno.makeTempDir(options);
^
at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
at file:///app/packages/init/src/init_test.ts:349:27
FAILURES
init - new project => ./packages/init/src/init_test.ts:99:6
init - create project dir => ./packages/init/src/init_test.ts:107:6
init - with tailwind => ./packages/init/src/init_test.ts:122:6
init - with vscode => ./packages/init/src/init_test.ts:140:6
init - fmt, lint, and type check project => ./packages/init/src/init_test.ts:153:6
init with tailwind - fmt, lint, and type check project => ./packages/init/src/init_test.ts:179:6
init - can start dev server => ./packages/init/src/init_test.ts:205:6
init - can start built project => ./packages/init/src/init_test.ts:233:6
init - errors on missing build cache in prod => ./packages/init/src/init_test.ts:265:6
init - with vite => ./packages/init/src/init_test.ts:348:6
FAILED | 449 passed (14 steps) | 10 failed | 17 ignored (2m38s)
```
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Vite has an internal check that limits CommonJS detection to only bare
specifier. This doesn't work well together with us resolving npm modules
to absolute file paths.
https://github.com/vitejs/vite/blob/main/packages/vite/src/node/ssr/fetchModule.ts#L46
I've tried re-using our own instance of `@rollup/plugin-commonjs` or
`esbuild` but couldn't get these to work in that setup. The easiest way
seems to be to just write our own CJS -> ESM translation layer.
With a little luck since the Deno ecosystem is heavy into ESM we might
get away with this. In either way this removes one of the two blockers
to using the vite plugin.
We're having a growing number of packages in this repository. This PR
moves them into a `packages/` directory like it's commonly done in other
projects.
This PR adds a vite plugin for Fresh. This enables:
- HMR (only for islands for now)
- self-contained output bundles for both server and client
- smarter chunking
It uses vite's new Environment API under the hood.