-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
refactor: replace isomorphic-ws with unws
#390
Conversation
|
@sxzz is attempting to deploy a commit to the wagmi Team on Vercel. A member of the Team first needs to authorize it. |
Hm. We are already doing the import dynamically. So why not just do the differentiation ourselve within |
@fubhy Good idea |
@fubhy I tried that. But unfortunately, Webpack cannot be aware that
|
Too bad :-(. Thanks for trying though. |
i've tried to riff around this issue, here's a log coming out of this code in Vite typescript environment with allowSyntheticDefaultImports = true and esModuleInterop = true (just for the kicks) const WebSocket2 = await import('isomorphic-ws')
const { WebSocket } = await import('isomorphic-ws')
console.log(window.WebSocket) // ƒ WebSocket() { [native code] }
console.log(WebSocket2) // Module {Symbol(Symbol.toStringTag): 'Module'}
console.log(WebSocket) // undefined i was wondering however if |
Yeah that could be related. Our vitest test suite runs only in node environment atm. which isn't ideal. I've also discussed with @tmm and @jxom to add consumer acceptance tests by adding a few different example packages with different setups, environments, bundlers, typescript version, etc. and seeing if they compile & run properly. |
checked, unws. seems to working properly. package.json includes cjs, esModules and typescript d.ts with that said, i think the core issue is that https://github.com/wagmi-dev/viem/blob/136c4022c3ab4020f37333876bed788a111bff47/src/utils/rpc.ts#L147 doesn't use default export check https://github.com/heineiuo/isomorphic-ws/blob/master/browser.js |
Right. We should probably completely remove the |
Vite or Rollup is an ES module bundler and it will strictly treat the modules. It won't convert or interop the code by default. But webpack will. All in all, Webpack has more compatibility and Vite respects the specs more (even though some specs are very weird) |
Yeah exactly. We should follow the strictest possible setup. 100% agree. |
are we good with @sxzz solution? can we merge this? |
@fubhy seems that |
FYI interopDefault is extremely complicated. See the table https://sokra.github.io/interop-test/ |
It might not be necessary for vite projects. I just noticed that it was enabled and it imho shouldn't be. Libraries shouldn't assume any interop whatsoever imho.
Yeah. I deep dived into that very topic not long ago as I was bumping a few of my own projects to TS5, NodeNext, etc. and revamped the build setup along the way. Complicated indeed. |
@fubhy I just checked. There's no import default or export default in viem codebase. So I guess it won't change anything, so we can safely disable this option. Done. |
Yeah. It'd basically act as a safe guard to prevent us from introducing sth. like that down the line by accident. I already opened #391 :) |
@fubhy Oh I revert my commit. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## main #390 +/- ##
==========================================
- Coverage 99.93% 95.22% -4.71%
==========================================
Files 270 267 -3
Lines 22974 22335 -639
Branches 1963 1748 -215
==========================================
- Hits 22958 21269 -1689
- Misses 16 1060 +1044
- Partials 0 6 +6
|
Let's put this PR on hold for now as |
@sxzz @jxom i'm still having issues transpiling with this is reproducible by cloning https://github.com/GMX-Blueberry-Club/Puppet building by running
|
same problem. any solutions? |
unws (https://github.com/sxzz/unws) is designed for modern browsers and bundlers.
isomorphic-ws
is a lack of active maintenance, see heineiuo/isomorphic-ws#33PR-Codex overview
This PR updates the
ws
package to version 8.12.0 and replacesisomorphic-ws
withunws
. It also updates theabitype
package to version 0.7.1.Detailed summary
ws
package to version 8.12.0isomorphic-ws
withunws
abitype
package to version 0.7.1.