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

fix: Tell webpack about dynamic import + fixed polyfills #1151

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

ecp4224
Copy link
Collaborator

@ecp4224 ecp4224 commented Nov 29, 2024

Explanation

This PR fixes a few things when bundling the SDK with projects using WebPack

  1. Disable es5Builds in StencilJS
    • This is not needed and is causing issues with not including webpack/vite magic comments in import statements
  2. Add a /* webpackIgnore: true */ comment to the generated dynamic import that StencilJS creates
    • This is done via a custom rollup plugin to inject the comment via a regex match
  3. Replace the globals() plugin with a more modern polyfill
    • Since StencilJS is no longer building es5, the old globals() plugin was having parsing issues. This plugin has been replaced with the modern replacement
    • The configuration for this plugin needs include: null to ensure that all files (including source files) are included in the plugin transformation (Pass in null to transform all files, including all files including any source files. from here)
  4. Instruct terser to not strip magic comments relating to vite and webpack
    • This is needed so other downstream bundlers know how to resolve the dynamic import introduced by StencilJS

I've tested that this fixes the existing issue with Rainbowkit + that devnext + react-demo all work.

References

Fixes wevm/wagmi#4429

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • [N/A] I've highlighted breaking changes using the "BREAKING" category above as appropriate

@ecp4224 ecp4224 self-assigned this Nov 29, 2024
@ecp4224 ecp4224 requested a review from a team as a code owner November 29, 2024 21:15
Copy link

codecov bot commented Nov 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.16%. Comparing base (a535262) to head (cdb3dfc).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1151   +/-   ##
=======================================
  Coverage   74.16%   74.16%           
=======================================
  Files         181      181           
  Lines        4296     4296           
  Branches     1052     1052           
=======================================
  Hits         3186     3186           
  Misses       1110     1110           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@abretonc7s abretonc7s merged commit 20378ca into main Nov 29, 2024
36 checks passed
@abretonc7s abretonc7s deleted the edkek/fix/webpack-dont-include-dynamic-imports branch November 29, 2024 23:37
@abretonc7s abretonc7s mentioned this pull request Nov 29, 2024
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.

Build fails with @metamask/sdk dependency in wagmi/connectors
3 participants