Repository: GoogleChrome/lighthouse (js)

Issue:
devtools bundle went form 1 MB -> 11 MB
this was accidentally made huge with #12721 . the browserify ignore in `build-bundle.js` only works for require.

`readFileSyncTransform` could be used to check if this is a locale file and return `{}`.



Pull request:
misc(build): do not include locales in devtools bundle
this also fixes brfs readFileTransform... `readFileSyncTransform` is not an option. Not sure how the PRs that I made introducing this recorded byte savings ... 😄 

fixes #12919

Patch:
diff --git a/build/build-bundle.js b/build/build-bundle.js
index c29375081..5156133c8 100644
--- a/build/build-bundle.js
+++ b/build/build-bundle.js
@@ -13,6 +13,7 @@
 const fs = require('fs');
 const path = require('path');
 const assert = require('assert').strict;
+const stream = require('stream');
 const mkdir = fs.promises.mkdir;
 const LighthouseRunner = require('../lighthouse-core/runner.js');
 const exorcist = require('exorcist');
@@ -66,7 +67,23 @@ async function browserifyFile(entryPath, distPath) {
     })
     // Transform the fs.readFile etc into inline strings.
     .transform('@wardpeet/brfs', {
-      readFileSyncTransform: minifyFileTransform,
+      /** @param {string} file */
+      readFileTransform: (file) => {
+        // Don't include locales in DevTools.
+        if (isDevtools(entryPath) && locales.includes(file)) {
+          return new stream.Transform({
+            transform(chunk, enc, next) {
+              next();
+            },
+            final(next) {
+              this.push('{}');
+              next();
+            },
+          });
+        }
+
+        return minifyFileTransform(file);
+      },
       global: true,
       parserOpts: {ecmaVersion: 12},
     })
@@ -90,12 +107,6 @@ async function browserifyFile(entryPath, distPath) {
     bundle.ignore(require.resolve('../report/report-assets.js'));
   }
 
-  // Don't include locales in DevTools.
-  if (isDevtools(entryPath)) {
-    // @ts-expect-error bundle.ignore does accept an array of strings.
-    bundle.ignore(locales);
-  }
-
   // Expose the audits, gatherers, and computed artifacts so they can be dynamically loaded.
   // Exposed path must be a relative path from lighthouse-core/config/config-helpers.js (where loading occurs).
   const corePath = './lighthouse-core/';
diff --git a/build/build-lightrider-bundles.js b/build/build-lightrider-bundles.js
index 27970be71..6a570d397 100644
--- a/build/build-lightrider-bundles.js
+++ b/build/build-lightrider-bundles.js
@@ -40,7 +40,7 @@ function buildReportGenerator() {
   browserify(generatorFilename, {standalone: 'ReportGenerator'})
     // Transform the fs.readFile etc into inline strings.
     .transform('@wardpeet/brfs', {
-      readFileSyncTransform: minifyFileTransform,
+      readFileTransform: minifyFileTransform,
       global: true,
       parserOpts: {ecmaVersion: 12},
     })
diff --git a/build/build-viewer.js b/build/build-viewer.js
index 32afb9f24..2794a458e 100644
--- a/build/build-viewer.js
+++ b/build/build-viewer.js
@@ -20,7 +20,7 @@ async function run() {
   const generatorFilename = `${LH_ROOT}/report/report-generator.js`;
   const generatorBrowserify = browserify(generatorFilename, {standalone: 'ReportGenerator'})
     .transform('@wardpeet/brfs', {
-      readFileSyncTransform: minifyFileTransform,
+      readFileTransform: minifyFileTransform,
     });
 
   /** @type {Promise<string>} */
diff --git a/docs/hacking-tips.md b/docs/hacking-tips.md
index 25140c015..74735a069 100644
--- a/docs/hacking-tips.md
+++ b/docs/hacking-tips.md
@@ -1,5 +1,10 @@
 A few assorted scripts and tips to make hacking on Lighthouse a bit easier
 
+# Eng team resources
+
+* [LH Build Tracker](https://lh-build-tracker.herokuapp.com/builds/limit/100) - plotted results of [build-tracker](../build-tracker.config.js) [data](../.github/workflows/ci.yml#:~:text=buildtracker)
+* [LH PR Tracking](https://paulirish.github.io/lh-pr-tracking/) - stats about open PRs, collected [daily](https://github.com/paulirish/lh-pr-tracking/blob/master/.github/workflows/update-stats.yml).
+
 ## Evaluate Lighthouse's runtime performance
 
 Lighthouse has instrumentation to collect timing data for its operations. The data is exposed at `LHR.timing.entries`.  You can generate a trace from this data for closer analysis.


Test patch:
diff --git a/lighthouse-core/test/gather/gather-runner-test.js b/lighthouse-core/test/gather/gather-runner-test.js
index 4605e3587..4e475b14d 100644
--- a/lighthouse-core/test/gather/gather-runner-test.js
+++ b/lighthouse-core/test/gather/gather-runner-test.js
@@ -1044,13 +1044,26 @@ describe('GatherRunner', function() {
         'warning0',
         'warning1',
         'warning2',
+        {
+          i18nId: 'LH.IcuMessage0',
+          formattedDefault: 'warning3',
+        },
+        {
+          i18nId: 'LH.IcuMessage1',
+          formattedDefault: 'warning4',
+        },
       ];
 
       class WarningGatherer extends Gatherer {
         /** @param {LH.Gatherer.PassContext} passContext */
         afterPass(passContext) {
-          passContext.LighthouseRunWarnings.push(...runWarnings, ...runWarnings);
-          assert.strictEqual(passContext.LighthouseRunWarnings.length, runWarnings.length * 2);
+          passContext.LighthouseRunWarnings.push(
+            ...runWarnings,
+            ...runWarnings,
+            // adding one of the warnings with keys in different order
+            {formattedDefault: 'warning3', i18nId: 'LH.IcuMessage0'}
+          );
+          assert.strictEqual(passContext.LighthouseRunWarnings.length, runWarnings.length * 2 + 1);
 
           return '';
         }