UNPKG

@sentry/nextjs

Version:
18 lines (15 loc) • 768 B
import { getCodeInjectionPosition } from '@sentry/bundler-plugins/loader-utils'; function valueInjectionLoader(userCode) { const { values } = "getOptions" in this ? this.getOptions() : this.query; this.cacheable(false); const injectedCode = ( // eslint-disable-next-line prefer-template ";" + Object.entries(values).map(([key, value]) => `globalThis["${key}"] = ${JSON.stringify(value)};`).join("") ); const injectionIndex = getCodeInjectionPosition(userCode); const codeToInject = injectionIndex === userCode.length ? ` ${injectedCode}` : injectedCode; return `${userCode.slice(0, injectionIndex)}${codeToInject}${userCode.slice(injectionIndex)}`; } export { valueInjectionLoader as default }; //# sourceMappingURL=valueInjectionLoader.js.map