@@ -74,6 +74,63 @@ function attachAfterEmitHook(compiler, callback) {
7474  } 
7575} 
7676
77+ function  attachAfterCodeGenerationHook ( compiler ,  options )  { 
78+   if  ( ! compiler . hooks  ||  ! compiler . hooks . make )  { 
79+     return ; 
80+   } 
81+ 
82+   let  webpackSources ; 
83+   try  { 
84+     // eslint-disable-next-line global-require, import/no-extraneous-dependencies 
85+     webpackSources  =  require ( 'webpack-sources' ) ; 
86+   }  catch  ( _e )  { 
87+     console . warn ( 
88+       'Coud not resolve package: webpack-sources. Skipping injection for the remote entry file.' 
89+     ) ; 
90+     return ; 
91+   } 
92+ 
93+   const  {  RawSource }  =  webpackSources ; 
94+   const  moduleFederationPlugin  = 
95+     compiler . options  && 
96+     compiler . options . plugins  && 
97+     compiler . options . plugins . find ( 
98+       x  =>  x . constructor . name  ===  'ModuleFederationPlugin' 
99+     ) ; 
100+ 
101+   if  ( ! moduleFederationPlugin )  { 
102+     return ; 
103+   } 
104+ 
105+   compiler . hooks . make . tapAsync ( 'SentryCliPlugin' ,  ( compilation ,  cb )  =>  { 
106+     options . releasePromise . then ( version  =>  { 
107+       compilation . hooks . afterCodeGeneration . tap ( 'SentryCliPlugin' ,  ( )  =>  { 
108+         compilation . modules . forEach ( module  =>  { 
109+           // eslint-disable-next-line no-underscore-dangle 
110+           if  ( module . _name  !==  moduleFederationPlugin . _options . name )  return ; 
111+           const  sourceMap  =  compilation . codeGenerationResults . get ( module ) 
112+             . sources ; 
113+           const  rawSource  =  sourceMap . get ( 'javascript' ) ; 
114+           sourceMap . set ( 
115+             'javascript' , 
116+             new  RawSource ( 
117+               `${ rawSource . source ( ) }  
118+ (function (){ 
119+ var globalThis = (typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}); 
120+ globalThis.SENTRY_RELEASES = globalThis.SENTRY_RELEASES || {}; 
121+ globalThis.SENTRY_RELEASES["${ options . project } ${  
122+                 options . org  
123+               }  "] = {"id":"${ version } 
124+ })();` 
125+             ) 
126+           ) ; 
127+         } ) ; 
128+       } ) ; 
129+       cb ( ) ; 
130+     } ) ; 
131+   } ) ; 
132+ } 
133+ 
77134class  SentryCliPlugin  { 
78135  constructor ( options  =  { } )  { 
79136    const  defaults  =  { 
@@ -318,6 +375,8 @@ class SentryCliPlugin {
318375      loader : SENTRY_LOADER , 
319376      options : { 
320377        releasePromise : this . release , 
378+         org : this . options . org  ||  process . env . SENTRY_ORG , 
379+         project : this . options . project  ||  process . env . SENTRY_PROJECT , 
321380      } , 
322381    } ; 
323382
@@ -333,6 +392,8 @@ class SentryCliPlugin {
333392          loader : SENTRY_LOADER , 
334393          options : { 
335394            releasePromise : this . release , 
395+             org : this . options . org  ||  process . env . SENTRY_ORG , 
396+             project : this . options . project  ||  process . env . SENTRY_PROJECT , 
336397          } , 
337398        } , 
338399      ] , 
@@ -501,6 +562,12 @@ class SentryCliPlugin {
501562      this . injectRelease ( compilerOptions ) ; 
502563    } 
503564
565+     attachAfterCodeGenerationHook ( compiler ,  { 
566+       releasePromise : this . release , 
567+       org : this . options . org  ||  process . env . SENTRY_ORG , 
568+       project : this . options . project  ||  process . env . SENTRY_PROJECT , 
569+     } ) ; 
570+ 
504571    attachAfterEmitHook ( compiler ,  ( compilation ,  cb )  =>  { 
505572      if  ( ! this . options . include  ||  ! this . options . include . length )  { 
506573        ensure ( compilerOptions ,  'output' ,  Object ) ; 
0 commit comments