mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
- Adds a `process.env.NEXT_DEPLOYMENT_ID` -> `globalThis.NEXT_DEPLOYMENT_ID` replacement - On startup, `globalThis.NEXT_DEPLOYMENT_ID` is initialized to `process.env.NEXT_DEPLOYMENT_ID_COMPILE_TIME` This prepares for https://github.com/vercel/next.js/pull/88761 to replace `process.env.NEXT_DEPLOYMENT_ID_COMPILE_TIME` with reading `<html data-dpl-id>` so that we can remove the env var inlining However, all of this is only done for Turbopack, because we cannot forward `globalThis.NEXT_DEPLOYMENT_ID` to web workers with Webpack easily.
36 lines
894 B
JavaScript
36 lines
894 B
JavaScript
'use client'
|
|
import { useState } from 'react'
|
|
|
|
export default function Home() {
|
|
const [workerDeploymentId, setWorkerDeploymentId] = useState('default')
|
|
const mainDeploymentId = process.env.NEXT_DEPLOYMENT_ID
|
|
|
|
return (
|
|
<div>
|
|
<button
|
|
onClick={() => {
|
|
const worker = new Worker(
|
|
new URL('../deployment-id-worker', import.meta.url),
|
|
{
|
|
type: 'module',
|
|
}
|
|
)
|
|
worker.addEventListener('message', (event) => {
|
|
setWorkerDeploymentId(event.data)
|
|
})
|
|
}}
|
|
>
|
|
Get deployment ID from worker
|
|
</button>
|
|
<p>
|
|
Main deployment ID:{' '}
|
|
<span id="main-deployment-id">{mainDeploymentId}</span>
|
|
</p>
|
|
<p>
|
|
Worker deployment ID:{' '}
|
|
<span id="worker-deployment-id">{workerDeploymentId}</span>
|
|
</p>
|
|
</div>
|
|
)
|
|
}
|