@@ -128,8 +128,9 @@ function generateSentryAlias(): Record<string, string> {
128128
129129 const modulePath = path . resolve ( PACKAGES_DIR , packageName ) ;
130130
131- if ( useCompiledModule && bundleKey && BUNDLE_PATHS [ packageName ] ?. [ bundleKey ] ) {
132- const bundlePath = path . resolve ( modulePath , BUNDLE_PATHS [ packageName ] [ bundleKey ] ) ;
131+ const bundleKeyPath = bundleKey && BUNDLE_PATHS [ packageName ] ?. [ bundleKey ] ;
132+ if ( useCompiledModule && bundleKeyPath ) {
133+ const bundlePath = path . resolve ( modulePath , bundleKeyPath ) ;
133134
134135 return [ packageJSON [ 'name' ] , bundlePath ] ;
135136 }
@@ -175,8 +176,8 @@ class SentryScenarioGenerationPlugin {
175176 ( statement : { specifiers : [ { imported : { name : string } } ] } , source : string ) => {
176177 const imported = statement . specifiers ?. [ 0 ] ?. imported ?. name ;
177178
178- if ( imported && IMPORTED_INTEGRATION_CDN_BUNDLE_PATHS [ imported ] ) {
179- const bundleName = IMPORTED_INTEGRATION_CDN_BUNDLE_PATHS [ imported ] ;
179+ const bundleName = imported && IMPORTED_INTEGRATION_CDN_BUNDLE_PATHS [ imported ] ;
180+ if ( bundleName ) {
180181 this . requiredIntegrations . push ( bundleName ) ;
181182 } else if ( source === '@sentry/wasm' ) {
182183 this . requiresWASMIntegration = true ;
@@ -190,7 +191,7 @@ class SentryScenarioGenerationPlugin {
190191 HtmlWebpackPlugin . getHooks ( compilation ) . alterAssetTags . tapAsync ( this . _name , ( data , cb ) => {
191192 if ( useBundleOrLoader ) {
192193 const bundleName = 'browser' ;
193- const bundlePath = BUNDLE_PATHS [ bundleName ] [ bundleKey ] ;
194+ const bundlePath = BUNDLE_PATHS [ bundleName ] ?. [ bundleKey ] ;
194195
195196 if ( ! bundlePath ) {
196197 throw new Error ( `Could not find bundle or loader for key ${ bundleKey } ` ) ;
@@ -215,10 +216,10 @@ class SentryScenarioGenerationPlugin {
215216 '__LOADER_OPTIONS__' ,
216217 JSON . stringify ( {
217218 dsn :
'https://[email protected] /1337' , 218- ...loaderConfig . options ,
219+ ...loaderConfig ? .options ,
219220 } ) ,
220221 )
221- . replace ( '__LOADER_LAZY__' , loaderConfig . lazy ? 'true' : 'false' ) ;
222+ . replace ( '__LOADER_LAZY__' , loaderConfig ? .lazy ? 'true' : 'false' ) ;
222223 } ) ;
223224 }
224225
@@ -240,36 +241,41 @@ class SentryScenarioGenerationPlugin {
240241 path . resolve (
241242 PACKAGES_DIR ,
242243 'feedback' ,
243- BUNDLE_PATHS [ 'feedback' ] [ integrationBundleKey ] . replace ( '[INTEGRATION_NAME]' , integration ) ,
244+ BUNDLE_PATHS [ 'feedback' ] ?. [ integrationBundleKey ] ? .replace ( '[INTEGRATION_NAME]' , integration ) || '' ,
244245 ) ,
245246 fileName ,
246247 ) ;
247248 } ) ;
248249 }
249250
250- this . requiredIntegrations . forEach ( integration => {
251- const fileName = `${ integration } .bundle.js` ;
252- addStaticAssetSymlink (
253- this . localOutPath ,
254- path . resolve (
255- PACKAGES_DIR ,
256- 'browser' ,
257- BUNDLE_PATHS [ 'integrations' ] [ integrationBundleKey ] . replace ( '[INTEGRATION_NAME]' , integration ) ,
258- ) ,
259- fileName ,
260- ) ;
251+ const baseIntegrationFileName = BUNDLE_PATHS [ 'integrations' ] ?. [ integrationBundleKey ] ;
261252
262- const integrationObject = createHtmlTagObject ( 'script' , {
263- src : fileName ,
264- } ) ;
253+ if ( baseIntegrationFileName ) {
254+ this . requiredIntegrations . forEach ( integration => {
255+ const fileName = `${ integration } .bundle.js` ;
256+ addStaticAssetSymlink (
257+ this . localOutPath ,
258+ path . resolve (
259+ PACKAGES_DIR ,
260+ 'browser' ,
261+ baseIntegrationFileName . replace ( '[INTEGRATION_NAME]' , integration ) ,
262+ ) ,
263+ fileName ,
264+ ) ;
265265
266- data . assetTags . scripts . unshift ( integrationObject ) ;
267- } ) ;
266+ const integrationObject = createHtmlTagObject ( 'script' , {
267+ src : fileName ,
268+ } ) ;
269+
270+ data . assetTags . scripts . unshift ( integrationObject ) ;
271+ } ) ;
272+ }
268273
269- if ( this . requiresWASMIntegration && BUNDLE_PATHS [ 'wasm' ] [ integrationBundleKey ] ) {
274+ const baseWasmFileName = BUNDLE_PATHS [ 'wasm' ] ?. [ integrationBundleKey ] ;
275+ if ( this . requiresWASMIntegration && baseWasmFileName ) {
270276 addStaticAssetSymlink (
271277 this . localOutPath ,
272- path . resolve ( PACKAGES_DIR , 'wasm' , BUNDLE_PATHS [ 'wasm' ] [ integrationBundleKey ] ) ,
278+ path . resolve ( PACKAGES_DIR , 'wasm' , baseWasmFileName ) ,
273279 'wasm.bundle.js' ,
274280 ) ;
275281
0 commit comments