Skip to content

Commit c9bf832

Browse files
committed
undo: globalThis.fetch defined in preact-iso
1 parent ca955f5 commit c9bf832

File tree

1 file changed

+0
-15
lines changed

1 file changed

+0
-15
lines changed

prerender.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,13 @@ import { h, options, cloneElement } from 'preact';
22
import renderToString from 'preact-render-to-string';
33

44
let vnodeHook;
5-
let initialized = false;
65

76
const old = options.vnode;
87
options.vnode = vnode => {
98
if (old) old(vnode);
109
if (vnodeHook) vnodeHook(vnode);
1110
};
1211

13-
async function init() {
14-
const fs = (await eval('u=>import(u)')('fs')).promises;
15-
// eslint-disable-next-line no-undef
16-
globalThis.fetch = async url => {
17-
const text = () => fs.readFile('dist/' + String(url).replace(/^\//, ''), 'utf-8');
18-
return { text, json: () => text().then(JSON.parse) };
19-
};
20-
}
21-
2212
/**
2313
* @param {ReturnType<h>} vnode The root JSX element to render (eg: `<App />`)
2414
* @param {object} [options]
@@ -28,11 +18,6 @@ async function init() {
2818
export default async function prerender(vnode, options) {
2919
options = options || {};
3020

31-
if (!initialized) {
32-
initialized = true;
33-
await init();
34-
}
35-
3621
const maxDepth = options.maxDepth || 10;
3722
const props = options.props;
3823
let tries = 0;

0 commit comments

Comments
 (0)