Skip to content

Document how to compile a Fresh site into an executable #2772

Open
@irbull

Description

With Deno 2.1.0, we can now compile assets directly into the executable. This means we should be able to ship a Deno Fresh (Application) as a single binary.

I've tried this, and it fails to load some of the assets at runtime. I'm not sure if this is just a documentation issue, or if something within Fresh needs to be adjusted to handle asset locations. Here is what I did:

  1. deno --version (deno 2.1.1 (stable, release, aarch64-apple-darwin)
  2. deno run -A -r https://fresh.deno.dev fresh-site (answered Y to all questions)
  3. cd fresh-site
  4. deno task build

There are a few options here:
5. deno compile --include static/ --include _fresh/ --include deno.json --include fresh.gen.ts -A dev.ts
6. ./dev

This fails with:

error: Uncaught (in promise) NotSupported: writefile '/var/folders/0v/jhqzvwhx345fsngdr12f6zg00000gn/T/deno-compile-dev/fresh-site/fresh.gen.ts': writefile '/var/folders/0v/jhqzvwhx345fsngdr12f6zg00000gn/T/deno-compile-dev/fresh-site/fresh.gen.ts'

We could also try and compile the main.ts
5. deno compile --include static/ --include _fresh/ --include deno.json --include fresh.gen.ts -A main.ts
6. ./fresh-site

This starts the Fresh application:

 $ ./fresh-site
 
Using snapshot found at /var/folders/0v/jhqzvwhx345fsngdr12f6zg00000gn/T/deno-compile-fresh-site/fresh-site/_fresh

 🍋 Fresh ready
    Local: http://localhost:8000/

But assets fail to load when rendering this site.

Are there other assets that need to be included? Other suggestions?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions