[ci] format

This commit is contained in:
matthewp 2022-04-21 16:11:09 +00:00 committed by github-actions[bot]
parent ae9ac5cbdc
commit 8768f23f95
5 changed files with 30 additions and 29 deletions

View file

@ -26,7 +26,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
vite.resolve = vite.resolve || {};
vite.resolve.alias = vite.resolve.alias || {};
const alias = vite.resolve.alias as Record<string, string>;
alias['react-dom/server'] = 'react-dom/server.browser'
alias['react-dom/server'] = 'react-dom/server.browser';
vite.ssr = {
noExternal: true,
};

View file

@ -14,7 +14,7 @@ Deno.test({
const html = await resp.text();
assert(html);
const doc = new DOMParser().parseFromString(html, `text/html`);
const div = doc.querySelector("#react");
const div = doc.querySelector('#react');
assert(div, 'div exists');
});
},

View file

@ -89,7 +89,7 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
vite.resolve = vite.resolve || {};
vite.resolve.alias = vite.resolve.alias || {};
const alias = vite.resolve.alias as Record<string, string>;
alias['react-dom/server'] = 'react-dom/server.browser'
alias['react-dom/server'] = 'react-dom/server.browser';
vite.ssr = {
noExternal: true,
};

View file

@ -8,9 +8,7 @@ Deno.test({
name: 'Edge Basics',
async fn() {
let close = await runBuild('./fixtures/edge-basic/');
const { default: handler } = await import(
'./fixtures/edge-basic/dist/edge-functions/entry.js'
);
const { default: handler } = await import('./fixtures/edge-basic/dist/edge-functions/entry.js');
const response = await handler(new Request('http://example.com/'));
assertEquals(response.status, 200);
const html = await response.text();

View file

@ -65,18 +65,17 @@ async function renderToStaticMarkup(Component, props, children, metadata) {
let html;
if (metadata && metadata.hydrate) {
html = ReactDOM.renderToString(vnode);
if('renderToReadableStream' in ReactDOM) {
if ('renderToReadableStream' in ReactDOM) {
html = await renderToReadableStreamAsync(vnode);
} else {
html = await renderToPipeableStreamAsync(vnode);
}
} else {
if('renderToReadableStream' in ReactDOM) {
if ('renderToReadableStream' in ReactDOM) {
html = await renderToReadableStreamAsync(vnode);
} else {
html = await renderToStaticNodeStreamAsync(vnode);
}
}
return { html };
}
@ -92,16 +91,18 @@ async function renderToPipeableStreamAsync(vnode) {
reject(error);
},
onAllReady() {
stream.pipe(new Writable({
write(chunk, _encoding, callback) {
html += chunk.toString('utf-8');
callback();
},
destroy() {
resolve(html);
}
}));
}
stream.pipe(
new Writable({
write(chunk, _encoding, callback) {
html += chunk.toString('utf-8');
callback();
},
destroy() {
resolve(html);
},
})
);
},
});
});
}
@ -111,15 +112,17 @@ async function renderToStaticNodeStreamAsync(vnode) {
let html = '';
return new Promise((resolve) => {
let stream = ReactDOM.renderToStaticNodeStream(vnode);
stream.pipe(new Writable({
write(chunk, _encoding, callback) {
html += chunk.toString('utf-8');
callback();
},
destroy() {
resolve(html);
}
}));
stream.pipe(
new Writable({
write(chunk, _encoding, callback) {
html += chunk.toString('utf-8');
callback();
},
destroy() {
resolve(html);
},
})
);
});
}
@ -127,7 +130,7 @@ async function renderToReadableStreamAsync(vnode) {
const decoder = new TextDecoder();
const stream = await ReactDOM.renderToReadableStream(vnode);
let html = '';
for await(const chunk of stream) {
for await (const chunk of stream) {
html += decoder.decode(chunk);
}
return html;