Skip to content

User/robpaveza/sourcemaps v4#47152

Closed
robpaveza wants to merge 6 commits intomicrosoft:mainfrom
robpaveza:user/robpaveza/sourcemaps-v4
Closed

User/robpaveza/sourcemaps v4#47152
robpaveza wants to merge 6 commits intomicrosoft:mainfrom
robpaveza:user/robpaveza/sourcemaps-v4

Conversation

@robpaveza
Copy link

@robpaveza robpaveza commented Dec 14, 2021

Source Maps v4 standard proposal is an addendum to source maps to
improve post-hoc debugging and analysis of call stacks. This proposal is
being put forward in MicrosoftEdge/MSEdgeExplainers#538
and is designed to enable an analysis of stack traces to reconstruct an
unminified stack trace.

To do so, two additional fields are added to the source maps output:

  • scopeNames
  • scopes

The latter field behaves similarly to the existing mappings field. The
former list are names that should be displayed for a given function once
it is determined to be responsible. The format of the scopes field is
a Base64 VLQ with 6 fields, which are, in order:

  • Source file index
  • Source line (relative offset)
  • Source character (relative offset)
  • End line (relative offset, should always be positive)
  • End character (relative offset)
  • Index into scopeNames

Fixes #46695

Source Maps v4 standard proposal is an addendum to source maps to
improve post-hoc debugging and analysis of call stacks. This proposal is
being put forward in
[https://github.com/MicrosoftEdge/MSEdgeExplainers/pull/538](Microsoft Edge)
and is designed to enable an analysis of stack traces to reconstruct an
unminified stack trace.

To do so, two additional fields are added to the source maps output:
 - `scopeNames`
 - `scopes`

The latter field behaves similarly to the existing `mappings` field. The
former list are names that should be displayed for a given function once
it is determined to be responsible. The format of the `scopes` field is
a Base64 VLQ with 6 fields, which are, in order:
 - Source file index
 - Source line (relative offset)
 - Source character (relative offset)
 - End line (relative offset, should always be positive)
 - End character (relative offset)
 - Index into `scopeNames`

(This first commit does not implement the VLQ encoding; rather, all
number values are directly passed in and are neither relative nor are
they encoded as VLQs).
 - Method declarations
 - Constructor
 - Class property accessors
 - Improved arrow scope
 - Arrow scope call expressions
 - Lambda class property
 - Base64 VLQ encoding of `scopes` property

Fixed a bug that allowed some code to execute in v3 passes.
Several tests related to tsc --init / tsc watch were breaking as a
result of the new option. These tests have been rebaselined or adjusted
as needed to accommodate the new `sourceMapVersion` setting.
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Dec 14, 2021
@robpaveza
Copy link
Author

I'm confused about this. I modified some of the tests to output the diff, and I see a diff, but I don't see a difference in the diff.

===================================================================
--- Expected    The current baseline
+++ Actual      The new version
@@ -1,12 +1,12 @@
-Input::
-//// [/user/username/projects/myproject/file1.ts]
-export const c = 30;
-
-//// [/user/username/projects/myproject/src/file2.ts]
-import {c} from "file1"; export const d = 30;
-
-//// [/a/lib/lib.d.ts]
+Input::
+//// [/user/username/projects/myproject/file1.ts]
+export const c = 30;
+
+//// [/user/username/projects/myproject/src/file2.ts]
+import {c} from "file1"; export const d = 30;
+
+//// [/a/lib/lib.d.ts]
 /// <reference no-default-lib="true"/>
 interface Boolean {}
 interface Function {}
 interface CallableFunction {}
@@ -15,11 +15,11 @@
 interface Number { toExponential: any; }
 interface Object {}
 interface RegExp {}
 interface String { charAt: any; }
-interface Array<T> { length: number; [n: number]: T; }
-
-//// [/user/username/projects/myproject/tsconfig.json]
+interface Array<T> { length: number; [n: number]: T; }
+
+//// [/user/username/projects/myproject/tsconfig.json]
 {
   "compilerOptions": {
     /* Visit https://aka.ms/tsconfig.json to read more about this file */

@@ -120,14 +120,14 @@
     // "skipDefaultLibCheck": true,                      /* Skip type checking .d.ts files that are included with TypeScript. */
     "skipLibCheck": true                                 /* Skip type checking all .d.ts files. */
   }
 }
-
-
-
-/a/lib/tsc.js -w -p /user/username/projects/myproject/tsconfig.json
-Output::
->> Screen clear
+
+
+
+/a/lib/tsc.js -w -p /user/username/projects/myproject/tsconfig.json
+Output::
+>> Screen clear

@robpaveza
Copy link
Author

Does not agree with the proposed spec on the encoding of scopes (an array of strings containing entries comprised of 5 VLQs, vs. a single string containing entries comprised of 6 VLQs). We will probably land on the version included in this implementation; the original proposal was done to try to make it as easy as possible for a tool like Webpack to implement. However, without scopeNames being an array of arrays, we'll need to modify the scopes list anyway.

@orta orta requested a review from rbuckton December 24, 2021 22:33
@sandersn
Copy link
Member

We can't review or merge speculative features, so I'm going to close this PR. If source maps v4 makes it through the standards process, please restart this PR.

@sandersn sandersn closed this Mar 31, 2025
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend Source Maps to support post-hoc debugging

4 participants