Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jridgewell/build-mapping
Build source and source maps
https://github.com/jridgewell/build-mapping
Last synced: 2 months ago
JSON representation
Build source and source maps
- Host: GitHub
- URL: https://github.com/jridgewell/build-mapping
- Owner: jridgewell
- License: mit
- Created: 2024-03-02T08:15:57.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-03T07:45:39.000Z (10 months ago)
- Last Synced: 2024-04-24T07:59:59.826Z (8 months ago)
- Language: TypeScript
- Size: 180 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @jridgewell/build-mapping
> Build source and source maps
Allows you to iteratively build source code and source maps from previously generated code/maps.
## Installation
```sh
npm install @jridgewell/build-mapping
```## Usage
```typescript
import { build, unnormalizedBuild } from '@jridgewell/build-mapping';const input = transformFileSync('input.js')
const { code, map } = build`foo ${input} bar`;assert.equal(code, `foo [input's code here…] bar`);
assert.deepEqual(map, {
version: 3,
sections: [
{ offset: { line: 0, column: 4 }, map: … },
{ offset: { line: 0, column: 24 }, map: … },
]
});// If you're using @jridgewell/trace-mapping's `AnyMap`, you can use a faster unnormalized builder:
const { code: sameCode, map: unnormalized } = unnormalizedBuild`foo ${input} bar`;// This can be anything that generates { code, map }.
function transformFileSync(file: string): { code: string, map: string } {
return babel.transformFileSync('input.js');
}
```