software-mansion / software-mansion/TypeGPU

feat: Source maps

Open
#2,935 1 comment 0 reactions 1 assignee View on GitHub

@aleksanderkatan is already working on this.

Since Aug 27, 2026.

MACROTASK
Dominant language
TypeScript
Stars
3.2k
Forks
122
Avg merge
3d 5h
Merged PRs (30d)
34

Description

The goal of this macrotask is to link to an appropriate line and character when 'use gpu' functions turns out to be invalid.

  • Add a node wrapper for Identifier, so that it can be sourcemapped (#2973)
  • Create a function for extracting sourcemaps from tinyest (#3023)
  • Accept source maps in transpileFn (#2975)
  • Collect source maps in plugin (#2942)
  • Include filename in metadata (#3039)
  • Update wgsl errors to all go through a report function that returns never (so that we can later use eval there)
  • Include source of error in WGSL errors
  • Document the feature
  • Make the error link clickable
    We could fake-include the errorous file in the stack trace, like WESL does. Something like this:
const fileUrl = `${window.location.origin}/src/main.ts?raw`;

const sourceMap = {
  version: 3,
  file: 'fakeErrorFile.js',
  sources: [fileUrl],
  mappings: `AA${toVLQ(/* line */ 11)}${toVLQ(/* char */ 4)}`,
};

const base64Map = btoa(
  String.fromCharCode(...new TextEncoder().encode(JSON.stringify(sourceMap))),
);

const errFile = `\
throw new Error(':c');
//# sourceMappingURL=data:application/json;base64,${base64Map}
//# sourceURL=apps/typegpu-docs/src/examples/simple/triangle/index.ts
`;
eval(errFile);

(RFC, extra work outside of original scope) Handle device errors.
WESL provides WeslDevice that takes generated source maps into account. We could do the same.
We should probably start with just catching and re-throwing errors. This may allow for easier RN debugging.
This will require us to collect another source map of generated WGSL.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.