mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
efc0905db3
Expand `config.compiler.define` to support number and boolean primitives as well. The support is already in Turbopack's rewrite engine, as well as Webpack's DefinePlugin. We just need to modify the zod schema to actually support passing numbers and bools. Added an E2E test that should check all supported types.
49 lines
1.0 KiB
JavaScript
49 lines
1.0 KiB
JavaScript
/* eslint-disable no-undef */
|
|
import {
|
|
ClientValue,
|
|
ClientExpr,
|
|
ClientNumber,
|
|
ClientBoolean,
|
|
} from './client-component'
|
|
|
|
export default function Page() {
|
|
return (
|
|
<ul>
|
|
<li>
|
|
Server value:{' '}
|
|
{typeof MY_MAGIC_VARIABLE === 'string' ? MY_MAGIC_VARIABLE : 'not set'}
|
|
</li>
|
|
<li>
|
|
Client value: <ClientValue />
|
|
</li>
|
|
<li>
|
|
Server expr:{' '}
|
|
{typeof process.env.MY_MAGIC_EXPR === 'string'
|
|
? process.env.MY_MAGIC_EXPR
|
|
: 'not set'}
|
|
</li>
|
|
<li>
|
|
Client expr: <ClientExpr />
|
|
</li>
|
|
<li>
|
|
Server number:{' '}
|
|
{typeof MY_NUMBER_VARIABLE === 'number'
|
|
? String(MY_NUMBER_VARIABLE)
|
|
: 'not set'}
|
|
</li>
|
|
<li>
|
|
Client number: <ClientNumber />
|
|
</li>
|
|
<li>
|
|
Server boolean:{' '}
|
|
{typeof MY_BOOLEAN_VARIABLE === 'boolean'
|
|
? String(MY_BOOLEAN_VARIABLE)
|
|
: 'not set'}
|
|
</li>
|
|
<li>
|
|
Client boolean: <ClientBoolean />
|
|
</li>
|
|
</ul>
|
|
)
|
|
}
|