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

add support for utilizing npm package in ESM environments #509

Merged
merged 4 commits into from
Jan 7, 2025

Conversation

solpkr1
Copy link
Contributor

@solpkr1 solpkr1 commented Jan 7, 2025

  • use --ts_proto_opt=esModuleInterop=true arg when generating with proto
  • split esm / cjs into 2 seperate tsconfigs
  • add npm run command to copy compiled encoding folder contents to esm/cjs
  • add script to fix the imports in the ESM version

Tested with CJS / ESM / TS enviroments for Subsrbribing to transactions for a program account

"esModuleInterop": true is required in projects tsconfig.json compilerOptions

@solpkr1 solpkr1 force-pushed the esm-package-support branch from 8928df7 to 230cf85 Compare January 7, 2025 03:49
@WilfredAlmeida WilfredAlmeida requested a review from fanatid January 7, 2025 06:21
@solpkr1 solpkr1 force-pushed the esm-package-support branch from 12f0325 to 3c08eff Compare January 7, 2025 13:20
@WilfredAlmeida
Copy link

  1. I've tested unary calls, accounts & transactions subscriptions and WASM parsing via the TypeScript example, it all works fine.
  2. Users might need to set "esModuleInterop": true in their tsconfig.json if not already, otherwise they'll face errors

Copy link
Collaborator

@fanatid fanatid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thank you!

@fanatid fanatid merged commit f113ddc into rpcpool:master Jan 7, 2025
2 checks passed
fanatid added a commit that referenced this pull request Jan 13, 2025
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 this pull request may close these issues.

3 participants