-
Notifications
You must be signed in to change notification settings - Fork 27.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SWC dynamic transform with suspense but without ssr (#36825)
The Babel plugin works fine, so it seems not a runtime issue. fixes #36636
- Loading branch information
1 parent
31a538d
commit c7f2c63
Showing
6 changed files
with
105 additions
and
6 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
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
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { createNext } from 'e2e-utils' | ||
import { NextInstance } from 'test/lib/next-modes/base' | ||
import { hasRedbox, renderViaHTTP } from 'next-test-utils' | ||
import webdriver from 'next-webdriver' | ||
|
||
const suite = | ||
process.env.NEXT_TEST_REACT_VERSION === '^17' ? describe.skip : describe | ||
|
||
// Skip the suspense test if react version is 17 | ||
suite('dynamic with suspense', () => { | ||
let next: NextInstance | ||
|
||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: { | ||
'pages/index.js': ` | ||
import { Suspense } from "react"; | ||
import dynamic from "next/dynamic"; | ||
const Thing = dynamic(() => import("./thing"), { ssr: false, suspense: true }); | ||
export default function IndexPage() { | ||
return ( | ||
<div> | ||
<p>Next.js Example</p> | ||
<Suspense fallback="Loading..."> | ||
<Thing /> | ||
</Suspense> | ||
</div> | ||
); | ||
} | ||
`, | ||
'pages/thing.js': ` | ||
export default function Thing() { | ||
return "Thing"; | ||
} | ||
`, | ||
}, | ||
dependencies: {}, | ||
}) | ||
}) | ||
afterAll(() => next.destroy()) | ||
|
||
it('should render server-side', async () => { | ||
const html = await renderViaHTTP(next.url, '/') | ||
expect(html).toContain('Next.js Example') | ||
expect(html).toContain('Thing') | ||
}) | ||
|
||
it('should render client-side', async () => { | ||
const browser = await webdriver(next.url, '/') | ||
expect(await hasRedbox(browser)).toBe(false) | ||
await browser.close() | ||
}) | ||
}) |