Skip to content

Commit

Permalink
remove ParsedURL
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Dec 7, 2019
1 parent 43da869 commit ed4bb21
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 291 deletions.
18 changes: 2 additions & 16 deletions build/build-cdt-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const glob = require('glob');

const files = [
'node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js',
'node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js',
];
const outDir = 'lighthouse-core/lib/cdt/generated';

Expand Down Expand Up @@ -41,24 +40,11 @@ for (const file of glob.sync(`${outDir}/**/*.js`)) {
}

let newLine = line;
if (file.endsWith('ParsedURL.js')) {
const match = line.match(/ParsedURL.(.*) =/);
const ignore = [
'_urlRegex',
'_urlRegexInstance',
'completeURL',
];
if (match && !ignore.includes(match[1])) {
console.log(match[1]);
deletionMode = true;
}
newLine = newLine.replace(/Common.ParsedURL/g, 'ParsedURL');
}
if (file.endsWith('SourceMap.js')) {
if (line.includes('TextSourceMap.load =')) deletionMode = true;
if (line.includes('prototype.sourceContentProvider =')) deletionMode = true;
if (line.includes(`url += Common.UIString('? [sm]');`)) newLine = '';
// newLine = line.replace(`Common.ParsedURL.completeURL(this._baseURL, href)`, `''`);
newLine = line.replace(`Common.ParsedURL.completeURL(this._baseURL, href)`, `''`);
}
newLine = newLine.replace('exports["default"]', 'exports.default');
if (deletionMode) {
Expand All @@ -72,7 +58,7 @@ for (const file of glob.sync(`${outDir}/**/*.js`)) {
}
return newLine;
});
modifiedLines.unshift(`const Common = require('../../Common.js')\n`);
modifiedLines.unshift(`const Common = require('../Common.js')\n`);
modifiedLines.unshift('// generated by build-cdt-lib.js\n');
modifiedLines.unshift('// @ts-nocheck\n');
fs.writeFileSync(file, modifiedLines.join(''));
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/lib/cdt/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
'use strict';

const Common = {
ParsedURL: require('./generated/common/ParsedURL.js').default,
console,
};

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/lib/cdt/SDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'use strict';

const SDK = {
...require('./generated/sdk/SourceMap.js'),
...require('./generated/SourceMap.js'),
};

const originalMappings = SDK.TextSourceMap.prototype.mappings;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
// generated by build-cdt-lib.js
const Common = require('../../Common.js')
const Common = require('../Common.js')
"use strict";
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
Expand Down Expand Up @@ -368,9 +368,10 @@ var TextSourceMap = /** @class */ (function () {
}
for (var i = 0; i < sourceMap.sources.length; ++i) {
var href = sourceRoot + sourceMap.sources[i];
var url = Common.ParsedURL.completeURL(this._baseURL, href) || href;
var url = '' || href;
var source = sourceMap.sourcesContent && sourceMap.sourcesContent[i];
if (url === this._compiledURL && source) {
url += Common.UIString('? [sm]');
}
this._sourceInfos.set(url, new TextSourceMap.SourceInfo(source, null));
sourcesList.push(url);
Expand Down
271 changes: 0 additions & 271 deletions lighthouse-core/lib/cdt/generated/common/ParsedURL.js

This file was deleted.

0 comments on commit ed4bb21

Please sign in to comment.