https://github.com/tomokimiyauci/source-map
Source Map, based on TC39 spec reference implementation
https://github.com/tomokimiyauci/source-map
source-map tc39
Last synced: about 1 month ago
JSON representation
Source Map, based on TC39 spec reference implementation
- Host: GitHub
- URL: https://github.com/tomokimiyauci/source-map
- Owner: TomokiMiyauci
- License: mit
- Created: 2024-09-19T04:34:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-23T12:47:43.000Z (over 1 year ago)
- Last Synced: 2025-11-03T23:25:06.769Z (5 months ago)
- Topics: source-map, tc39
- Homepage: https://jsr.io/@miyauci/source-map
- Size: 39.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# source-map
> 🚧 WIP at [beta branch](https://github.com/TomokiMiyauci/source-map/tree/beta)
[Source Map](https://tc39.es/source-map/), based on TC39 spec reference
implementation.
Based on 18 September 2024 update.
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Contributing](#contributing)
- [License](#license)
## Install
deno:
```bash
deno add @miyauci/source-map
```
node:
```bash
npx jsr add @miyauci/source-map
```
## Usage
Here are some modules.
`decodeSourceMapFromJSONString` is the implementation of
[decode a source map from a JSON string](https://tc39.es/source-map/#decode-a-source-map-from-a-json-string).
```ts
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](https://tc39.es/source-map/#extract-a-source-map-url-from-javascript-without-parsing).
```ts
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](#api) section.
## API
See [jsr doc](https://jsr.io/@miyauci/source-map) for all APIs.
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
## License
[MIT](LICENSE) © 2024 Tomoki Miyauchi