Skip to content

feat: Add source mapping functions - #3023

Open
aleksanderkatan wants to merge 24 commits into
feat/bool-and-ident-nodesfrom
feat/add-sourcemaps-to-tinyest
Open

aleksanderkatan wants to merge 24 commits into
feat/bool-and-ident-nodesfrom
feat/add-sourcemaps-to-tinyest

Conversation

@aleksanderkatan

@aleksanderkatan aleksanderkatan commented Sep 15, 2026

Copy link
Copy Markdown
Member

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.

@aleksanderkatan
aleksanderkatan added this pull request to stack #3024 September 15, 2026 12:03
@aleksanderkatan
aleksanderkatan force-pushed the feat/add-sourcemaps-to-tinyest branch 2 times, most recently from 998ef7a to 44d2371 Compare September 15, 2026 13:09
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/eslint-plugin-typegpu@6f36a4ef28d6572c52f98021f9b30b4f85ece60e
https://pkg.pr.new/software-mansion/TypeGPU/tinyest@6f36a4ef28d6572c52f98021f9b30b4f85ece60e
https://pkg.pr.new/software-mansion/TypeGPU/tinyest-for-wgsl@6f36a4ef28d6572c52f98021f9b30b4f85ece60e
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@6f36a4ef28d6572c52f98021f9b30b4f85ece60e
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@6f36a4ef28d6572c52f98021f9b30b4f85ece60e
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@6f36a4ef28d6572c52f98021f9b30b4f85ece60e

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

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]
Loading
---
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]
Loading
---
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]
Loading

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 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 ($${\color{red}+0.6\%}$$)
tgpu_resolve.ts 165.50 kB ($${\color{red}+0.6\%}$$)

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

@aleksanderkatan aleksanderkatan changed the title feat: Add stripSourceMap function to tinyest feat: Add source map functions to tinyest Sep 15, 2026
@aleksanderkatan
aleksanderkatan removed this pull request from stack #3024 September 15, 2026 15:58
@aleksanderkatan
aleksanderkatan added this pull request to stack #3025 September 15, 2026 15:58
@aleksanderkatan

Copy link
Copy Markdown
Member Author

@pullfrog review

pullfrog[bot]

This comment was marked as outdated.

@aleksanderkatan
aleksanderkatan force-pushed the feat/add-sourcemaps-to-tinyest branch 3 times, most recently from 4c0b4de to d920bde Compare September 17, 2026 09:21
@aleksanderkatan aleksanderkatan mentioned this pull request Sep 17, 2026
9 tasks
@aleksanderkatan aleksanderkatan changed the title feat: Add source map functions to tinyest feat: Add source mapping functions Sep 18, 2026
@aleksanderkatan
aleksanderkatan force-pushed the feat/add-sourcemaps-to-tinyest branch from 4ff8bbf to a54f1d4 Compare September 18, 2026 14:36
@aleksanderkatan
aleksanderkatan marked this pull request as ready for review September 18, 2026 14:38
Copilot AI lite review requested due to automatic review settings September 18, 2026 14:38

This comment was marked as outdated.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — a docs fix inline plus a typecheck-coverage note.

Reviewed changes

  • New source-mapping APIembedSourceMap/stripSourceMap in packages/tinyest/src/sourceMapping.ts wrap mapped array nodes as [-1, line, column, node] and unwrap them back into a SourceMap, always operating on fresh AST copies.
  • New public typesSourceMap and the opaque SourceMappedNode brand in packages/tinyest/src/nodes.ts, re-exported through index.ts.
  • Tests — 20 new vitest cases covering embed/strip and the embed -> strip / strip -> embed inverse, plus a vitest devDependency 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 checks sourceMap.size === 3, so a wrong-key regression would still pass even though sibling tests assert exact keys.
  • pnpm-lock.yaml also bumps @types/bun/bun-types from 1.4.0 to 1.4.2, unrelated to this feature and avoidable lockfile noise.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread packages/tinyest/README.md Outdated
aleksanderkatan and others added 3 commits September 18, 2026 16:59
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>
@aleksanderkatan

Copy link
Copy Markdown
Member Author

packages/tinyest has no test:types script, so pnpm test:types (pnpm -r test:types) skips it entirely,

I don't think that's true

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants