Skip to content
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: add source-maps gatherer to default config #10990

Merged
merged 8 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from 7 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
3 changes: 3 additions & 0 deletions lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,9 @@ Object {
Object {
"path": "inspector-issues",
},
Object {
"path": "source-maps",
},
],
"loadFailureMode": "fatal",
"networkQuietThresholdMs": 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ const config = {
],
throttlingMethod: 'devtools',
},
// source-maps is not yet in the default config.
passes: [{
passName: 'defaultPass',
gatherers: [
'source-maps',
],
}],
audits: [
{path: 'byte-efficiency/unused-javascript', options: {
// Lower the threshold so we don't need huge resources to make a test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
*/
module.exports = {
extends: 'lighthouse:default',
passes: [{
passName: 'defaultPass',
gatherers: [
'source-maps',
],
}],
settings: {
onlyCategories: [
'performance',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@
* Config file for running source map smokehouse.
*/

// source-maps currently isn't in the default config yet, so we make a new one with it.
// Also, no audits use source-maps yet, and at least one is required for a successful run,
// so `viewport` and its required gatherer `meta-elements` is used.

/** @type {LH.Config.Json} */
module.exports = {
passes: [{
passName: 'defaultPass',
gatherers: [
'source-maps',
'meta-elements',
],
}],
audits: ['viewport'],
extends: 'lighthouse:default',
settings: {
onlyAudits: ['unused-javascript'],
},
};
5 changes: 2 additions & 3 deletions lighthouse-core/audits/byte-efficiency/unused-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
title: str_(UIStrings.title),
description: str_(UIStrings.description),
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['JsUsage', 'ScriptElements', 'devtoolsLogs', 'traces'],
__internalOptionalArtifacts: ['SourceMaps'],
requiredArtifacts: ['JsUsage', 'ScriptElements', 'SourceMaps', 'devtoolsLogs', 'traces'],
};
}

Expand All @@ -79,7 +78,7 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
* @return {Promise<ByteEfficiencyAudit.ByteEfficiencyProduct>}
*/
static async audit_(artifacts, networkRecords, context) {
const bundles = artifacts.SourceMaps ? await JsBundles.request(artifacts, context) : [];
const bundles = await JsBundles.request(artifacts, context);
const {
unusedThreshold = IGNORE_THRESHOLD_IN_BYTES,
bundleSourceUnusedThreshold = IGNORE_BUNDLE_SOURCE_THRESHOLD_IN_BYTES,
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const defaultConfig = {
'accessibility',
'trace-elements',
'inspector-issues',
'source-maps',
],
},
{
Expand Down
6 changes: 0 additions & 6 deletions lighthouse-core/config/experimental-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
/** @type {LH.Config.Json} */
const config = {
extends: 'lighthouse:default',
passes: [{
passName: 'defaultPass',
gatherers: [
'source-maps',
],
}],
audits: [
'byte-efficiency/duplicated-javascript',
'legacy-javascript',
Expand Down
57 changes: 2 additions & 55 deletions lighthouse-core/test/config/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('Config', () => {
'ViewportDimensions', // from gatherer
],
__internalOptionalArtifacts: [
'SourceMaps', // Not in the config.
'NotInTheConfig',
],
};
}
Expand Down Expand Up @@ -201,13 +201,6 @@ describe('Config', () => {

const config = new Config({
extends: 'lighthouse:default',
// TODO(cjamcl): remove when source-maps is in default config.
passes: [{
passName: 'defaultPass',
gatherers: [
'source-maps',
],
}],
audits: [ButWillStillTakeYourCrap],
}, {
// Trigger filtering logic.
Expand All @@ -217,38 +210,6 @@ describe('Config', () => {
.toEqual(['viewport-dimensions', 'source-maps']);
});

// eslint-disable-next-line max-len
it('does not throw when an audit requests an optional artifact with no gatherer supplying it', async () => {
class DoesntNeedYourCrap extends Audit {
static get meta() {
return {
id: 'optional-artifact-audit',
title: 'none',
description: 'none',
requiredArtifacts: [
'URL', // base artifact
'ViewportDimensions', // from gatherer
],
__internalOptionalArtifacts: [
'SourceMaps', // Not in the config.
],
};
}

static audit() {}
}

// Shouldn't throw.
const config = new Config({
extends: 'lighthouse:default',
audits: [DoesntNeedYourCrap],
}, {
// Trigger filtering logic.
onlyAudits: ['optional-artifact-audit'],
});
expect(config.passes[0].gatherers.map(g => g.path)).toEqual(['viewport-dimensions']);
});

it('should keep optional artifacts in gatherers after filter', async () => {
class ButWillStillTakeYourCrap extends Audit {
static get meta() {
Expand All @@ -271,13 +232,6 @@ describe('Config', () => {

const config = new Config({
extends: 'lighthouse:default',
// TODO(cjamcl): remove when source-maps is in default config.
passes: [{
passName: 'defaultPass',
gatherers: [
'source-maps',
],
}],
audits: [ButWillStillTakeYourCrap],
}, {
// Trigger filtering logic.
Expand All @@ -300,7 +254,7 @@ describe('Config', () => {
'ViewportDimensions', // from gatherer
],
__internalOptionalArtifacts: [
'SourceMaps', // Not in the config.
'NotInTheConfig',
],
};
}
Expand Down Expand Up @@ -341,13 +295,6 @@ describe('Config', () => {

const config = new Config({
extends: 'lighthouse:default',
// TODO(cjamcl): remove when source-maps is in default config.
passes: [{
passName: 'defaultPass',
gatherers: [
'source-maps',
],
}],
audits: [ButWillStillTakeYourCrap],
}, {
// Trigger filtering logic.
Expand Down