Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit dd1f581

Browse files
committed
Expose an ESM-FULL bundle which includes optimizely deps
1 parent a21da49 commit dd1f581

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

packages/optimizely-sdk/rollup.config.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const cjsBuildFor = (platform) => ({
2626
plugins: [
2727
resolve(),
2828
commonjs(),
29-
visualizer(),
3029
],
3130
external: ['https', 'http', 'url'].concat(Object.keys(dependencies || {})),
3231
input: `lib/index.${platform}.js`,
@@ -54,8 +53,39 @@ const esmBundle = {
5453
}]
5554
}
5655

56+
// ESM Bundle for browsers with all optimizely deps included
57+
const esmFullBundle = {
58+
input: 'lib/index.browser.js',
59+
external: ['https', 'http', 'url'],
60+
plugins: [
61+
resolve({browser: true}),
62+
commonjs({
63+
namedExports: {
64+
'@optimizely/js-sdk-logging': [
65+
'ConsoleLogHandler',
66+
'getLogger',
67+
'setLogLevel',
68+
'LogLevel',
69+
'setLogHandler',
70+
'setErrorHandler',
71+
'getErrorHandler',
72+
],
73+
'@optimizely/js-sdk-event-processor': [
74+
'LogTierV1EventProcessor',
75+
'LocalStoragePendingEventsDispatcher',
76+
]
77+
}
78+
}),
79+
],
80+
output: {
81+
format: 'es',
82+
file: 'dist/optimizely.browser.es.full.js',
83+
sourcemap: true,
84+
},
85+
}
86+
5787
const esmSlimBundle = {
58-
...esmBundle,
88+
...esmFullBundle,
5989
plugins: [
6090
alias({ entries: [
6191
{ find: './project_config_schema',
@@ -65,7 +95,8 @@ const esmSlimBundle = {
6595
{ find: /.*\/enums$/,
6696
replacement: path.resolve(__dirname, 'ext/enums.js') }
6797
]}),
68-
...esmBundle.plugins
98+
...esmFullBundle.plugins,
99+
visualizer(),
69100
],
70101
output: {
71102
format: 'es',
@@ -136,6 +167,7 @@ const bundles = {
136167
'cjs-browser': cjsBuildFor('browser'),
137168
'cjs-react-native': cjsBuildFor('react_native'),
138169
'esm': esmBundle,
170+
'esm-full': esmFullBundle,
139171
'esm-slim': esmSlimBundle,
140172
'json-schema': jsonSchemaBundle,
141173
'umd': umdBundle,

0 commit comments

Comments
 (0)