silverwolf-x/project / packages /next /src /build /webpack /plugins /telemetry-plugin /update-telemetry-loader-context-from-swc.ts
silverwolf-x's picture
download
raw
910 Bytes
import type { TelemetryLoaderContext } from './telemetry-plugin'
export type SwcTransformTelemetryOutput = {
eliminatedPackages?: string
useCacheTelemetryTracker?: string
}
export function updateTelemetryLoaderCtxFromTransformOutput(
ctx: TelemetryLoaderContext,
output: SwcTransformTelemetryOutput
) {
if (output.eliminatedPackages && ctx.eliminatedPackages) {
for (const pkg of JSON.parse(output.eliminatedPackages)) {
ctx.eliminatedPackages.add(pkg)
}
}
if (output.useCacheTelemetryTracker && ctx.useCacheTracker) {
for (const [key, value] of JSON.parse(output.useCacheTelemetryTracker)) {
const prefixedKey = `useCache/${key}` as const
const numericValue = Number(value)
if (!isNaN(numericValue)) {
ctx.useCacheTracker.set(
prefixedKey,
(ctx.useCacheTracker.get(prefixedKey) || 0) + numericValue
)
}
}
}
}

Xet Storage Details

Size:
910 Bytes
·
Xet hash:
bbd3296e11d0cbcab34c11b84188195e239f4453058431ee3940d24326fbb5b7

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