Skip to content

Commit 659dda2

Browse files
committed
refactor: split site into site/vercel/cloudflare apps
Separates platform concerns so Next.js upgrades and Vercel-specific deps are no longer gated on OpenNext's compatibility window (and vice versa), and so each deployment ships only the dependencies it actually uses. - apps/site: platform-neutral. No @vercel/*, no @opennextjs/cloudflare, no VERCEL_ENV or 'Cloudflare' in global runtime forks. - apps/vercel: owns Analytics, SpeedInsights, OTel instrumentation, vercel.json. - apps/cloudflare: owns OpenNext, Wrangler, image loader, worker entrypoint (Sentry), version_metadata binding. Host apps reach site source via git-tracked symlinks, plus one real parallel-route slot per host (app/[locale]/@analytics/default.tsx) for platform-specific layout injection. MDX engine choice moved from a runtime 'Cloudflare' in global check to MDX_WASM / MDX_TWOSLASH build env vars. middleware.ts renamed to proxy.ts on the Vercel/standalone side; Cloudflare keeps middleware.ts (OpenNext requirement) via symlink. Commands: pnpm build/dev/start still target site. Platform commands are now pnpm build:vercel, build:cloudflare, dev:vercel, dev:cloudflare, cloudflare:preview, cloudflare:deploy. Vercel project Root Directory needs to move to apps/vercel in the Vercel dashboard when this ships. All three apps pass lint:types independently.
1 parent 524e64b commit 659dda2

86 files changed

Lines changed: 1560 additions & 900 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ You can check the items by adding an `x` between the brackets, like this: `[x]`
2828
- [ ] I have read the [Contributing Guidelines](https://github.com/nodejs/nodejs.org/blob/main/CONTRIBUTING.md) and made commit messages that follow the guideline.
2929
- [ ] I have run `pnpm format` to ensure the code follows the style guide.
3030
- [ ] I have run `pnpm test` to check if all tests are passing.
31-
- [ ] I have run `pnpm build` to check if the website builds without errors.
31+
- [ ] I have run `pnpm build` to check if the website builds without errors. (Optional: `pnpm build:vercel` / `pnpm build:cloudflare` for deployment-target-specific builds.)
3232
- [ ] I've covered new added functionality with unit tests if necessary.

.github/workflows/build.yml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,37 @@ jobs:
5555

5656
- uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
5757
with:
58-
path: ${{ github.workspace }}/apps/site/.next/cache
58+
path: |
59+
${{ github.workspace }}/apps/site/.next/cache
60+
${{ github.workspace }}/apps/vercel/.next/cache
61+
${{ github.workspace }}/apps/cloudflare/.next/cache
5962
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
6063
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
6164

62-
- name: Build Next.js
65+
- name: Build apps/site (standalone)
6366
# We want a ISR build on CI to ensure that regular Next.js builds work as expected.
64-
run: node_modules/.bin/turbo build --cache-dir=.turbo/cache
67+
run: node_modules/.bin/turbo build --filter=@node-core/website --cache-dir=.turbo/cache
6568
env:
66-
# We want to ensure we have enough RAM allocated to the Node.js process
67-
# this should be a last resort in case by any chances the build memory gets too high
68-
# but in general this should never happen
6969
NODE_OPTIONS: '--max_old_space_size=4096'
70-
# See https://github.com/vercel/next.js/pull/81318
7170
TURBOPACK_STATS: ${{ matrix.os == 'ubuntu-latest' }}
7271

72+
- name: Build apps/vercel (Vercel deployment target)
73+
# Ensures the Vercel deployment target builds with its platform-specific
74+
# `@analytics` slot + instrumentation wired through the shared site source.
75+
run: node_modules/.bin/turbo build --filter=@node-core/website-vercel --cache-dir=.turbo/cache
76+
env:
77+
NODE_OPTIONS: '--max_old_space_size=4096'
78+
TURBOPACK_STATS: ${{ matrix.os == 'ubuntu-latest' }}
79+
80+
- name: Build apps/cloudflare (Cloudflare / OpenNext deployment target)
81+
# Ensures the Cloudflare deployment target builds with its Cloudflare
82+
# Images loader and MDX_WASM=false Shiki path.
83+
# Windows skip: OpenNext/wrangler asset polyfilling is POSIX-only.
84+
if: matrix.os == 'ubuntu-latest'
85+
run: node_modules/.bin/turbo cloudflare:build:worker --filter=@node-core/website-cloudflare --cache-dir=.turbo/cache
86+
env:
87+
NODE_OPTIONS: '--max_old_space_size=4096'
88+
7389
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
7490
if: matrix.os == 'ubuntu-latest'
7591
with:
@@ -78,11 +94,8 @@ jobs:
7894

7995
- name: Build Next.js (Static Export)
8096
# We want to generate a static build, as it is a requirement of our website.
81-
run: node_modules/.bin/turbo deploy --cache-dir=.turbo/cache
97+
run: node_modules/.bin/turbo deploy --filter=@node-core/website --cache-dir=.turbo/cache
8298
env:
83-
# We want to ensure we have enough RAM allocated to the Node.js process
84-
# this should be a last resort in case by any chances the build memory gets too high
85-
# but in general this should never happen
8699
NODE_OPTIONS: '--max_old_space_size=4096'
87100
# We want to ensure that static exports for all locales do not occur on `pull_request` events
88101
# TODO: The output of this is too large, and it crashes the GitHub Runner

.github/workflows/playwright-cloudflare-open-next.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: Get Playwright version
3838
id: playwright-version
39-
working-directory: apps/site
39+
working-directory: apps/cloudflare
4040
run: echo "version=$(node_modules/.bin/playwright --version | awk '{print $2}')" >> $GITHUB_OUTPUT
4141

4242
- name: Cache Playwright browsers
@@ -47,11 +47,11 @@ jobs:
4747
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
4848

4949
- name: Install Playwright Browsers
50-
working-directory: apps/site
50+
working-directory: apps/cloudflare
5151
run: node_modules/.bin/playwright install --with-deps
5252

5353
- name: Run Playwright tests
54-
working-directory: apps/site
54+
working-directory: apps/cloudflare
5555
run: node --run playwright
5656
env:
5757
PLAYWRIGHT_RUN_CLOUDFLARE_PREVIEW: true
@@ -62,4 +62,4 @@ jobs:
6262
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
6363
with:
6464
name: playwright-report
65-
path: apps/site/playwright-report/
65+
path: apps/cloudflare/playwright-report/

.github/workflows/playwright.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444

4545
- name: Get Playwright version
4646
id: playwright-version
47-
working-directory: apps/site
47+
working-directory: apps/vercel
4848
run: echo "version=$(node_modules/.bin/playwright --version | awk '{print $2}')" >> $GITHUB_OUTPUT
4949

5050
- name: Cache Playwright browsers
@@ -55,11 +55,11 @@ jobs:
5555
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
5656

5757
- name: Install Playwright Browsers
58-
working-directory: apps/site
58+
working-directory: apps/vercel
5959
run: node_modules/.bin/playwright install --with-deps
6060

6161
- name: Run Playwright tests
62-
working-directory: apps/site
62+
working-directory: apps/vercel
6363
run: node --run playwright
6464
env:
6565
PLAYWRIGHT_BASE_URL: ${{ steps.deployment.outputs.url }}
@@ -69,4 +69,4 @@ jobs:
6969
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
7070
with:
7171
name: playwright-report
72-
path: apps/site/playwright-report/
72+
path: apps/vercel/playwright-report/

.github/workflows/tmp-cloudflare-open-next-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ jobs:
5757
run: node --run build:blog-data
5858

5959
- name: Build open-next site
60-
working-directory: apps/site
60+
working-directory: apps/cloudflare
6161
run: node --run cloudflare:build:worker
6262

6363
- name: Deploy open-next site
64-
working-directory: apps/site
64+
working-directory: apps/cloudflare
6565
run: node --run cloudflare:deploy
6666
env:
6767
CF_WORKERS_SCRIPTS_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ npm-debug.log
99
package-lock.json
1010

1111
# Next.js Build Output
12-
apps/site/.next
13-
apps/site/build
1412
apps/site/public/blog-data.json
15-
apps/site/next-env.d.ts
13+
apps/*/build
14+
apps/*/.next
15+
apps/*/next-env.d.ts
1616

1717
# Test Runner
1818
junit.xml
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { FC } from 'react';
2+
3+
const CloudflareAnalytics: FC = () => null;
4+
5+
export default CloudflareAnalytics;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../site/app/[locale]/[...path]

apps/cloudflare/app/[locale]/blog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../site/app/[locale]/blog
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../site/app/[locale]/download

0 commit comments

Comments
 (0)