Skip to content

Commit 1e3e973

Browse files
committed
fix: Wrap injected code in self-invoking function to contain scope
1 parent b2a0529 commit 1e3e973

File tree

1 file changed

+3
-1
lines changed
  • packages/bundler-plugin-core/src

1 file changed

+3
-1
lines changed

packages/bundler-plugin-core/src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ export function generateGlobalInjectorCode({
314314
}) {
315315
// The code below is mostly ternary operators because it saves bundle size.
316316
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
317-
let code = `
317+
let code = `(function () {
318318
var _global =
319319
typeof window !== 'undefined' ?
320320
window :
@@ -335,6 +335,8 @@ export function generateGlobalInjectorCode({
335335
_global.SENTRY_BUILD_INFO=${JSON.stringify(buildInfo)};`;
336336
}
337337

338+
code += '})();';
339+
338340
return code;
339341
}
340342

0 commit comments

Comments
 (0)