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

feat: bundler module resolution #885

Merged
merged 6 commits into from
Jul 17, 2024
Merged

Conversation

rin-st
Copy link
Collaborator

@rin-st rin-st commented Jul 12, 2024

Description

Change ts moduleResolution to Bundler

Context: scaffold-eth#74 (comment)

Also added paths for abitype/viem/wagmi since with Bundler abi.d.ts is ignored

Note: Could you check is everything ok with types? My Vscode getting mad, it can show or not show errors for same code. (as you see build works fine)

Additional Information

@technophile-04
Copy link
Collaborator

technophile-04 commented Jul 15, 2024

Thanks @rin-st !

Note: Could you check is everything ok with types? My Vscode getting mad, it can show or not show errors for same code. (as you see build works fine)

Yup it seems to work fine for me in both vscode and neovim.

But when I update the typescript to 5.5.3, it seems to break again :(

To reproduce:

  1. Up typescript version
yarn workspace @se-2/nextjs up typescript
  1. Check for types:
yarn next:check-types

Umm, we could merge this already but I am bit skeptical because of above thing and also on this branch when I hover over "viem/node_modules/abitype" in abi.d.ts it doesn't seem to resolve the path:

this branch main branch
Screenshot 2024-07-15 at 11 51 26 AM Screenshot 2024-07-15 at 11 52 29 AM

See how on main it nicely resolves the whole path

@rin-st
Copy link
Collaborator Author

rin-st commented Jul 15, 2024

I don't know why, but extending interface Register doesn't work for me with moduleResolution: "Bundler".

Possible solution is to rewrite Address type directly, not through Register. It works, but am I missing something? Do we really need to use Register. Also updated TS version and looks like everything works fine. 1528a71 . Of course I'll revert it if something is wrong

As I remember we added string because it will be easier to work with our components to newcomers, am I right? Another solution is to remove abi.d.ts and add some as 0x${string}`, but we need to think if it really helps or not

Copy link
Collaborator

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

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

Possible solution is to rewrite Address type directly, not through Register. It works, but am I missing something? Do we really need to use Register. Also updated TS version and looks like everything works fine.

Actually it was suggested in abitype docs: https://abitype.dev/config#overview

also while digging I found this in their release logs:
Screenshot 2024-07-16 at 1 43 45 PM

Maybe this was the reason Register were not working?

As I remember we added string because it will be easier to work with our components to newcomers, am I right? Another solution is to remove abi.d.ts and add some as 0x${string}`, but we need to think if it really helps or not

Yup yup mainly for newcomers. here is the OG discussion : #515


But your current approach seems to works nicely, also tried deploying to vercel and works nicely too.

I think with this approach the problem will reappear again in future when viem / wagmi internal abitype version deviates from our abitype version? But since we have locked the version, I think we can only encounter it while manually trying to update the viem / wagmi.

We can merge this though since currently everything works and its required for scaffold-eth/create-eth-extensions#11. Just cc @carletex once.

packages/nextjs/tsconfig.json Outdated Show resolved Hide resolved
@rin-st
Copy link
Collaborator Author

rin-st commented Jul 16, 2024

Maybe this was the reason Register were not working?

Thanks Shiv, yes! 🙏 After update abitype to 1.0.5 problem disappeared, so I switched to Register again.
There were no errors but for being more confident I also updated wagmi/viem to latest versions

Copy link
Collaborator

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

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

Thanks Shiv, yes! 🙏 After update abitype to 1.0.5 problem disappeared, so I switched to Register again. There were no errors but for being more confident I also updated wagmi/viem to latest versions

Noicce! Yup also updating wagmi / viem make sense just to be sure.

All in all, I think everything looks great and works fine!!

  • We are using suggested way to update addressType using Register
  • Deploys to vercel nicely : https://ts-address-type.vercel.app/
  • Also we have switched to moduleResolution: "Bundler"

Thanks Rinat!! Merging this!

@technophile-04 technophile-04 merged commit 4e8b444 into main Jul 17, 2024
1 check passed
@technophile-04 technophile-04 deleted the module-resolution-bundler branch July 17, 2024 07:00
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.

None yet

2 participants