-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes using React.lazy and Suspense (#3160)
* Revert "Revert "Fixes using React.lazy and Suspense"" This reverts commit e621c2f. * Adds a changeset * Fix ts errors * Remove netlify metadata folder
- Loading branch information
Showing
21 changed files
with
183 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@astrojs/deno': patch | ||
'@astrojs/netlify': patch | ||
'@astrojs/react': patch | ||
--- | ||
|
||
Allows using React.lazy, Suspense in SSR and with hydration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ package-lock.json | |
*.env | ||
|
||
!packages/astro/vendor/vite/dist | ||
packages/integrations/**/.netlify/ |
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/react-component/src/components/LazyComponent.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
export const LazyComponent = () => { | ||
return ( | ||
<span id="lazy">inner content</span> | ||
); | ||
}; | ||
|
||
export default LazyComponent; |
14 changes: 14 additions & 0 deletions
14
packages/astro/test/fixtures/react-component/src/components/Suspense.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React, { Suspense } from 'react'; | ||
const LazyComponent = React.lazy(() => import('./LazyComponent.jsx')); | ||
|
||
export const ParentComponent = () => { | ||
return ( | ||
<div id="outer"> | ||
<Suspense> | ||
<LazyComponent /> | ||
</Suspense> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ParentComponent; |
17 changes: 17 additions & 0 deletions
17
packages/astro/test/fixtures/react-component/src/pages/suspense.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
import Suspense from '../components/Suspense.jsx'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<!-- Head Stuff --> | ||
</head> | ||
<body> | ||
<div id="client"> | ||
<Suspense client:load /> | ||
</div> | ||
<div id="server"> | ||
<Suspense /> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/integrations/deno/test/fixtures/basics/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/integrations/deno/test/fixtures/basics/src/components/React.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
export default function() { | ||
return ( | ||
<div id="react">testing</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// @ts-nocheck | ||
export { fromFileUrl } from 'https://deno.land/[email protected]/path/mod.ts'; | ||
export { assertEquals, assert } from 'https://deno.land/[email protected]/testing/asserts.ts'; | ||
export * from 'https://deno.land/x/deno_dom/deno-dom-wasm.ts'; |
9 changes: 7 additions & 2 deletions
9
packages/integrations/netlify/test/edge-functions/edge-basic.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
// @ts-ignore | ||
import { runBuild } from './test-utils.ts'; | ||
// @ts-ignore | ||
import { assertEquals, assert } from './deps.ts'; | ||
import { assertEquals, assert, DOMParser } from './deps.ts'; | ||
|
||
// @ts-ignore | ||
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.mjs' | ||
'./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(); | ||
assert(html, 'got some html'); | ||
|
||
const doc = new DOMParser().parseFromString(html, `text/html`)!; | ||
const div = doc.querySelector('#react'); | ||
assert(div, 'div exists'); | ||
|
||
await close(); | ||
}, | ||
}); |
2 changes: 2 additions & 0 deletions
2
packages/integrations/netlify/test/edge-functions/fixtures/edge-basic/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...ges/integrations/netlify/test/edge-functions/fixtures/edge-basic/src/components/React.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
|
||
export default function() { | ||
return ( | ||
<div id="react">testing</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.