Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add sourcemapIgnoreList configuration option #12174

Merged
merged 8 commits into from
Mar 1, 2023
Prev Previous commit
Next Next commit
feat: support setting option to false
  • Loading branch information
danielroe committed Mar 1, 2023
commit ecda87b0d69a806ac8553f4b84963c37228bc24a
2 changes: 1 addition & 1 deletion docs/config/server-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export default defineConfig({

## server.sourcemapIgnoreList

- **Type:** `(sourcePath: string, sourcemapPath: string) => boolean`
- **Type:** `false | (sourcePath: string, sourcemapPath: string) => boolean`
- **Default:** `(sourcePath) => sourcePath.includes('node_modules')`

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).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bmeurer not blocking for the PR, but it would be nice to be able to link to a more focused blog post about x_google_ignoreList. If your team ends up having a better resource in the future, would you do a PR to rewire these references?

Copy link
Contributor

@jecfish jecfish Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to this, I will draft something up and send another PR to update it. Thanks for calling that out!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jecfish, sounds great!

Expand Down
20 changes: 16 additions & 4 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ export interface ServerOptions extends CommonServerOptions {
/**
* Whether or not to ignore-list source files in the dev 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).
* By default, it excludes all paths containing `/node_modules/`.
*
* 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.
*/
sourcemapIgnoreList?: (sourcePath: string, sourcemapPath: string) => boolean
sourcemapIgnoreList?:
| false
| ((sourcePath: string, sourcemapPath: string) => boolean)
/**
* Force dep pre-optimization regardless of whether deps have changed.
*
Expand All @@ -133,7 +138,10 @@ export interface ServerOptions extends CommonServerOptions {
export interface ResolvedServerOptions extends ServerOptions {
fs: Required<FileSystemServeOptions>
middlewareMode: boolean
sourcemapIgnoreList: NonNullable<ServerOptions['sourcemapIgnoreList']>
sourcemapIgnoreList: Exclude<
ServerOptions['sourcemapIgnoreList'],
false | undefined
>
}

export interface FileSystemServeOptions {
Expand Down Expand Up @@ -753,8 +761,12 @@ export function resolveServerOptions(
): ResolvedServerOptions {
const server: ResolvedServerOptions = {
preTransformRequests: true,
sourcemapIgnoreList: (sourcePath) => sourcePath.includes('node_modules'),
...(raw as Omit<ResolvedServerOptions, 'sourcemapIgnoreList'>),
sourcemapIgnoreList:
raw?.sourcemapIgnoreList === false
? () => false
: raw?.sourcemapIgnoreList ||
((sourcePath) => sourcePath.includes('node_modules')),
middlewareMode: !!raw?.middlewareMode,
}
let allowDirs = server.fs?.allow
Expand Down