silverwolf-x/project / packages /next /src /server /app-render /get-asset-query-string.ts
silverwolf-x's picture
download
raw
795 Bytes
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.sharedContext.clientAssetToken) {
qs += `${shouldAddVersion ? '&' : '?'}dpl=${ctx.sharedContext.clientAssetToken}`
}
return qs
}

Xet Storage Details

Size:
795 Bytes
·
Xet hash:
2d1258d657ee11260ba54474a9ddd2a9ea2ee93287623281621704c5fdd9eec6

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.