misc(build): rename bundled files (devtools/ext/lr) (#6179)
This commit is contained in:
Родитель
1d17df099e
Коммит
32b02f10e4
|
@ -93,8 +93,8 @@ git push --tags
|
|||
echo "Rebuild extension and viewer to get the latest, tagged master commit"
|
||||
yarn build-all;
|
||||
|
||||
# zip the extension files, but remove lh-background as it's not needed
|
||||
cd lighthouse-extension; command rm -f dist/scripts/lighthouse-background.js; gulp package; cd ..
|
||||
# zip the extension files, but remove lh-dt-bundle & lh-lr-bundle as it's not needed
|
||||
cd lighthouse-extension; command rm -f dist/scripts/lighthouse-dt-bundle.js dist/scripts/lighthouse-lr-bundle.js; gulp package; cd ..
|
||||
echo "Go here: https://chrome.google.com/webstore/developer/edit/blipmdconlkpinefehnmjammfjpmpbjk "
|
||||
echo "Upload the package zip to CWS dev dashboard"
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ class ExtensionConnection extends Connection {
|
|||
}
|
||||
|
||||
/**
|
||||
* Used by lighthouse-ext-background to kick off the run on the current page
|
||||
* Used by extension-entry to kick off the run on the current page
|
||||
* @return {Promise<string>}
|
||||
*/
|
||||
getCurrentTabURL() {
|
||||
|
|
|
@ -33,13 +33,13 @@ fi
|
|||
report_dir="lighthouse-core/report/html"
|
||||
fe_lh_dir="$frontend_dir/audits2/lighthouse"
|
||||
|
||||
lh_bg_js="lighthouse-extension/dist/scripts/lighthouse-background.js"
|
||||
lh_bg_js="lighthouse-extension/dist/scripts/lighthouse-dt-bundle.js"
|
||||
lh_worker_dir="$frontend_dir/audits2_worker/lighthouse"
|
||||
|
||||
# copy report files
|
||||
cp -pPR $report_dir/{report-styles.css,templates.html,renderer} "$fe_lh_dir"
|
||||
echo -e "\033[32m ✓\033[39m Report renderer files copied."
|
||||
|
||||
# copy lighthouse-background (potentially stale)
|
||||
cp -pPR "$lh_bg_js" "$lh_worker_dir/lighthouse-background.js"
|
||||
echo -e "\033[96m ✓\033[39m (Potentially stale) lighthouse-background copied."
|
||||
# copy lighthouse-dt-bundle (potentially stale)
|
||||
cp -pPR "$lh_bg_js" "$lh_worker_dir/lighthouse-dt-bundle.js"
|
||||
echo -e "\033[96m ✓\033[39m (Potentially stale) lighthouse-dt-bundle copied."
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"default_locale": "en",
|
||||
"background": {
|
||||
"scripts": [
|
||||
"scripts/lighthouse-ext-background.js"
|
||||
"scripts/lighthouse-ext-bundle.js"
|
||||
],
|
||||
"persistent": false
|
||||
},
|
||||
|
|
|
@ -61,7 +61,7 @@ function listenForStatus(listenCallback) {
|
|||
}
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
// export for lighthouse-ext-background to require (via browserify).
|
||||
// export for extension-entry to require (via browserify).
|
||||
module.exports = {
|
||||
getDefaultConfigForCategories,
|
||||
runLighthouseInWorker,
|
|
@ -6,7 +6,7 @@
|
|||
'use strict';
|
||||
|
||||
const lighthouse = require('../../../lighthouse-core/index');
|
||||
const background = require('./lighthouse-background');
|
||||
const background = require('./devtools-entry');
|
||||
|
||||
const ExtensionProtocol = require('../../../lighthouse-core/gather/connections/extension');
|
||||
const log = require('lighthouse-logger');
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
/** @typedef {typeof import('./lighthouse-ext-background.js') & {console: typeof console}} BackgroundPage */
|
||||
/** @typedef {typeof import('./extension-entry.js') & {console: typeof console}} BackgroundPage */
|
||||
|
||||
/**
|
||||
* Error strings that indicate a problem in how Lighthouse was run, not in
|
||||
|
@ -234,7 +234,7 @@ async function initPopup() {
|
|||
|
||||
/**
|
||||
* Really the Window of the background page, but since we only want what's exposed
|
||||
* on window in lighthouse-ext-background.js, use its module API as the type.
|
||||
* on window in extension-entry.js, use its module API as the type.
|
||||
* @type {BackgroundPage}
|
||||
*/
|
||||
const background = await new Promise(resolve => chrome.runtime.getBackgroundPage(resolve));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
// HACK: patch astw before it's required to use acorn with ES2018
|
||||
// We add the right acorn version to package.json deps, resolve the path to it here,
|
||||
// and then inject the modified require statement into astw's code.
|
||||
|
@ -36,9 +37,18 @@ const distDir = 'dist';
|
|||
|
||||
// list of all consumers we build for (easier to understand which file is used for which)
|
||||
const CONSUMERS = {
|
||||
DEVTOOLS: 'lighthouse-background.js',
|
||||
EXTENSION: 'lighthouse-ext-background.js',
|
||||
LIGHTRIDER: 'lighthouse-lr-background.js',
|
||||
DEVTOOLS: {
|
||||
src: 'devtools-entry.js',
|
||||
dist: 'lighthouse-dt-bundle.js',
|
||||
},
|
||||
EXTENSION: {
|
||||
src: 'extension-entry.js',
|
||||
dist: 'lighthouse-ext-bundle.js',
|
||||
},
|
||||
LIGHTRIDER: {
|
||||
src: 'lightrider-entry.js',
|
||||
dist: 'lighthouse-lr-bundle.js',
|
||||
},
|
||||
};
|
||||
|
||||
const VERSION = pkg.version;
|
||||
|
@ -60,8 +70,10 @@ const computedArtifacts = LighthouseRunner.getComputedGathererList()
|
|||
const locales = fs.readdirSync('../lighthouse-core/lib/i18n/locales/')
|
||||
.map(f => require.resolve(`../lighthouse-core/lib/i18n/locales/${f}`));
|
||||
|
||||
const isDevtools = file => file.endsWith(CONSUMERS.DEVTOOLS);
|
||||
const isExtension = file => file.endsWith(CONSUMERS.EXTENSION);
|
||||
const isDevtools = file =>
|
||||
file.endsWith(CONSUMERS.DEVTOOLS.src);
|
||||
const isExtension = file =>
|
||||
file.endsWith(CONSUMERS.EXTENSION.src);
|
||||
|
||||
gulp.task('extras', () => {
|
||||
return gulp.src([
|
||||
|
@ -109,7 +121,7 @@ gulp.task('chromeManifest', () => {
|
|||
const manifestOpts = {
|
||||
buildnumber: false,
|
||||
background: {
|
||||
target: `scripts/${CONSUMERS.EXTENSION}`,
|
||||
target: `scripts/${CONSUMERS.EXTENSION.dist}`,
|
||||
},
|
||||
};
|
||||
return gulp.src('app/manifest.json')
|
||||
|
@ -127,10 +139,10 @@ function applyBrowserifyTransforms(bundle) {
|
|||
}
|
||||
|
||||
gulp.task('browserify-lighthouse', () => {
|
||||
const consumerSources = Object.values(CONSUMERS).map(consumer => `app/src/${consumer}`);
|
||||
const consumerSources = Object.values(CONSUMERS).map(consumer => `app/src/${consumer.src}`);
|
||||
return gulp.src(consumerSources, {read: false})
|
||||
.pipe(tap(file => {
|
||||
let bundle = browserify(file.path, {debug: true}); // for sourcemaps
|
||||
let bundle = browserify(file.path); // , {debug: true}); // for sourcemaps
|
||||
bundle = applyBrowserifyTransforms(bundle);
|
||||
|
||||
// scripts will need some additional transforms, ignores and requires…
|
||||
|
@ -176,6 +188,18 @@ gulp.task('browserify-lighthouse', () => {
|
|||
// Inject the new browserified contents back into our gulp pipeline
|
||||
file.contents = bundle.bundle();
|
||||
}))
|
||||
.pipe(debug({title: ''}))
|
||||
.pipe(tap(file => {
|
||||
// rename our bundles
|
||||
const basename = path.basename(file.path);
|
||||
|
||||
// find the dist file of the given file
|
||||
const consumer = Object.values(CONSUMERS)
|
||||
.find(consumer => consumer.src === basename);
|
||||
|
||||
file.path = file.path.replace(consumer.src, consumer.dist);
|
||||
}))
|
||||
.pipe(debug({title: 'renamed into:'}))
|
||||
.pipe(gulp.dest('app/scripts'))
|
||||
.pipe(gulp.dest('dist/scripts'));
|
||||
});
|
||||
|
@ -212,7 +236,7 @@ gulp.task('compilejs', () => {
|
|||
// sourceMaps: 'both'
|
||||
};
|
||||
|
||||
const compiledSources = Object.values(CONSUMERS).map(consumer => `dist/scripts/${consumer}`);
|
||||
const compiledSources = Object.values(CONSUMERS).map(consumer => `dist/scripts/${consumer.dist}`);
|
||||
return gulp.src(compiledSources)
|
||||
.pipe(tap(file => {
|
||||
const minified = babel.transform(file.contents.toString(), opts).code;
|
||||
|
@ -229,7 +253,6 @@ gulp.task('clean', () => {
|
|||
);
|
||||
});
|
||||
|
||||
|
||||
gulp.task('watch', ['browserify', 'html'], () => {
|
||||
livereload.listen();
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const lhBackground = require('../../../app/src/lighthouse-lr-background.js');
|
||||
const lhBackground = require('../../../app/src/lightrider-entry.js');
|
||||
const LHError = require('../../../../lighthouse-core/lib/lh-error.js');
|
||||
|
||||
/* eslint-env mocha */
|
||||
|
||||
describe('lighthouse-lr-background', () => {
|
||||
describe('lightrider-entry', () => {
|
||||
describe('#runLighthouseInLR', () => {
|
||||
it('returns a runtimeError LHR when lighthouse throws a runtimeError', async () => {
|
||||
const connectionError = new LHError(LHError.errors.FAILED_DOCUMENT_REQUEST);
|
|
@ -157,7 +157,7 @@
|
|||
},
|
||||
"bundlesize": [
|
||||
{
|
||||
"path": "./lighthouse-extension/dist/scripts/lighthouse-background.js",
|
||||
"path": "./lighthouse-extension/dist/scripts/lighthouse-ext-bundle.js",
|
||||
"threshold": "520 Kb"
|
||||
},
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче