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: viem/node esm/cjs conflict #2298

Merged
merged 2 commits into from
May 23, 2024
Merged

fix: viem/node esm/cjs conflict #2298

merged 2 commits into from
May 23, 2024

Conversation

tmm
Copy link
Member

@tmm tmm commented May 23, 2024

Adds CJS and ESM versions of trustedSetups.ts and uses specific one based on the build type.

Fixes #2297


Alternative approach could be creating a 'viem/node/trustedSetups' entrypoint, chucking the compiled files in there, and exporting those in 'viem/node'.


PR-Codex overview

This PR focuses on adding support for ESM (ECMAScript Modules) for trusted setups in the project.

Detailed summary

  • Added src/node/trustedSetups_esm.ts for ESM support
  • Updated tsconfig.build.json for ESM module resolution
  • Modified file paths and imports for ESM compatibility

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented May 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
viem ✅ Ready (Inspect) Visit Preview May 23, 2024 9:07pm

Copy link

changeset-bot bot commented May 23, 2024

🦋 Changeset detected

Latest commit: 836ff50

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tmm tmm force-pushed the tmm/node-export-fix branch 2 times, most recently from 7357716 to 79abf44 Compare May 23, 2024 18:44
@@ -6,8 +6,10 @@
"bench": "vitest bench",
"bench:ci": "CI=true vitest bench",
"build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types",
"build:cjs": "tsc --project ./tsconfig.build.json --module commonjs --outDir ./src/_cjs --removeComments --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./src/_cjs/package.json",
"build:cjs": "bun run build:trustedSetups:start && tsc --project ./tsconfig.build.json --module commonjs --outDir ./src/_cjs --removeComments --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./src/_cjs/package.json && bun run build:trustedSetups:end",
Copy link
Member Author

Choose a reason for hiding this comment

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

move commonjs version trustedSetups_cjs.ts to trustedSetups.ts, then cleans up at the end

@tmm tmm requested a review from jxom May 23, 2024 18:46
Copy link
Contributor

github-actions bot commented May 23, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
viem (esm) 56.85 KB (0%) 1.2 s (0%) 7.8 s (+28.91% 🔺) 9 s
viem (cjs) 68.21 KB (0%) 1.4 s (0%) 12.8 s (+24.68% 🔺) 14.1 s
viem (minimal surface - tree-shaking) 3.3 KB (0%) 67 ms (0%) 645 ms (+245.24% 🔺) 711 ms
viem/accounts 73.9 KB (0%) 1.5 s (0%) 3.4 s (-24.96% 🔽) 4.9 s
viem/accounts (tree-shaking) 19.17 KB (0%) 384 ms (0%) 2.6 s (-6.83% 🔽) 3 s
viem/actions 41.72 KB (0%) 835 ms (0%) 2.9 s (-36.69% 🔽) 3.7 s
viem/actions (tree-shaking) 318 B (0%) 10 ms (0%) 30 ms (-32.45% 🔽) 40 ms
viem/chains 27.85 KB (0%) 557 ms (0%) 6.2 s (+32.62% 🔺) 6.8 s
viem/chains (tree-shaking) 324 B (0%) 10 ms (0%) 33 ms (-21.03% 🔽) 43 ms
viem/chains/utils 1.02 KB (0%) 21 ms (0%) 75 ms (+7.55% 🔺) 95 ms
viem/ens 41.72 KB (0%) 835 ms (0%) 3 s (-24.49% 🔽) 3.8 s
viem/ens (tree-shaking) 18.41 KB (0%) 369 ms (0%) 1.4 s (-70.86% 🔽) 1.7 s

Copy link

codecov bot commented May 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.69%. Comparing base (f3d77e7) to head (a04e683).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2298      +/-   ##
==========================================
- Coverage   99.70%   99.69%   -0.01%     
==========================================
  Files         680      680              
  Lines       57684    57692       +8     
  Branches     2749     2749              
==========================================
+ Hits        57511    57518       +7     
  Misses        156      156              
- Partials       17       18       +1     

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

@tmm tmm changed the title tmm/node export fix fix: viem/node esm/cjs conflict May 23, 2024
@tmm tmm marked this pull request as ready for review May 23, 2024 19:45
@jxom jxom merged commit 601cb74 into main May 23, 2024
14 of 20 checks passed
@jxom jxom deleted the tmm/node-export-fix branch May 23, 2024 21:02
@github-actions github-actions bot mentioned this pull request May 23, 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.

bug: cannot import ipc anymore
2 participants