braze-inc / braze-web-sdk

Public repo for the Braze Web SDK
https://www.braze.com
Other
71 stars 25 forks source link

[Feature]: Export SDK in CommonJS #132

Closed VictorJSV closed 1 year ago

VictorJSV commented 1 year ago

What problem are you facing?

When I test angular components with Jest and it have a Braze SDK configuration. Show me in console image

Inside node_modules/@braze/web-sdk have ESM modules. image

Jest support CommonJS files and ESM modules is in experimental mode.

Jest v28.1.2 Angular v14

Workarounds

I'm investigating

Ideal Solution

Could be export in commonJS?

Other Information

No response

wesleyorbin commented 1 year ago

Hi @VictorJSV. We have no plans at this time to export the SDK as CommonJS. Can you try adding the below transformIgnorePatterns option to your package.json?

"jest": {
  "transformIgnorePatterns": [
    "/node_modules/(?!@braze)"
  ]
}
VictorJSV commented 1 year ago

Oops!. It works, but I needed to add some more characters

jestConfig = {
  transformIgnorePatterns: ["/node_modules/(?!.*\\.mjs$|@braze)"],
}

Thank you!