simonmcallister0210 / cognito-srp-helper

A helper for SRP authentication in AWS Cognito
Apache License 2.0
12 stars 1 forks source link

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

Open pappnase99 opened 1 month ago

pappnase99 commented 1 month ago

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 commented 1 week ago

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