Skip to content

[flagd-provider] Can't import flagd provider in ESM Typescript project #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
talzion12 opened this issue Dec 25, 2022 · 5 comments · Fixed by #201 or #212
Closed

[flagd-provider] Can't import flagd provider in ESM Typescript project #198

talzion12 opened this issue Dec 25, 2022 · 5 comments · Fixed by #201 or #212
Assignees
Labels
bug Something isn't working

Comments

@talzion12
Copy link

Trying to import FlagdProvider in Typescript with ESM causes the following error:

node_modules/@openfeature/flagd-provider/src/index.d.ts:1:15 - error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.

1 export * from './lib/flagd-provider';
                ~~~~~~~~~~~~~~~~~~~~~~

src/main.ts:2:10 - error TS2305: Module '"@openfeature/flagd-provider"' has no exported member 'FlagdProvider'.

2 import { FlagdProvider } from '@openfeature/flagd-provider';
           ~~~~~~~~~~~~~


Found 2 errors in 2 files.

Errors  Files
     1  node_modules/@openfeature/flagd-provider/src/index.d.ts:1
     1  src/main.ts:2

When I switch my project to CommonJS the problem is resolved.
I'm not sure if this is a bug or if I'm doing something wrong here.

Steps to reproduce

  • Create Typescript ESM project.
  • Import FlagdProvider like so: import { FlagdProvider } from '@openfeature/flagd-provider';.

I also created a simple example repo. Running npm run build shows the error.

@beeme1mr beeme1mr added the bug Something isn't working label Dec 26, 2022
@beeme1mr
Copy link
Member

Hi @talzion12, thanks for reporting this. Sorry you keep running into ESM issues! The team has limited availability this week but we'll address it as soon as possible.

@talzion12
Copy link
Author

@beeme1mr Haha yes ESM is causing me quite a bit of issues 😅
No problem, in the meantime I created a custom provider.
Thanks!

@toddbaert
Copy link
Member

I'll look into this today and hopefully publish a fix.

@toddbaert
Copy link
Member

toddbaert commented Dec 29, 2022

Thanks again for the report @talzion12 . Looks like this might have been a change/regression in NX.

I published 0.7.3 which resolves the issue in your example project.

If the issue remains, please re-open!

@toddbaert toddbaert reopened this Jan 18, 2023
@toddbaert
Copy link
Member

I'm still seeing issues with this. I have a fix I'll push tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants