UNPKG

@sentry/nextjs

Version:
14 lines (11 loc) 996 B
import { findInjectionIndexAfterDirectives } from './valueInjectionLoader.js'; function moduleMetadataInjectionLoader(userCode) { const { applicationKey } = "getOptions" in this ? this.getOptions() : this.query; this.cacheable(false); const metadata = JSON.stringify({ [`_sentryBundlerPluginAppKey:${applicationKey}`]: true }); const injectedCode = `;!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=Object.assign({},e._sentryModuleMetadata[(new e.Error).stack],${metadata});}catch(e){}}();`; const injectionIndex = findInjectionIndexAfterDirectives(userCode); return `${userCode.slice(0, injectionIndex)}${injectedCode}${userCode.slice(injectionIndex)}`; } export { moduleMetadataInjectionLoader as default }; //# sourceMappingURL=moduleMetadataInjectionLoader.js.map