diff --git a/packages/vite/src/node/plugins/define.ts b/packages/vite/src/node/plugins/define.ts index 39d7b6bf8f3f5e..2b7a7cd8d508d8 100644 --- a/packages/vite/src/node/plugins/define.ts +++ b/packages/vite/src/node/plugins/define.ts @@ -1,5 +1,4 @@ import { transform } from 'esbuild' -import { TraceMap, decodedMap, encodedMap } from '@jridgewell/trace-mapping' import type { ResolvedConfig } from '../config' import type { Plugin } from '../plugin' import { escapeRegex } from '../utils' @@ -201,26 +200,6 @@ export async function replaceDefine( : true, }) - // remove esbuild's source entries - // since they would confuse source map remapping/collapsing which expects a single source - if (result.map.includes('= 2) { - const sourceIndex = originalMap.sources.indexOf(id) - const decoded = decodedMap(originalMap) - decoded.sources = [id] - decoded.mappings = decoded.mappings.map((segments) => - segments.filter((segment) => { - // modify and filter - const index = segment[1] - segment[1] = 0 - return index === sourceIndex - }), - ) - result.map = JSON.stringify(encodedMap(new TraceMap(decoded as any))) - } - } - return { code: result.code, map: result.map || null,