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

fix(pluginContainer): should not exclude client sourcemap source content #13092

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions packages/vite/src/node/server/pluginContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import {
prettifyUrl,
timeFrom,
} from '../utils'
import { FS_PREFIX } from '../constants'
import { CLIENT_ENTRY, ENV_ENTRY, FS_PREFIX } from '../constants'
import type { ResolvedConfig } from '../config'
import { createPluginHookUtils } from '../plugins'
import { buildErrorMessage } from './middlewares/error'
Expand Down Expand Up @@ -134,6 +134,9 @@ type PluginContext = Omit<
| 'moduleIds'
>

const normalizedClientEntry = normalizePath(CLIENT_ENTRY)
const normalizedEnvEntry = normalizePath(ENV_ENTRY)

export let parser = acorn.Parser

export async function createPluginContainer(
Expand Down Expand Up @@ -528,6 +531,9 @@ export async function createPluginContainer(
}

let combinedMap = this.combinedMap
const excludeContent =
this.filename !== normalizedClientEntry &&
this.filename !== normalizedEnvEntry
for (let m of this.sourcemapChain) {
if (typeof m === 'string') m = JSON.parse(m)
if (!('version' in (m as SourceMap))) {
Expand All @@ -539,13 +545,17 @@ export async function createPluginContainer(
if (!combinedMap) {
combinedMap = m as SourceMap
} else {
combinedMap = combineSourcemaps(cleanUrl(this.filename), [
{
...(m as RawSourceMap),
sourcesContent: combinedMap.sourcesContent,
},
combinedMap as RawSourceMap,
]) as SourceMap
combinedMap = combineSourcemaps(
cleanUrl(this.filename),
[
{
...(m as RawSourceMap),
sourcesContent: combinedMap.sourcesContent,
},
combinedMap as RawSourceMap,
],
excludeContent,
) as SourceMap
}
}
if (!combinedMap) {
Expand Down