node-js-server-sdk icon indicating copy to clipboard operation
node-js-server-sdk copied to clipboard

Typescript/ESM issue

Open ethos-seth opened this issue 1 year ago • 3 comments

Hey folks, I have a project I just migrated to ESM and the the statsig client is giving me some trouble.

I put together a small sample project to demonstrate the issue I'm having: https://github.com/ethos-seth/statsig-esm-demo

It shows import two approaches:

  1. Default imports
  2. Named imports

Each fails in their own way.

I suspect it might have something to do with:

module.exports = { default: Statsig as Statsig, ...Statsig };

ethos-seth avatar Nov 02 '24 07:11 ethos-seth

@ethos-seth Thanks for flagging this issue. We realize our export syntax does not work for ESM and are planning to address it. In the meantime, i'd recommend using the following import syntax import { default as Statsig } from 'statsig-node'

kenny-statsig avatar Nov 05 '24 20:11 kenny-statsig

@kenny-statsig that works at runtime, but TypeScript complains about it. Would love to see an upstream fix!

bcherny avatar Dec 04 '24 17:12 bcherny

@kenny-statsig Do you have any sort of timeline on a fix for this issue? We've been bitten by this a couple of times already and would really appreciate it if there weren't obvious footguns and the typescript types matched what node is expecting.

ryanquinn3 avatar Feb 27 '25 15:02 ryanquinn3