-
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
misc(build): add build step for report #12707
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3a38115
build: add build step for report
connorjclark 53033c8
mkdir
connorjclark 9b425a0
build that shiz
connorjclark 19e11bb
rm
connorjclark 844d5bf
ohhhh windows
connorjclark cafef7c
ugh
connorjclark 9073d97
fix viewer
connorjclark f574fe2
fix collect strings
connorjclark 353c772
dist
connorjclark fd5128b
Merge remote-tracking branch 'origin/master' into build-report
connorjclark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
|
||
function concatRendererCode() { | ||
return [ | ||
fs.readFileSync(__dirname + '/../report/renderer/util.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/dom.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/details-renderer.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/crc-details-renderer.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/snippet-renderer.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/element-screenshot-renderer.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../lighthouse-core/lib/file-namer.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/logger.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/report-ui-features.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/category-renderer.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/performance-category-renderer.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/pwa-category-renderer.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/report-renderer.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/i18n.js', 'utf8'), | ||
fs.readFileSync(__dirname + '/../report/renderer/text-encoding.js', 'utf8'), | ||
].join(';\n'); | ||
} | ||
|
||
async function buildStandaloneReport() { | ||
const REPORT_JAVASCRIPT = [ | ||
concatRendererCode(), | ||
fs.readFileSync(__dirname + '/../report/clients/standalone.js', 'utf8'), | ||
].join(';\n'); | ||
fs.mkdirSync(__dirname + '/../dist/report', {recursive: true}); | ||
fs.writeFileSync(__dirname + '/../dist/report/standalone.js', REPORT_JAVASCRIPT); | ||
} | ||
|
||
if (require.main === module) { | ||
buildStandaloneReport(); | ||
} | ||
|
||
module.exports = { | ||
buildStandaloneReport, | ||
concatRendererCode, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ | |
}, | ||
"scripts": { | ||
"build-all": "npm-run-posix-or-windows build-all:task", | ||
"build-all:task": "yarn build-cdt-lib && yarn build-devtools && (yarn build-extension & yarn build-lr & yarn build-viewer & yarn build-treemap & yarn build-smokehouse-bundle & wait) && yarn build-pack", | ||
"build-all:task:windows": "yarn build-cdt-lib && yarn build-extension && yarn build-devtools && yarn build-lr && yarn build-viewer && yarn build-treemap && yarn build-smokehouse-bundle", | ||
"build-all:task": "yarn build-report && yarn build-cdt-lib && yarn build-devtools && (yarn build-extension & yarn build-lr & yarn build-viewer & yarn build-treemap & yarn build-smokehouse-bundle & wait) && yarn build-pack", | ||
"build-all:task:windows": "yarn build-report && yarn build-cdt-lib && yarn build-extension && yarn build-devtools && yarn build-lr && yarn build-viewer && yarn build-treemap && yarn build-smokehouse-bundle", | ||
"build-cdt-lib": "node ./build/build-cdt-lib.js", | ||
"build-extension": "yarn build-extension-chrome && yarn build-extension-firefox", | ||
"build-extension-chrome": "node ./build/build-extension.js chrome", | ||
|
@@ -23,6 +23,7 @@ | |
"build-smokehouse-bundle": "node ./build/build-smokehouse-bundle.js", | ||
"build-lr": "yarn reset-link && node ./build/build-lightrider-bundles.js", | ||
"build-pack": "bash build/build-pack.sh", | ||
"build-report": "node build/build-report.js", | ||
"build-treemap": "node ./build/build-treemap.js", | ||
"build-viewer": "node ./build/build-viewer.js", | ||
"reset-link": "(yarn unlink || true) && yarn link && yarn link lighthouse", | ||
|
@@ -31,7 +32,7 @@ | |
"lint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint .", | ||
"smoke": "node lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js", | ||
"debug": "node --inspect-brk ./lighthouse-cli/index.js", | ||
"start": "node ./lighthouse-cli/index.js", | ||
"start": "yarn build-report && node ./lighthouse-cli/index.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 😃 |
||
"test": "yarn diff:sample-json && yarn lint --quiet && yarn unit && yarn type-check", | ||
"test-bundle": "yarn smoke --runner bundle -j=1 --retries=2 --invert-match forms", | ||
"test-clients": "jest \"clients/\"", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
'use strict'; | ||
|
||
/* global document window ga DOM ReportRenderer ReportUIFeatures Logger */ | ||
|
||
(function __initLighthouseReport__() { | ||
const dom = new DOM(document); | ||
const renderer = new ReportRenderer(dom); | ||
const container = dom.find('main', document); | ||
/** @type {LH.ReportResult} */ | ||
// @ts-expect-error | ||
const lhr = window.__LIGHTHOUSE_JSON__; | ||
renderer.renderReport(lhr, container); | ||
|
||
// Hook in JS features and page-level event listeners after the report | ||
// is in the document. | ||
const features = new ReportUIFeatures(dom); | ||
features.initFeatures(lhr); | ||
})(); | ||
|
||
document.addEventListener('lh-analytics', /** @param {Event} e */ e => { | ||
// @ts-expect-error | ||
if (window.ga) ga(e.detail.cmd, e.detail.fields); | ||
}); | ||
|
||
document.addEventListener('lh-log', /** @param {Event} e */ e => { | ||
const el = document.querySelector('#lh-log'); | ||
if (!el) return; | ||
|
||
const logger = new Logger(el); | ||
// @ts-expect-error | ||
const detail = e.detail; | ||
|
||
switch (detail.cmd) { | ||
case 'log': | ||
logger.log(detail.msg); | ||
break; | ||
case 'warn': | ||
logger.warn(detail.msg); | ||
break; | ||
case 'error': | ||
logger.error(detail.msg); | ||
break; | ||
case 'hide': | ||
logger.hide(); | ||
break; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
drive by change to also build devtools when rolling