UNPKG

532 BJavaScriptView Raw
1
2import {charCodes} from "./parser/util/charcodes";
3
4
5
6
7
8
9
10
11
12
13
14/**
15 * Generate a simple source map indicating that each line maps directly to the original line.
16 */
17export default function computeSourceMap(
18 code,
19 filePath,
20 {compiledFilename},
21) {
22 let mappings = "AAAA";
23 for (let i = 0; i < code.length; i++) {
24 if (code.charCodeAt(i) === charCodes.lineFeed) {
25 mappings += ";AACA";
26 }
27 }
28 return {
29 version: 3,
30 file: compiledFilename || "",
31 sources: [filePath],
32 mappings,
33 names: [],
34 };
35}