-
Notifications
You must be signed in to change notification settings - Fork 232
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: circumvent issues with ESM process polyfills #543
base: main
Are you sure you want to change the base?
Conversation
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 for opening a PR! Can you please add a unit test?
Sorry for the delay! I've added the task |
This is strange- despite using the reprex as a reference, the test does not break when commenting out the patching functionality of the shim introduced by this PR. It's possible that the issue only crops up when the Vite source is TypeScript, since that's the only obvious difference. I may have to consider updating the test to use TypeScript- or perhaps throw this all out and consider it a TypeScript issue. EDIT: Or maybe Vite is caching the version of EDIT 2: Made the apparent version change randomly from run to run in an attempt to bust any caches that may exist; same behavior. |
@WasabiThumb any update? |
Moving this along would require writing a test that would actually fail without the fix, perhaps by converting the existing test's Vite source to TypeScript as that is a likely component of this issue and seems to be present whenever it's reported. Since I'm not actively developing the project in which I ran into this issue right now, it might be a while until I am able to do that myself. If you want to get ahead of it, you can fork my repo and PR a test/modify the existing test such that it demonstrates this behavior; then I'll happily resolve the conflicts and request a review. |
@mcollina isn't there any way you can alleviate the blockage of this PR. readable-stream doesn't work with vite based esm builds... |
I have no time to volunteer to work on a comprehensive test suite for this bug. Without it, we'll keep releasing versions after versions to chase all the different tool combinations. If you are writing on behalf of a company and would like to sponsor this work, ping me via email. |
@mcollina can't you just release it as a beta version? no need for the test suite, I can test the beta version in my app directly. |
@mesqueeb You can always fork the package, or use something like patch-package to apply patches directly to the Or even better, since you apparently ran into this issue yourself: try to make a minimal reproduction case that we can use for the test! 😉 As you can read in the thread, we're struggling to make a good test for this, so any help with that would be appreciated. |
Would resolve #539. This is a hacky solution that may preferrably be made obsolete by resolution of davidmyersdev/vite-plugin-node-polyfills#106.
The root issue is that some
node:process
polyfills export an ES module that is not unwrapped at runtime. This change would introduce a patch that conditionally unwraps the module in the event that checks pass indicating that it is wrapped. Those checks are:require("node:process")["__esModule"] === true
"nextTick" in require("node:process")["default"] || "nextTick" in require("node:process")["process"]
default
orprocess
property of the import is indeed intended to polyfillnode:process
. The choice ofnextTick
here is arbitrary, however the method would be required for proper function of this package.This also inherits the curiosity introduced by #497 where
node:process
is imported viaprocess/
.