Skip to content

Commit 7f9028f

Browse files
committed
Update instruction
1 parent f372d62 commit 7f9028f

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

TODO.txt

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,62 @@
1-
TODO:
1+
# POC
22

3+
## TODO
4+
5+
- wrangler alias
6+
- move the wrangler.toml to the templates
37
- figure out the assets
48
- dependency graph
59

610
DONE:
711

812
- copy the template folders
913

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
1132

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+
```
1343

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
1645

17-
find -L . -type l -ls
46+
```
47+
pnpm --filter builder build:watch
48+
```
1849

19-
symlinks -rv
50+
- To build for workers:
2051

21-
----
52+
Build the next app once:
2253

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+
```
2457

25-
---
58+
Then you can skip building the next app
2659

60+
```
61+
SKIP_NEXT_APP_BUILD=1 node /path/to/poc-next/builder/dist/index.mjs && wrangler dev
62+
```

0 commit comments

Comments
 (0)