@@ -109,14 +109,51 @@ const esmBundleFor = (platform, opt) => {
109
109
110
110
const min = minify ? '.min' : '' ;
111
111
112
+ const targets = platform === 'node' ? {
113
+ node : '18' ,
114
+ } : {
115
+ browsers : [ 'chrome 102' ] ,
116
+ }
112
117
return {
113
118
...cjsBundleFor ( platform ) ,
119
+ plugins : [
120
+ resolve ( ) ,
121
+ commonjs ( {
122
+ namedExports : {
123
+ // '@optimizely/js-sdk-event-processor': ['LogTierV1EventProcessor', 'LocalStoragePendingEventsDispatcher'],
124
+ 'json-schema' : [ 'validate' ] ,
125
+ } ,
126
+ } ) ,
127
+ typescript ( typescriptPluginOptions ) ,
128
+ // babel({
129
+ // babelHelpers: 'bundled',
130
+ // extensions: ['.js', '.jsx', '.ts', '.tsx'],
131
+ // include: ['lib/**/*', 'node_modules/**/*.js'],
132
+ // })
133
+ ] ,
134
+ external : [ 'https' , 'http' , 'url' ] . concat ( Object . keys ( { ...peerDependencies } || { } ) ) ,
114
135
output : [
115
136
{
116
137
format : 'es' ,
117
138
file : `dist/index.${ platform } .es${ min } ${ ext } ` ,
118
139
plugins : minify ? [ terser ( ) ] : undefined ,
119
140
sourcemap : true ,
141
+ plugins :[
142
+ getBabelOutputPlugin ( {
143
+ "presets" : [
144
+ [ "@babel/preset-env" , {
145
+ targets,
146
+ // "modules": "umd",
147
+ // "allowAllFormats": true,
148
+ "useBuiltIns" : "usage" , // Automatically include required polyfills
149
+ "corejs" : 3 // Use core-js version 3
150
+ // "extensions": [".js", ".jsx", ".ts", ".tsx"],
151
+ // "include": ["lib/**/*", "node_modules/**/*"]
152
+ } ]
153
+ ]
154
+ }
155
+ ) ,
156
+ ] ,
120
157
} ,
121
158
] ,
122
159
}
@@ -189,10 +226,11 @@ const umdBundle = {
189
226
name : 'optimizelySdk' ,
190
227
format : 'es' ,
191
228
file : 'dist/optimizely.browser.umd.js' ,
192
- plugins :[ getBabelOutputPlugin ( {
193
- // babelHelpers: 'bundled',
194
- configFile : path . resolve ( __dirname , '.babelrc' ) ,
195
- } ) ] ,
229
+ plugins :[
230
+ getBabelOutputPlugin ( {
231
+ configFile : path . resolve ( __dirname , '.babelrc' ) ,
232
+ } ) ,
233
+ ] ,
196
234
exports : 'named' ,
197
235
} ,
198
236
// {
@@ -243,6 +281,7 @@ const bundles = {
243
281
'esm-browser-min' : esmBundleFor ( 'browser' ) ,
244
282
'esm-browser' : esmBundleFor ( 'browser' , { minify : false } ) ,
245
283
'esm-node-min' : esmBundleFor ( 'node' , { ext : '.mjs' } ) ,
284
+ 'esm-node' : esmBundleFor ( 'node' , { minify : false } ) ,
246
285
'esm-react-native-min' : esmBundleFor ( 'react_native' ) ,
247
286
'esm-universal' : esmBundleFor ( 'universal' ) ,
248
287
'json-schema' : jsonSchemaBundle ,
0 commit comments