Unverified Commit a71a764c authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

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.
parent 58b627c1
...@@ -48,6 +48,7 @@ bench/nested-deps/components/**/* ...@@ -48,6 +48,7 @@ bench/nested-deps/components/**/*
**/.tina/__generated__/** **/.tina/__generated__/**
test/lib/amp-validator-wasm.js test/lib/amp-validator-wasm.js
test/production/pages-dir/production/fixture/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/internal-pkg/sourcemapped.js
test/e2e/app-dir/server-source-maps/fixtures/default/external-pkg/sourcemapped.js test/e2e/app-dir/server-source-maps/fixtures/default/external-pkg/sourcemapped.js
test/e2e/async-modules/amp-validator-wasm.js test/e2e/async-modules/amp-validator-wasm.js
......
import { connection } from 'next/server' import { connection } from 'next/server'
import { run as runInternal } from 'internal-pkg' import { runInternal } from 'internal-pkg'
import { run as runInternalSourceMapped } from 'internal-pkg/sourcemapped' import { runInternalSourceMapped } from 'internal-pkg/sourcemapped'
import { run as runExternal } from 'external-pkg' import { runInternalIgnored } from 'internal-pkg/ignored'
import { run as runExternalSourceMapped } from 'external-pkg/sourcemapped' import { runExternal } from 'external-pkg'
import { runExternalSourceMapped } from 'external-pkg/sourcemapped'
function logError() { function logError() {
const error = new Error('Boom') const error = new Error('Boom')
...@@ -16,7 +17,9 @@ export default async function Page() { ...@@ -16,7 +17,9 @@ export default async function Page() {
runInternalSourceMapped(function runWithInternalSourceMapped() { runInternalSourceMapped(function runWithInternalSourceMapped() {
runExternal(function runWithExternal() { runExternal(function runWithExternal() {
runExternalSourceMapped(function runWithExternalSourceMapped() { runExternalSourceMapped(function runWithExternalSourceMapped() {
logError() runInternalIgnored(function runWithInternalIgnored() {
logError()
})
}) })
}) })
}) })
......
'use client' 'use client'
import { run as runInternal } from 'internal-pkg' import { runInternal } from 'internal-pkg'
import { run as runInternalSourceMapped } from 'internal-pkg/sourcemapped' import { runInternalSourceMapped } from 'internal-pkg/sourcemapped'
import { run as runExternal } from 'external-pkg' import { runInternalIgnored } from 'internal-pkg/ignored'
import { run as runExternalSourceMapped } from 'external-pkg/sourcemapped' import { runExternal } from 'external-pkg'
import { runExternalSourceMapped } from 'external-pkg/sourcemapped'
function logError() { function logError() {
const error = new Error('Boom') const error = new Error('Boom')
...@@ -14,7 +15,9 @@ export default function Page() { ...@@ -14,7 +15,9 @@ export default function Page() {
runInternalSourceMapped(function runWithInternalSourceMapped() { runInternalSourceMapped(function runWithInternalSourceMapped() {
runExternal(function runWithExternal() { runExternal(function runWithExternal() {
runExternalSourceMapped(function runWithExternalSourceMapped() { runExternalSourceMapped(function runWithExternalSourceMapped() {
logError() runInternalIgnored(function runWithInternalIgnored() {
logError()
})
}) })
}) })
}) })
......
export function run(fn) { export function runExternal(fn) {
return fn() return fn()
} }
export function run(fn) { export function runExternalSourceMapped(fn) {
return fn(); return fn();
} }
//# sourceMappingURL=sourcemapped.js.map //# sourceMappingURL=sourcemapped.js.map
\ No newline at end of file
{"version":3,"file":"sourcemapped.js","sourceRoot":"","sources":["sourcemapped.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,GAAG,CAAI,EAAS;IAC9B,OAAO,EAAE,EAAE,CAAA;AACb,CAAC"} {
\ No newline at end of file "version": 3,
"file": "sourcemapped.js",
"sourceRoot": "",
"sources": [
"sourcemapped.ts"
],
"names": [],
"mappings": "AAGA,MAAM,UAAU,uBAAuB,CAAI,EAAS;IAClD,OAAO,EAAE,EAAE,CAAA;AACb,CAAC"
}
// Compile with pnpm tsc test/e2e/app-dir/server-source-maps/fixtures/default/external-pkg/sourcemapped.ts --sourceMap --target esnext // 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 // tsc compile errors can be ignored
type Fn<T> = () => T type Fn<T> = () => T
export function run<T>(fn: Fn<T>): T { export function runExternalSourceMapped<T>(fn: Fn<T>): T {
return fn() return fn()
} }
export function runInternalIgnored(fn) {
return fn();
}
//# sourceMappingURL=ignored.js.map
\ No newline at end of file
{
"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"
}
// 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()
}
export function run(fn) { export function runInternal(fn) {
return fn() return fn()
} }
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
".": { ".": {
"default": "./index.js" "default": "./index.js"
}, },
"./ignored": {
"default": "./ignored.js"
},
"./sourcemapped": { "./sourcemapped": {
"default": "./sourcemapped.js" "default": "./sourcemapped.js"
} }
......
export function run(fn) { export function runInternalSourceMapped(fn) {
return fn(); return fn();
} }
//# sourceMappingURL=sourcemapped.js.map //# sourceMappingURL=sourcemapped.js.map
\ No newline at end of file
{"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"}
\ No newline at end of file \ No newline at end of file
// 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 // tsc compile errors can be ignored
type Fn<T> = () => T type Fn<T> = () => T
export function run<T>(fn: Fn<T>): T { export function runInternalSourceMapped<T>(fn: Fn<T>): T {
return fn() return fn()
} }
...@@ -9,13 +9,11 @@ function normalizeCliOutput(output: string) { ...@@ -9,13 +9,11 @@ function normalizeCliOutput(output: string) {
} }
describe('app-dir - server source maps', () => { describe('app-dir - server source maps', () => {
const dependencies = const dependencies = {
// 'link:' is not suitable for this test since this makes packages // `link:` simulates a package in a monorepo
// not appear in node_modules. 'internal-pkg': `link:./internal-pkg`,
{ 'external-pkg': `file:./external-pkg`,
'internal-pkg': `file:./internal-pkg`, }
'external-pkg': `file:./external-pkg`,
}
const { skipped, next, isNextDev, isTurbopack } = nextTestSetup({ const { skipped, next, isNextDev, isTurbopack } = nextTestSetup({
dependencies, dependencies,
files: path.join(__dirname, 'fixtures/default'), files: path.join(__dirname, 'fixtures/default'),
...@@ -89,71 +87,107 @@ describe('app-dir - server source maps', () => { ...@@ -89,71 +87,107 @@ describe('app-dir - server source maps', () => {
} }
}) })
// TODO(veil): Turbopack resolver bug it('stack frames are ignore-listed in ssr', async () => {
// TODO(veil): Turbopack build? bugs taint the whole dev server const outputIndex = next.cliOutput.length
;(isTurbopack ? it.skip : it)( await next.render('/ssr-error-log-ignore-listed')
'stack frames are ignore-listed in ssr',
async () => { if (isNextDev) {
const outputIndex = next.cliOutput.length await retry(() => {
await next.render('/ssr-error-log-ignore-listed') expect(next.cliOutput.slice(outputIndex)).toContain('Error: Boom')
})
if (isNextDev) { expect(normalizeCliOutput(next.cliOutput.slice(outputIndex))).toContain(
await retry(() => { isTurbopack
expect(next.cliOutput.slice(outputIndex)).toContain('Error: Boom') ? '\nError: Boom' +
}) '\n at logError (app/ssr-error-log-ignore-listed/page.js:9:16)' +
expect(normalizeCliOutput(next.cliOutput.slice(outputIndex))).toContain( '\n at runWithInternalIgnored (app/ssr-error-log-ignore-listed/page.js:19:12)' +
isTurbopack // TODO(veil): Turbopack's sourcemap loader drops `ignoreList`
? // TODO(veil): Turbopack resolver bug '\n at runInternalIgnored (internal-pkg/ignored.ts:6:9)' +
"Module not found: Can't resolve 'internal-pkg'" '\n at runWithExternalSourceMapped (app/ssr-error-log-ignore-listed/page.js:18:29)' +
: '\nError: Boom' + '\n at runWithExternal (app/ssr-error-log-ignore-listed/page.js:17:32)' +
'\n at logError (app/ssr-error-log-ignore-listed/page.js:8:16)' + '\n at runWithInternalSourceMapped (app/ssr-error-log-ignore-listed/page.js:16:18)' +
'\n at runWithExternalSourceMapped (app/ssr-error-log-ignore-listed/page.js:17:10)' + // Realpath does not point into node_modules so we don't ignore it.
'\n at runWithExternal (app/ssr-error-log-ignore-listed/page.js:16:32)' + '\n at runInternalSourceMapped (internal-pkg/sourcemapped.ts:5:9)' +
'\n at runWithInternalSourceMapped (app/ssr-error-log-ignore-listed/page.js:15:18)' + '\n at runWithInternal (app/ssr-error-log-ignore-listed/page.js:15:28)' +
'\n at runWithInternal (app/ssr-error-log-ignore-listed/page.js:14:28)' + // Realpath does not point into node_modules so we don't ignore it.
'\n at Page (app/ssr-error-log-ignore-listed/page.js:13:14)' + '\n at runInternal (internal-pkg/index.js:2:9)' +
'\n 6 |' + '\n at Page (app/ssr-error-log-ignore-listed/page.js:14:14)' +
'\n' '\n 7 |' +
) '\n'
} else { : '\nError: Boom' +
// TODO: Test `next build` with `--enable-source-maps`. '\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 it('stack frames are ignore-listed in rsc', async () => {
// TODO(veil): Turbopack build? bugs taint the whole dev server const outputIndex = next.cliOutput.length
;(isTurbopack ? it.skip : it)( await next.render('/rsc-error-log-ignore-listed')
'stack frames are ignore-listed in rsc',
async () => { if (isNextDev) {
const outputIndex = next.cliOutput.length await retry(() => {
await next.render('/rsc-error-log-ignore-listed')
if (isNextDev) {
await retry(() => {
expect(
normalizeCliOutput(next.cliOutput.slice(outputIndex))
).toContain('Error: Boom')
})
expect(normalizeCliOutput(next.cliOutput.slice(outputIndex))).toContain( expect(normalizeCliOutput(next.cliOutput.slice(outputIndex))).toContain(
isTurbopack 'Error: Boom'
? // 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'
) )
} 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 () => { it('thrown SSR errors', async () => {
const outputIndex = next.cliOutput.length const outputIndex = next.cliOutput.length
......
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