@@ -128,8 +128,9 @@ function generateSentryAlias(): Record<string, string> {
128
128
129
129
const modulePath = path . resolve ( PACKAGES_DIR , packageName ) ;
130
130
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 ) ;
133
134
134
135
return [ packageJSON [ 'name' ] , bundlePath ] ;
135
136
}
@@ -175,8 +176,8 @@ class SentryScenarioGenerationPlugin {
175
176
( statement : { specifiers : [ { imported : { name : string } } ] } , source : string ) => {
176
177
const imported = statement . specifiers ?. [ 0 ] ?. imported ?. name ;
177
178
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 ) {
180
181
this . requiredIntegrations . push ( bundleName ) ;
181
182
} else if ( source === '@sentry/wasm' ) {
182
183
this . requiresWASMIntegration = true ;
@@ -190,7 +191,7 @@ class SentryScenarioGenerationPlugin {
190
191
HtmlWebpackPlugin . getHooks ( compilation ) . alterAssetTags . tapAsync ( this . _name , ( data , cb ) => {
191
192
if ( useBundleOrLoader ) {
192
193
const bundleName = 'browser' ;
193
- const bundlePath = BUNDLE_PATHS [ bundleName ] [ bundleKey ] ;
194
+ const bundlePath = BUNDLE_PATHS [ bundleName ] ?. [ bundleKey ] ;
194
195
195
196
if ( ! bundlePath ) {
196
197
throw new Error ( `Could not find bundle or loader for key ${ bundleKey } ` ) ;
@@ -215,10 +216,10 @@ class SentryScenarioGenerationPlugin {
215
216
'__LOADER_OPTIONS__' ,
216
217
JSON . stringify ( {
217
218
dsn : 'https://public@dsn.ingest.sentry.io/1337' ,
218
- ...loaderConfig . options ,
219
+ ...loaderConfig ? .options ,
219
220
} ) ,
220
221
)
221
- . replace ( '__LOADER_LAZY__' , loaderConfig . lazy ? 'true' : 'false' ) ;
222
+ . replace ( '__LOADER_LAZY__' , loaderConfig ? .lazy ? 'true' : 'false' ) ;
222
223
} ) ;
223
224
}
224
225
@@ -240,36 +241,41 @@ class SentryScenarioGenerationPlugin {
240
241
path . resolve (
241
242
PACKAGES_DIR ,
242
243
'feedback' ,
243
- BUNDLE_PATHS [ 'feedback' ] [ integrationBundleKey ] . replace ( '[INTEGRATION_NAME]' , integration ) ,
244
+ BUNDLE_PATHS [ 'feedback' ] ?. [ integrationBundleKey ] ? .replace ( '[INTEGRATION_NAME]' , integration ) || '' ,
244
245
) ,
245
246
fileName ,
246
247
) ;
247
248
} ) ;
248
249
}
249
250
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 ] ;
261
252
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
+ ) ;
265
265
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
+ }
268
273
269
- if ( this . requiresWASMIntegration && BUNDLE_PATHS [ 'wasm' ] [ integrationBundleKey ] ) {
274
+ const baseWasmFileName = BUNDLE_PATHS [ 'wasm' ] ?. [ integrationBundleKey ] ;
275
+ if ( this . requiresWASMIntegration && baseWasmFileName ) {
270
276
addStaticAssetSymlink (
271
277
this . localOutPath ,
272
- path . resolve ( PACKAGES_DIR , 'wasm' , BUNDLE_PATHS [ 'wasm' ] [ integrationBundleKey ] ) ,
278
+ path . resolve ( PACKAGES_DIR , 'wasm' , baseWasmFileName ) ,
273
279
'wasm.bundle.js' ,
274
280
) ;
275
281
0 commit comments