File size: 781 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import type { AppRenderContext } from './app-render'

const isDev = process.env.NODE_ENV === 'development'
const isTurbopack = !!process.env.TURBOPACK

export function getAssetQueryString(
  ctx: AppRenderContext,
  addTimestamp: boolean
) {
  let qs = ''

  // In development we add the request timestamp to allow react to
  // reload assets when a new RSC response is received.
  // Turbopack handles HMR of assets itself and react doesn't need to reload them
  // so this approach is not needed for Turbopack.
  const shouldAddVersion = isDev && !isTurbopack && addTimestamp
  if (shouldAddVersion) {
    qs += `?v=${ctx.requestTimestamp}`
  }

  if (ctx.renderOpts.deploymentId) {
    qs += `${shouldAddVersion ? '&' : '?'}dpl=${ctx.renderOpts.deploymentId}`
  }
  return qs
}