spotify / confidence-sdk-js

Other
7 stars 1 forks source link

Reconsider adding a CommonJS build output #156

Open andreas-karlsson opened 1 month ago

andreas-karlsson commented 1 month ago

It's still tricky to make Node execute TS with esm imports.

Feature Suggestion

Add cjs output in the build.

nicklasl commented 3 days ago

For now, the workaround is to use an approach similar to this:

async function main() {
  const { Confidence } = await import("@spotify-confidence/sdk");
  const confidence = Confidence.create({
    ...
  });

  const flagValue = await confidence.getFlag("MyFlag.flag_property", false);
  console.log("Flag value: ", flagValue);
}
main();

and combine it with the following in the tsconfig.json of the project:

"ts-node": {
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "Node"
  }
},