fix: add missing compile entry (#3410)
Fixes https://github.com/denoland/fresh/issues/3409
This commit is contained in:
@@ -11,7 +11,7 @@ platform without requiring Deno to be installed.
|
|||||||
# Build your app first
|
# Build your app first
|
||||||
$ deno task build
|
$ deno task build
|
||||||
# Generate self-contained executable
|
# 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:
|
The compiled entry supports two environment variables out of the box:
|
||||||
|
|||||||
@@ -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
|
be now done via vite's `createBuilder` function. See the
|
||||||
[testing page](/docs/testing) for more information.
|
[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
|
## Getting help
|
||||||
|
|
||||||
If you run into problems with upgrading your app, reach out to us by creating an
|
If you run into problems with upgrading your app, reach out to us by creating an
|
||||||
|
|||||||
@@ -381,15 +381,7 @@ export class DiskBuildCache<State> implements DevBuildCache<State> {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
await Deno.writeTextFile(
|
await writeCompiledEntry(outDir);
|
||||||
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
|
|
||||||
);`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,6 +417,18 @@ export interface PendingStaticFile {
|
|||||||
hash: string | null;
|
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(
|
export async function generateSnapshotServer(
|
||||||
options: {
|
options: {
|
||||||
outDir: string;
|
outDir: string;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export {
|
|||||||
type IslandModChunk,
|
type IslandModChunk,
|
||||||
type PendingStaticFile,
|
type PendingStaticFile,
|
||||||
prepareStaticFile,
|
prepareStaticFile,
|
||||||
|
writeCompiledEntry,
|
||||||
} from "./dev/dev_build_cache.ts";
|
} from "./dev/dev_build_cache.ts";
|
||||||
export { specToName } from "./dev/builder.ts";
|
export { specToName } from "./dev/builder.ts";
|
||||||
export { pathToSpec, UniqueNamer } from "./utils.ts";
|
export { pathToSpec, UniqueNamer } from "./utils.ts";
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
generateServerEntry,
|
generateServerEntry,
|
||||||
type PendingStaticFile,
|
type PendingStaticFile,
|
||||||
prepareStaticFile,
|
prepareStaticFile,
|
||||||
|
writeCompiledEntry,
|
||||||
} from "fresh/internal-dev";
|
} from "fresh/internal-dev";
|
||||||
import { pathWithRoot, type ResolvedFreshViteConfig } from "../utils.ts";
|
import { pathWithRoot, type ResolvedFreshViteConfig } from "../utils.ts";
|
||||||
import * as path from "@std/path";
|
import * as path from "@std/path";
|
||||||
@@ -154,6 +155,8 @@ export default {
|
|||||||
};
|
};
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await writeCompiledEntry(outDir);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,19 @@ Deno.test({
|
|||||||
sanitizeResources: false,
|
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({
|
Deno.test({
|
||||||
name: "vite build - serves static files",
|
name: "vite build - serves static files",
|
||||||
fn: async () => {
|
fn: async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user