tryretool / retoolrpc

MIT License
6 stars 5 forks source link

Typescript checks fail under "module": "CommonJS" and "moduleResolution": "bundler" #18

Closed noahsark769 closed 9 months ago

noahsark769 commented 9 months ago

Hey Retool team! We've been prototyping Retool RPC for @replohq and we noticed a couple of issues related to typescript checks in certain typescript configs.

I created https://github.com/noahsark769/retoolrpc-typescript-issue which demonstrates both issues in a minimal reproduction and the README has the full error, but I'll detail the two issues here:

  1. When checked as a dependency of a package with "module": "CommonJS", retoolrpc reports errors about possibly undefined object accesses, etc. As I understand, this is fixed by using main correctly in package.json. See https://docs.npmjs.com/cli/v10/configuring-npm/package-json#main and https://stackoverflow.com/questions/22512992/how-to-use-the-main-parameter-in-package-json

  2. When checked as a dependency of a package with "moduleResolution": "bundler", retoolrpc reports issues about types being misconfigured. https://github.com/microsoft/TypeScript/issues/52363 has some discussion of the issue, and https://github.com/gxmari007/vite-plugin-eslint/pull/60 and https://github.com/nolimits4web/swiper/issues/6508 are example fixes for other packages.

If it's okay with you, I'm going to submit a PR which updates package.json to fix these issues (we're using patch-package internally for now). Let me know if you need anything from me here!

noahsark769 commented 9 months ago

Went ahead and added a pull request at https://github.com/tryretool/retoolrpc/pull/19 - feel free to reach out if I can help here!

huytool157 commented 9 months ago

@noahsark769 Thanks for contributing. ESM/CJS compatibility issues are always nightwares. Your change should be live on 0.1.4.

noahsark769 commented 9 months ago

Woohoo! Thanks y'all!