Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: third_party/WebKit/Source/devtools/scripts/extract_module/extract_module.js

Issue 2623743002: DevTools: extract modules (non-extensions) (Closed)
Patch Set: rebaseline Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/unit_test_runner.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 'use strict'; 4 'use strict';
5 const fs = require('fs'); 5 const fs = require('fs');
6 const path = require('path'); 6 const path = require('path');
7 7
8 const utils = require('../utils'); 8 const utils = require('../utils');
9 9
10 const FRONTEND_PATH = path.resolve(__dirname, '..', '..', 'front_end'); 10 const FRONTEND_PATH = path.resolve(__dirname, '..', '..', 'front_end');
11 const BUILD_GN_PATH = path.resolve(__dirname, '..', '..', 'BUILD.gn'); 11 const BUILD_GN_PATH = path.resolve(__dirname, '..', '..', 'BUILD.gn');
12 const SPECIAL_CASE_NAMESPACES_PATH = path.resolve(__dirname, '..', 'special_case _namespaces.json'); 12 const SPECIAL_CASE_NAMESPACES_PATH = path.resolve(__dirname, '..', 'special_case _namespaces.json');
13 13
14 const APPLICATION_DESCRIPTORS = [ 14 const APPLICATION_DESCRIPTORS = [
15 'inspector.json', 15 'inspector.json',
16 'unit_test_runner.json', 16 'unit_test_runner.json',
17 ]; 17 ];
18 18
19 // Replace based on specified transformation 19 // Replace based on specified transformation
20 20 const MODULES_TO_REMOVE = ['components_lazy', 'ui_lazy'];
21 const MODULES_TO_REMOVE = []; // ['components_lazy', 'ui_lazy'];
22
23 // NOTE: Extensions-only change
24 const FILES_AFFECTING_EXTENSIONS = [
25 'components_lazy/LineLevelProfile.js',
26 'components_lazy/GCActionDelegate.js',
27 'components/RequestAppBannerActionDelegate.js',
28 'ui_lazy/CommandMenu.js',
29 ];
30 21
31 const JS_FILES_MAPPING = [ 22 const JS_FILES_MAPPING = [
32 // {file: 'components_lazy/CookiesTable.js', new: 'cookie_table'}, 23 {file: 'components_lazy/CookiesTable.js', new: 'cookie_table'},
33 // {file: 'ui/BezierEditor.js', new: 'inline_editor'}, 24 {file: 'ui/BezierEditor.js', new: 'inline_editor'},
34 // {file: 'ui/BezierUI.js', new: 'inline_editor'}, 25 {file: 'ui/BezierUI.js', new: 'inline_editor'},
35 // {file: 'ui/ColorSwatch.js', new: 'inline_editor'}, 26 {file: 'ui/ColorSwatch.js', new: 'inline_editor'},
36 // {file: 'ui/CSSShadowEditor.js', new: 'inline_editor'}, 27 {file: 'ui/CSSShadowEditor.js', new: 'inline_editor'},
37 // {file: 'ui/SwatchPopoverHelper.js', new: 'inline_editor'}, 28 {file: 'ui/SwatchPopoverHelper.js', new: 'inline_editor'},
38 // {file: 'components/Spectrum.js', new: 'color_picker'}, 29 {file: 'components/Spectrum.js', new: 'color_picker'},
39 // 30
40 // // Cannot extract dom_ui because of cyclic dependency with components 31 // Cannot extract dom_ui because of cyclic dependency with components
41 // // {file: 'components/DOMPresentationUtils.js', new: 'dom_ui'}, 32 // {file: 'components/DOMPresentationUtils.js', new: 'dom_ui'},
42 // {file: 'components/ExecutionContextSelector.js', existing: 'main'}, 33 {file: 'components/ExecutionContextSelector.js', existing: 'main'},
43 // {file: 'components_lazy/FilmStripModel.js', existing: 'sdk'}, 34 {file: 'components_lazy/FilmStripModel.js', existing: 'sdk'},
44 // 35 {file: 'components_lazy/FilmStripView.js', existing: 'perf_ui'},
45 // {file: 'components_lazy/FilmStripView.js', new: 'perf_ui'}, 36 {file: 'components/ShortcutsScreen.js', existing: 'ui'},
46 {file: 'components_lazy/GCActionDelegate.js', existing: 'main'}, 37 {file: 'ui_lazy/DataGrid.js', new: 'data_grid'},
47 {file: 'components_lazy/LineLevelProfile.js', new: 'perf_ui'}, 38 {file: 'ui_lazy/ViewportDataGrid.js', new: 'data_grid'},
48 {file: 'components/RequestAppBannerActionDelegate.js', existing: 'main'}, 39 {file: 'ui_lazy/SortableDataGrid.js', new: 'data_grid'},
49 // {file: 'components/ShortcutsScreen.js', existing: 'ui'}, 40 {file: 'ui_lazy/ShowMoreDataGridNode.js', new: 'data_grid'},
50 {file: 'ui_lazy/FilteredListWidget.js', new: 'quick_open'}, 41 {file: 'ui_lazy/ChartViewport.js', existing: 'perf_ui'},
51 {file: 'ui_lazy/CommandMenu.js', new: 'quick_open'}, 42 {file: 'ui_lazy/FlameChart.js', existing: 'perf_ui'},
52 // {file: 'ui_lazy/DataGrid.js', new: 'data_grid'}, 43 {file: 'ui_lazy/OverviewGrid.js', existing: 'perf_ui'},
53 // {file: 'ui_lazy/ViewportDataGrid.js', new: 'data_grid'}, 44 {file: 'ui_lazy/PieChart.js', existing: 'perf_ui'},
54 // {file: 'ui_lazy/SortableDataGrid.js', new: 'data_grid'}, 45 {file: 'ui_lazy/TimelineGrid.js', existing: 'perf_ui'},
55 // {file: 'ui_lazy/ShowMoreDataGridNode.js', new: 'data_grid'}, 46 {file: 'ui_lazy/TimelineOverviewPane.js', existing: 'perf_ui'},
56 // {file: 'ui_lazy/ChartViewport.js', new: 'perf_ui'},
57 // {file: 'ui_lazy/FlameChart.js', new: 'perf_ui'},
58 // {file: 'ui_lazy/OverviewGrid.js', new: 'perf_ui'},
59 // {file: 'ui_lazy/PieChart.js', new: 'perf_ui'},
60 // {file: 'ui_lazy/TimelineGrid.js', new: 'perf_ui'},
61 // {file: 'ui_lazy/TimelineOverviewPane.js', new: 'perf_ui'},
62 {file: 'sources/UISourceCodeFrame.js', existing: 'source_frame'},
63 {file: 'sources/SourceCodeDiff.js', existing: 'source_frame'},
64 ]; 47 ];
65 48
66 const MODULE_MAPPING = { 49 const MODULE_MAPPING = {
67 // cookie_table: { 50 cookie_table: {
68 // dependencies: ['ui', 'sdk', 'data_grid'], 51 dependencies: ['ui', 'sdk', 'data_grid'],
69 // dependents: ['resources', 'network'], 52 dependents: ['resources', 'network'],
70 // applications: ['inspector.json'],
71 // autostart: false,
72 // },
73 // inline_editor: {
74 // dependencies: ['ui'],
75 // dependents: ['sources', 'elements', 'resources'],
76 // applications: ['inspector.json', 'unit_test_runner.json'],
77 // autostart: false,
78 // },
79 // color_picker: {
80 // dependencies: ['ui', 'sdk'],
81 // dependents: ['sources', 'elements'],
82 // applications: ['inspector.json'],
83 // autostart: false,
84 // },
85 perf_ui: {
86 dependencies: ['ui', 'sdk', 'bindings', 'source_frame', 'text_editor'],
87 dependents: ['network', 'timeline', 'profiler', 'layer_viewer'],
88 applications: ['inspector.json'], 53 applications: ['inspector.json'],
89 autostart: false, 54 autostart: false,
90 }, 55 },
91 quick_open: { 56 inline_editor: {
92 dependencies: ['ui', 'diff'], 57 dependencies: ['ui'],
93 dependents: ['sources'], 58 dependents: ['sources', 'elements', 'resources'],
94 applications: ['inspector.json', 'unit_test_runner.json'], 59 applications: ['inspector.json', 'unit_test_runner.json'],
95 autostart: false, 60 autostart: false,
96 }, 61 },
97 // data_grid: { 62 color_picker: {
98 // dependencies: ['ui'], 63 dependencies: ['ui', 'sdk'],
99 // dependents: ['network', 'profiler', 'resources', 'console', 'timeline'], 64 dependents: ['sources', 'elements'],
100 // applications: ['inspector.json', 'unit_test_runner.json'], 65 applications: ['inspector.json'],
101 // autostart: false, 66 autostart: false,
102 // }, 67 },
68 data_grid: {
69 dependencies: ['ui'],
70 dependents: ['network', 'profiler', 'resources', 'console', 'timeline'],
71 applications: ['inspector.json', 'unit_test_runner.json'],
72 autostart: false,
73 },
103 }; 74 };
104 75
105 const NEW_DEPENDENCIES_BY_EXISTING_MODULES = { 76 const NEW_DEPENDENCIES_BY_EXISTING_MODULES = {
106 // resources: ['components'], 77 resources: ['components'],
107 source_frame: ['persistence', 'diff'],
108 timeline: ['extensions'],
109 css_tracker: ['source_frame'],
110 }; 78 };
111 79
112 const REMOVE_DEPENDENCIES_BY_EXISTING_MODULES = { 80 const REMOVE_DEPENDENCIES_BY_EXISTING_MODULES = {
113 css_tracker: ['sources'],
114 }; 81 };
115 82
116 const DEPENDENCIES_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => { 83 const DEPENDENCIES_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => {
117 acc[module] = MODULE_MAPPING[module].dependencies; 84 acc[module] = MODULE_MAPPING[module].dependencies;
118 return acc; 85 return acc;
119 }, {}); 86 }, {});
120 87
121 const APPLICATIONS_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => { 88 const APPLICATIONS_BY_MODULE = Object.keys(MODULE_MAPPING).reduce((acc, module) => {
122 acc[module] = MODULE_MAPPING[module].applications; 89 acc[module] = MODULE_MAPPING[module].applications;
123 return acc; 90 return acc;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 let content = fs.readFileSync(filePath).toString(); 391 let content = fs.readFileSync(filePath).toString();
425 let newContent = content; 392 let newContent = content;
426 for (let key of identifierMap.keys()) { 393 for (let key of identifierMap.keys()) {
427 let originalIdentifier = key; 394 let originalIdentifier = key;
428 let newIdentifier = identifierMap.get(key); 395 let newIdentifier = identifierMap.get(key);
429 newContent = newContent.replaceAll(originalIdentifier, newIdentifier); 396 newContent = newContent.replaceAll(originalIdentifier, newIdentifier);
430 } 397 }
431 // one-off 398 // one-off
432 if (filePath.includes('LayoutTests/http/tests/inspector-unit/filtered-item-s election-dialog-filtering.js')) 399 if (filePath.includes('LayoutTests/http/tests/inspector-unit/filtered-item-s election-dialog-filtering.js'))
433 newContent = newContent.replaceAll('ui_lazy', 'quick_open'); 400 newContent = newContent.replaceAll('ui_lazy', 'quick_open');
434 // if (filePath.includes('LayoutTests/inspector/components/cookies-table.htm l')) 401 if (filePath.includes('LayoutTests/inspector/components/cookies-table.html') )
435 // newContent = newContent.replaceAll('components_lazy', 'cookie_table'); 402 newContent = newContent.replaceAll('components_lazy', 'cookie_table');
436 // if (filePath.includes('LayoutTests/inspector/components/datagrid-autosize .html')) 403 if (filePath.includes('LayoutTests/inspector/components/datagrid-autosize.ht ml'))
437 // newContent = newContent.replaceAll('ui_lazy', 'data_grid'); 404 newContent = newContent.replaceAll('ui_lazy', 'data_grid');
438 // if (filePath.includes('LayoutTests/inspector/components/datagrid-test.js' )) 405 if (filePath.includes('LayoutTests/inspector/components/datagrid-test.js'))
439 // newContent = newContent.replaceAll('ui_lazy', 'data_grid'); 406 newContent = newContent.replaceAll('ui_lazy', 'data_grid');
440 407
441 if (content !== newContent) 408 if (content !== newContent)
442 fs.writeFileSync(filePath, newContent); 409 fs.writeFileSync(filePath, newContent);
443 } 410 }
444 } 411 }
445 412
446 function removeFromExistingModuleDescriptors(modules, identifierMap, cssFilesMap ping) { 413 function removeFromExistingModuleDescriptors(modules, identifierMap, cssFilesMap ping) {
447 let extensionMap = new Map(); 414 let extensionMap = new Map();
448 let moduleFileMap = new Map(); 415 let moduleFileMap = new Map();
449 416
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 return string.split("") 707 return string.split("")
741 .map(function (char) { 708 .map(function (char) {
742 var charCode = char.charCodeAt(0); 709 var charCode = char.charCodeAt(0);
743 return charCode > 127 ? unicodeCharEscape(charCode) : char; 710 return charCode > 127 ? unicodeCharEscape(charCode) : char;
744 }) 711 })
745 .join(""); 712 .join("");
746 } 713 }
747 714
748 if (require.main === module) 715 if (require.main === module)
749 extractModule(); 716 extractModule();
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/unit_test_runner.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698