feat: Add source mapping functions - #3023
aleksanderkatan wants to merge 24 commits into
Conversation
998ef7a to
44d2371
Compare
|
pkg.pr.new packages benchmark commit |
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.72, 1.41, 3.16, 4.87, 5.34, 9.69, 17.97, 19.81]
line [0.79, 1.51, 3.11, 5.11, 5.74, 9.40, 18.08, 20.76]
line [0.72, 1.44, 3.08, 4.49, 5.51, 8.34, 18.45, 19.78]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.21, 0.35, 0.53, 0.61, 0.79, 0.85, 1.00, 1.14]
line [0.27, 0.36, 0.53, 0.63, 0.87, 0.88, 1.11, 1.24]
line [0.26, 0.41, 0.50, 0.62, 0.84, 0.83, 1.00, 1.09]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.60, 1.57, 2.64, 5.25, 9.00, 19.72, 39.89, 82.53]
line [0.69, 1.71, 3.38, 5.96, 9.15, 19.50, 41.58, 84.34]
line [0.68, 1.83, 3.10, 5.37, 9.18, 19.67, 41.91, 84.77]
|
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased (max 0.65%) | ❔ Unknown |
|---|---|---|---|
| 0 | 319 | 6 | 0 |
import * as ... in PR vs import * as ... in target (did bundle size increase?):
| Test | tsdown |
|---|---|
| tgpu_resolveWithContext.ts | 165.44 kB ( |
| tgpu_resolve.ts | 165.50 kB ( |
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
stripSourceMap function to tinyest|
@pullfrog review |
4c0b4de to
d920bde
Compare
4ff8bbf to
a54f1d4
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — a docs fix inline plus a typecheck-coverage note.
Reviewed changes
- New source-mapping API —
embedSourceMap/stripSourceMapinpackages/tinyest/src/sourceMapping.tswrap mapped array nodes as[-1, line, column, node]and unwrap them back into aSourceMap, always operating on fresh AST copies. - New public types —
SourceMapand the opaqueSourceMappedNodebrand inpackages/tinyest/src/nodes.ts, re-exported throughindex.ts. - Tests — 20 new vitest cases covering embed/strip and the
embed -> strip/strip -> embedinverse, plus avitestdevDependency and README documentation.
ℹ️ New tinyest code isn't covered by the repo typecheck gate
packages/tinyest has no test:types script, so pnpm test:types (pnpm -r test:types) skips it entirely, unlike tinyest-for-wgsl and unplugin-typegpu. The new tests only run through vitest's esbuild transform, which does not typecheck, and I confirmed that tsdown's dts emit does not fail on a deliberate type error in sourceMapping.ts. A one-line script (validated against the current tree) closes the gap.
Technical details
# Add a `test:types` script to `tinyest`
## Affected sites
- `packages/tinyest/package.json` — `scripts` has no `test:types`
- `packages/tinyest/src/sourceMapping.ts` — new generic-heavy code
- `packages/tinyest/test/sourceMapping.test.ts` — new test file
## Required outcome
- New source and tests are validated by `tsc` in CI, matching the sibling packages' convention.
## Suggested approach
- Add `"test:types": "pnpm tsc --p ./tsconfig.json --noEmit"`. The base tsconfig already includes both `src/**` and `test/**`, and this command exits cleanly on the current head.ℹ️ Nitpicks
packages/tinyest/test/sourceMapping.test.ts:193— test name reads'works for with property list'; likely meant'works for a property list'. Its assertion only checkssourceMap.size === 3, so a wrong-key regression would still pass even though sibling tests assert exact keys.pnpm-lock.yamlalso bumps@types/bun/bun-typesfrom1.4.0to1.4.2, unrelated to this feature and avoidable lockfile noise.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>


A node is mapped by wrapping it in
[SourceMapNodeType, line, column, node].I intend this to be an implementation detail, and for users to never embed/strip the source maps manually.