-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scopes: support for hiding new injected scopes from the stack trace #113
Comments
Intuitively I would have said we should emit a generated range for |
I agree with @szuend, that's a generated range without an original scope. This should already be implemented in my beta |
I didn't implement anything yet but just thinking out loud. I modified the example a bit so we have the following input: function run(x) {
x();
}
function foo() {
for (let x of [1, 2, 3]) {
console.trace(x);
run(() => x);
}
}
foo(); And Babel generates: function run(x) {
x();
}
function foo() {
var _loop = function _loop() {
var x = _arr[_i];
console.trace(x);
run(function () {
return x;
});
};
for (var _i = 0, _arr = [1, 2, 3]; _i < _arr.length; _i++) {
_loop();
}
}
foo(); Now I would expect the following generated ranges (among others): One for var x = _arr[_i];
console.trace(x);
run(function () {
return x;
}); that points back to the original block scope for the The stack trace for pausing on the
For
The resulting stack trace would be:
Note that this approach uses the current proposal only. It would require generators to hide functions from stack traces by "masking" their call-sites with generated ranges that have no definition. Second note: Emitting a generated range for the whole Hope all of this makes sense. Please keep more examples coming, this is a great way to think through if the proposal actually works for the various transformations babel and other generators are doing. |
Alternative implementation: If we add a Then processing a stack trace would look something like this:
For the above example this would mean: Generators would emit a range for Why a Just annotating generated ranges with
|
While we focused a lot on function inlining, sometimes Babel does the opposite. For example, given this input:
Babel generates this code:
With the scopes proposal, is it possible to somehow mark
_loop
so that it does not appear in the stack when placing a breakpoint atconsole.trace(x)
?The text was updated successfully, but these errors were encountered: