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

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

Merged
merged 4 commits into from
Apr 17, 2021

Conversation

GrygrFlzr
Copy link
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
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