mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Add test for missing sourcemap loader support of ignoreList (#75907)
Neither Webpack nor Turbopack preserve this property. Webpack is even worse because the original source URLs are malformed.
This commit is contained in:
@@ -48,6 +48,7 @@ bench/nested-deps/components/**/*
|
||||
**/.tina/__generated__/**
|
||||
test/lib/amp-validator-wasm.js
|
||||
test/production/pages-dir/production/fixture/amp-validator-wasm.js
|
||||
test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/ignored.js
|
||||
test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/sourcemapped.js
|
||||
test/e2e/app-dir/server-source-maps/fixtures/default/external-pkg/sourcemapped.js
|
||||
test/e2e/async-modules/amp-validator-wasm.js
|
||||
|
||||
+8
-5
@@ -1,8 +1,9 @@
|
||||
import { connection } from 'next/server'
|
||||
import { run as runInternal } from 'internal-pkg'
|
||||
import { run as runInternalSourceMapped } from 'internal-pkg/sourcemapped'
|
||||
import { run as runExternal } from 'external-pkg'
|
||||
import { run as runExternalSourceMapped } from 'external-pkg/sourcemapped'
|
||||
import { runInternal } from 'internal-pkg'
|
||||
import { runInternalSourceMapped } from 'internal-pkg/sourcemapped'
|
||||
import { runInternalIgnored } from 'internal-pkg/ignored'
|
||||
import { runExternal } from 'external-pkg'
|
||||
import { runExternalSourceMapped } from 'external-pkg/sourcemapped'
|
||||
|
||||
function logError() {
|
||||
const error = new Error('Boom')
|
||||
@@ -16,7 +17,9 @@ export default async function Page() {
|
||||
runInternalSourceMapped(function runWithInternalSourceMapped() {
|
||||
runExternal(function runWithExternal() {
|
||||
runExternalSourceMapped(function runWithExternalSourceMapped() {
|
||||
logError()
|
||||
runInternalIgnored(function runWithInternalIgnored() {
|
||||
logError()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
+8
-5
@@ -1,8 +1,9 @@
|
||||
'use client'
|
||||
import { run as runInternal } from 'internal-pkg'
|
||||
import { run as runInternalSourceMapped } from 'internal-pkg/sourcemapped'
|
||||
import { run as runExternal } from 'external-pkg'
|
||||
import { run as runExternalSourceMapped } from 'external-pkg/sourcemapped'
|
||||
import { runInternal } from 'internal-pkg'
|
||||
import { runInternalSourceMapped } from 'internal-pkg/sourcemapped'
|
||||
import { runInternalIgnored } from 'internal-pkg/ignored'
|
||||
import { runExternal } from 'external-pkg'
|
||||
import { runExternalSourceMapped } from 'external-pkg/sourcemapped'
|
||||
|
||||
function logError() {
|
||||
const error = new Error('Boom')
|
||||
@@ -14,7 +15,9 @@ export default function Page() {
|
||||
runInternalSourceMapped(function runWithInternalSourceMapped() {
|
||||
runExternal(function runWithExternal() {
|
||||
runExternalSourceMapped(function runWithExternalSourceMapped() {
|
||||
logError()
|
||||
runInternalIgnored(function runWithInternalIgnored() {
|
||||
logError()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export function run(fn) {
|
||||
export function runExternal(fn) {
|
||||
return fn()
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export function run(fn) {
|
||||
export function runExternalSourceMapped(fn) {
|
||||
return fn();
|
||||
}
|
||||
//# sourceMappingURL=sourcemapped.js.map
|
||||
+10
-1
@@ -1 +1,10 @@
|
||||
{"version":3,"file":"sourcemapped.js","sourceRoot":"","sources":["sourcemapped.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,GAAG,CAAI,EAAS;IAC9B,OAAO,EAAE,EAAE,CAAA;AACb,CAAC"}
|
||||
{
|
||||
"version": 3,
|
||||
"file": "sourcemapped.js",
|
||||
"sourceRoot": "",
|
||||
"sources": [
|
||||
"sourcemapped.ts"
|
||||
],
|
||||
"names": [],
|
||||
"mappings": "AAGA,MAAM,UAAU,uBAAuB,CAAI,EAAS;IAClD,OAAO,EAAE,EAAE,CAAA;AACb,CAAC"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Compile with pnpm tsc test/e2e/app-dir/server-source-maps/fixtures/default/external-pkg/sourcemapped.ts --sourceMap --target esnext
|
||||
// tsc compile errors can be ignored
|
||||
type Fn<T> = () => T
|
||||
export function run<T>(fn: Fn<T>): T {
|
||||
export function runExternalSourceMapped<T>(fn: Fn<T>): T {
|
||||
return fn()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export function runInternalIgnored(fn) {
|
||||
return fn();
|
||||
}
|
||||
//# sourceMappingURL=ignored.js.map
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 3,
|
||||
"file": "ignored.js",
|
||||
"sourceRoot": "",
|
||||
"sources": [
|
||||
"ignored.ts"
|
||||
],
|
||||
"ignoreList": [
|
||||
0
|
||||
],
|
||||
"names": [],
|
||||
"mappings": "AAIA,MAAM,UAAU,kBAAkB,CAAI,EAAS;IAC7C,OAAO,EAAE,EAAE,CAAA;AACb,CAAC"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Compile with pnpm tsc test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/ignored.ts --sourceMap --target esnext
|
||||
// tsc compile errors can be ignored
|
||||
// Then ensure `ignoreList` references all `sources`
|
||||
type Fn<T> = () => T
|
||||
export function runInternalIgnored<T>(fn: Fn<T>): T {
|
||||
return fn()
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
export function run(fn) {
|
||||
export function runInternal(fn) {
|
||||
return fn()
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
".": {
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./ignored": {
|
||||
"default": "./ignored.js"
|
||||
},
|
||||
"./sourcemapped": {
|
||||
"default": "./sourcemapped.js"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export function run(fn) {
|
||||
export function runInternalSourceMapped(fn) {
|
||||
return fn();
|
||||
}
|
||||
//# sourceMappingURL=sourcemapped.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"sourcemapped.js","sourceRoot":"","sources":["sourcemapped.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,GAAG,CAAI,EAAS;IAC9B,OAAO,EAAE,EAAE,CAAA;AACb,CAAC"}
|
||||
{"version":3,"file":"sourcemapped.js","sourceRoot":"","sources":["sourcemapped.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,uBAAuB,CAAI,EAAS;IAClD,OAAO,EAAE,EAAE,CAAA;AACb,CAAC"}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Compile with p tsc test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/sourcemapped.ts --sourceMap --target esnext
|
||||
// Compile with pnpm tsc test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/sourcemapped.ts --sourceMap --target esnext
|
||||
// tsc compile errors can be ignored
|
||||
type Fn<T> = () => T
|
||||
export function run<T>(fn: Fn<T>): T {
|
||||
export function runInternalSourceMapped<T>(fn: Fn<T>): T {
|
||||
return fn()
|
||||
}
|
||||
|
||||
@@ -9,13 +9,11 @@ function normalizeCliOutput(output: string) {
|
||||
}
|
||||
|
||||
describe('app-dir - server source maps', () => {
|
||||
const dependencies =
|
||||
// 'link:' is not suitable for this test since this makes packages
|
||||
// not appear in node_modules.
|
||||
{
|
||||
'internal-pkg': `file:./internal-pkg`,
|
||||
'external-pkg': `file:./external-pkg`,
|
||||
}
|
||||
const dependencies = {
|
||||
// `link:` simulates a package in a monorepo
|
||||
'internal-pkg': `link:./internal-pkg`,
|
||||
'external-pkg': `file:./external-pkg`,
|
||||
}
|
||||
const { skipped, next, isNextDev, isTurbopack } = nextTestSetup({
|
||||
dependencies,
|
||||
files: path.join(__dirname, 'fixtures/default'),
|
||||
@@ -89,71 +87,107 @@ describe('app-dir - server source maps', () => {
|
||||
}
|
||||
})
|
||||
|
||||
// TODO(veil): Turbopack resolver bug
|
||||
// TODO(veil): Turbopack build? bugs taint the whole dev server
|
||||
;(isTurbopack ? it.skip : it)(
|
||||
'stack frames are ignore-listed in ssr',
|
||||
async () => {
|
||||
const outputIndex = next.cliOutput.length
|
||||
await next.render('/ssr-error-log-ignore-listed')
|
||||
it('stack frames are ignore-listed in ssr', async () => {
|
||||
const outputIndex = next.cliOutput.length
|
||||
await next.render('/ssr-error-log-ignore-listed')
|
||||
|
||||
if (isNextDev) {
|
||||
await retry(() => {
|
||||
expect(next.cliOutput.slice(outputIndex)).toContain('Error: Boom')
|
||||
})
|
||||
expect(normalizeCliOutput(next.cliOutput.slice(outputIndex))).toContain(
|
||||
isTurbopack
|
||||
? // TODO(veil): Turbopack resolver bug
|
||||
"Module not found: Can't resolve 'internal-pkg'"
|
||||
: '\nError: Boom' +
|
||||
'\n at logError (app/ssr-error-log-ignore-listed/page.js:8:16)' +
|
||||
'\n at runWithExternalSourceMapped (app/ssr-error-log-ignore-listed/page.js:17:10)' +
|
||||
'\n at runWithExternal (app/ssr-error-log-ignore-listed/page.js:16:32)' +
|
||||
'\n at runWithInternalSourceMapped (app/ssr-error-log-ignore-listed/page.js:15:18)' +
|
||||
'\n at runWithInternal (app/ssr-error-log-ignore-listed/page.js:14:28)' +
|
||||
'\n at Page (app/ssr-error-log-ignore-listed/page.js:13:14)' +
|
||||
'\n 6 |' +
|
||||
'\n'
|
||||
)
|
||||
} else {
|
||||
// TODO: Test `next build` with `--enable-source-maps`.
|
||||
}
|
||||
if (isNextDev) {
|
||||
await retry(() => {
|
||||
expect(next.cliOutput.slice(outputIndex)).toContain('Error: Boom')
|
||||
})
|
||||
expect(normalizeCliOutput(next.cliOutput.slice(outputIndex))).toContain(
|
||||
isTurbopack
|
||||
? '\nError: Boom' +
|
||||
'\n at logError (app/ssr-error-log-ignore-listed/page.js:9:16)' +
|
||||
'\n at runWithInternalIgnored (app/ssr-error-log-ignore-listed/page.js:19:12)' +
|
||||
// TODO(veil): Turbopack's sourcemap loader drops `ignoreList`
|
||||
'\n at runInternalIgnored (internal-pkg/ignored.ts:6:9)' +
|
||||
'\n at runWithExternalSourceMapped (app/ssr-error-log-ignore-listed/page.js:18:29)' +
|
||||
'\n at runWithExternal (app/ssr-error-log-ignore-listed/page.js:17:32)' +
|
||||
'\n at runWithInternalSourceMapped (app/ssr-error-log-ignore-listed/page.js:16:18)' +
|
||||
// Realpath does not point into node_modules so we don't ignore it.
|
||||
'\n at runInternalSourceMapped (internal-pkg/sourcemapped.ts:5:9)' +
|
||||
'\n at runWithInternal (app/ssr-error-log-ignore-listed/page.js:15:28)' +
|
||||
// Realpath does not point into node_modules so we don't ignore it.
|
||||
'\n at runInternal (internal-pkg/index.js:2:9)' +
|
||||
'\n at Page (app/ssr-error-log-ignore-listed/page.js:14:14)' +
|
||||
'\n 7 |' +
|
||||
'\n'
|
||||
: '\nError: Boom' +
|
||||
'\n at logError (app/ssr-error-log-ignore-listed/page.js:9:16)' +
|
||||
'\n at runWithInternalIgnored (app/ssr-error-log-ignore-listed/page.js:19:12)' +
|
||||
// TODO(veil): Webpacks's sourcemap loader drops `ignoreList`
|
||||
// TODO(veil): Webpack's sourcemap loader creates an incorrect `sources` entry
|
||||
'\n at runInternalIgnored (webpack-internal:/(ssr)/internal-pkg/ignored.ts:6:9)' +
|
||||
'\n at runWithExternalSourceMapped (app/ssr-error-log-ignore-listed/page.js:18:29)' +
|
||||
'\n at runWithExternal (app/ssr-error-log-ignore-listed/page.js:17:32)' +
|
||||
'\n at runWithInternalSourceMapped (app/ssr-error-log-ignore-listed/page.js:16:18)' +
|
||||
// TODO(veil): Webpack's sourcemap loader creates an incorrect `sources` entry
|
||||
// Realpath does not point into node_modules so we don't ignore it.
|
||||
'\n at runInternalSourceMapped (webpack-internal:/(ssr)/internal-pkg/sourcemapped.ts:5:9)' +
|
||||
'\n at runWithInternal (app/ssr-error-log-ignore-listed/page.js:15:28)' +
|
||||
// Realpath does not point into node_modules so we don't ignore it.
|
||||
'\n at runInternal (internal-pkg/index.js:2:9)' +
|
||||
'\n at Page (app/ssr-error-log-ignore-listed/page.js:14:14)' +
|
||||
'\n 7 |' +
|
||||
'\n'
|
||||
)
|
||||
} else {
|
||||
// TODO: Test `next build` with `--enable-source-maps`.
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
// TODO(veil): Turbopack resolver bug
|
||||
// TODO(veil): Turbopack build? bugs taint the whole dev server
|
||||
;(isTurbopack ? it.skip : it)(
|
||||
'stack frames are ignore-listed in rsc',
|
||||
async () => {
|
||||
const outputIndex = next.cliOutput.length
|
||||
await next.render('/rsc-error-log-ignore-listed')
|
||||
it('stack frames are ignore-listed in rsc', async () => {
|
||||
const outputIndex = next.cliOutput.length
|
||||
await next.render('/rsc-error-log-ignore-listed')
|
||||
|
||||
if (isNextDev) {
|
||||
await retry(() => {
|
||||
expect(
|
||||
normalizeCliOutput(next.cliOutput.slice(outputIndex))
|
||||
).toContain('Error: Boom')
|
||||
})
|
||||
if (isNextDev) {
|
||||
await retry(() => {
|
||||
expect(normalizeCliOutput(next.cliOutput.slice(outputIndex))).toContain(
|
||||
isTurbopack
|
||||
? // TODO(veil): Turbopack resolver bug
|
||||
"Module not found: Can't resolve 'internal-pkg'"
|
||||
: '\nError: Boom' +
|
||||
'\n at logError (app/rsc-error-log-ignore-listed/page.js:8:16)' +
|
||||
'\n at runWithExternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:19:10)' +
|
||||
'\n at runWithExternal (app/rsc-error-log-ignore-listed/page.js:18:32)' +
|
||||
'\n at runWithInternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:17:18)' +
|
||||
'\n at runWithInternal (app/rsc-error-log-ignore-listed/page.js:16:28)' +
|
||||
'\n at Page (app/rsc-error-log-ignore-listed/page.js:15:14)' +
|
||||
'\n 6 |' +
|
||||
'\n'
|
||||
'Error: Boom'
|
||||
)
|
||||
} else {
|
||||
// TODO: Test `next build` with `--enable-source-maps`.
|
||||
}
|
||||
})
|
||||
expect(normalizeCliOutput(next.cliOutput.slice(outputIndex))).toContain(
|
||||
isTurbopack
|
||||
? '\nError: Boom' +
|
||||
'\n at logError (app/rsc-error-log-ignore-listed/page.js:9:16)' +
|
||||
'\n at runWithInternalIgnored (app/rsc-error-log-ignore-listed/page.js:21:12)' +
|
||||
// TODO(veil): Turbopack's sourcemap loader drops `ignoreList`
|
||||
'\n at runInternalIgnored (internal-pkg/ignored.ts:6:9)' +
|
||||
'\n at runWithExternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:20:29)' +
|
||||
'\n at runWithExternal (app/rsc-error-log-ignore-listed/page.js:19:32)' +
|
||||
'\n at runWithInternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:18:18)' +
|
||||
// Realpath does not point into node_modules so we don't ignore it.
|
||||
'\n at runInternalSourceMapped (internal-pkg/sourcemapped.ts:5:9)' +
|
||||
'\n at runWithInternal (app/rsc-error-log-ignore-listed/page.js:17:28)' +
|
||||
// Realpath does not point into node_modules so we don't ignore it.
|
||||
'\n at runInternal (internal-pkg/index.js:2:9)' +
|
||||
'\n at Page (app/rsc-error-log-ignore-listed/page.js:16:14)' +
|
||||
'\n 7 |' +
|
||||
'\n'
|
||||
: '\nError: Boom' +
|
||||
'\n at logError (app/rsc-error-log-ignore-listed/page.js:9:16)' +
|
||||
'\n at runWithInternalIgnored (app/rsc-error-log-ignore-listed/page.js:21:12)' +
|
||||
// TODO(veil): Webpacks's sourcemap loader drops `ignoreList`
|
||||
// TODO(veil): Webpack's sourcemap loader creates an incorrect `sources` entry
|
||||
'\n at runInternalIgnored (webpack-internal:/(rsc)/internal-pkg/ignored.ts:6:9)' +
|
||||
'\n at runWithExternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:20:29)' +
|
||||
'\n at runWithExternal (app/rsc-error-log-ignore-listed/page.js:19:32)' +
|
||||
'\n at runWithInternalSourceMapped (app/rsc-error-log-ignore-listed/page.js:18:18)' +
|
||||
// TODO(veil): Webpack's sourcemap loader creates an incorrect `sources` entry
|
||||
// Realpath does not point into node_modules so we don't ignore it.
|
||||
'\n at runInternalSourceMapped (webpack-internal:/(rsc)/internal-pkg/sourcemapped.ts:5:9)' +
|
||||
'\n at runWithInternal (app/rsc-error-log-ignore-listed/page.js:17:28)' +
|
||||
// Realpath does not point into node_modules so we don't ignore it.
|
||||
'\n at runInternal (internal-pkg/index.js:2:9)' +
|
||||
'\n at Page (app/rsc-error-log-ignore-listed/page.js:16:14)' +
|
||||
'\n 7 |' +
|
||||
'\n'
|
||||
)
|
||||
} else {
|
||||
// TODO: Test `next build` with `--enable-source-maps`.
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('thrown SSR errors', async () => {
|
||||
const outputIndex = next.cliOutput.length
|
||||
|
||||
Reference in New Issue
Block a user