Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d7b6e7e
refactor: consolidate platform detection into NEXT_PUBLIC_DEPLOY_TARGET
ovflowd Apr 23, 2026
641d0b9
refactor: split platform-specific code into platform-vercel and platf…
ovflowd Apr 23, 2026
c88bfc5
Merge branch 'main' into refactor/split-apps-by-deployment-target
ovflowd Apr 23, 2026
1a61747
fix: use project-relative alias strings in default platform config
ovflowd Apr 23, 2026
78a6852
fix(vercel): restore mdx defaults for shiki
cursoragent Apr 23, 2026
517dfcb
chore(deps): catalog next versions across workspace
cursoragent Apr 23, 2026
6664f19
refactor(config): restrict platform nextConfig overrides
cursoragent Apr 23, 2026
0ac46dc
refactor(types): enforce platform nextConfig via type-only constraints
cursoragent Apr 23, 2026
4641a0c
refactor: move platform workspaces from packages/ to apps/ and decoup…
ovflowd Apr 23, 2026
23bfde7
docs: update Repository Structure to list apps/vercel and apps/cloudf…
ovflowd Apr 23, 2026
87f739f
refactor(platform): resolve via #platform import map and unify type c…
ovflowd Apr 23, 2026
35a58e3
fix(ci): build open-next in a dedicated step and skip turbo for wrangler
ovflowd Apr 23, 2026
ed3b670
fix(ci): invoke cloudflare:preview via pnpm filter so wrangler resolves
ovflowd Apr 23, 2026
93751a4
fix(platform): defer Node-only config behind async thunks
ovflowd Apr 23, 2026
ecf659d
chore(cloudflare): drop cd-prefixed scripts and ignore wrangler state…
ovflowd Apr 23, 2026
62528e8
refactor(platform): relocate deploy-target apps under platforms/
ovflowd Apr 24, 2026
68b5524
fix(platform): restore platform-vercel next config test under platforms/
ovflowd Apr 24, 2026
53b1ce5
Merge branch 'main' into refactor/split-apps-by-deployment-target
ovflowd Apr 25, 2026
1c47205
refactor(platform): flatten platform packages and route via #platform
ovflowd Apr 26, 2026
df43651
fix(cloudflare): repair paths after platforms/cloudflare flatten
ovflowd Apr 26, 2026
c6e6ed4
refactor(platform): rename platform scripts and add default platform …
ovflowd Apr 26, 2026
8318b5f
refactor(platform): collapse @platform aliases into a single wildcard
ovflowd Apr 26, 2026
b6fb2df
chore: tiny next.config.mjs simplification
ovflowd Apr 26, 2026
4be6e5e
fix(platform): stop tsconfig paths from shadowing the @platform alias
ovflowd Apr 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/CODEOWNERS
Comment thread
ovflowd marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ turbo.json @nodejs/nodejs-website @nodejs/web-infra
crowdin.yml @nodejs/web-infra
apps/site/redirects.json @nodejs/web-infra
apps/site/site.json @nodejs/web-infra
apps/site/wrangler.jsonc @nodejs/web-infra
apps/site/open-next.config.ts @nodejs/web-infra
apps/cloudflare/wrangler.jsonc @nodejs/web-infra
apps/cloudflare/open-next.config.ts @nodejs/web-infra
apps/cloudflare/next.platform.config.mjs @nodejs/web-infra
apps/vercel/next.platform.config.mjs @nodejs/web-infra
apps/site/redirects.json @nodejs/web-infra

# Critical Documents
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/playwright-cloudflare-open-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,19 @@ jobs:
working-directory: apps/site
run: node_modules/.bin/playwright install --with-deps

- name: Build open-next site
working-directory: apps/cloudflare
run: node --run cloudflare:build:worker
env:
NEXT_PUBLIC_DEPLOY_TARGET: cloudflare
NODE_OPTIONS: --conditions=cloudflare

- name: Run Playwright tests
working-directory: apps/site
run: node --run playwright
env:
PLAYWRIGHT_RUN_CLOUDFLARE_PREVIEW: true
PLAYWRIGHT_BASE_URL: http://127.0.0.1:8787
NEXT_PUBLIC_DEPLOY_TARGET: cloudflare
NODE_OPTIONS: --conditions=cloudflare

- name: Upload Playwright test results
if: always()
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tmp-cloudflare-open-next-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ jobs:
cache: 'pnpm'

- name: Install packages
run: pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile --filter=@node-core/website... --filter=@node-core/platform-cloudflare...

- name: Build blog data
working-directory: apps/site
run: node --run build:blog-data

- name: Build open-next site
working-directory: apps/site
working-directory: apps/cloudflare
Comment thread
ovflowd marked this conversation as resolved.
Outdated
run: node --run cloudflare:build:worker

- name: Deploy open-next site
working-directory: apps/site
working-directory: apps/cloudflare
run: node --run cloudflare:deploy
env:
CF_WORKERS_SCRIPTS_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Expand Down
49 changes: 49 additions & 0 deletions apps/cloudflare/next.platform.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { createRequire } from 'node:module';
import { relative } from 'node:path';

import { getDeploymentId } from '@opennextjs/cloudflare';

const require = createRequire(import.meta.url);

/**
* Platform config contributed by the Cloudflare deployment target.
*
* Consumed by `apps/site/next.config.mjs` via the platform-config loader.
* Must export a default `{ nextConfig, aliases, images }` shape — any of
* which may be omitted when the platform has nothing to contribute.
*
* @type {import('../site/next.platform.config').PlatformConfig}
*/
export default {
nextConfig: {
// Skew protection: Cloudflare routes requests by deploymentId so that
// a client and the worker stay in sync across rolling deploys.
deploymentId: await getDeploymentId(),
},
aliases: {
'@platform/analytics': '@node-core/platform-cloudflare/analytics',
'@platform/instrumentation':
'@node-core/platform-cloudflare/instrumentation',
},
images: {
// Route optimized images through Cloudflare's Images service via the
// custom loader. `remotePatterns` do NOT apply here — Cloudflare
// enforces allowed origins at the edge instead.
loader: 'custom',
// Next.js joins `loaderFile` onto its own cwd (apps/site), so pass a
// path relative to that cwd rather than an absolute one. Resolving via
// `require.resolve` avoids the `new URL(..., import.meta.url)` pattern,
// which webpack rewrites as an asset reference and mangles at runtime.
loaderFile: relative(
process.cwd(),
require.resolve('@node-core/platform-cloudflare/image-loader')
),
},
mdx: {
// Cloudflare workers can't load `shiki/wasm` via `WebAssembly.instantiate`
// with custom imports (blocked for security), so fall back to the
// JavaScript RegEx engine. Twoslash also needs a VFS we don't have here.
wasm: false,
twoslash: false,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const cloudflareConfig = defineCloudflareConfig({

const openNextConfig: OpenNextConfig = {
...cloudflareConfig,
buildCommand: 'pnpm build --webpack',
buildCommand:
'cross-env NEXT_PUBLIC_DEPLOY_TARGET=cloudflare NODE_OPTIONS=--conditions=cloudflare pnpm build --webpack',
cloudflare: {
skewProtection: { enabled: true },
},
Expand Down
45 changes: 45 additions & 0 deletions apps/cloudflare/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@node-core/platform-cloudflare",
"version": "1.0.0",
"private": true,
"type": "module",
"exports": {
"./analytics": "./src/analytics.tsx",
"./image-loader": "./src/image-loader.ts",
"./instrumentation": "./src/instrumentation.ts",
"./next.platform.config": "./next.platform.config.mjs",
"./playwright.platform.config": "./playwright.platform.config.mjs",
"./worker-entrypoint": "./src/worker-entrypoint.ts"
},
"repository": {
"type": "git",
"url": "https://github.com/nodejs/nodejs.org",
"directory": "apps/cloudflare"
},
"scripts": {
"cloudflare:build:worker": "cd ../site && opennextjs-cloudflare build --openNextConfigPath ../cloudflare/open-next.config.ts --config ../cloudflare/wrangler.jsonc",
"cloudflare:deploy": "cd ../site && opennextjs-cloudflare deploy --openNextConfigPath ../cloudflare/open-next.config.ts --config ../cloudflare/wrangler.jsonc",
"cloudflare:preview": "cd ../site && wrangler dev --config ../cloudflare/wrangler.jsonc",
Comment thread
ovflowd marked this conversation as resolved.
Outdated
"lint:types": "tsc --noEmit"
},
"dependencies": {
"@flarelabs-net/wrangler-build-time-fs-assets-polyfilling": "^0.0.1",
"@opennextjs/cloudflare": "^1.19.3",
"@sentry/cloudflare": "^10.49.0",
"wrangler": "^4.77.0"
},
"peerDependencies": {
"next": "catalog:",
"react": "catalog:"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20260418.1",
"@playwright/test": "^1.58.2",
"@types/node": "catalog:",
"@types/react": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
18 changes: 18 additions & 0 deletions apps/cloudflare/playwright.platform.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Playwright overrides contributed by the Cloudflare deployment target.
*
* Consumed by `apps/site/playwright.config.ts` via the platform-config
* loader. Spins up the wrangler preview so E2E runs against the
* OpenNext worker artifact rather than `next dev`.
*
* @type {import('../site/playwright.platform.config').PlatformPlaywrightConfig}
*/
export default {
baseURL: 'http://127.0.0.1:8787',
webServer: {
stdout: 'pipe',
command: 'pnpm --filter=@node-core/platform-cloudflare cloudflare:preview',
url: 'http://127.0.0.1:8787',
timeout: 60_000 * 3,
},
};
1 change: 1 addition & 0 deletions apps/cloudflare/src/analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => null;
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { ImageLoaderProps } from 'next/image';

const normalizeSrc = (src: string) => {
return src.startsWith('/') ? src.slice(1) : src;
};
const normalizeSrc = (src: string) =>
src.startsWith('/') ? src.slice(1) : src;

export default function cloudflareLoader({
src,
Expand Down
1 change: 1 addition & 0 deletions apps/cloudflare/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const register = () => {};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
Request,
} from '@cloudflare/workers-types';

import { default as handler } from '../.open-next/worker.js';
import { default as handler } from '../../site/.open-next/worker.js';

export default withSentry(
(env: {
Expand Down Expand Up @@ -50,4 +50,4 @@ export default withSentry(
}
);

export { DOQueueHandler } from '../.open-next/worker.js';
export { DOQueueHandler } from '../../site/.open-next/worker.js';
22 changes: 22 additions & 0 deletions apps/cloudflare/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "esnext",
"lib": ["dom", "dom.iterable", "esnext"],
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "Bundler",
"customConditions": ["default"],
"isolatedModules": true,
"jsx": "react-jsx"
},
"include": [
"src",
"next.platform.config.mjs",
"playwright.platform.config.mjs"
],
"exclude": ["src/worker-entrypoint.ts"]
}
43 changes: 43 additions & 0 deletions apps/cloudflare/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"tasks": {
"cloudflare:build:worker": {
"dependsOn": ["@node-core/website#build:blog-data"],
"inputs": [
"open-next.config.ts",
"wrangler.jsonc",
"src/**/*.ts",
"../site/{app,components,hooks,i18n,layouts,middlewares,pages,providers,types,util}/**/*.{ts,tsx}",
"../site/{app,components,layouts,pages,styles}/**/*.css",
"../site/{next-data,scripts,i18n}/**/*.{mjs,json}",
"../site/{app,pages}/**/*.{mdx,md}",
"../site/*.{md,mdx,json,ts,tsx,mjs,yml}"
],
"outputs": ["../site/.open-next/**"],
"env": [
"NEXT_PUBLIC_DEPLOY_TARGET",
"NEXT_PUBLIC_BASE_URL",
"NEXT_PUBLIC_DIST_URL",
"NEXT_PUBLIC_DOCS_URL",
"NEXT_PUBLIC_BASE_PATH",
"NEXT_PUBLIC_ORAMA_API_KEY",
"NEXT_PUBLIC_ORAMA_ENDPOINT",
"NEXT_PUBLIC_DATA_URL",
"NEXT_GITHUB_API_KEY"
]
},
"cloudflare:preview": {
"dependsOn": ["cloudflare:build:worker"],
"cache": false,
"persistent": true
},
"cloudflare:deploy": {
"dependsOn": ["cloudflare:build:worker"],
"cache": false
},
"lint:types": {
"cache": false
}
}
}
15 changes: 9 additions & 6 deletions apps/site/wrangler.jsonc → apps/cloudflare/wrangler.jsonc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"$schema": "./node_modules/wrangler/config-schema.json",
"main": "./cloudflare/worker-entrypoint.ts",
"main": "./src/worker-entrypoint.ts",
"name": "nodejs-website",
"compatibility_date": "2024-11-07",
"compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],
"account_id": "fb4a2d0f103c6ff38854ac69eb709272",
"minify": true,
"keep_names": false,
"assets": {
"directory": ".open-next/assets",
"directory": "../site/.open-next/assets",
"binding": "ASSETS",
"run_worker_first": true,
},
Expand All @@ -31,13 +31,16 @@
"head_sampling_rate": 1,
},
"build": {
// Run the asset polyfiller from apps/site so that `pages`, `snippets`, and
// the `.open-next` output directory resolve against the Next.js app.
"cwd": "../site",
"command": "wrangler-build-time-fs-assets-polyfilling --assets pages --assets snippets --assets-output-dir .open-next/assets",
},
"alias": {
"node:fs": "./.wrangler/fs-assets-polyfilling/polyfills/node/fs.ts",
"node:fs/promises": "./.wrangler/fs-assets-polyfilling/polyfills/node/fs/promises.ts",
"fs": "./.wrangler/fs-assets-polyfilling/polyfills/node/fs.ts",
"fs/promises": "./.wrangler/fs-assets-polyfilling/polyfills/node/fs/promises.ts",
"node:fs": "../site/.wrangler/fs-assets-polyfilling/polyfills/node/fs.ts",
"node:fs/promises": "../site/.wrangler/fs-assets-polyfilling/polyfills/node/fs/promises.ts",
"fs": "../site/.wrangler/fs-assets-polyfilling/polyfills/node/fs.ts",
"fs/promises": "../site/.wrangler/fs-assets-polyfilling/polyfills/node/fs/promises.ts",
},
"r2_buckets": [
{
Expand Down
1 change: 1 addition & 0 deletions apps/site/app/[locale]/@analytics/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@platform/analytics';
19 changes: 8 additions & 11 deletions apps/site/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import { availableLocales, defaultLocale } from '@node-core/website-i18n';
import { Analytics } from '@vercel/analytics/react';
import { SpeedInsights } from '@vercel/speed-insights/next';
import classNames from 'classnames';
import { NextIntlClientProvider } from 'next-intl';

import BaseLayout from '#site/layouts/Base';
import { VERCEL_ENV } from '#site/next.constants.mjs';
import { IBM_PLEX_MONO, OPEN_SANS } from '#site/next.fonts';
import { ThemeProvider } from '#site/providers/themeProvider';

import type { FC, PropsWithChildren } from 'react';
import type { FC, PropsWithChildren, ReactNode } from 'react';

import '#site/styles/index.css';

const fontClasses = classNames(IBM_PLEX_MONO.variable, OPEN_SANS.variable);

type RootLayoutProps = PropsWithChildren<{
params: Promise<{ locale: string }>;
analytics: ReactNode;
}>;

const RootLayout: FC<RootLayoutProps> = async ({ children, params }) => {
const RootLayout: FC<RootLayoutProps> = async ({
children,
analytics,
params,
}) => {
const { locale } = await params;

const { langDir, hrefLang } =
Expand All @@ -46,12 +48,7 @@ const RootLayout: FC<RootLayoutProps> = async ({ children, params }) => {
href="https://social.lfx.dev/@nodejs"
/>

{VERCEL_ENV && (
<>
<Analytics />
<SpeedInsights />
</>
)}
{analytics}
</body>
</html>
);
Expand Down
10 changes: 1 addition & 9 deletions apps/site/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ import baseConfig from '../../eslint.config.js';

export default baseConfig.concat([
{
ignores: [
'pages/en/blog/**/*.{md,mdx}/**',
'public',
'next-env.d.ts',
// The worker entrypoint is bundled by wrangler, not tsc. Its imports
// trigger a tsc crash (see tsconfig.json), so it is excluded from both
// type checking and ESLint's type-aware linting.
'cloudflare/worker-entrypoint.ts',
],
ignores: ['pages/en/blog/**/*.{md,mdx}/**', 'public', 'next-env.d.ts'],
},

eslintReact.configs['recommended-typescript'],
Expand Down
8 changes: 1 addition & 7 deletions apps/site/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
export async function register() {
if (!('Cloudflare' in globalThis)) {
// Note: we don't need to set up the Vercel OTEL if the application is running on Cloudflare
const { registerOTel } = await import('@vercel/otel');
registerOTel({ serviceName: 'nodejs-org' });
}
}
export { register } from '@platform/instrumentation';
Comment thread
ovflowd marked this conversation as resolved.
Loading
Loading