@@ -15,7 +15,7 @@ interface LoaderContext {
1515
1616type LoaderFn = ( this : LoaderContext , code : string , inputSourceMap ?: unknown ) => void ;
1717
18- const upstreamLoader = codeTransformerLoaderImpl as unknown as LoaderFn ;
18+ const upstreamLoader : LoaderFn = codeTransformerLoaderImpl ;
1919
2020/**
2121 * The npm package name for a module path.
@@ -40,15 +40,18 @@ function packageNameFromPath(resourcePath: string): string | undefined {
4040}
4141
4242/**
43- * Announce a runtime-injected module the way the runtime `--import` hook does,
44- * so the lazily-registered channel integrations subscribe. Appended to each
45- * transformed module's code, it runs when that module loads.
43+ * Announce a runtime-injected module the way the banner and runtime `--import`
44+ * hook do, so the lazily-registered channel integrations subscribe. Appended to
45+ * each transformed module's code, it runs when that module loads.
4646 */
4747function onInjectSnippet ( moduleName : string ) : string {
48+ const name = JSON . stringify ( moduleName ) ;
4849 return (
4950 ';(function(){' +
50- 'var g=globalThis.__SENTRY_ORCHESTRION__;' +
51- `if(g&&typeof g.onInject==='function')g.onInject(${ JSON . stringify ( moduleName ) } );` +
51+ 'var g=globalThis.__SENTRY_ORCHESTRION__=globalThis.__SENTRY_ORCHESTRION__||{};' +
52+ 'if(!Array.isArray(g.bundler))g.bundler=[];' +
53+ `if(g.bundler.indexOf(${ name } )<0)g.bundler.push(${ name } );` +
54+ `if(typeof g.onInject==='function')g.onInject(${ name } );` +
5255 '})();\n'
5356 ) ;
5457}
0 commit comments