From 8768f23f95840f3b66504fc2ecb39678c986cbe8 Mon Sep 17 00:00:00 2001 From: matthewp Date: Thu, 21 Apr 2022 16:11:09 +0000 Subject: [PATCH] [ci] format --- packages/integrations/deno/src/index.ts | 2 +- .../integrations/deno/test/basics.test.js | 2 +- .../netlify/src/integration-edge-functions.ts | 2 +- .../test/edge-functions/edge-basic.test.ts | 4 +- packages/integrations/react/server.js | 49 ++++++++++--------- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/packages/integrations/deno/src/index.ts b/packages/integrations/deno/src/index.ts index f0658f2c8..3959e63a8 100644 --- a/packages/integrations/deno/src/index.ts +++ b/packages/integrations/deno/src/index.ts @@ -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; - alias['react-dom/server'] = 'react-dom/server.browser' + alias['react-dom/server'] = 'react-dom/server.browser'; vite.ssr = { noExternal: true, }; diff --git a/packages/integrations/deno/test/basics.test.js b/packages/integrations/deno/test/basics.test.js index 42efc87d9..bc7322067 100644 --- a/packages/integrations/deno/test/basics.test.js +++ b/packages/integrations/deno/test/basics.test.js @@ -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'); }); }, diff --git a/packages/integrations/netlify/src/integration-edge-functions.ts b/packages/integrations/netlify/src/integration-edge-functions.ts index b76617f1e..08835bd26 100644 --- a/packages/integrations/netlify/src/integration-edge-functions.ts +++ b/packages/integrations/netlify/src/integration-edge-functions.ts @@ -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; - alias['react-dom/server'] = 'react-dom/server.browser' + alias['react-dom/server'] = 'react-dom/server.browser'; vite.ssr = { noExternal: true, }; diff --git a/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts b/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts index 0b29fc1a9..e7b720900 100644 --- a/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts +++ b/packages/integrations/netlify/test/edge-functions/edge-basic.test.ts @@ -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(); diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js index b41492a7a..776901563 100644 --- a/packages/integrations/react/server.js +++ b/packages/integrations/react/server.js @@ -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;