kit
kit copied to clipboard
Add ability to disable Node polyfills
Describe the problem
We've been using Mock Service Worker to mock out requests to our backend. We use the Node interceptor for it so that the mocks work in both SSR and on the client. However, when we recently started updating our SvelteKit version, we noticed that this stopped working. We think that this is due to the Undici polyfill, which appears to completely avoid standard global Node modules like http
and https
.
In addition, the error logs for these mocked libraries and significantly harder to read and debug, as they use a few tricks for scheduling that make the original call site difficult to find.
Describe the proposed solution
Modern versions of Node (e.g. Node 18) have all of the mocked libraries available as globals by default, so there is no need to mock them. I propose either adding an option to disable the polyfills manually, or ignoring the polyfill if a global version exists already.
Alternatives considered
None
Importance
would make my life easier
Additional Information
No response
For reference, Node 18 has been available since April, 2022. However, AWS Lambda does not yet support Node 18. Based on past history, it usually takes them about a year to add support.
Re-opening — #7668 caused #7673
(we should add a multipart test before attempting this again)
After discussion, we agreed to add a polyfill: false
option (or similar) to adapter-node
, so that the polyfills can be excluded from server code altogether where applicable.
Removing from the 1.0 milestone since this update won't affect Kit itself
For reference, Node 18 has been available since April, 2022. However, AWS Lambda does not yet support Node 18. Based on past history, it usually takes them about a year to add support.
Looks like AWS Lambda now supports node 18
I just tried Netlify. It still uses Node 16 by default, but does support Node 18.
After discussion, we agreed to add a
polyfill: false
option (or similar) toadapter-node
, so that the polyfills can be excluded from server code altogether where applicable.
We are using adapter-cloudflare-workers
where this is happening - can we also have an option to disable polyfills there?
adapter-cloudflare-workers
doesn't add polyfills. You must be experiencing something else