Skip to content

Commit ab6ae07

Browse files
patak-devbluwy
andauthoredMar 6, 2023
fix: enforce absolute path for server.sourcemapIgnoreList (#12309)
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
1 parent 5968bec commit ab6ae07

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
 

‎docs/config/server-options.md

+2
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ export default defineConfig({
326326

327327
Whether or not to ignore source files in the server sourcemap, used to populate the [`x_google_ignoreList` source map extension](https://developer.chrome.com/blog/devtools-better-angular-debugging/#the-x_google_ignorelist-source-map-extension).
328328

329+
`server.sourcemapIgnoreList` is the equivalent of [build.rollupOptions.output.sourcemapIgnoreList](https://rollupjs.org/configuration-options/#output-sourcemapignorelist) for the dev server. A difference between the two config options is that the rollup function is called with a relative path for `sourcePath` while `server.sourcemapIgnoreList` is called with an absolute path. During dev, most modules have the map and the source in the same folder, so the relative path for `sourcePath` is the file name itself. In these cases, absolute paths makes it convenient to be used instead.
330+
329331
By default, it excludes all paths containing `node_modules`. You can pass `false` to disable this behavior, or, for full control, a function that takes the source path and sourcemap path and returns whether to ignore the source path.
330332

331333
```js

‎packages/vite/src/node/server/transformRequest.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ async function loadAndTransform(
281281

282282
const sourcemapPath = `${mod.file}.map`
283283
const ignoreList = config.server.sourcemapIgnoreList(
284-
sourcePath,
284+
path.isAbsolute(sourcePath)
285+
? sourcePath
286+
: path.resolve(path.dirname(sourcemapPath), sourcePath),
285287
sourcemapPath,
286288
)
287289
if (typeof ignoreList !== 'boolean') {

0 commit comments

Comments
 (0)
Please sign in to comment.