-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core(legacy-javascript): use source maps #10564
Conversation
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.
nice work! another carrot for the sourcemapping folks :)
@@ -28,6 +28,7 @@ const createArtifacts = (scripts) => { | |||
}; | |||
return acc; | |||
}, {}), | |||
SourceMaps: [], |
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.
could we a unit test or two in here to exercise the deduplication piece and any other flow that isn't currently covered by the bash script?
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.
done
Co-Authored-By: Patrick Hulce <[email protected]>
@patrickhulce bump :) |
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.
LGTM
travis says legacy-javascript smoketest failed to produce a report though so I'm a little concerned what I'm missing :/
I'm not bothering to look until #10566 lands, maybe moot. |
@@ -191,7 +76,8 @@ async function createVariant(options) { | |||
fs.writeFileSync(`${dir}/.babelrc`, JSON.stringify(babelrc || {}, null, 2)); | |||
// Not used in this script, but useful for running Lighthouse manually. | |||
// Just need to start a web server first. | |||
fs.writeFileSync(`${dir}/index.html`, `<title>${name}</title><script src=main.bundle.min.js>`); |
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.
lack of closing script element = bad sad times w/ no debuggability in CDT. chrome still requests the script, still shows in Network as a script, yet never loads.
}, | ||
{ | ||
"name": "core-js-2-only-polyfill/es6-array-find", | ||
"signals": "Array.prototype.find" | ||
}, | ||
{ | ||
"name": "core-js-2-only-polyfill/es6-array-find-index", | ||
"signals": "Array.prototype.findIndex" | ||
"signals": "Array.prototype.findIndex, Array.prototype.find" |
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.
Array.prototype.find
is a false positive
@@ -137,45 +29,33 @@ | |||
"name": "core-js-2-only-polyfill/es6-array-from", | |||
"signals": "Array.from" | |||
}, | |||
{ | |||
"name": "core-js-2-only-polyfill/es6-array-index-of", | |||
"signals": "" |
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 were empty because legacy javascript never checked for these polyfills, because I omitted them intentionally. The duplication of the polys in the run.js
script had some extra stuff. fixed now they it uses the same data source.
{ | ||
"name": "core-js-3-only-polyfill/es6-array-last-index-of", | ||
"signals": "Array.prototype.lastIndexOf" | ||
}, | ||
{ | ||
"name": "core-js-3-only-polyfill/es6-array-map", | ||
"signals": "" | ||
"signals": "Array.prototype.map" |
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.
example of the pattern matching not yielding results, but using source maps filled a gap.
}, | ||
{ | ||
"name": "core-js-3-only-polyfill/es6-array-reduce-right", | ||
"signals": "" | ||
"signals": "Array.prototype.reduce, Array.prototype.reduceRight" |
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.
another false positive. I think the map sources substring check is too loose.
// Skip if the pattern matching found a match for this polyfill. | ||
if (matches.some(m => m.name === name)) continue; | ||
|
||
const source = bundle.rawMap.sources.find(source => source.includes(module)); |
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 was avoiding endsWith
here because I know that webpack sometimes adds ?
to the end of things ... I don't know if that's actually true from a sane configuration and maybe that's not an issue.
@patrickhulce think we can just uses endsWith
here`? should we try to strip anything after a question mark ?
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.
a86f324 fixed many false positives
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.
does it need to be endsWith
or something more like
new RegExp(`${module}($|\/|\\?)`
perhaps? these are the file names right?
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.
yeah this is the entire file path, resolvable in node. I don't think those slashes are needed. module
is the name like es.array.fill
and the node module is named ...es.array.fill.js
.
I'm just unclear if sometimes there is a ?
in webpack maps and if I should account for that.
@@ -1,238 +1,176 @@ | |||
core-js-2-only-polyfill | |||
47738 es6-typed-uint8-clamped-array/main.bundle.min.js |
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.
source map comments made everything bigger
I'm a little unclear what the status is here @connorjclark. Marked as waiting on me so presumably the blockers were cleared, but the linked issue was an issue not a PR (but I guess its linked PR landed). Are the current build failures expected? The only substantial change I see since my last review is the |
note: runner unit test is flaky in GH |
Sorry, I jumped the gun there. It should be ready to land now. I commented a lot to explain why some changes happened. |
maybe we should increase the timeout? |
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.
LGTM
Part of #10369
If source maps are present, use our knowledge of what node module a polyfill comes from to find signals. Pattern matching takes precedence - the line/column information is more accurate. Otherwise, the first mapping entry for the relevant module is used as the source location.
Because the case of no source maps is important by itself, I introduced a second summary json file in the test.
Diff between the two new summary jsons (This represents the improvement in using maps + pattern matching) (same as what github shows for summary-signals.json in this PR, but this markdown is a bit nicer to look at) :