Skip to content

Commit 0ac46dc

Browse files
committed
refactor(types): enforce platform nextConfig via type-only constraints
Assisted-by: Codex 5.3
1 parent 6664f19 commit 0ac46dc

3 files changed

Lines changed: 11 additions & 28 deletions

File tree

apps/site/next.config.mjs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ const { default: platform } = DEPLOY_TARGET
2121
? await import(`@node-core/platform-${DEPLOY_TARGET}/next.platform.config`)
2222
: await import('./next.platform.config.mjs');
2323

24-
/**
25-
* Apply only an explicit allowlist of Next.js config keys from platform
26-
* packages so critical core config (e.g. `webpack`, `turbopack`) cannot be
27-
* overridden accidentally.
28-
*/
29-
const platformNextConfigOverrides = {
30-
env: platform.nextConfig?.env,
31-
deploymentId: platform.nextConfig?.deploymentId,
32-
};
33-
3424
/** @type {import('next').NextConfig} */
3525
const nextConfig = {
3626
// Full Support of React 18 SSR and Streaming
@@ -106,7 +96,7 @@ const nextConfig = {
10696
...config,
10797
resolve: { ...resolve, alias: { ...resolve.alias, ...platform.aliases } },
10898
}),
109-
...platformNextConfigOverrides,
99+
...platform.nextConfig,
110100
};
111101

112102
const withNextIntl = createNextIntlPlugin('./i18n.tsx');

packages/platform-cloudflare/next.platform.config.d.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import type { NextConfig } from 'next';
22

3-
type PlatformMdxConfig = {
4-
wasm?: boolean;
5-
twoslash?: boolean;
6-
};
7-
8-
type PlatformNextConfig = {
9-
deploymentId?: string;
10-
env?: NextConfig['env'];
11-
};
3+
type PlatformMdxConfig = Pick<
4+
import('@node-core/rehype-shiki').HighlighterOptions,
5+
'wasm' | 'twoslash'
6+
>;
7+
type PlatformNextConfig = Pick<NextConfig, 'deploymentId' | 'env'>;
128

139
export type PlatformConfig = {
1410
aliases?: Record<string, string>;

packages/platform-vercel/next.platform.config.d.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import type { NextConfig } from 'next';
22

3-
type PlatformMdxConfig = {
4-
wasm?: boolean;
5-
twoslash?: boolean;
6-
};
3+
type PlatformMdxConfig = Pick<
4+
import('@node-core/rehype-shiki').HighlighterOptions,
5+
'wasm' | 'twoslash'
6+
>;
77

8-
type PlatformNextConfig = {
9-
deploymentId?: string;
10-
env?: NextConfig['env'];
11-
};
8+
type PlatformNextConfig = Pick<NextConfig, 'deploymentId' | 'env'>;
129

1310
export type PlatformConfig = {
1411
aliases?: Record<string, string>;

0 commit comments

Comments
 (0)