Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
irbull opened this issue Nov 22, 2024 · 4 comments
Open

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

irbull opened this issue Nov 22, 2024 · 4 comments

Comments

@irbull
Copy link

irbull commented Nov 22, 2024

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?

@jueewo
Copy link

jueewo commented Nov 23, 2024

I've the same issue, would be great if that would work

@predaytor
Copy link

#2757

@chibat
Copy link
Contributor

chibat commented Nov 29, 2024

I believe this issue has been fixed in Deno v2.1.2.
denoland/deno#27008 denoland/deno#27006

@jueewo
Copy link

jueewo commented Nov 29, 2024

I've just run some tests and it seems to be fixed. Thank you @chibat & and to the Deno & Fresh team. Now I'm ready to use it for a production system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants