Skip to content
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

Import errors with --moduleResolution 'node16' or 'nodenext' #41

Closed
pappnase99 opened this issue Aug 22, 2024 · 8 comments · Fixed by #50
Closed

Import errors with --moduleResolution 'node16' or 'nodenext' #41

pappnase99 opened this issue Aug 22, 2024 · 8 comments · Fixed by #50

Comments

@pappnase99
Copy link

My Typescript project is set up with both these settings in the tsconfig.json: "module": "NodeNext", "moduleResolution": "NodeNext".

I tried to import functions from cognito-srp-helper like 'createSrpSession' but this produced the error "Module 'cognito-srp-helper' has no exported member 'createSrpSession'. When I looked into the file 'node_modules/cognito-srp-helper/dist/types/index.d.ts' I see multiple errors like

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 "./cognito-srp-helper";

and so on. I could manually fix these by appending the '.ts' extension to the exports and make the compiler happy. Same with 'cognito-srp-helper.d.ts' file.

@simonmcallister0210
Copy link
Owner

Really I should be using moduleResolution: "bundler"... lesson learned

If I update it now I'm worried it'll be a breaking change. Need to do some research on the impact of changing moduleResolution. Worst case I'll queue the change up for the next major release

@DmitryLyubetsky
Copy link

DmitryLyubetsky commented Nov 22, 2024

Hello @simonmcallister0210 first of all, thanks for your work, is there any progress for this issue? The solution from author are works, but we are not want to patch or fork from this repo.

@simonmcallister0210
Copy link
Owner

Would be risky making this change in a minor version update. What I could do is push a beta release of the package that would contain the fix. Would that work as a temporary solution? (at least until v3 is released)

@DmitryLyubetsky
Copy link

@simonmcallister0210 sounds good, would been really appreciated if you do it :)

@simonmcallister0210 simonmcallister0210 linked a pull request Dec 1, 2024 that will close this issue
@simonmcallister0210
Copy link
Owner

simonmcallister0210 commented Dec 1, 2024

Hey @DmitryLyubetsky, looking at the fix I've just bundled the declaration files into file to avoid import statements. This shouldn't cause any issues for existing users so should be safe for release in v2

I've published a beta version under 2.3.2-beta-v1. Let me know if there are any issues. If there's no issues I'll merge it in

@DmitryLyubetsky
Copy link

@simonmcallister0210 hey, sorry for the late reply, I check the beta version, and it's works without issues, thanks.

@simonmcallister0210
Copy link
Owner

Cool I'll merge it in tonight

@simonmcallister0210
Copy link
Owner

Just published. Should be live under the latest patch 2.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants