Repository navigation
Source hint for production builds, through the page's source maps - #29
Closed
gowtham012 wants to merge 1 commit into
Closed
gowtham012 wants to merge 1 commit into
gowtham012 wants to merge 1 commit into
Conversation
When a minified build has stripped React's _debugSource and Vue's __file, inspector.js hands the nearest component function's own source text and the page's script URLs to the worker, which finds the script that holds it, follows its sourceMappingURL (or SourceMap header; data: and indexed maps too), decodes the VLQ mappings and puts the original file:line and component name into the source hint with method "sourcemap". Same origin (or loopback from a loopback page) only, redirects refused, no cookies, 8 MB per file, 1.5 s total; any failure leaves no hint. No new permission or dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Included in #30 (merged), together with fixes found by testing on real Vite/React/Next/webpack/Vue production builds. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a production build has stripped the framework's debug info (React
_debugSource/_debugStack, Vue__file), Pinpoint now maps the clicked element back through the page's source maps to the original component and file.How it works
inspector.js(MAIN world) answers a newpinpoint:probeevent: the nearest component's function (fiber.type/.type.render/.type.type, Vuesetup/render), the first 120 chars of itsFunction.prototype.toString, and the page's script URLs (document.scriptsandperformanceresource entries withinitiatorType: "script").content.jsasks for this only when the hint has no file and the framework is React or Vue. It starts when the popover opens, so the lookup is usually done by Send. The crop is now measured before the note is built.extension/sourcemap.js) keeps only allowed URLs, fetches them, finds the snippet (it must appear exactly once) and gets a 0-based line/col. Then it reads the last//# sourceMappingURL=or theSourceMap/X-SourceMapheader (data: and relative URLs work), decodes the VLQmappings, takes the segment at or before that position, and returns{file, line, column, name}.sources[]are cleaned to project-relative paths. Indexed maps work;urlsections are skipped.sourcegetsmethod: "sourcemap", and the minified name in the component chain is replaced by the original PascalCasenames[]entry. The agent markdown says "(found through the page's source map)".Why the worker: the page's CSP
connect-srcand anyfetchoverride the page has installed play no part, and the page never sees the requests. The allowed origin comes fromsender.url, never from the message. It runs only for local dev pages.Limits: only same origin, or loopback from a loopback page; a map on a CDN or other host is never requested. Redirects are refused, no cookies are sent, the cap is 8 MB per file, the budget is 1.5 s, and results are cached per URL for 60 s (8 entries). Inline and eval'd scripts are not listed, so they are not found. Code-split chunks work only if the chunk appears in
performanceentries (lazy chunks loaded withimport()do). A function text that appears twice gives no hint. Sources under node_modules give no hint.No new manifest permission and no new dependency. Firefox's
background.scriptsgainssourcemap.js.Tests:
ui-sourcemap.test.mjs(10 tests: VLQ, a check against source-map-js on every segment of a real esbuild map, lookup, cleanup, indexed maps, fetch policy, resolve with cache/data:/cross-origin/timeout) ande2e-sourcemap.test.mjs(production bundle →src/components/PriceTag.js:9via sourcemap; a map on another origin is never requested and gives no hint). Full suite: 227 tests, 226 pass, 0 fail, 1 skipped. Firefox packageweb-ext lint: 0 errors.🤖 Generated with Claude Code