Skip to content

Commit 4242a46

Browse files
committed
ignore-list published sources if they have have a sourcemap
This shouldn't affect most users since in those case these files would be inside node_modules/ and therefore ignore-listed by default. The only exception I can think of is setups where modules are not inside node_modules/ but inside another folder (Yarn Berry has such on option). It's mostly targetted at our own testing where the Next.js installation may be symlinked and therefore not point into node_modules. Webpack-bundled code may not be affected due to https://linear.app/vercel/issue/NDX-464.
1 parent 94ef480 commit 4242a46

File tree

2 files changed

+140
-306
lines changed

2 files changed

+140
-306
lines changed

packages/next/taskfile-swc.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,24 @@ if ((typeof exports.default === 'function' || (typeof exports.default === 'objec
166166

167167
output.code += Buffer.from(`\n//# sourceMappingURL=${map}`)
168168

169+
const sourceMapPayload = JSON.parse(output.map)
170+
if ('ignoreList' in sourceMapPayload) {
171+
throw new Error(
172+
'SWC already sets an ignoreList. We may no longer need to manually set ignoreList.'
173+
)
174+
}
175+
// ignore-list everything
176+
sourceMapPayload.ignoreList = sourceMapPayload.sources.map(
177+
(source, sourceIndex) => {
178+
return sourceIndex
179+
}
180+
)
181+
169182
// add sourcemap to `files` array
170183
this._.files.push({
171184
base: map,
172185
dir: file.dir,
173-
data: Buffer.from(output.map),
186+
data: Buffer.from(JSON.stringify(sourceMapPayload)),
174187
})
175188
}
176189

0 commit comments

Comments
 (0)