Unverified Commit f54e05f7 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

[Fast Refresh] Reorder Loaders (#12671)

parent 92edfb95
......@@ -765,15 +765,15 @@ export default async function getBaseWebpackConfig(
workerParallelJobs: Infinity,
},
},
defaultLoaders.babel,
hasReactRefresh
? require.resolve('@next/react-refresh-utils/loader')
: '',
defaultLoaders.babel,
].filter(Boolean)
: hasReactRefresh
? [
defaultLoaders.babel,
require.resolve('@next/react-refresh-utils/loader'),
defaultLoaders.babel,
]
: defaultLoaders.babel,
},
......
......@@ -565,3 +565,43 @@ test('boundaries', async () => {
await cleanup()
})
test('unterminated JSX', async () => {
const [session, cleanup] = await sandbox()
await session.patch(
'index.js',
`
export default () => {
return (
<div>
<p>lol</p>
</div>
)
}
`
)
expect(await session.hasRedbox()).toBe(false)
await session.patch(
'index.js',
`
export default () => {
return (
<div>
<p>lol</p>
div
)
}
`
)
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
expect(source).not.toMatch('Unexpected token')
expect(source).toMatch('Unterminated JSX contents')
await cleanup()
})
......@@ -134,8 +134,20 @@ export async function sandbox(id = nanoid(), initialFiles = new Map()) {
} while (expected)
return false
},
async getRedboxSource() {
return this.evaluate(() => {
async getRedboxSource(includeHeader = false) {
const header = includeHeader
? await this.evaluate(() => {
const portal = [].slice
.call(document.querySelectorAll('nextjs-portal'))
.find(p =>
p.shadowRoot.querySelector('[data-nextjs-dialog-header')
)
const root = portal.shadowRoot
return root.querySelector('[data-nextjs-dialog-header]').innerText
})
: ''
const source = await this.evaluate(() => {
const portal = [].slice
.call(document.querySelectorAll('nextjs-portal'))
.find(p =>
......@@ -148,6 +160,11 @@ export async function sandbox(id = nanoid(), initialFiles = new Map()) {
'[data-nextjs-codeframe], [data-nextjs-terminal]'
).innerText
})
if (includeHeader) {
return `${header}\n\n${source}`
}
return source
},
},
function cleanup() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment