|
1 |
| -TODO: |
| 1 | +# POC |
2 | 2 |
|
| 3 | +## TODO |
| 4 | + |
| 5 | +- wrangler alias |
| 6 | +- move the wrangler.toml to the templates |
3 | 7 | - figure out the assets
|
4 | 8 | - dependency graph
|
5 | 9 |
|
6 | 10 | DONE:
|
7 | 11 |
|
8 | 12 | - copy the template folders
|
9 | 13 |
|
10 |
| ------ |
| 14 | +## Install: |
| 15 | + |
| 16 | +- npx create-next-app@latest <app-name> --use-npm |
| 17 | +(use npm to avoid symlinks) |
| 18 | + |
| 19 | +- add "node-url": "npm:url@^0.11.4" to the package.json |
| 20 | + |
| 21 | +- add a wrangler.tom int the generated app |
| 22 | + |
| 23 | +``` |
| 24 | +#:schema node_modules/wrangler/config-schema.json |
| 25 | +name = "api" |
| 26 | +main = ".worker-next/index.mjs" |
| 27 | +assets = ".worker-next/assets" |
| 28 | +compatibility_date = "2024-08-29" |
| 29 | +compatibility_flags = ["nodejs_compat_v2"] |
| 30 | +workers_dev = true |
| 31 | +minify = false |
11 | 32 |
|
12 |
| -wrangler alias |
| 33 | +# The aliases below should not be needed (we don't want users to have to define the aliases themselves) |
| 34 | +[alias] |
| 35 | +# critters is `require`d from `pages.runtime.prod.js` when running wrangler dev, so we need to stub it out |
| 36 | +"critters" = "./.next/standalone/node_modules/cf/templates/shims/empty.ts" |
| 37 | +# @opentelemetry/api is `require`d when running wrangler dev, so we need to stub it out |
| 38 | +# IMPORTANT: we shim @opentelemetry/api to the throwing shim so that it will throw right away, this is so that we throw inside the |
| 39 | +# try block here: https://github.com/vercel/next.js/blob/9e8266a7/packages/next/src/server/lib/trace/tracer.ts#L27-L31 |
| 40 | +# causing the code to require the 'next/dist/compiled/@opentelemetry/api' module instead (which properly works) |
| 41 | +"@opentelemetry/api" = "./.next/standalone/node_modules/cf/templates/shims/throw.ts" |
| 42 | +``` |
13 | 43 |
|
14 |
| --> % cp -r .next/standalone/node_modules/.pnpm/ [email protected]_@ [email protected][email protected][email protected][email protected]/node_modules/next .next/standalone/next/api/node_modules/ |
15 |
| --> % cp -r .next/standalone/node_modules/.pnpm/ [email protected]/node_modules/react .next/standalone/next/api/node_modules/ |
| 44 | +- Build the builder |
16 | 45 |
|
17 |
| -find -L . -type l -ls |
| 46 | +``` |
| 47 | +pnpm --filter builder build:watch |
| 48 | +``` |
18 | 49 |
|
19 |
| -symlinks -rv |
| 50 | +- To build for workers: |
20 | 51 |
|
21 |
| ----- |
| 52 | +Build the next app once: |
22 | 53 |
|
23 |
| -Need to add "node-url": "npm:url@^0.11.4" |
| 54 | +``` |
| 55 | +node /path/to/poc-next/builder/dist/index.mjs && wrangler dev |
| 56 | +``` |
24 | 57 |
|
25 |
| ---- |
| 58 | +Then you can skip building the next app |
26 | 59 |
|
| 60 | +``` |
| 61 | +SKIP_NEXT_APP_BUILD=1 node /path/to/poc-next/builder/dist/index.mjs && wrangler dev |
| 62 | +``` |
0 commit comments