Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Distinguish between a ExistingRawSourceMap and ExistingDecodedSourceMap * Start work on DecodedSourceMapOrMissing type * Add decodedSourcemap helper * Fix collapseSourcemaps types * Specify Link|Source type * Handle missing map in collapseSourcemaps * Remove remaining any casts * Handle single item SourceMapSegmentVector * Fix tests * Fix lint issues * Handle null sourcemaps meaning no change in code * Handle a no-mappings sourcemap * Remove sourcemap-coded declaration It has types now * Undo comment changes * Use sourcemap-codec's types * Get rid of TODO * Use our own SourceMapSegment tuple type
- Loading branch information
1 parent
8fe1385
commit e66d7be
Showing
12 changed files
with
181 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { decode } from 'sourcemap-codec'; | ||
import { ExistingDecodedSourceMap, ExistingRawSourceMap, SourceMapInput } from '../rollup/types'; | ||
|
||
type Input = SourceMapInput | ExistingDecodedSourceMap | undefined; | ||
|
||
export function decodedSourcemap(map: Input): ExistingDecodedSourceMap | null { | ||
if (!map) return null; | ||
|
||
if (typeof map === 'string') { | ||
map = JSON.parse(map) as ExistingRawSourceMap; | ||
} | ||
if (map.mappings === '') { | ||
return { | ||
mappings: [], | ||
names: [], | ||
sources: [], | ||
version: 3 | ||
}; | ||
} | ||
|
||
let mappings; | ||
if (typeof map.mappings === 'string') { | ||
mappings = decode(map.mappings); | ||
} else { | ||
mappings = map.mappings; | ||
} | ||
|
||
return { ...(map as ExistingRawSourceMap | ExistingDecodedSourceMap), mappings }; | ||
} |
Oops, something went wrong.