|
| 1 | +# nodejs.org on OpenNext for Cloudflare |
| 2 | + |
| 3 | +## Getting started |
| 4 | + |
| 5 | +To develop, build, preview, and deploy nodejs.org, execute the following commands to get started: |
| 6 | + |
| 7 | +``` |
| 8 | +nvm use |
| 9 | +npm install |
| 10 | +cd apps/site |
| 11 | +``` |
| 12 | + |
| 13 | +## Developing locally |
| 14 | + |
| 15 | +To develop locally, run the usual: |
| 16 | + |
| 17 | +``` |
| 18 | +npm run dev |
| 19 | +``` |
| 20 | + |
| 21 | +## Build nodejs.org production distribution using OpenNext |
| 22 | + |
| 23 | +To build you need connection to the Internet because the build system will try to fetch the following files: |
| 24 | + |
| 25 | +- https://nodejs.org/dist/index.json |
| 26 | +- https://raw.githubusercontent.com/nodejs/Release/master/schedule.json |
| 27 | + |
| 28 | +``` |
| 29 | +npm run cf:build |
| 30 | +``` |
| 31 | + |
| 32 | +## Preview a production build locally |
| 33 | + |
| 34 | +You can preview production build locally using [wrangler](https://developers.cloudflare.com/workers/wrangler/): |
| 35 | + |
| 36 | +``` |
| 37 | +npm run cf:preview |
| 38 | +``` |
| 39 | + |
| 40 | +## Deploying a build to production |
| 41 | + |
| 42 | +To build and deploy the application run: |
| 43 | + |
| 44 | +``` |
| 45 | +npm run cf:deploy |
| 46 | +``` |
| 47 | + |
| 48 | +The build is currently deployed to a dedicated "nodejs.org" (Cloudflare account id: 8ed4d03ac99f77561d0e8c9cbcc76cb6): https://nodejs-website.web-experiments.workers.dev |
| 49 | + |
| 50 | +You can monitor and configure the project at https://dash.cloudflare.com/8ed4d03ac99f77561d0e8c9cbcc76cb6/workers/services/view/nodejs-website/production |
| 51 | + |
| 52 | +## TODOs |
| 53 | + |
| 54 | +The following is an incomplete list of tasks and problems that still need to be resolved: |
| 55 | + |
| 56 | +- [x] update `@opennextjs/cloudflare` to the latest in `/apps/site/package.json` |
| 57 | +- [x] sort out issues with `eval` and MDX (Claudio is looking into this one) |
| 58 | +- [x] and undo edits in `./app/[locale]/[[...path]]/page.tsx` |
| 59 | +- [x] reimplement `getMarkdownFiles` in `next.helpers.mjs` to be generated at build time |
| 60 | + - this can be accomplished either via a npm/turbo prebuild task, or possibly as part of next.js SSG/staticProps but |
| 61 | + - [ ] we need to ensure that we don't end up accidentally downloading this big file to the client as part of hydration |
| 62 | + - [x] once we have easy access to the list of files, we should roll back changes to `next-data/providers/blogData.ts` |
| 63 | +- [x] back out most changes from `next.dynamic.mjs` |
| 64 | + - [x] instead of using runtime detection via `globalThis.navigator?.userAgent`, we should instead use `alias` feature in `wrangler.toml` to override the implementation of `node:fs` calls but only when running in workerd as we need the build to keep on running in node.js for SSG to work |
| 65 | + - [x] could we reimplement the `existsAsync` call as sync `exists` which consults `getMarkdownFiles` from the task above? |
| 66 | +- [ ] remove symlink hack in `package.json#build:cloudflare` |
| 67 | + - would it be possible to make the pages directory part of assets in a less hacky way? |
| 68 | + - [ ] move these files under `.open-next/assets/cdn-cgi/pages` so that these raw md files are not publicly accessible as that could become a maintenance burden down the road. |
| 69 | +- [ ] wire up the changes with turborepo (right now just plain npm scripts are used) |
| 70 | +- [ ] reenable minification in `next.config.mjs` |
| 71 | +- [ ] remove as many `alias`es as possible from the `wrangler.toml` file |
| 72 | + (the `alias`es that can't be removed should be fully investigated and documented) |
| 73 | +- [ ] fix flashes of unstyled content present on hard navigation |
| 74 | +- [x] enable caching |
| 75 | +- [x] fix routes for languages besides `en` 404ing |
0 commit comments