···11+Copyright (c) 2020 Cloudflare, Inc.
22+33+Permission is hereby granted, free of charge, to any
44+person obtaining a copy of this software and associated
55+documentation files (the "Software"), to deal in the
66+Software without restriction, including without
77+limitation the rights to use, copy, modify, merge,
88+publish, distribute, sublicense, and/or sell copies of
99+the Software, and to permit persons to whom the Software
1010+is furnished to do so, subject to the following
1111+conditions:
1212+1313+The above copyright notice and this permission notice
1414+shall be included in all copies or substantial portions
1515+of the Software.
1616+1717+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
1818+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
1919+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
2020+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
2121+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
2222+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2323+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
2424+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2525+DEALINGS IN THE SOFTWARE.
+1
TODO.md
···1414## Install
15151616- `npx create-next-app@latest <app-name> --use-npm` (use npm to avoid symlinks)
1717+1718- update next.config.mjs as follows
18191920 ```typescript
+46
builder/README.md
···11+# Next.js builder for Cloudflare
22+33+## Build your app
44+55+- update the `next.config.mjs` as follows
66+77+ ```typescript
88+ /** @type {import('next').NextConfig} */
99+ const nextConfig = {
1010+ output: "standalone",
1111+ experimental: {
1212+ serverMinification: false,
1313+ },
1414+ };
1515+1616+ export default nextConfig;
1717+ ```
1818+1919+- add the following `devDependency` to the `package.json`:
2020+2121+ ```json
2222+ "node-url": "npm:url@^0.11.4",
2323+ "wrangler": "^3.77.0"
2424+ ```
2525+2626+- Execute `npx @flarelabs-net/builder@latest` in your app folder
2727+2828+## Serve your app
2929+3030+- add a `wrangler.toml` at the root of your project
3131+3232+ ```toml
3333+ #:schema node_modules/wrangler/config-schema.json
3434+ name = "<app-name>"
3535+ main = ".worker-next/index.mjs"
3636+3737+ compatibility_date = "2024-08-29"
3838+ compatibility_flags = ["nodejs_compat_v2"]
3939+ workers_dev = true
4040+ minify = false
4141+4242+ # Use the new Workers + Assets to host the static frontend files
4343+ experimental_assets = { directory = ".worker-next/assets", binding = "ASSETS" }
4444+ ```
4545+4646+- Use `wrangler dev`
···11import { globSync } from "glob";
22-import { NextjsAppPaths } from "../../../../nextjs-paths";
22+import { NextjsAppPaths } from "../../../nextjs-paths";
3344/**
55 * `evalManifest` relies on readFileSync so we need to patch the function so that it instead returns the content of the manifest files
···11import { readFileSync, existsSync } from "node:fs";
22-import { NextjsAppPaths } from "../../../../nextjs-paths";
22+import { NextjsAppPaths } from "../../../nextjs-paths";
3344/**
55 * The following avoid various Next.js specific files `require`d at runtime since we can just read