fix: add missing compile entry (#3410)

Fixes https://github.com/denoland/fresh/issues/3409
This commit is contained in:
Marvin Hagemeister
2025-09-12 13:08:49 +02:00
committed by GitHub
parent 7ce6aeff8b
commit e06f03ac67
6 changed files with 36 additions and 10 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ platform without requiring Deno to be installed.
# Build your app first
$ deno task build
# Generate self-contained executable
deno compile --include static --include _fresh --include deno.json -A my-app _fresh/compiled-entry.js
deno compile --output my-app --include _fresh -A _fresh/compiled-entry.js
```
The compiled entry supports two environment variables out of the box:
+5
View File
@@ -283,6 +283,11 @@ The `createHandler` function was often used to launch Fresh for tests. This can
be now done via vite's `createBuilder` function. See the
[testing page](/docs/testing) for more information.
## `deno compile`
If you're using `deno compile` to generate a binary out of the Fresh app be sure
to [update the command](/docs/deployment/deno-compile) to generate the binary.
## Getting help
If you run into problems with upgrading your app, reach out to us by creating an
+13 -9
View File
@@ -381,15 +381,7 @@ export class DiskBuildCache<State> implements DevBuildCache<State> {
}),
);
await Deno.writeTextFile(
path.join(outDir, "compiled-entry.js"),
`import fetcher from "./server.js";
Deno.serve(
{ port: Deno.env.get("PORT"), hostname: Deno.env.get("HOSTNAME") },
fetcher.fetch
);`,
);
await writeCompiledEntry(outDir);
}
}
@@ -425,6 +417,18 @@ export interface PendingStaticFile {
hash: string | null;
}
export async function writeCompiledEntry(outDir: string) {
await Deno.writeTextFile(
path.join(outDir, "compiled-entry.js"),
`import fetcher from "./server.js";
Deno.serve(
{ port: Deno.env.get("PORT"), hostname: Deno.env.get("HOSTNAME") },
fetcher.fetch
);`,
);
}
export async function generateSnapshotServer(
options: {
outDir: string;
+1
View File
@@ -7,6 +7,7 @@ export {
type IslandModChunk,
type PendingStaticFile,
prepareStaticFile,
writeCompiledEntry,
} from "./dev/dev_build_cache.ts";
export { specToName } from "./dev/builder.ts";
export { pathToSpec, UniqueNamer } from "./utils.ts";
@@ -3,6 +3,7 @@ import {
generateServerEntry,
type PendingStaticFile,
prepareStaticFile,
writeCompiledEntry,
} from "fresh/internal-dev";
import { pathWithRoot, type ResolvedFreshViteConfig } from "../utils.ts";
import * as path from "@std/path";
@@ -154,6 +155,8 @@ export default {
};
`,
);
await writeCompiledEntry(outDir);
},
};
}
+13
View File
@@ -27,6 +27,19 @@ Deno.test({
sanitizeResources: false,
});
Deno.test({
name: "vite build - creates compiled entry",
fn: async () => {
const stat = await Deno.stat(
path.join(viteResult.tmp, "_fresh", "compiled-entry.js"),
);
expect(stat.isFile).toEqual(true);
},
sanitizeOps: false,
sanitizeResources: false,
});
Deno.test({
name: "vite build - serves static files",
fn: async () => {