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

Add ability to disable Node polyfills #7374

Closed
pzuraq opened this issue Oct 24, 2022 · 9 comments · Fixed by #8991
Closed

Add ability to disable Node polyfills #7374

pzuraq opened this issue Oct 24, 2022 · 9 comments · Fixed by #8991
Labels
Milestone

Comments

@pzuraq
Copy link
Contributor

pzuraq commented Oct 24, 2022

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

@pzuraq pzuraq changed the title Add ability to disable polyfills Add ability to disable Node polyfills Oct 24, 2022
@benmccann
Copy link
Member

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.

@Rich-Harris
Copy link
Member

Re-opening — #7668 caused #7673

@Rich-Harris Rich-Harris reopened this Nov 16, 2022
@Rich-Harris
Copy link
Member

(we should add a multipart test before attempting this again)

@Rich-Harris
Copy link
Member

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.

@Rich-Harris
Copy link
Member

Removing from the 1.0 milestone since this update won't affect Kit itself

@Rich-Harris Rich-Harris modified the milestones: 1.0, whenever Nov 27, 2022
@bluwy
Copy link
Member

bluwy commented Nov 29, 2022

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

@benmccann
Copy link
Member

I just tried Netlify. It still uses Node 16 by default, but does support Node 18.

@chronicIntrovert
Copy link

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.

We are using adapter-cloudflare-workers where this is happening - can we also have an option to disable polyfills there?

@Rich-Harris
Copy link
Member

adapter-cloudflare-workers doesn't add polyfills. You must be experiencing something else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants