🚧 WIP at beta branch
Source Map, based on TC39 spec reference implementation.
Based on 18 September 2024 update.
deno:
deno add @miyauci/source-map
node:
npx jsr add @miyauci/source-map
Here are some modules.
decodeSourceMapFromJSONString
is the implementation of
decode a source map from a JSON string.
import { decodeSourceMapFromJSONString } from "@miyauci/source-map";
const sourceMap = `{
"version": 3,
"file": "helloworld.js",
"sources": [
"helloworld.coffee"
],
"names": [],
"mappings": "AAAA;AAAA,EAAA,OAAO,CAAC,GAAR,CAAY,aAAZ,CAAA,CAAA;AAAA"
}`;
declare const baseURL: URL;
const decodedSourceMap = decodeSourceMapFromJSONString(sourceMap, baseURL);
extractSourceMapURLWithoutParsing
is the implementation of
extract a Source Map URL from JavaScript without parsing.
import { extractSourceMapURLWithoutParsing } from "@miyauci/source-map";
import { expect } from "@std/expect";
const source = `// Here is source code
//# sourceMappingURL=foo.js.map
`;
const urlString = extractSourceMapURLWithoutParsing(source);
expect(urlString).toBe("foo.js.map");
For all modules, see API section.
See jsr doc for all APIs.
See CONTRIBUTING.md
MIT © 2024 Tomoki Miyauchi