Skip to content

Commit 49114b9

Browse files
authored
fix: polyfill fetch before running any app code (sveltejs#3400)
1 parent 02a12af commit 49114b9

File tree

9 files changed

+20
-11
lines changed

9 files changed

+20
-11
lines changed

.changeset/strong-owls-jam.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@sveltejs/adapter-netlify': patch
3+
'@sveltejs/adapter-node': patch
4+
'@sveltejs/adapter-vercel': patch
5+
---
6+
7+
Polyfill fetch before running any app code

packages/adapter-netlify/rollup.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import json from '@rollup/plugin-json';
55
export default [
66
{
77
input: {
8-
handler: 'src/handler.js'
8+
handler: 'src/handler.js',
9+
shims: 'src/shims.js'
910
},
1011
output: [
1112
{

packages/adapter-netlify/src/handler.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { __fetch_polyfill } from '@sveltejs/kit/install-fetch';
1+
import './shims';
22
import { App } from './server/app.js';
33

4-
__fetch_polyfill();
5-
64
/**
75
*
86
* @param {import('@sveltejs/kit').SSRManifest} manifest

packages/adapter-netlify/src/shims.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { __fetch_polyfill } from '@sveltejs/kit/install-fetch';
2+
__fetch_polyfill();

packages/adapter-node/rollup.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export default [
66
{
77
input: {
88
index: 'src/index.js',
9-
handler: 'src/handler.js'
9+
handler: 'src/handler.js',
10+
shims: 'src/shims.js'
1011
},
1112
output: {
1213
dir: 'files',

packages/adapter-node/src/handler.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1+
import './shims';
12
import fs from 'fs';
23
import path from 'path';
34
import sirv from 'sirv';
45
import { fileURLToPath } from 'url';
56
import { getRawBody } from '@sveltejs/kit/node';
6-
import { __fetch_polyfill } from '@sveltejs/kit/install-fetch';
77

88
// @ts-ignore
99
import { App } from 'APP';
1010
import { manifest } from 'MANIFEST';
1111

12-
__fetch_polyfill();
13-
1412
const app = new App(manifest);
1513

1614
const __dirname = path.dirname(fileURLToPath(import.meta.url));

packages/adapter-node/src/shims.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { __fetch_polyfill } from '@sveltejs/kit/install-fetch';
2+
__fetch_polyfill();

packages/adapter-vercel/files/entry.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { __fetch_polyfill } from '@sveltejs/kit/install-fetch';
1+
import './shims';
22
import { getRawBody } from '@sveltejs/kit/node';
33
import { App } from 'APP';
44
import { manifest } from 'MANIFEST';
55

6-
__fetch_polyfill();
7-
86
const app = new App(manifest);
97

108
export default async (req, res) => {
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { __fetch_polyfill } from '@sveltejs/kit/install-fetch';
2+
__fetch_polyfill();

0 commit comments

Comments
 (0)