File tree Expand file tree Collapse file tree 13 files changed +42
-27
lines changed
server/route-modules/pages Expand file tree Collapse file tree 13 files changed +42
-27
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import { getProxiedPluginState } from '../../build-context'
1919import { WEBPACK_LAYERS } from '../../../lib/constants'
2020import { normalizePagePath } from '../../../shared/lib/page-path/normalize-page-path'
2121import { CLIENT_STATIC_FILES_RUNTIME_MAIN_APP } from '../../../shared/lib/constants'
22- import { getDeploymentIdQueryOrEmptyString } from '../../deployment-id'
22+ import { getDeploymentIdQueryOrEmptyString } from '../../../shared/lib/ deployment-id'
2323import {
2424 formatBarrelOptimizedResource ,
2525 getModuleReferencesInOrder ,
Original file line number Diff line number Diff line change 11// Override chunk URL mapping in the webpack runtime
22// https://github.com/webpack/webpack/blob/2738eebc7880835d88c727d364ad37f3ec557593/lib/RuntimeGlobals.js#L204
33
4- import { getDeploymentIdQueryOrEmptyString } from '../build /deployment-id'
4+ import { getDeploymentIdQueryOrEmptyString } from '../shared/lib /deployment-id'
55import { encodeURIPath } from '../shared/lib/encode-uri-path'
66
77declare const __webpack_require__ : any
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ import RootErrorBoundary from './errors/root-error-boundary'
4646import DefaultGlobalError from './builtin/global-error'
4747import { RootLayoutBoundary } from '../../lib/framework/boundary-components'
4848import type { StaticIndicatorState } from '../dev/hot-reloader/app/hot-reloader-app'
49+ import { getDeploymentIdQueryOrEmptyString } from '../../shared/lib/deployment-id'
4950
5051const globalMutable : {
5152 pendingMpaPath ?: string
@@ -622,9 +623,7 @@ function RuntimeStyles() {
622623 }
623624 } , [ renderedStylesSize , forceUpdate ] )
624625
625- const dplId = process . env . NEXT_DEPLOYMENT_ID
626- ? `?dpl=${ process . env . NEXT_DEPLOYMENT_ID } `
627- : ''
626+ const dplId = getDeploymentIdQueryOrEmptyString ( )
628627 return [ ...runtimeStyles ] . map ( ( href , i ) => (
629628 < link
630629 key = { i }
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ import {
4141 urlToUrlWithoutFlightMarker ,
4242} from '../../route-params'
4343import type { NormalizedSearch } from '../segment-cache/cache-key'
44+ import { getDeploymentId } from '../../../shared/lib/deployment-id'
4445
4546const createFromReadableStream =
4647 createFromReadableStreamBrowser as ( typeof import ( 'react-server-dom-webpack/client.browser' ) ) [ 'createFromReadableStream' ]
@@ -329,8 +330,9 @@ export async function createFetch<T>(
329330 headers [ 'Next-Test-Fetch-Priority' ] = fetchPriority
330331 }
331332
332- if ( process . env . NEXT_DEPLOYMENT_ID ) {
333- headers [ 'x-deployment-id' ] = process . env . NEXT_DEPLOYMENT_ID
333+ const deploymentId = getDeploymentId ( )
334+ if ( deploymentId ) {
335+ headers [ 'x-deployment-id' ] = deploymentId
334336 }
335337
336338 if ( process . env . NODE_ENV !== 'production' ) {
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ import {
5656 omitUnusedArgs ,
5757} from '../../../../shared/lib/server-reference-info'
5858import { revalidateEntireCache } from '../../segment-cache/cache'
59+ import { getDeploymentId } from '../../../../shared/lib/deployment-id'
5960
6061const createFromFetch =
6162 createFromFetchBrowser as ( typeof import ( 'react-server-dom-webpack/client.browser' ) ) [ 'createFromFetch' ]
@@ -110,8 +111,9 @@ async function fetchServerAction(
110111 ) ,
111112 }
112113
113- if ( process . env . NEXT_DEPLOYMENT_ID ) {
114- headers [ 'x-deployment-id' ] = process . env . NEXT_DEPLOYMENT_ID
114+ const deploymentId = getDeploymentId ( )
115+ if ( deploymentId ) {
116+ headers [ 'x-deployment-id' ] = deploymentId
115117 }
116118
117119 if ( nextUrl ) {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import type { ProxyMatcher } from '../build/analysis/get-page-static-info'
33import getAssetPathFromRoute from '../shared/lib/router/utils/get-asset-path-from-route'
44import { __unsafeCreateTrustedScriptURL } from './trusted-types'
55import { requestIdleCallback } from './request-idle-callback'
6- import { getDeploymentIdQueryOrEmptyString } from '../build /deployment-id'
6+ import { getDeploymentIdQueryOrEmptyString } from '../shared/lib /deployment-id'
77import { encodeURIPath } from '../shared/lib/encode-uri-path'
88
99// 3.8s was arbitrarily chosen as it's what https://web.dev/interactive
Original file line number Diff line number Diff line change 11declare const __webpack_require__ : any
22declare let __webpack_public_path__ : string
33
4- import { getDeploymentIdQueryOrEmptyString } from '../build/deployment-id'
4+ import {
5+ getDeploymentId ,
6+ getDeploymentIdQueryOrEmptyString ,
7+ } from '../shared/lib/deployment-id'
58
69// If we have a deployment ID, we need to append it to the webpack chunk names
710// I am keeping the process check explicit so this can be statically optimized
8- if ( process . env . NEXT_DEPLOYMENT_ID ) {
11+ if ( getDeploymentId ( ) ) {
912 const suffix = getDeploymentIdQueryOrEmptyString ( )
1013 const getChunkScriptFilename = __webpack_require__ . u
1114 __webpack_require__ . u = ( ...args : any [ ] ) =>
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ import type {
4242 GetStaticPaths ,
4343 GetStaticProps ,
4444} from '../../../types'
45+ import { getDeploymentId } from '../../../shared/lib/deployment-id'
4546
4647export const getHandler = ( {
4748 srcPage : originalSrcPage ,
@@ -257,7 +258,7 @@ export const getHandler = ({
257258 buildId,
258259 customServer :
259260 Boolean ( routerServerContext ?. isCustomServer ) || undefined ,
260- deploymentId : process . env . NEXT_DEPLOYMENT_ID ,
261+ deploymentId : getDeploymentId ( ) ,
261262 } ,
262263 renderOpts : {
263264 params,
Original file line number Diff line number Diff line change 1+ // This could also be a variable instead of a function, but some unit tests want to change the ID at
2+ // runtime. Even though that would never happen in a real deployment.
3+ export function getDeploymentId ( ) : string | undefined {
4+ return process . env . NEXT_DEPLOYMENT_ID
5+ }
6+
7+ export function getDeploymentIdQueryOrEmptyString ( ) : string {
8+ let deploymentId = getDeploymentId ( )
9+ if ( deploymentId ) {
10+ return `?dpl=${ deploymentId } `
11+ }
12+ return ''
13+ }
You can’t perform that action at this time.
0 commit comments