@srcmap/remapping
v0.3.6
Published
Drop-in replacement for @jridgewell/remapping and @ampproject/remapping powered by Rust via WebAssembly
Downloads
313
Maintainers
Readme
@srcmap/remapping
Drop-in replacement for @jridgewell/remapping and @ampproject/remapping powered by Rust via WebAssembly.
Same API, same types, same behavior. Swap the import and get source map composition backed by Rust under the hood.
Install
npm install @srcmap/remappingUsage
// Before:
// import remapping from '@jridgewell/remapping'
// import remapping from '@ampproject/remapping'
// After:
import remapping from '@srcmap/remapping'
// Remap a single source map through a loader
const composed = remapping(minifiedMap, (sourcefile) => {
// Return the upstream source map for this file, or null
return upstreamMaps[sourcefile] ?? null
})
console.log(composed.sources) // Original sources
console.log(composed.mappings) // Composed VLQ mappings
console.log(composed.toString()) // JSON stringCompose an array of source maps
// When you have the full chain: [minified map, intermediate map, original map]
const composed = remapping([minifiedMap, intermediateMap], (sourcefile) => {
return upstreamMaps[sourcefile] ?? null
})Options
const composed = remapping(minifiedMap, loader, {
excludeContent: true, // Omit sourcesContent from the output
})API compatibility
| Export | Description |
|--------|-------------|
| remapping(input, loader, options?) | Remap a single source map through a loader |
| remapping(inputs[], loader, options?) | Compose an array of source maps |
| SourceMap | Result class with version, file, mappings, sources, sourcesContent, names, ignoreList |
The loader function receives a source filename and should return the upstream source map (as a JSON string, parsed object, or decoded source map), or null if no upstream map exists.
SourceMap result
| Property / Method | Type | Description |
|--------|------|-------------|
| version | number | Source map version (always 3) |
| file | string \| undefined | Output filename |
| mappings | string | VLQ-encoded mappings |
| sources | (string \| null)[] | Source filenames |
| sourcesContent | (string \| null)[] \| undefined | Inline source contents |
| names | string[] | Name strings |
| ignoreList | number[] \| undefined | Indices of ignored sources |
| toString() | string | Serialize as JSON string |
| toJSON() | RawSourceMap | Return as parsed object |
Differences from @jridgewell/remapping
- WASM-powered: Composition runs in Rust via WebAssembly
- Indexed source maps: Handled natively (no JS-side flattening)
Part of srcmap
High-performance source map tooling written in Rust. See also:
@srcmap/trace-mapping- Drop-in for@jridgewell/trace-mapping(consumer)@srcmap/gen-mapping- Drop-in for@jridgewell/gen-mapping(generator)@srcmap/remapping-wasm- Lower-level WASM remapping API
License
MIT
