-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Use maybeAddMapping
to add sourcemap markings
#14510
Conversation
This lets the generator decide whether a mapping is worth keeping, instead of implementing it in every project that wants to produce a sorucemap.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51811/ |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51807/ |
jest.config.js
Outdated
runner: supportsESMAndJestLightRunner ? "jest-light-runner" : "jest-runner", | ||
runner: | ||
supportsESMAndJestLightRunner && !debug | ||
? "jest-light-runner" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think light runner is running in a Worker? I'm also having troubles when using TEST_DEBUG
with a test label, it only seems to work when I use a describe label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#14488 adds --runInBand
support.
@@ -1,13 +1,15 @@ | |||
{ | |||
"mappings": "AAAC;ACAD,K", | |||
"version": 3, | |||
"mappings": "AAAC,KCAD;ACAA,K", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually a bug fix. We were testing:
if (
this._lastGenLine === generatedLine &&
this._lastSourceLine === line &&
this._lastSourceColumn === column
) {
return;
}
However, we forgot to check whether the filename is different! Eg, here were on the same generated line, and pointing at the same source line/column. But we're pointing at two totally separate source files. AAAC
is pointing at the firs file, and KCAD
is pointing at the second file.
// start of this range. We use 'force' here to explicitly start a new | ||
// mapping range for this new token. | ||
this.source("start", loc, true /* force */); | ||
this.source("start", loc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no longer need to force. gen-mapping
can determine that a name index has changed, and will preserve the mapping.
Eg, const foo = x => y;
, we have two mappings pointing at the x
variable. The first mapping is the arrow function, and it does not have a name
field. The second mapping is for the identifier, and it does have a name
. Because the name changed between the mappings, we'll keep both mappings instead of skipping the second. This is what force
accomplished because we didn't check for identifierName
changes in the lastXyz === xyz
section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, but the jest.config.js
changes can/should be reverted.
jest-light-runner update will fix this.
Reverted changes to |
Projects trying to create sourcemaps shouldn't have to concern themselves with whether adding a mapping is useful or just clutters the mappings.
gen-mapping
has newly introducedmaybeAddMapping
which will determine if a mapping is useful, or skip it.