(
options: {
root: string;
serverEntry: string;
snapshotSpecifier: string;
},
)
| 588 | } |
| 589 | |
| 590 | export function generateServerEntry( |
| 591 | options: { |
| 592 | root: string; |
| 593 | serverEntry: string; |
| 594 | snapshotSpecifier: string; |
| 595 | }, |
| 596 | ): string { |
| 597 | const root = toPosix(options.root); |
| 598 | const serverEntry = toPosix(options.serverEntry); |
| 599 | const snapshotSpecifier = toPosix(options.snapshotSpecifier); |
| 600 | |
| 601 | let rootPath = `path.join(import.meta.dirname, ${JSON.stringify(root)})`; |
| 602 | if (path.isAbsolute(root)) { |
| 603 | // deno-lint-ignore no-console |
| 604 | console.warn( |
| 605 | `WARN: using absolute root path in snapshot: "${root}"`, |
| 606 | ); |
| 607 | |
| 608 | rootPath = JSON.stringify(root); |
| 609 | } |
| 610 | |
| 611 | return `${EDIT_WARNING} |
| 612 | import { setBuildCache, ProdBuildCache, path } from "fresh/internal"; |
| 613 | import * as snapshot from "${snapshotSpecifier}"; |
| 614 | import { app } from "${serverEntry}"; |
| 615 | |
| 616 | const root = ${rootPath}; |
| 617 | setBuildCache(app, new ProdBuildCache(root, snapshot), "production"); |
| 618 | |
| 619 | export default { |
| 620 | fetch: app.handler() |
| 621 | }; |
| 622 | `; |
| 623 | } |
| 624 | |
| 625 | function getClientEntry(buildId: string) { |
| 626 | return `/_fresh/js/${buildId}/fresh-runtime.js`; |
no test coverage detected