-
Notifications
You must be signed in to change notification settings - Fork 572
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
fix: project module resolution #1421
Conversation
🟡 Heimdall Review Status
|
Greetings Jake! We'll prioritize reviewing your work here. Thanks for helping out. |
just saw this update on extension rewrite from microsoft should we opt in to this? |
@fan-zhang-sv – Perhaps! I don't think it is released yet though – unsure if it's worth waiting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jxom for the PR. Definitely some changes that are needed. I'm seeing some import errors when running the playground sdk (can be started w/yarn dev
from root).
packages/wallet-sdk/src/sign/walletlink/relay/ui/components/RedirectDialog/RedirectDialog.tsx
Show resolved
Hide resolved
@jxom Thanks for this PR. All in all everything looks good. A few callouts that we should look into:
Edit: Looks like you addressed the preact pragma. Thank you! |
@cb-jake – thanks! made the changes. Although, I was unable to repro the
This shouldn't be the case as we aren't changing any of the build configuration. :) |
Thanks @jxom Taking a look now. |
@jxom changes look good. Running CI now. Walletlink/SCW interactions worked as expected. |
@jxom looks like we need to update CI. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conducted manual testing via playground, smart wallet and walletlink connection both work as expected in major CUJs, including signUp/signIn, signMsg/Tx/Calls, etc
@cb-jake pushed! |
Thanks @jxom! Looks like there is a merge conflict (sorry about that). |
np, just resolved |
@jxom This looks great, looks like the imports in |
@jxon thanks again for all your work on this. It looks like older version of node are missing |
Do you think we should remove the 16.x / 18.x tests? Or are there Node.js consumers of Note: Node 16 is now end-of-life, and Node 18 will be end-of-life ~Apr 2025. |
With the exception of SSR apps, theres probably no other nodejs consumers. We can safely remove support for Node 16. I'm on the fence with 18 since its still in active LTS. @fan-zhang-sv @spencerstock What are your thoughts on removing the test suites for Node 16 and 18? We can replace them with v22 and v24 (In a separate PR) |
I'm aligned on removing Node 16, but think im also leaning towards keep supporting Node 18 til end of life, to maximize the support for our consumer. |
Clean lines should be drawn here.
@cb-jake what do you recommend? |
@spencerstock As I think about it, the more inclined I am to remove test support for 16 and 18. We can update the matrix to include 22 and 24. Internally we can add in a separate PR. @jxom I have a PR to remove support for 16 and 18. Once we land this, you can rebase and we'll get these changes landed. #1424 |
Upon assisting @wilsoncusack with Wagmi + importing a @wevm ESM-only library into the Coinbase Wallet SDK, I noticed that the repository wasn't set up properly for importing such packages.
What is introduced?
type: "module"
property topackage.json
NodeNext
module resolutionWhy?
To break it down:
tsconfig.json#32
package.json
had a non-existenttype: "module"
(ESM flag) field, even though the package is being bundled as an ESM-only package. As thetype: "module"
property doesn't exist, TS "thinks" the project files are CJS modules, and as a result, we get an import error when we try to import an ESM-only moduleThe current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'.
type: "module"
– TS now recognizes that our project is ESM – however, sincemoduleResolution: "NodeNext"
, this means we need to add the.js
extension to all imports (yes it is a throw-off, but justification makes sense).type: "module"
property, this broke Jest. Jest's ESM support is nearly non-existent, so I migrated from Jest to Vitest, which is a trivial migration and makes the tests run a bit faster.src/core/message/index.ts
) which reduced bundle size by 10%.Before
Bundle Size (gzipped):
33.38kB
$ yarn size ✔ Adding to empty webpack project ✔ Running JS in headless Chrome Size: 33.38 kB with all dependencies, minified and brotlied
After
Bundle Size (gzipped):
30.29kB
$ yarn size ✔ Adding to empty webpack project ✔ Running JS in headless Chrome Size: 30.29 kB with all dependencies, minified and brotlied
Next
I believe this repository can also benefit from the following quick wins:
Buffer
in-favor ofTypedArray
s, so consumers don't have to installBuffer
polyfills.hashTypedData
tslib
to further decrease bundle size.