Closed tylerexmg closed 1 year ago
The LaunchDarkly JS SDK v3.0 and up uses optional chaining which is supported by modern browsers. It looks like you bundle your react app using webpack. The issue is webpack 4 uses a version of acorn which does not transpile the optional chaining operator. The solution as you can see in the react async provider example is to resolve the acorn package version that does support it. To do this, in your package.json file:
"resolutions": {
"acorn": "npm:acorn-with-stage3"
}
Webpack 5 supports optional chaining out of the box so we recommend you upgrade to that if possible. If you use other bundlers, make sure to enable/include plugins for optional chaining for your bundler.
This is also covered in our v2 to v3 migration docs. Read more here.
Hi @yusinto thank you for your reply. We are using Webpack 5 "webpack": "^5.73.0"
and also use optional chaining in our code without issue when reverting to the LD JS SDK v2.
My project updated from npm package v2 to v3 and it is causing a breaking error in Safari 12 and 13.
Unfortunately I'm having a hard time debugging beyond this error to see exactly what the problem is. I just can confirm that using "launchdarkly-js-client-sdk": "^3.0.0" errors but "launchdarkly-js-client-sdk": "^2.24.2" does not.