-
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): new audit #10303
Conversation
resolved another false positive found from running on paul's site. Here's what Wikipedia gives
Should ignore those too, I think. |
https://www.redditstatic.com/mweb2x/vendors~Mweb.15c8b87d53fe9156dd3a.js ctrl + f "node_modules" |
@connorjclark you're planning on adding "waiting4reviewer" with a specific call to action when you feel you're blocked on us again, correct? |
I think the |
Is the table still empty without a message once you expand the notapplicable audit? That seems to be an equivalent problem to the passing audit with an empty table. |
NVM, I had strange expectations for what notApplicable does :) fixed the empty table thing. also, noticed that the row counting logic was wrong - it assumed that each row would have only one url item type. that is not true, so I changed it to count |
anything else reviewers @patrickhulce @paulirish ? |
score: foundSignalInFirstPartyCode ? 0 : 1, | ||
notApplicable: !foundSignalInFirstPartyCode, | ||
extendedInfo: { | ||
signalCount, |
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.
should this be numericValue and "unitless"?
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.
IMO if it isn't immediately clear from the unit + name of the audit what the numericValue represents (CLS, dom-size, opportunity, etc) then it should live in extendedInfo, so I like it as-is
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! 🎉🎉
Aight @paulirish speak now or forever hold your peace :) |
(previous PR #6730 has too many comments, so here's a new one).
New Audit:
legacy-javascript
Goal: Encourage developers to serve modern code to modern browsers.
Design Doc
This audit fails if legacy code is found in any first party code. The recommended action is to use the module/nomodule pattern, in addition to @babel/preset-modules (instead of @babel/preset-env).
This first pass does not add this audit to the default config.
Legacy code, defined
Legacy code contains either polyfills or transformed code for features that modern browsers don't need. "modern browser" is defined as a browser that support ES modules. The relevant polyfills / transforms are in this spreadsheet.
Polyfills overwrite native prototypes in regular patterns (
String.prototype.startsWith = ...
,Object.defineProperty(String.prototype, 'startsWith', ...
) or via common libraries (core-js). The patterns that emerge are fairly detectable with a regex. The major focus was on detecting core-js polyfills, although some effort was made to detect simple ways of polyfilling.Only some of the transforms are detectable. I went with 3 that were simple and common.
Woah, regex. Does it even work?
I wrote a tool to create a bunch of babel projects, varying on individual polyfills / transforms. The results of the tool are also checked into git. All that takes too long to run in CI, so it's just there as a manual verification. Any updates to the audit should also run that tool and check for changes in precision.
See it
http://misc-hoten.surge.sh/lh-legacy-javascript-pr/www.wikipedia.org_2020-02-06_13-20-38.report.html
http://misc-hoten.surge.sh/lh-legacy-javascript-pr/www.wix.com_2020-02-06_13-27-56.report.html
Follow up work
Runtime cost