Skip to content

Commit 01e5a2e

Browse files
authored
revert: bring back prior changes of compiler util (#5471)
Fixes #5469
1 parent 8e35da6 commit 01e5a2e

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

‎src/legacy/compiler/compiler-utils.spec.ts‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { resolve } from 'path'
2-
import { fileURLToPath } from 'url'
32

43
import { updateOutput } from './compiler-utils'
54

65
describe('updateOutput', () => {
76
it.each(['source-map.test.ts', 'source map.test.ts', 'source#100%.test.ts'])(
8-
'should preserve the source path as a file URL for %s',
7+
'should preserve the source path as a normalized path for %s',
98
(fileName) => {
10-
const sourcePath = resolve('src', fileName)
11-
const normalizedFileName = sourcePath.replace(/\\/g, '/')
9+
const normalizedFileName = resolve('src', fileName).replace(/\\/g, '/')
1210
const sourceMap = {
1311
version: 3,
1412
file: 'source-map.test.js',
@@ -24,11 +22,8 @@ describe('updateOutput', () => {
2422
JSON.stringify(sourceMap),
2523
)
2624
const updatedMap = JSON.parse(Buffer.from(output.split('base64,')[1], 'base64').toString('utf8'))
27-
const sourceUrl = new URL(updatedMap.sources[0])
2825

29-
expect(sourceUrl.protocol).toBe('file:')
30-
expect(fileURLToPath(sourceUrl)).toBe(sourcePath)
31-
expect(sourceUrl.hash).toBe('')
26+
expect(updatedMap.sources).toEqual([normalizedFileName])
3227
expect(updatedMap.file).toBe(normalizedFileName)
3328
expect(updatedMap.sourceRoot).toBeUndefined()
3429
expect(updatedMap.sourcesContent).toEqual(sourceMap.sourcesContent)

‎src/legacy/compiler/compiler-utils.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { pathToFileURL } from 'url'
2-
31
import { stringify } from '../../utils'
42

53
/**
@@ -31,8 +29,7 @@ export function updateOutput(outputText: string, normalizedFileName: string, sou
3129
const updateSourceMap = (sourceMapText: string, normalizedFileName: string): string => {
3230
const sourceMap = JSON.parse(sourceMapText)
3331
sourceMap.file = normalizedFileName
34-
// Source-map consumers resolve sources as URLs, where Windows drive paths are relative.
35-
sourceMap.sources = [pathToFileURL(normalizedFileName).href]
32+
sourceMap.sources = [normalizedFileName]
3633
delete sourceMap.sourceRoot
3734

3835
return stringify(sourceMap)

0 commit comments

Comments
 (0)