@srcmap/remapping-wasm 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -0
- package/package.json +18 -6
- package/pkg/README.md +99 -0
- package/pkg/package.json +2 -2
- package/pkg/srcmap_remapping_wasm_bg.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @srcmap/remapping-wasm
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@srcmap/remapping-wasm)
|
|
4
|
+
[](https://github.com/BartWaardenburg/srcmap/actions/workflows/ci.yml)
|
|
5
|
+
|
|
6
|
+
High-performance source map concatenation and composition powered by Rust via WebAssembly.
|
|
7
|
+
|
|
8
|
+
**Concatenation** merges source maps from multiple bundled files into one, adjusting line offsets. **Composition** chains source maps through multiple transforms (e.g. TS -> JS -> minified) into a single map pointing to original sources. Alternative to [`@ampproject/remapping`](https://github.com/nicolo-ribaudo/source-map-js).
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @srcmap/remapping-wasm
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Works in Node.js, browsers, and any WebAssembly-capable runtime. No native compilation required.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Concatenation
|
|
21
|
+
|
|
22
|
+
Merge source maps from multiple files into a single combined map:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import { ConcatBuilder } from '@srcmap/remapping-wasm'
|
|
26
|
+
|
|
27
|
+
const builder = new ConcatBuilder('bundle.js')
|
|
28
|
+
|
|
29
|
+
// Add source maps with their line offsets in the output
|
|
30
|
+
builder.addMap(chunkASourceMapJson, 0) // chunk A starts at line 0
|
|
31
|
+
builder.addMap(chunkBSourceMapJson, 1000) // chunk B starts at line 1000
|
|
32
|
+
|
|
33
|
+
const combinedJson = builder.toJSON()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Composition / Remapping
|
|
37
|
+
|
|
38
|
+
Chain source maps through a transform pipeline into a single map:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
import { remap } from '@srcmap/remapping-wasm'
|
|
42
|
+
|
|
43
|
+
// Your build: original.ts -> intermediate.js -> minified.js
|
|
44
|
+
// You have: minified.js.map (outer) and intermediate.js.map (inner)
|
|
45
|
+
|
|
46
|
+
const composedJson = remap(minifiedSourceMapJson, (source) => {
|
|
47
|
+
// Called for each source in the outer map
|
|
48
|
+
if (source === 'intermediate.js') {
|
|
49
|
+
return intermediateSourceMapJson // upstream source map JSON
|
|
50
|
+
}
|
|
51
|
+
return null // no upstream map, keep as-is
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
### `new ConcatBuilder(file?: string)`
|
|
58
|
+
|
|
59
|
+
Create a builder for concatenating source maps.
|
|
60
|
+
|
|
61
|
+
| Method | Returns | Description |
|
|
62
|
+
|--------|---------|-------------|
|
|
63
|
+
| `addMap(json, lineOffset)` | `void` | Add a source map JSON at the given line offset |
|
|
64
|
+
| `toJSON()` | `string` | Generate the concatenated source map JSON |
|
|
65
|
+
|
|
66
|
+
### `remap(outerJson, loader)`
|
|
67
|
+
|
|
68
|
+
Compose source maps through a transform chain.
|
|
69
|
+
|
|
70
|
+
| Parameter | Type | Description |
|
|
71
|
+
|-----------|------|-------------|
|
|
72
|
+
| `outerJson` | `string` | The final-stage source map JSON |
|
|
73
|
+
| `loader` | `(source: string) => string \| null` | Returns upstream source map JSON, or `null` |
|
|
74
|
+
|
|
75
|
+
Returns the composed source map as a JSON string.
|
|
76
|
+
|
|
77
|
+
## Build targets
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Node.js (default)
|
|
81
|
+
npm run build
|
|
82
|
+
|
|
83
|
+
# Browser (ES module + .wasm)
|
|
84
|
+
npm run build:web
|
|
85
|
+
|
|
86
|
+
# Bundler (e.g. webpack, vite)
|
|
87
|
+
npm run build:bundler
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Part of [srcmap](https://github.com/BartWaardenburg/srcmap)
|
|
91
|
+
|
|
92
|
+
High-performance source map tooling written in Rust. See also:
|
|
93
|
+
- [`@srcmap/sourcemap-wasm`](https://www.npmjs.com/package/@srcmap/sourcemap-wasm) - Source map parser (WASM)
|
|
94
|
+
- [`@srcmap/generator-wasm`](https://www.npmjs.com/package/@srcmap/generator-wasm) - Source map generator (WASM)
|
|
95
|
+
- [`@srcmap/symbolicate-wasm`](https://www.npmjs.com/package/@srcmap/symbolicate-wasm) - Stack trace symbolication (WASM)
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srcmap/remapping-wasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "High-performance source map concatenation and remapping powered by Rust (WebAssembly)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "pkg/srcmap_remapping_wasm.js",
|
|
7
7
|
"types": "pkg/srcmap_remapping_wasm.d.ts",
|
|
8
|
+
"browser": "web/srcmap_remapping_wasm.js",
|
|
9
|
+
"module": "web/srcmap_remapping_wasm.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"node": "./pkg/srcmap_remapping_wasm.js",
|
|
13
|
+
"browser": "./web/srcmap_remapping_wasm.js",
|
|
14
|
+
"default": "./pkg/srcmap_remapping_wasm.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
8
17
|
"license": "MIT",
|
|
9
18
|
"files": [
|
|
10
19
|
"pkg/",
|
|
20
|
+
"web/",
|
|
11
21
|
"README.md"
|
|
12
22
|
],
|
|
13
23
|
"scripts": {
|
|
14
|
-
"build": "wasm-pack build --target nodejs",
|
|
15
|
-
"build:web": "wasm-pack build --target web",
|
|
16
|
-
"build:bundler": "wasm-pack build --target bundler",
|
|
24
|
+
"build": "wasm-pack build --target nodejs --out-dir pkg",
|
|
25
|
+
"build:web": "wasm-pack build --target web --out-dir web",
|
|
26
|
+
"build:bundler": "wasm-pack build --target bundler --out-dir bundler",
|
|
27
|
+
"build:all": "npm run build && npm run build:web",
|
|
17
28
|
"test": "node --test __tests__/remapping-wasm.test.mjs"
|
|
18
29
|
},
|
|
19
30
|
"repository": {
|
|
20
31
|
"type": "git",
|
|
21
|
-
"url": "https://github.com/BartWaardenburg/srcmap"
|
|
32
|
+
"url": "git+https://github.com/BartWaardenburg/srcmap.git"
|
|
22
33
|
},
|
|
23
34
|
"keywords": [
|
|
24
35
|
"sourcemap",
|
|
@@ -29,6 +40,7 @@
|
|
|
29
40
|
"rust",
|
|
30
41
|
"wasm",
|
|
31
42
|
"webassembly",
|
|
32
|
-
"performance"
|
|
43
|
+
"performance",
|
|
44
|
+
"browser"
|
|
33
45
|
]
|
|
34
46
|
}
|
package/pkg/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @srcmap/remapping-wasm
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@srcmap/remapping-wasm)
|
|
4
|
+
[](https://github.com/BartWaardenburg/srcmap/actions/workflows/ci.yml)
|
|
5
|
+
|
|
6
|
+
High-performance source map concatenation and composition powered by Rust via WebAssembly.
|
|
7
|
+
|
|
8
|
+
**Concatenation** merges source maps from multiple bundled files into one, adjusting line offsets. **Composition** chains source maps through multiple transforms (e.g. TS -> JS -> minified) into a single map pointing to original sources. Alternative to [`@ampproject/remapping`](https://github.com/nicolo-ribaudo/source-map-js).
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @srcmap/remapping-wasm
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Works in Node.js, browsers, and any WebAssembly-capable runtime. No native compilation required.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Concatenation
|
|
21
|
+
|
|
22
|
+
Merge source maps from multiple files into a single combined map:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import { ConcatBuilder } from '@srcmap/remapping-wasm'
|
|
26
|
+
|
|
27
|
+
const builder = new ConcatBuilder('bundle.js')
|
|
28
|
+
|
|
29
|
+
// Add source maps with their line offsets in the output
|
|
30
|
+
builder.addMap(chunkASourceMapJson, 0) // chunk A starts at line 0
|
|
31
|
+
builder.addMap(chunkBSourceMapJson, 1000) // chunk B starts at line 1000
|
|
32
|
+
|
|
33
|
+
const combinedJson = builder.toJSON()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Composition / Remapping
|
|
37
|
+
|
|
38
|
+
Chain source maps through a transform pipeline into a single map:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
import { remap } from '@srcmap/remapping-wasm'
|
|
42
|
+
|
|
43
|
+
// Your build: original.ts -> intermediate.js -> minified.js
|
|
44
|
+
// You have: minified.js.map (outer) and intermediate.js.map (inner)
|
|
45
|
+
|
|
46
|
+
const composedJson = remap(minifiedSourceMapJson, (source) => {
|
|
47
|
+
// Called for each source in the outer map
|
|
48
|
+
if (source === 'intermediate.js') {
|
|
49
|
+
return intermediateSourceMapJson // upstream source map JSON
|
|
50
|
+
}
|
|
51
|
+
return null // no upstream map, keep as-is
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
### `new ConcatBuilder(file?: string)`
|
|
58
|
+
|
|
59
|
+
Create a builder for concatenating source maps.
|
|
60
|
+
|
|
61
|
+
| Method | Returns | Description |
|
|
62
|
+
|--------|---------|-------------|
|
|
63
|
+
| `addMap(json, lineOffset)` | `void` | Add a source map JSON at the given line offset |
|
|
64
|
+
| `toJSON()` | `string` | Generate the concatenated source map JSON |
|
|
65
|
+
|
|
66
|
+
### `remap(outerJson, loader)`
|
|
67
|
+
|
|
68
|
+
Compose source maps through a transform chain.
|
|
69
|
+
|
|
70
|
+
| Parameter | Type | Description |
|
|
71
|
+
|-----------|------|-------------|
|
|
72
|
+
| `outerJson` | `string` | The final-stage source map JSON |
|
|
73
|
+
| `loader` | `(source: string) => string \| null` | Returns upstream source map JSON, or `null` |
|
|
74
|
+
|
|
75
|
+
Returns the composed source map as a JSON string.
|
|
76
|
+
|
|
77
|
+
## Build targets
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Node.js (default)
|
|
81
|
+
npm run build
|
|
82
|
+
|
|
83
|
+
# Browser (ES module + .wasm)
|
|
84
|
+
npm run build:web
|
|
85
|
+
|
|
86
|
+
# Bundler (e.g. webpack, vite)
|
|
87
|
+
npm run build:bundler
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Part of [srcmap](https://github.com/BartWaardenburg/srcmap)
|
|
91
|
+
|
|
92
|
+
High-performance source map tooling written in Rust. See also:
|
|
93
|
+
- [`@srcmap/sourcemap-wasm`](https://www.npmjs.com/package/@srcmap/sourcemap-wasm) - Source map parser (WASM)
|
|
94
|
+
- [`@srcmap/generator-wasm`](https://www.npmjs.com/package/@srcmap/generator-wasm) - Source map generator (WASM)
|
|
95
|
+
- [`@srcmap/symbolicate-wasm`](https://www.npmjs.com/package/@srcmap/symbolicate-wasm) - Stack trace symbolication (WASM)
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT
|
package/pkg/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srcmap-remapping-wasm",
|
|
3
3
|
"description": "WebAssembly bindings for srcmap-remapping",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/
|
|
8
|
+
"url": "https://github.com/BartWaardenburg/srcmap"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"srcmap_remapping_wasm_bg.wasm",
|
|
Binary file
|