cloudflare / miniflare

🔥 Fully-local simulator for Cloudflare Workers. For the latest version, see https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare.
https://miniflare.dev
MIT License
3.78k stars 205 forks source link

[Miniflare 3] Serve linked source maps from loopback server (enable breakpoint debugging for TypeScript) #660

Closed mrbbot closed 1 year ago

mrbbot commented 1 year ago

Hey! 👋 With cloudflare/workerd#710, workerd supports breakpoint debugging! Support for this in Miniflare just worked, assuming you were using a plain JavaScript worker, or you had inline source maps. workerd doesn't know where workers are located on disk, it just knows files' locations relative to each other. This means it's unable to resolve locations of corresponding linked .map files in sourceMappingURL comments.

Miniflare does have this information though. This PR detects linked source maps and rewrites sourceMappingURL comments to http URLs pointing to Miniflare's loopback server. This then looks for the source map relative to the known on-disk source location. Source maps' sourceRoot attributes are updated to ensure correct locations are displayed in DevTools.

This enables breakpoint debugging for compiled TypeScript with linked source maps! :tada:

image image

Closes DEVX-872

changeset-bot[bot] commented 1 year ago

⚠️ No Changeset found

Latest commit: 73c06dc17683ed320a7b306ed735b453608cc17d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR