@@ -17,6 +17,7 @@ import {
1717 makeTerserPlugin ,
1818 makeTSPlugin ,
1919 makeSetSDKSourcePlugin ,
20+ getEs5Polyfills ,
2021} from './plugins/index.js' ;
2122import { mergePlugins } from './utils' ;
2223
@@ -25,6 +26,8 @@ const BUNDLE_VARIANTS = ['.js', '.min.js', '.debug.min.js'];
2526export function makeBaseBundleConfig ( options ) {
2627 const { bundleType, entrypoints, jsVersion, licenseTitle, outputFileBase, packageSpecificConfig } = options ;
2728
29+ const isEs5 = jsVersion . toLowerCase ( ) === 'es5' ;
30+
2831 const nodeResolvePlugin = makeNodeResolvePlugin ( ) ;
2932 const sucrasePlugin = makeSucrasePlugin ( ) ;
3033 const cleanupPlugin = makeCleanupPlugin ( ) ;
@@ -42,6 +45,10 @@ export function makeBaseBundleConfig(options) {
4245 output : {
4346 format : 'iife' ,
4447 name : 'Sentry' ,
48+ outro : ( ) => {
49+ // Add polyfills for ES6 array/string methods at the end of the bundle
50+ return isEs5 ? getEs5Polyfills ( ) : '' ;
51+ } ,
4552 } ,
4653 context : 'window' ,
4754 plugins : [ markAsBrowserBuildPlugin ] ,
@@ -101,10 +108,9 @@ export function makeBaseBundleConfig(options) {
101108 strict : false ,
102109 esModule : false ,
103110 } ,
104- plugins :
105- jsVersion === 'es5'
106- ? [ tsPlugin , nodeResolvePlugin , cleanupPlugin , licensePlugin ]
107- : [ sucrasePlugin , nodeResolvePlugin , cleanupPlugin , licensePlugin ] ,
111+ plugins : isEs5
112+ ? [ tsPlugin , nodeResolvePlugin , cleanupPlugin , licensePlugin ]
113+ : [ sucrasePlugin , nodeResolvePlugin , cleanupPlugin , licensePlugin ] ,
108114 treeshake : 'smallest' ,
109115 } ;
110116
0 commit comments