Unverified Commit 0060de1c authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Reapply "Turbopack: convert between locations correctly (#61477)" (#61733) (#61735)

This reverts commit a32d654c.


Closes PACK-2421
parent ad15817f
...@@ -791,7 +791,9 @@ pub fn project_update_info_subscribe( ...@@ -791,7 +791,9 @@ pub fn project_update_info_subscribe(
#[derive(Debug)] #[derive(Debug)]
#[napi(object)] #[napi(object)]
pub struct StackFrame { pub struct StackFrame {
// 1-indexed, unlike source map tokens
pub column: Option<u32>, pub column: Option<u32>,
// 1-indexed, unlike source map tokens
pub file: String, pub file: String,
pub is_server: bool, pub is_server: bool,
pub line: u32, pub line: u32,
...@@ -876,7 +878,10 @@ pub async fn project_trace_source( ...@@ -876,7 +878,10 @@ pub async fn project_trace_source(
}; };
let token = map let token = map
.lookup_token(frame.line as usize, frame.column.unwrap_or(0) as usize) .lookup_token(
(frame.line as usize).saturating_sub(1),
(frame.column.unwrap_or(1) as usize).saturating_sub(1),
)
.await? .await?
.clone_value() .clone_value()
.context("Unable to trace token from sourcemap")?; .context("Unable to trace token from sourcemap")?;
...@@ -893,8 +898,8 @@ pub async fn project_trace_source( ...@@ -893,8 +898,8 @@ pub async fn project_trace_source(
Ok(Some(StackFrame { Ok(Some(StackFrame {
file: source_file.to_string(), file: source_file.to_string(),
method_name: token.name, method_name: token.name,
line: token.original_line as u32, line: token.original_line as u32 + 1,
column: Some(token.original_column as u32), column: Some(token.original_column as u32 + 1),
is_server: frame.is_server, is_server: frame.is_server,
})) }))
}) })
......
...@@ -507,8 +507,18 @@ export interface Issue { ...@@ -507,8 +507,18 @@ export interface Issue {
content?: string content?: string
} }
range?: { range?: {
start: { line: number; column: number } start: {
end: { line: number; column: number } // 0-indexed
line: number
// 0-indexed
column: number
}
end: {
// 0-indexed
line: number
// 0-indexed
column: number
}
} }
} }
documentationLink: string documentationLink: string
......
...@@ -339,7 +339,7 @@ async function startWatcher(opts: SetupOpts) { ...@@ -339,7 +339,7 @@ async function startWatcher(opts: SetupOpts) {
if (source && source.range) { if (source && source.range) {
const { start } = source.range const { start } = source.range
message = `${formattedFilePath}:${start.line + 1}:${ message = `${formattedFilePath}:${start.line + 1}:${
start.column start.column + 1
}\n${formattedTitle}` }\n${formattedTitle}`
} else if (formattedFilePath) { } else if (formattedFilePath) {
message = `${formattedFilePath}\n${formattedTitle}` message = `${formattedFilePath}\n${formattedTitle}`
......
...@@ -16,7 +16,9 @@ interface Project { ...@@ -16,7 +16,9 @@ interface Project {
} }
interface TurbopackStackFrame { interface TurbopackStackFrame {
// 1-based
column: number | null column: number | null
// 1-based
file: string file: string
isServer: boolean isServer: boolean
line: number line: number
...@@ -87,7 +89,7 @@ export async function createOriginalStackFrame( ...@@ -87,7 +89,7 @@ export async function createOriginalStackFrame(
{ {
start: { start: {
line: traced.frame.lineNumber, line: traced.frame.lineNumber,
column: traced.frame.column ?? 0, column: traced.frame.column ?? 1,
}, },
}, },
{ forceColor: true } { forceColor: true }
......
...@@ -194,6 +194,7 @@ export async function createOriginalStackFrame({ ...@@ -194,6 +194,7 @@ export async function createOriginalStackFrame({
return moduleNotFoundResult return moduleNotFoundResult
} }
// This returns 1-based lines and 0-based columns
return await findOriginalSourcePositionAndContent(source, { return await findOriginalSourcePositionAndContent(source, {
line, line,
column, column,
...@@ -225,7 +226,7 @@ export async function createOriginalStackFrame({ ...@@ -225,7 +226,7 @@ export async function createOriginalStackFrame({
? path.relative(rootDirectory, filePath) ? path.relative(rootDirectory, filePath)
: sourcePosition.source, : sourcePosition.source,
lineNumber: sourcePosition.line, lineNumber: sourcePosition.line,
column: sourcePosition.column, column: (sourcePosition.column ?? 0) + 1,
methodName: methodName:
sourcePosition.name || sourcePosition.name ||
// default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export // default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export
...@@ -245,7 +246,7 @@ export async function createOriginalStackFrame({ ...@@ -245,7 +246,7 @@ export async function createOriginalStackFrame({
{ {
start: { start: {
line: sourcePosition.line, line: sourcePosition.line,
column: sourcePosition.column ?? 0, column: (sourcePosition.column ?? 0) + 1,
}, },
}, },
{ forceColor: true } { forceColor: true }
......
...@@ -52,7 +52,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -52,7 +52,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
expect(await session.hasRedbox()).toBe(true) expect(await session.hasRedbox()).toBe(true)
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./node_modules/my-package/index.js:1:12 "./node_modules/my-package/index.js:1:13
Module not found: Can't resolve 'dns' Module not found: Can't resolve 'dns'
> 1 | const dns = require('dns') > 1 | const dns = require('dns')
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
...@@ -62,7 +62,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -62,7 +62,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`) `)
} else { } else {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./node_modules/my-package/index.js:1:12 "./node_modules/my-package/index.js:1:13
Module not found: Can't resolve 'dns' Module not found: Can't resolve 'dns'
https://nextjs.org/docs/messages/module-not-found https://nextjs.org/docs/messages/module-not-found
...@@ -98,7 +98,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -98,7 +98,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
const source = await session.getRedboxSource() const source = await session.getRedboxSource()
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./index.js:1:0 "./index.js:1:1
Module not found: Can't resolve 'b' Module not found: Can't resolve 'b'
> 1 | import Comp from 'b' > 1 | import Comp from 'b'
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
...@@ -110,9 +110,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -110,9 +110,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`) `)
} else { } else {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./index.js:1:0 "./index.js:1:1
Module not found: Can't resolve 'b' Module not found: Can't resolve 'b'
> 1 | import Comp from 'b' > 1 | import Comp from 'b'
| ^
2 | export default function Oops() { 2 | export default function Oops() {
3 | return ( 3 | return (
4 | <div> 4 | <div>
...@@ -150,7 +151,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -150,7 +151,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
const source = await session.getRedboxSource() const source = await session.getRedboxSource()
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./app/page.js:2:0 "./app/page.js:2:1
Module not found: Can't resolve 'b' Module not found: Can't resolve 'b'
1 | 'use client' 1 | 'use client'
> 2 | import Comp from 'b' > 2 | import Comp from 'b'
...@@ -163,10 +164,11 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -163,10 +164,11 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`) `)
} else { } else {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./app/page.js:2:0 "./app/page.js:2:1
Module not found: Can't resolve 'b' Module not found: Can't resolve 'b'
1 | 'use client' 1 | 'use client'
> 2 | import Comp from 'b' > 2 | import Comp from 'b'
| ^
3 | export default function Oops() { 3 | export default function Oops() {
4 | return ( 4 | return (
5 | <div> 5 | <div>
...@@ -199,7 +201,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -199,7 +201,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
const source = await session.getRedboxSource() const source = await session.getRedboxSource()
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./app/page.js:2:0 "./app/page.js:2:1
Module not found: Can't resolve './non-existent.css' Module not found: Can't resolve './non-existent.css'
1 | 'use client' 1 | 'use client'
> 2 | import './non-existent.css' > 2 | import './non-existent.css'
...@@ -212,10 +214,11 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -212,10 +214,11 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`) `)
} else { } else {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./app/page.js:2:0 "./app/page.js:2:1
Module not found: Can't resolve './non-existent.css' Module not found: Can't resolve './non-existent.css'
1 | 'use client' 1 | 'use client'
> 2 | import './non-existent.css' > 2 | import './non-existent.css'
| ^
3 | export default function Page(props) { 3 | export default function Page(props) {
4 | return <p>index page</p> 4 | return <p>index page</p>
5 | } 5 | }
......
...@@ -222,7 +222,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -222,7 +222,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
const source = next.normalizeTestDirContent(await session.getRedboxSource()) const source = next.normalizeTestDirContent(await session.getRedboxSource())
if (IS_TURBOPACK) { if (IS_TURBOPACK) {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./index.js:7:0 "./index.js:7:1
Parsing ecmascript source code failed Parsing ecmascript source code failed
5 | div 5 | div
6 | ) 6 | )
...@@ -357,7 +357,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -357,7 +357,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
expect(await session.hasRedbox()).toBe(true) expect(await session.hasRedbox()).toBe(true)
const source = await session.getRedboxSource() const source = await session.getRedboxSource()
expect(source).toMatch( expect(source).toMatch(
IS_TURBOPACK ? './index.module.css:1:8' : './index.module.css:1:1' IS_TURBOPACK ? './index.module.css:1:9' : './index.module.css:1:1'
) )
if (!IS_TURBOPACK) { if (!IS_TURBOPACK) {
expect(source).toMatch('Syntax error: ') expect(source).toMatch('Syntax error: ')
......
...@@ -11,9 +11,10 @@ Import trace for requested module: ...@@ -11,9 +11,10 @@ Import trace for requested module:
`; `;
exports[`ReactRefreshLogBox app default Import trace when module not found in layout 1`] = ` exports[`ReactRefreshLogBox app default Import trace when module not found in layout 1`] = `
"./app/module.js:1:0 "./app/module.js:1:1
Module not found: Can't resolve 'non-existing-module' Module not found: Can't resolve 'non-existing-module'
> 1 | import "non-existing-module" > 1 | import "non-existing-module"
| ^
https://nextjs.org/docs/messages/module-not-found https://nextjs.org/docs/messages/module-not-found
...@@ -22,7 +23,7 @@ Import trace for requested module: ...@@ -22,7 +23,7 @@ Import trace for requested module:
`; `;
exports[`ReactRefreshLogBox app default Should not show __webpack_exports__ when exporting anonymous arrow function 1`] = ` exports[`ReactRefreshLogBox app default Should not show __webpack_exports__ when exporting anonymous arrow function 1`] = `
"index.js (3:10) @ default "index.js (3:11) @ default
1 | export default () => { 1 | export default () => {
2 | if (typeof window !== 'undefined') { 2 | if (typeof window !== 'undefined') {
...@@ -34,14 +35,14 @@ exports[`ReactRefreshLogBox app default Should not show __webpack_exports__ when ...@@ -34,14 +35,14 @@ exports[`ReactRefreshLogBox app default Should not show __webpack_exports__ when
`; `;
exports[`ReactRefreshLogBox app default boundaries 1`] = ` exports[`ReactRefreshLogBox app default boundaries 1`] = `
"FunctionDefault.js (1:50) @ FunctionDefault "FunctionDefault.js (1:51) @ FunctionDefault
> 1 | export default function FunctionDefault() { throw new Error('no'); } > 1 | export default function FunctionDefault() { throw new Error('no'); }
| ^" | ^"
`; `;
exports[`ReactRefreshLogBox app default conversion to class component (1) 1`] = ` exports[`ReactRefreshLogBox app default conversion to class component (1) 1`] = `
"Child.js (4:10) @ ClickCount.render "Child.js (4:11) @ ClickCount.render
2 | export default class ClickCount extends Component { 2 | export default class ClickCount extends Component {
3 | render() { 3 | render() {
...@@ -76,7 +77,7 @@ exports[`ReactRefreshLogBox app default logbox: anchors links in error messages ...@@ -76,7 +77,7 @@ exports[`ReactRefreshLogBox app default logbox: anchors links in error messages
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 9`] = `"http://example.com/"`; exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 9`] = `"http://example.com/"`;
exports[`ReactRefreshLogBox app default module init error not shown 1`] = ` exports[`ReactRefreshLogBox app default module init error not shown 1`] = `
"index.js (3:6) @ eval "index.js (3:7) @ eval
1 | // top offset for snapshot 1 | // top offset for snapshot
2 | import * as React from 'react'; 2 | import * as React from 'react';
...@@ -88,7 +89,7 @@ exports[`ReactRefreshLogBox app default module init error not shown 1`] = ` ...@@ -88,7 +89,7 @@ exports[`ReactRefreshLogBox app default module init error not shown 1`] = `
`; `;
exports[`ReactRefreshLogBox app default should strip whitespace correctly with newline 1`] = ` exports[`ReactRefreshLogBox app default should strip whitespace correctly with newline 1`] = `
"index.js (7:14) @ onClick "index.js (7:15) @ onClick
5 | 5 |
6 | <a onClick={() => { 6 | <a onClick={() => {
...@@ -100,7 +101,7 @@ exports[`ReactRefreshLogBox app default should strip whitespace correctly with n ...@@ -100,7 +101,7 @@ exports[`ReactRefreshLogBox app default should strip whitespace correctly with n
`; `;
exports[`ReactRefreshLogBox app turbo Can't resolve @import in CSS file 1`] = ` exports[`ReactRefreshLogBox app turbo Can't resolve @import in CSS file 1`] = `
"./app/styles1.css:1:0 "./app/styles1.css:1:1
Parsing css source code failed Parsing css source code failed
> 1 | @import "./styles2.css" > 1 | @import "./styles2.css"
| ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^
...@@ -109,7 +110,7 @@ Unexpected end of file, but expected ';' or '{'" ...@@ -109,7 +110,7 @@ Unexpected end of file, but expected ';' or '{'"
`; `;
exports[`ReactRefreshLogBox app turbo Import trace when module not found in layout 1`] = ` exports[`ReactRefreshLogBox app turbo Import trace when module not found in layout 1`] = `
"./app/module.js:1:0 "./app/module.js:1:1
Module not found: Can't resolve 'non-existing-module' Module not found: Can't resolve 'non-existing-module'
> 1 | import "non-existing-module" > 1 | import "non-existing-module"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...@@ -118,7 +119,7 @@ https://nextjs.org/docs/messages/module-not-found" ...@@ -118,7 +119,7 @@ https://nextjs.org/docs/messages/module-not-found"
`; `;
exports[`ReactRefreshLogBox app turbo Should not show __webpack_exports__ when exporting anonymous arrow function 1`] = ` exports[`ReactRefreshLogBox app turbo Should not show __webpack_exports__ when exporting anonymous arrow function 1`] = `
"index.js (3:2) @ {default export} "index.js (3:11) @ {default export}
1 | export default () => { 1 | export default () => {
2 | if (typeof window !== 'undefined') { 2 | if (typeof window !== 'undefined') {
...@@ -130,9 +131,10 @@ exports[`ReactRefreshLogBox app turbo Should not show __webpack_exports__ when e ...@@ -130,9 +131,10 @@ exports[`ReactRefreshLogBox app turbo Should not show __webpack_exports__ when e
`; `;
exports[`ReactRefreshLogBox app turbo boundaries 1`] = ` exports[`ReactRefreshLogBox app turbo boundaries 1`] = `
"FunctionDefault.js (0:67) @ FunctionDefault "FunctionDefault.js (1:51) @ FunctionDefault
1 | export default function FunctionDefault() { throw new Error('no'); }" > 1 | export default function FunctionDefault() { throw new Error('no'); }
| ^"
`; `;
exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 1`] = `"Error: end http://nextjs.org"`; exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 1`] = `"Error: end http://nextjs.org"`;
...@@ -152,7 +154,7 @@ exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 8` ...@@ -152,7 +154,7 @@ exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 8`
exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 9`] = `"http://example.com/"`; exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 9`] = `"http://example.com/"`;
exports[`ReactRefreshLogBox app turbo module init error not shown 1`] = ` exports[`ReactRefreshLogBox app turbo module init error not shown 1`] = `
"index.js (3:6) @ <unknown> "index.js (3:7) @ <unknown>
1 | // top offset for snapshot 1 | // top offset for snapshot
2 | import * as React from 'react'; 2 | import * as React from 'react';
...@@ -164,7 +166,7 @@ exports[`ReactRefreshLogBox app turbo module init error not shown 1`] = ` ...@@ -164,7 +166,7 @@ exports[`ReactRefreshLogBox app turbo module init error not shown 1`] = `
`; `;
exports[`ReactRefreshLogBox app turbo should strip whitespace correctly with newline 1`] = ` exports[`ReactRefreshLogBox app turbo should strip whitespace correctly with newline 1`] = `
"index.js (7:6) @ onClick "index.js (7:15) @ onClick
5 | 5 |
6 | <a onClick={() => { 6 | <a onClick={() => {
......
...@@ -6,7 +6,7 @@ import path from 'path' ...@@ -6,7 +6,7 @@ import path from 'path'
import { outdent } from 'outdent' import { outdent } from 'outdent'
describe.each(['default', 'turbo'])('Error recovery app %s', () => { describe.each(['default', 'turbo'])('Error recovery app %s', () => {
const { next, isTurbopack } = nextTestSetup({ const { next } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')), files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: { dependencies: {
react: 'latest', react: 'latest',
...@@ -144,9 +144,8 @@ describe.each(['default', 'turbo'])('Error recovery app %s', () => { ...@@ -144,9 +144,8 @@ describe.each(['default', 'turbo'])('Error recovery app %s', () => {
await session.waitForAndOpenRuntimeError() await session.waitForAndOpenRuntimeError()
if (isTurbopack) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"index.js (7:5) @ eval "index.js (7:11) @ eval
5 | const increment = useCallback(() => { 5 | const increment = useCallback(() => {
6 | setCount(c => c + 1) 6 | setCount(c => c + 1)
...@@ -156,19 +155,6 @@ describe.each(['default', 'turbo'])('Error recovery app %s', () => { ...@@ -156,19 +155,6 @@ describe.each(['default', 'turbo'])('Error recovery app %s', () => {
9 | return ( 9 | return (
10 | <main>" 10 | <main>"
`) `)
} else {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"index.js (7:10) @ eval
5 | const increment = useCallback(() => {
6 | setCount(c => c + 1)
> 7 | throw new Error('oops')
| ^
8 | }, [setCount])
9 | return (
10 | <main>"
`)
}
await session.patch( await session.patch(
'index.js', 'index.js',
......
...@@ -359,7 +359,7 @@ describe('Error overlay - RSC build errors', () => { ...@@ -359,7 +359,7 @@ describe('Error overlay - RSC build errors', () => {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(next.normalizeTestDirContent(await session.getRedboxSource())) expect(next.normalizeTestDirContent(await session.getRedboxSource()))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"./app/server-with-errors/error-file/error.js:1:0 "./app/server-with-errors/error-file/error.js:1:1
Parsing ecmascript source code failed Parsing ecmascript source code failed
> 1 | export default function Error() {} > 1 | export default function Error() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
...@@ -48,7 +48,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -48,7 +48,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
expect(await session.getRedboxSource()).toMatchInlineSnapshot( expect(await session.getRedboxSource()).toMatchInlineSnapshot(
process.env.TURBOPACK process.env.TURBOPACK
? ` ? `
"./node_modules/my-package/index.js:1:12 "./node_modules/my-package/index.js:1:13
Module not found: Can't resolve 'dns' Module not found: Can't resolve 'dns'
> 1 | const dns = require('dns') > 1 | const dns = require('dns')
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
...@@ -57,7 +57,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -57,7 +57,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
https://nextjs.org/docs/messages/module-not-found" https://nextjs.org/docs/messages/module-not-found"
` `
: ` : `
"./node_modules/my-package/index.js:1:0 "./node_modules/my-package/index.js:1:1
Module not found: Can't resolve 'dns' Module not found: Can't resolve 'dns'
https://nextjs.org/docs/messages/module-not-found https://nextjs.org/docs/messages/module-not-found
...@@ -94,7 +94,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -94,7 +94,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
const source = await session.getRedboxSource() const source = await session.getRedboxSource()
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./index.js:1:0 "./index.js:1:1
Module not found: Can't resolve 'b' Module not found: Can't resolve 'b'
> 1 | import Comp from 'b' > 1 | import Comp from 'b'
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
...@@ -106,9 +106,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -106,9 +106,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
`) `)
} else { } else {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./index.js:1:0 "./index.js:1:1
Module not found: Can't resolve 'b' Module not found: Can't resolve 'b'
> 1 | import Comp from 'b' > 1 | import Comp from 'b'
| ^
2 | 2 |
3 | export default function Oops() { 3 | export default function Oops() {
4 | return ( 4 | return (
...@@ -146,7 +147,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -146,7 +147,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
const source = await session.getRedboxSource() const source = await session.getRedboxSource()
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./pages/index.js:1:0 "./pages/index.js:1:1
Module not found: Can't resolve 'b' Module not found: Can't resolve 'b'
> 1 | import Comp from 'b' > 1 | import Comp from 'b'
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
...@@ -158,9 +159,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -158,9 +159,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
`) `)
} else { } else {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./pages/index.js:1:0 "./pages/index.js:1:1
Module not found: Can't resolve 'b' Module not found: Can't resolve 'b'
> 1 | import Comp from 'b' > 1 | import Comp from 'b'
| ^
2 | 2 |
3 | export default function Oops() { 3 | export default function Oops() {
4 | return ( 4 | return (
...@@ -201,7 +203,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -201,7 +203,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
const source = await session.getRedboxSource() const source = await session.getRedboxSource()
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./pages/_app.js:1:0 "./pages/_app.js:1:1
Module not found: Can't resolve './non-existent.css' Module not found: Can't resolve './non-existent.css'
> 1 | import './non-existent.css' > 1 | import './non-existent.css'
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
...@@ -213,9 +215,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -213,9 +215,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
`) `)
} else { } else {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./pages/_app.js:1:0 "./pages/_app.js:1:1
Module not found: Can't resolve './non-existent.css' Module not found: Can't resolve './non-existent.css'
> 1 | import './non-existent.css' > 1 | import './non-existent.css'
| ^
2 | 2 |
3 | export default function App({ Component, pageProps }) { 3 | export default function App({ Component, pageProps }) {
4 | return <Component {...pageProps} /> 4 | return <Component {...pageProps} />
......
...@@ -211,7 +211,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -211,7 +211,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
const source = next.normalizeTestDirContent(await session.getRedboxSource()) const source = next.normalizeTestDirContent(await session.getRedboxSource())
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./index.js:7:0 "./index.js:7:1
Parsing ecmascript source code failed Parsing ecmascript source code failed
5 | div 5 | div
6 | ) 6 | )
...@@ -347,7 +347,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -347,7 +347,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
const source = await session.getRedboxSource() const source = await session.getRedboxSource()
expect(source).toMatch( expect(source).toMatch(
process.env.TURBOPACK process.env.TURBOPACK
? './index.module.css:1:8' ? './index.module.css:1:9'
: './index.module.css:1:1' : './index.module.css:1:1'
) )
if (!process.env.TURBOPACK) { if (!process.env.TURBOPACK) {
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ReactRefreshLogBox default boundaries 1`] = ` exports[`ReactRefreshLogBox default boundaries 1`] = `
"FunctionDefault.js (1:50) @ FunctionDefault "FunctionDefault.js (1:51) @ FunctionDefault
> 1 | export default function FunctionDefault() { throw new Error('no'); } > 1 | export default function FunctionDefault() { throw new Error('no'); }
| ^" | ^"
`; `;
exports[`ReactRefreshLogBox default conversion to class component (1) 1`] = ` exports[`ReactRefreshLogBox default conversion to class component (1) 1`] = `
"Child.js (4:10) @ ClickCount.render "Child.js (4:11) @ ClickCount.render
2 | export default class ClickCount extends Component { 2 | export default class ClickCount extends Component {
3 | render() { 3 | render() {
...@@ -47,7 +47,7 @@ exports[`ReactRefreshLogBox default logbox: anchors links in error messages 11`] ...@@ -47,7 +47,7 @@ exports[`ReactRefreshLogBox default logbox: anchors links in error messages 11`]
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 12`] = `"http://example.com/"`; exports[`ReactRefreshLogBox default logbox: anchors links in error messages 12`] = `"http://example.com/"`;
exports[`ReactRefreshLogBox default module init error not shown 1`] = ` exports[`ReactRefreshLogBox default module init error not shown 1`] = `
"index.js (3:6) @ eval "index.js (3:7) @ eval
1 | // top offset for snapshot 1 | // top offset for snapshot
2 | import * as React from 'react'; 2 | import * as React from 'react';
...@@ -59,7 +59,7 @@ exports[`ReactRefreshLogBox default module init error not shown 1`] = ` ...@@ -59,7 +59,7 @@ exports[`ReactRefreshLogBox default module init error not shown 1`] = `
`; `;
exports[`ReactRefreshLogBox default should strip whitespace correctly with newline 1`] = ` exports[`ReactRefreshLogBox default should strip whitespace correctly with newline 1`] = `
"index.js (8:26) @ onClick "index.js (8:27) @ onClick
6 | 6 |
7 | <a onClick={() => { 7 | <a onClick={() => {
...@@ -93,7 +93,7 @@ exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 11`] = ...@@ -93,7 +93,7 @@ exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 11`] =
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 12`] = `"http://example.com/"`; exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 12`] = `"http://example.com/"`;
exports[`ReactRefreshLogBox turbo module init error not shown 1`] = ` exports[`ReactRefreshLogBox turbo module init error not shown 1`] = `
"index.js (3:6) @ <unknown> "index.js (3:7) @ <unknown>
1 | // top offset for snapshot 1 | // top offset for snapshot
2 | import * as React from 'react'; 2 | import * as React from 'react';
...@@ -105,7 +105,7 @@ exports[`ReactRefreshLogBox turbo module init error not shown 1`] = ` ...@@ -105,7 +105,7 @@ exports[`ReactRefreshLogBox turbo module init error not shown 1`] = `
`; `;
exports[`ReactRefreshLogBox turbo should strip whitespace correctly with newline 1`] = ` exports[`ReactRefreshLogBox turbo should strip whitespace correctly with newline 1`] = `
"index.js (8:18) @ onClick "index.js (8:27) @ onClick
6 | 6 |
7 | <a onClick={() => { 7 | <a onClick={() => {
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ReactRefreshLogBox default syntax > runtime error 1`] = ` exports[`ReactRefreshLogBox default syntax > runtime error 1`] = `
"index.js (5:8) @ Error "index.js (5:9) @ Error
3 | setInterval(() => { 3 | setInterval(() => {
4 | i++ 4 | i++
......
...@@ -107,7 +107,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -107,7 +107,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
expect(await session.hasRedbox()).toBe(true) expect(await session.hasRedbox()).toBe(true)
if (isTurbopack) { if (isTurbopack) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"index.js (7:5) @ <unknown> "index.js (7:11) @ <unknown>
5 | const increment = useCallback(() => { 5 | const increment = useCallback(() => {
6 | setCount(c => c + 1) 6 | setCount(c => c + 1)
...@@ -119,7 +119,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -119,7 +119,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
`) `)
} else { } else {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"index.js (7:10) @ eval "index.js (7:11) @ eval
5 | const increment = useCallback(() => { 5 | const increment = useCallback(() => {
6 | setCount(c => c + 1) 6 | setCount(c => c + 1)
......
...@@ -57,7 +57,7 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -57,7 +57,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(next.normalizeTestDirContent(await session.getRedboxSource())) expect(next.normalizeTestDirContent(await session.getRedboxSource()))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"./components/Comp.js:1:0 "./components/Comp.js:1:1
Parsing ecmascript source code failed Parsing ecmascript source code failed
> 1 | import { cookies } from 'next/headers' > 1 | import { cookies } from 'next/headers'
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...@@ -116,7 +116,7 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -116,7 +116,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(next.normalizeTestDirContent(await session.getRedboxSource())) expect(next.normalizeTestDirContent(await session.getRedboxSource()))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"./components/Comp.js:1:0 "./components/Comp.js:1:1
Parsing ecmascript source code failed Parsing ecmascript source code failed
> 1 | import 'server-only' > 1 | import 'server-only'
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
......
...@@ -524,7 +524,7 @@ describe.each([[''], ['/docs']])( ...@@ -524,7 +524,7 @@ describe.each([[''], ['/docs']])(
`) `)
} else if (basePath === '' && process.env.TURBOPACK) { } else if (basePath === '' && process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./pages/hmr/about2.js:7:0 "./pages/hmr/about2.js:7:1
Parsing ecmascript source code failed Parsing ecmascript source code failed
5 | div 5 | div
6 | ) 6 | )
...@@ -562,7 +562,7 @@ describe.each([[''], ['/docs']])( ...@@ -562,7 +562,7 @@ describe.each([[''], ['/docs']])(
`) `)
} else if (basePath === '/docs' && process.env.TURBOPACK) { } else if (basePath === '/docs' && process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"./pages/hmr/about2.js:7:0 "./pages/hmr/about2.js:7:1
Parsing ecmascript source code failed Parsing ecmascript source code failed
5 | div 5 | div
6 | ) 6 | )
......
...@@ -1385,7 +1385,7 @@ createNextDescribe( ...@@ -1385,7 +1385,7 @@ createNextDescribe(
const text = await getRedboxSource(browser) const text = await getRedboxSource(browser)
expect(text).toMatch(/An Expected error occurred/) expect(text).toMatch(/An Expected error occurred/)
expect(text).toMatch( expect(text).toMatch(
/pages[\\/]error-inside-browser-page\.js \(5:12\)/ /pages[\\/]error-inside-browser-page\.js \(5:13\)/
) )
} finally { } finally {
if (browser) { if (browser) {
...@@ -1404,7 +1404,7 @@ createNextDescribe( ...@@ -1404,7 +1404,7 @@ createNextDescribe(
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
const text = await getRedboxSource(browser) const text = await getRedboxSource(browser)
expect(text).toMatch(/An Expected error occurred/) expect(text).toMatch(/An Expected error occurred/)
expect(text).toMatch(/error-in-the-browser-global-scope\.js \(2:8\)/) expect(text).toMatch(/error-in-the-browser-global-scope\.js \(2:9\)/)
} finally { } finally {
if (browser) { if (browser) {
await browser.close() await browser.close()
......
...@@ -40,7 +40,7 @@ const appDir = join(__dirname, '../') ...@@ -40,7 +40,7 @@ const appDir = join(__dirname, '../')
// TODO: add win32 snapshot // TODO: add win32 snapshot
} else { } else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"pages/index.js (5:10) @ eval "pages/index.js (5:11) @ eval
3 | export default function Index(props) { 3 | export default function Index(props) {
4 | useEffect(() => { 4 | useEffect(() => {
......
...@@ -206,7 +206,7 @@ describe('server-side dev errors', () => { ...@@ -206,7 +206,7 @@ describe('server-side dev errors', () => {
const err = stderr.slice(stderrIdx) const err = stderr.slice(stderrIdx)
return err.includes('pages/uncaught-rejection.js') && return err.includes('pages/uncaught-rejection.js') &&
(err.includes('7:19') || err.includes('7:5')) && err.includes('7:20') &&
err.includes('getServerSideProps') && err.includes('getServerSideProps') &&
err.includes('catch this rejection') err.includes('catch this rejection')
? 'success' ? 'success'
...@@ -222,7 +222,7 @@ describe('server-side dev errors', () => { ...@@ -222,7 +222,7 @@ describe('server-side dev errors', () => {
const cleanStderr = stripAnsi(stderr.slice(stderrIdx)) const cleanStderr = stripAnsi(stderr.slice(stderrIdx))
return cleanStderr.includes('pages/uncaught-empty-rejection.js') && return cleanStderr.includes('pages/uncaught-empty-rejection.js') &&
(cleanStderr.includes('7:19') || cleanStderr.includes('7:5')) && cleanStderr.includes('7:20') &&
cleanStderr.includes('getServerSideProps') && cleanStderr.includes('getServerSideProps') &&
cleanStderr.includes('new Error()') cleanStderr.includes('new Error()')
? 'success' ? 'success'
...@@ -238,7 +238,7 @@ describe('server-side dev errors', () => { ...@@ -238,7 +238,7 @@ describe('server-side dev errors', () => {
const err = stderr.slice(stderrIdx) const err = stderr.slice(stderrIdx)
return err.includes('pages/uncaught-exception.js') && return err.includes('pages/uncaught-exception.js') &&
(err.includes('7:10') || err.includes('7:5')) && err.includes('7:11') &&
err.includes('getServerSideProps') && err.includes('getServerSideProps') &&
err.includes('catch this exception') err.includes('catch this exception')
? 'success' ? 'success'
...@@ -254,7 +254,7 @@ describe('server-side dev errors', () => { ...@@ -254,7 +254,7 @@ describe('server-side dev errors', () => {
const cleanStderr = stripAnsi(stderr.slice(stderrIdx)) const cleanStderr = stripAnsi(stderr.slice(stderrIdx))
return cleanStderr.includes('pages/uncaught-empty-exception.js') && return cleanStderr.includes('pages/uncaught-empty-exception.js') &&
(cleanStderr.includes('7:10') || cleanStderr.includes('7:5')) && cleanStderr.includes('7:11') &&
cleanStderr.includes('getServerSideProps') && cleanStderr.includes('getServerSideProps') &&
cleanStderr.includes('new Error()') cleanStderr.includes('new Error()')
? 'success' ? 'success'
......
...@@ -990,11 +990,11 @@ ...@@ -990,11 +990,11 @@
}, },
"test/development/acceptance-app/ReactRefreshRegression.test.ts": { "test/development/acceptance-app/ReactRefreshRegression.test.ts": {
"passed": [ "passed": [
"ReactRefreshRegression app can fast refresh a page with static generation" "ReactRefreshRegression app can fast refresh a page with static generation",
"ReactRefreshRegression app shows an overlay for server-side error in client component"
], ],
"failed": [ "failed": [
"ReactRefreshRegression app shows an overlay for anonymous function server-side error", "ReactRefreshRegression app shows an overlay for anonymous function server-side error",
"ReactRefreshRegression app shows an overlay for server-side error in client component",
"ReactRefreshRegression app shows an overlay for server-side error in server component" "ReactRefreshRegression app shows an overlay for server-side error in server component"
], ],
"pending": [ "pending": [
...@@ -1336,11 +1336,10 @@ ...@@ -1336,11 +1336,10 @@
"ReactRefreshRegression can fast refresh a page with config", "ReactRefreshRegression can fast refresh a page with config",
"ReactRefreshRegression can fast refresh a page with getServerSideProps", "ReactRefreshRegression can fast refresh a page with getServerSideProps",
"ReactRefreshRegression can fast refresh a page with getStaticProps", "ReactRefreshRegression can fast refresh a page with getStaticProps",
"ReactRefreshRegression shows an overlay for a server-side error",
"ReactRefreshRegression styled-components hydration mismatch" "ReactRefreshRegression styled-components hydration mismatch"
], ],
"failed": [ "failed": [],
"ReactRefreshRegression shows an overlay for a server-side error"
],
"pending": [ "pending": [
"ReactRefreshRegression Turbopack skipped tests custom loader (mdx) should have Fast Refresh enabled" "ReactRefreshRegression Turbopack skipped tests custom loader (mdx) should have Fast Refresh enabled"
], ],
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