Skip to content

Commit c6e6ed4

Browse files
ovflowdclaude
andcommitted
refactor(platform): rename platform scripts and add default platform package
Rename platform build/dev/deploy scripts to suffixed names (build:cloudflare, build:vercel, dev:cloudflare, dev:vercel, deploy:cloudflare) so they no longer collide with Turbo's ^build cascade. Add a platforms/default package as the standalone baseline (analytics noop, instrumentation, playwright, next config), matching the same shape as the cloudflare and vercel packages. Drop the per- platform turbo.json files in favor of a root lint:types task. Co-Authored-By: Claude Opus 4.7 <[email protected]>
1 parent df43651 commit c6e6ed4

32 files changed

Lines changed: 182 additions & 165 deletions

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ apps/site/redirects.json @nodejs/web-infra
2929
apps/site/site.json @nodejs/web-infra
3030
platforms/cloudflare/wrangler.jsonc @nodejs/web-infra
3131
platforms/cloudflare/open-next.config.ts @nodejs/web-infra
32-
platforms/cloudflare/next.platform.config.mjs @nodejs/web-infra
32+
platforms/cloudflare/next.config.mjs @nodejs/web-infra
3333
platforms/vercel/vercel.json @nodejs/web-infra
34-
platforms/vercel/next.platform.config.mjs @nodejs/web-infra
34+
platforms/vercel/next.config.mjs @nodejs/web-infra
3535

3636
# Critical Documents
3737
LICENSE @nodejs/tsc

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,13 @@ jobs:
5252

5353
- name: Build open-next site
5454
working-directory: platforms/cloudflare
55-
run: node --run cloudflare:build:worker
56-
env:
57-
NEXT_PUBLIC_DEPLOY_TARGET: cloudflare
58-
NODE_OPTIONS: --conditions=cloudflare
55+
run: node --run build:cloudflare
5956

6057
- name: Run Playwright tests
6158
working-directory: apps/site
6259
run: node --run playwright
6360
env:
6461
NEXT_PUBLIC_DEPLOY_TARGET: cloudflare
65-
NODE_OPTIONS: --conditions=cloudflare
6662

6763
- name: Upload Playwright test results
6864
if: always()

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,12 @@ jobs:
5858

5959
- name: Build open-next site
6060
working-directory: platforms/cloudflare
61-
run: node --run cloudflare:build:worker
62-
env:
63-
NEXT_PUBLIC_DEPLOY_TARGET: cloudflare
64-
NODE_OPTIONS: --conditions=cloudflare
61+
run: node --run build:cloudflare
6562

6663
- name: Deploy open-next site
6764
working-directory: platforms/cloudflare
68-
run: node --run cloudflare:deploy
65+
run: node --run deploy:cloudflare
6966
env:
70-
NEXT_PUBLIC_DEPLOY_TARGET: cloudflare
71-
NODE_OPTIONS: --conditions=cloudflare
7267
CF_WORKERS_SCRIPTS_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
7368
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
7469
CLOUDFLARE_ACCOUNT_ID: fb4a2d0f103c6ff38854ac69eb709272

apps/site/mdx/plugins.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
'use strict';
22

33
import rehypeShikiji from '@node-core/rehype-shiki/plugin';
4+
import platform from '@platform/next.config.mjs';
45
import remarkHeadings from '@vcarl/remark-headings';
56
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
67
import rehypeSlug from 'rehype-slug';
78
import remarkGfm from 'remark-gfm';
89
import readingTime from 'remark-reading-time';
910

10-
import platform from '#platform/next.platform.config.mjs';
11-
1211
import remarkTableTitles from '../util/table';
1312

1413
// Shiki is created out here to avoid an async rehype plugin

apps/site/next.config.mjs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22

33
import createNextIntlPlugin from 'next-intl/plugin';
44

5-
import platform from '#platform/next.platform.config.mjs';
6-
75
import { BASE_PATH, ENABLE_STATIC_EXPORT } from './next.constants.mjs';
86
import { getImagesConfig } from './next.image.config.mjs';
97
import { DEPLOY_TARGET } from './next.platform.constants.mjs';
108
import { redirects, rewrites } from './next.rewrites.mjs';
119

10+
// Loaded by Node directly (Next.js doesn't bundle `next.config.mjs`), so
11+
// we resolve the active platform via a dynamic import keyed on
12+
// `DEPLOY_TARGET` rather than a `@platform/*` alias (those only resolve
13+
// inside Turbopack/webpack).
14+
const { default: platform } = await import(
15+
`@node-core/platform-${DEPLOY_TARGET}/next.config.mjs`
16+
);
17+
1218
const platformImages = await platform.images?.();
1319
const platformNextConfig = await platform.nextConfig?.();
1420

15-
const transpilePackages = DEPLOY_TARGET
16-
? [`@node-core/platform-${DEPLOY_TARGET}`]
17-
: [];
18-
1921
/** @type {import('next').NextConfig} */
2022
const nextConfig = {
2123
// Full Support of React 18 SSR and Streaming
@@ -27,7 +29,7 @@ const nextConfig = {
2729
basePath: BASE_PATH,
2830
images: getImagesConfig(platformImages),
2931
serverExternalPackages: ['twoslash'],
30-
transpilePackages,
32+
transpilePackages: [`@node-core/platform-${DEPLOY_TARGET}`],
3133
outputFileTracingIncludes: {
3234
// Twoslash needs TypeScript declarations to function, and, by default, Next.js
3335
// strips them for brevity. Therefore, they must be explicitly included.
@@ -81,10 +83,7 @@ const nextConfig = {
8183
},
8284
// Provide Turbopack Aliases for Platform Resolution
8385
turbopack: { resolveAlias: platform.aliases },
84-
// Provide Webpack Aliases for Platform Resolution. The active deployment
85-
// target is also surfaced to the resolver via `conditionNames` so that
86-
// `#platform/*` subpath imports in `package.json` pick the matching
87-
// branch when webpack bundles server code.
86+
// Provide Webpack Aliases for Platform Resolution.
8887
webpack: ({ resolve, ...config }) => ({
8988
...config,
9089
resolve: {

apps/site/next.constants.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const ENABLE_STATIC_EXPORT_LOCALE =
3232
* The full canonical URL of the deployed Website (used e.g. for the RSS feed).
3333
*
3434
* Platform-specific base URLs (such as Vercel's `VERCEL_URL`) are inlined into
35-
* `NEXT_PUBLIC_BASE_URL` at build time by each platform's `next.platform.config.mjs`,
35+
* `NEXT_PUBLIC_BASE_URL` at build time by each platform's `next.config.mjs`,
3636
* keeping this module free of platform-specific branches.
3737
*/
3838
export const BASE_URL =

apps/site/next.platform.config.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ type PlatformNextConfig = Pick<NextConfig, 'deploymentId' | 'env'>;
88
* Shared platform-config contract consumed by `apps/site/next.config.mjs`
99
* and implemented by each `@node-core/platform-<target>` package.
1010
*
11+
* `aliases` are surfaced as Turbopack/webpack aliases so that
12+
* `@platform/*` imports in bundled code (e.g. the `@analytics/`
13+
* parallel-route slot, `instrumentation.ts`, `mdx/plugins.mjs`) resolve
14+
* to the active platform's files.
15+
*
1116
* `nextConfig` and `images` are async thunks so that platform modules
1217
* that depend on Node-only tooling (e.g. `@opennextjs/cloudflare`,
1318
* `require.resolve`) can keep those imports out of the module's

apps/site/next.platform.constants.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
* The `NEXT_PUBLIC_` prefix makes Next.js inline the value at build time,
1111
* enabling dead-code elimination of platform-specific branches.
1212
*
13-
* @type {'vercel' | 'cloudflare' | undefined}
13+
* @type {'vercel' | 'cloudflare' | 'default'}
1414
*/
15-
export const DEPLOY_TARGET = process.env.NEXT_PUBLIC_DEPLOY_TARGET;
15+
export const DEPLOY_TARGET = process.env.NEXT_PUBLIC_DEPLOY_TARGET ?? 'default';

apps/site/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
},
9999
"peerDependencies": {
100100
"@node-core/platform-cloudflare": "workspace:*",
101+
"@node-core/platform-default": "workspace:*",
101102
"@node-core/platform-vercel": "workspace:*"
102103
},
103104
"peerDependenciesMeta": {
@@ -106,6 +107,9 @@
106107
},
107108
"@node-core/platform-vercel": {
108109
"optional": true
110+
},
111+
"@node-core/platform-default": {
112+
"optional": true
109113
}
110114
},
111115
"imports": {
@@ -117,12 +121,7 @@
117121
"./*/index.ts",
118122
"./*.mjs",
119123
"./*/index.mjs"
120-
],
121-
"#platform/*": {
122-
"cloudflare": "@node-core/platform-cloudflare/*",
123-
"vercel": "@node-core/platform-vercel/*",
124-
"default": "./platform/*"
125-
}
124+
]
126125
},
127126
"engines": {
128127
"node": "24.x"

apps/site/platform/next.platform.config.mjs

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)