You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to import the ESM bundle from optimizely-sdk
What I expected to happen
Expected it to import successfully.
What actually happened
When using rollup on a bundle that imports optimizely-sdk's ESM bundle:
[!] Error: 'ConsoleLogHandler' is not exported by ../optimizely-javascript-sdk/packages/optimizely-sdk/node_modules/@optimizely/js-sdk-logging/lib/index.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
../optimizely-javascript-sdk/packages/optimizely-sdk/dist/optimizely.browser.es.min.js (1:7)
Steps to reproduce
The root cause is an issue with the commonjs wrapping of some of the optimizely deps. Because these are declared as external in the ESM bundle, this error does not manifest during optimizely's build. However, a trivial way to repro the issue:
Doing this will force rollup to attempt to embed the logging dependency directly, rather than ignore it. This exposes the same problem that consumers will have when they attempt to import the main sdk ESM bundle (at which point, rollup will need to import the logging dep)
It appears that this was worked around for the UMD build by adding namedExports to the commonjs plugin. However, this option is no longer available with recent versions of the commonjs plugin. rollup/plugins#149
I believe this will be fixed implicitly by converting the logging dependency to ESM.
@optimizely/optimizely-sdk version:
4.0
The text was updated successfully, but these errors were encountered:
What I wanted to do
Trying to import the ESM bundle from optimizely-sdk
What I expected to happen
Expected it to import successfully.
What actually happened
When using rollup on a bundle that imports optimizely-sdk's ESM bundle:
Steps to reproduce
The root cause is an issue with the commonjs wrapping of some of the optimizely deps. Because these are declared as
external
in the ESM bundle, this error does not manifest during optimizely's build. However, a trivial way to repro the issue:external: []
above:javascript-sdk/packages/optimizely-sdk/rollup.config.js
Line 44 in 146fb43
npm run build
Doing this will force rollup to attempt to embed the logging dependency directly, rather than ignore it. This exposes the same problem that consumers will have when they attempt to import the main sdk ESM bundle (at which point, rollup will need to import the logging dep)
It appears that this was worked around for the UMD build by adding
namedExports
to the commonjs plugin. However, this option is no longer available with recent versions of the commonjs plugin. rollup/plugins#149I believe this will be fixed implicitly by converting the logging dependency to ESM.
@optimizely/optimizely-sdk
version:4.0
The text was updated successfully, but these errors were encountered: