Skip to content

Move server-side fetch responsibility to adapters instead of build step#1066

Merged
Rich-Harris merged 4 commits intomasterfrom
alt-native-fetch
Apr 17, 2021
Merged

Move server-side fetch responsibility to adapters instead of build step#1066
Rich-Harris merged 4 commits intomasterfrom
alt-native-fetch

Conversation

@GrygrFlzr
Copy link
Copy Markdown
Member

@GrygrFlzr GrygrFlzr commented Apr 17, 2021

Alternative PR to #1034.

Notes:

  • Use of fetch inside server endpoints - do we want to re-export node-fetch or is this a userland problem?
    Endpoints now have de-facto access to global fetch
  • Begin adapter still needs major updates so I haven't touched it

@Rich-Harris
Copy link
Copy Markdown
Member

This is great. We also need global fetch in sveltekit-start (the tests were passing because they run build then start in the same process, but if you build an app then run start, it fails), so I moved the logic into a separate node-fetch-global.js module to DRY things out rather than repeating them a third time.

I almost wonder if we should expose that module to adapters somehow, rather than expecting them all to include that block correctly. It would also prevent things like version mismatches between dev and prod.

Re userland, I think it's solved by this PR? If fetch is available as a global to SvelteKit itself, then it's also available to endpoints. I've removed node-fetch from the realworld and HN examples accordingly.

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.

adapter-cfw: server-side fetch fails due to dependency on Node's util.types

2 participants