Skip to content

misc(build): do not include locales in devtools bundle #12921

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

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions build/build-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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},
})
Expand All @@ -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/';
Expand Down
2 changes: 1 addition & 1 deletion build/build-lightrider-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
})
Expand Down
2 changes: 1 addition & 1 deletion build/build-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>} */
Expand Down