[cr145] Cherry-picked minify fix for devtools landed

Chromium change:
https://chromium.googlesource.com/devtools/devtools-frontend/+/c66e983a63869bc9c0b5fe7db427cfd66d525ea2

commit c66e983a63869bc9c0b5fe7db427cfd66d525ea2
Author: Simon Zünd <szuend@chromium.org>
Date:   Wed Jan 14 21:15:28 2026 +0100

    [build] Minify release builds with esbuild instead of rollup

    Rollup is currently causing crashes so we replace it with esbuild
    using "--bundle" and "--minify". From a cursory comparison common.js
    and sdk.js are minified even better then the rollup+terser combo.

    Fixed: 461602362
    Change-Id: Id900f5991bdb1e95fea8cfeb2fe49f07d73489eb
    Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7476237
    Commit-Queue: Wolfgang Beyer <wolfi@chromium.org>
    Commit-Queue: Simon Zünd <szuend@chromium.org>
    Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
    Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
    Auto-Submit: Simon Zünd <szuend@chromium.org>
    Reviewed-by: Wolfgang Beyer <wolfi@chromium.org>
This commit is contained in:
Claudio DeSouza
2026-01-29 13:41:23 -05:00
committed by Max Karolinskiy
parent 12ae1483c2
commit 2cc6952e54
6 changed files with 0 additions and 318 deletions
@@ -1,73 +0,0 @@
diff --git a/front_end/models/ai_assistance/injected.ts b/front_end/models/ai_assistance/injected.ts
index af9c3c14e6ea48c8abddd07009d707957fa8f2a4..cff188cbbab3cf2bc988058f8d27c542a8adf2a6 100644
--- a/front_end/models/ai_assistance/injected.ts
+++ b/front_end/models/ai_assistance/injected.ts
@@ -9,10 +9,6 @@
* They need remain isolated for importing other function so
* bundling them for production does not create issues.
*/
-/* eslint-disable @devtools/no-adopted-style-sheets --
- * The scripts in this file aren't executed as part of DevTools front-end,
- * but are injected into the page.
- **/
export const AI_ASSISTANCE_CSS_CLASS_NAME = 'ai-style-change';
export const FREESTYLER_WORLD_NAME = 'DevTools AI Assistance';
@@ -100,19 +96,9 @@ export const PAGE_EXPOSED_FUNCTIONS = ['setElementStyles'];
/**
* Please see fileoverview
*/
-function setupSetElementStyles(prefix: typeof AI_ASSISTANCE_CSS_CLASS_NAME): void {
- // Executed in another world
- const global = globalThis as unknown as {
- freestyler: FreestylerBinding,
- setElementStyles: unknown,
- };
- async function setElementStyles(
- el: HTMLElement&{
- // eslint-disable-next-line
- __freestylerClassName?: `${typeof AI_ASSISTANCE_CSS_CLASS_NAME}-${number}`,
- },
- styles: Record<string, string>,
- ): Promise<void> {
+const setupSetElementStyles = `function setupSetElementStyles(prefix) {
+ const global = globalThis;
+ async function setElementStyles(el, styles) {
let selector = el.tagName.toLowerCase();
if (el.id) {
selector = '#' + el.id;
@@ -131,7 +117,7 @@ function setupSetElementStyles(prefix: typeof AI_ASSISTANCE_CSS_CLASS_NAME): voi
// __freestylerClassName is not exposed to the page due to this being
// run in the isolated world.
- const className = el.__freestylerClassName ?? `${prefix}-${global.freestyler.id}`;
+ const className = el.__freestylerClassName ?? \`\${prefix}-\${global.freestyler.id}\`;
el.__freestylerClassName = className;
el.classList.add(className);
@@ -140,7 +126,6 @@ function setupSetElementStyles(prefix: typeof AI_ASSISTANCE_CSS_CLASS_NAME): voi
// if it's kebab case.
el.style.removeProperty(key);
// If it's camel case.
- // @ts-expect-error this won't throw if wrong
el.style[key] = '';
}
@@ -168,7 +153,7 @@ function setupSetElementStyles(prefix: typeof AI_ASSISTANCE_CSS_CLASS_NAME): voi
continue;
}
- hasAiStyleChange = rule.selectorText.startsWith(`.${prefix}`);
+ hasAiStyleChange = rule.selectorText.startsWith(\`.\${prefix}\`);
if (hasAiStyleChange) {
stylesheet = sheet;
break;
@@ -183,6 +168,6 @@ function setupSetElementStyles(prefix: typeof AI_ASSISTANCE_CSS_CLASS_NAME): voi
}
global.setElementStyles = setElementStyles;
-}
+}`;
-export const injectedFunctions = `(${String(setupSetElementStyles)})('${AI_ASSISTANCE_CSS_CLASS_NAME}')`;
+export const injectedFunctions = `(${setupSetElementStyles})('${AI_ASSISTANCE_CSS_CLASS_NAME}')`;
@@ -1,12 +0,0 @@
diff --git a/front_end/panels/application/BUILD.gn b/front_end/panels/application/BUILD.gn
index b0be3bdbc40028cef67062ed08d9ec8dcd60939d..20b81546d8839917ffed356fdd83fb573f4f06fe 100644
--- a/front_end/panels/application/BUILD.gn
+++ b/front_end/panels/application/BUILD.gn
@@ -178,6 +178,7 @@ devtools_ui_module("unittests") {
"../../core/sdk:bundle",
"../../testing",
"../../ui/components/render_coordinator:bundle",
+ "../../ui/legacy:bundle",
"./components",
"./preloading/components",
]
@@ -1,61 +0,0 @@
diff --git a/front_end/panels/application/InterestGroupStorageView.test.ts b/front_end/panels/application/InterestGroupStorageView.test.ts
index 70e1011ee48215e787eb43b3d5da7a8956d9aa00..f2e31be0f03925808fed30eccf687b98b7d2ca3f 100644
--- a/front_end/panels/application/InterestGroupStorageView.test.ts
+++ b/front_end/panels/application/InterestGroupStorageView.test.ts
@@ -6,6 +6,7 @@ import * as Protocol from '../../generated/protocol.js';
import {raf} from '../../testing/DOMHelpers.js';
import {expectCall} from '../../testing/ExpectStubCall.js';
import {describeWithMockConnection} from '../../testing/MockConnection.js';
+import * as UI from '../../ui/legacy/legacy.js';
import * as Resources from './application.js';
@@ -66,7 +67,7 @@ describeWithMockConnection('InterestGroupStorageView', () => {
it('initially has placeholder sidebar', () => {
const view = new View.InterestGroupStorageView(new InterestGroupDetailsGetter());
- assert.notDeepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
+ assert.notInstanceOf(view.sidebarWidget(), UI.SearchableView.SearchableView);
const placeholder = view.sidebarWidget()?.contentElement;
assert.deepEqual(
@@ -86,7 +87,7 @@ describeWithMockConnection('InterestGroupStorageView', () => {
grid.dispatchEvent(new CustomEvent('select', {detail: events[0]}));
await raf();
sinon.assert.calledOnce(spy);
- assert.deepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
+ assert.instanceOf(view.sidebarWidget(), UI.SearchableView.SearchableView);
});
it('Clears sidebarWidget upon receiving cellFocusedEvent on an additionalBid-type events', async function() {
@@ -109,7 +110,7 @@ describeWithMockConnection('InterestGroupStorageView', () => {
grid.dispatchEvent(new CustomEvent('select', {detail: {...events[0], type: eventType}}));
await sideBarUpdateDone;
sinon.assert.calledOnce(spy);
- assert.notDeepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
+ assert.notInstanceOf(view.sidebarWidget(), UI.SearchableView.SearchableView);
assert.isTrue(view.sidebarWidget()?.contentElement.firstChild?.textContent?.includes('No details'));
}
});
@@ -130,7 +131,7 @@ describeWithMockConnection('InterestGroupStorageView', () => {
grid.dispatchEvent(new CustomEvent('select', {detail: events[0]}));
await raf();
sinon.assert.calledOnce(spy);
- assert.notDeepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
+ assert.notInstanceOf(view.sidebarWidget(), UI.SearchableView.SearchableView);
assert.isTrue(view.sidebarWidget()?.contentElement.firstChild?.textContent?.includes('No details'));
});
@@ -145,10 +146,10 @@ describeWithMockConnection('InterestGroupStorageView', () => {
grid.dispatchEvent(new CustomEvent('select', {detail: events[0]}));
await raf();
sinon.assert.calledOnce(spy);
- assert.deepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
+ assert.instanceOf(view.sidebarWidget(), UI.SearchableView.SearchableView);
view.clearEvents();
sinon.assert.calledTwice(spy);
- assert.notDeepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
+ assert.notInstanceOf(view.sidebarWidget(), UI.SearchableView.SearchableView);
assert.isTrue(view.sidebarWidget()?.contentElement.textContent?.includes(
'No interest group selectedSelect any interest group event to display the group\'s current state'));
});
@@ -1,43 +0,0 @@
diff --git a/front_end/panels/application/SharedStorageEventsView.test.ts b/front_end/panels/application/SharedStorageEventsView.test.ts
index 7c7b95ad164cc0ed963701d3cc8838c90c9a8677..d06dfa17f8db09178421f7884dafe63ea7d18311 100644
--- a/front_end/panels/application/SharedStorageEventsView.test.ts
+++ b/front_end/panels/application/SharedStorageEventsView.test.ts
@@ -5,6 +5,7 @@
import * as Protocol from '../../generated/protocol.js';
import {raf} from '../../testing/DOMHelpers.js';
import {describeWithMockConnection} from '../../testing/MockConnection.js';
+import * as UI from '../../ui/legacy/legacy.js';
import * as Resources from './application.js';
@@ -178,7 +179,7 @@ describeWithMockConnection('SharedStorageEventsView', () => {
it('initially has placeholder sidebar', () => {
const view = new View.SharedStorageEventsView();
- assert.notDeepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
+ assert.notInstanceOf(view.sidebarWidget(), UI.SearchableView.SearchableView);
assert.deepEqual(view.sidebarWidget()?.contentElement.firstChild?.textContent, 'No shared storage event selected');
});
@@ -196,7 +197,7 @@ describeWithMockConnection('SharedStorageEventsView', () => {
grid.onSelect(EVENTS[0]);
await raf();
sinon.assert.calledOnce(spy);
- assert.deepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
+ assert.instanceOf(view.sidebarWidget(), UI.SearchableView.SearchableView);
});
it('clears sidebarWidget upon clearEvents', async () => {
@@ -213,10 +214,10 @@ describeWithMockConnection('SharedStorageEventsView', () => {
grid.onSelect(EVENTS[0]);
await raf();
sinon.assert.calledOnce(spy);
- assert.deepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
+ assert.instanceOf(view.sidebarWidget(), UI.SearchableView.SearchableView);
view.clearEvents();
sinon.assert.calledTwice(spy);
- assert.notDeepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
+ assert.notInstanceOf(view.sidebarWidget(), UI.SearchableView.SearchableView);
assert.deepEqual(view.sidebarWidget()?.contentElement.firstChild?.textContent, 'No shared storage event selected');
});
@@ -1,23 +0,0 @@
diff --git a/scripts/build/esbuild.js b/scripts/build/esbuild.js
index 096edc81b9b1bf6fde428cff49017f893a23f7fc..708f79d35e8fc8bfc92f9c121a963cee248cb02d 100644
--- a/scripts/build/esbuild.js
+++ b/scripts/build/esbuild.js
@@ -25,7 +25,9 @@ const esbuild = require('esbuild');
const entryPoints = [process.argv[2]];
const outfile = process.argv[3];
-const useSourceMaps = process.argv.slice(4).includes('--configSourcemaps');
+const additionalArgs = process.argv.slice(4);
+const useSourceMaps = additionalArgs.includes('--configSourcemaps');
+const minify = additionalArgs.includes('--minify');
const outdir = path.dirname(outfile);
@@ -46,6 +48,7 @@ esbuild
platform: 'browser',
plugins: [plugin],
sourcemap: useSourceMaps,
+ minify,
})
.catch(err => {
console.error('Failed to run esbuild:', err);
@@ -1,106 +0,0 @@
diff --git a/scripts/build/ninja/bundle.gni b/scripts/build/ninja/bundle.gni
index 9b44b1f1b5f950dbd7b78972e703cdca7b75332d..7d8fee3433a3c481505608b814003777c6f08e28 100644
--- a/scripts/build/ninja/bundle.gni
+++ b/scripts/build/ninja/bundle.gni
@@ -10,72 +10,38 @@ template("bundle") {
assert(defined(invoker.entrypoint),
"You must define the 'entrypoint' for a bundle target")
- _fast_bundle = is_debug || devtools_skip_typecheck
- assert(!is_official_build || !_fast_bundle,
- "Fast bundling is disallowed for official builds.")
-
- if (_fast_bundle) {
- node_action(target_name) {
- script = "scripts/build/esbuild.js"
- forward_variables_from(invoker,
- [
- "visibility",
- "deps",
- "public_deps",
- ])
-
- inputs = [
- invoker.entrypoint,
- devtools_location_prepend + "scripts/build/devtools_plugin.js",
- devtools_location_prepend + "scripts/devtools_paths.js",
- ]
-
- _esbuild = devtools_location_prepend + "third_party/esbuild/esbuild"
- if (host_os == "win") {
- inputs += [ _esbuild + ".exe" ]
- } else {
- inputs += [ _esbuild ]
- }
-
- args = [
- rebase_path(invoker.entrypoint, root_build_dir),
- rebase_path(invoker.output_file_location, root_build_dir),
- "--configSourcemaps",
- ]
-
- outputs = [ invoker.output_file_location ]
+ node_action(target_name) {
+ script = "scripts/build/esbuild.js"
+ forward_variables_from(invoker,
+ [
+ "visibility",
+ "deps",
+ "public_deps",
+ ])
+
+ inputs = [
+ invoker.entrypoint,
+ devtools_location_prepend + "scripts/build/devtools_plugin.js",
+ devtools_location_prepend + "scripts/devtools_paths.js",
+ ]
+
+ _esbuild = devtools_location_prepend + "third_party/esbuild/esbuild"
+ if (host_os == "win") {
+ inputs += [ _esbuild + ".exe" ]
+ } else {
+ inputs += [ _esbuild ]
}
- } else {
- node_action(target_name) {
- script = "node_modules/@rollup/wasm-node/dist/bin/rollup"
-
- forward_variables_from(invoker,
- [
- "visibility",
- "deps",
- "public_deps",
- ])
- inputs = [
- invoker.entrypoint,
- devtools_location_prepend + "scripts/build/rollup.config.mjs",
- devtools_location_prepend + "scripts/build/devtools_plugin.js",
- devtools_location_prepend + "scripts/devtools_paths.js",
- ]
+ args = [
+ rebase_path(invoker.entrypoint, root_build_dir),
+ rebase_path(invoker.output_file_location, root_build_dir),
+ "--configSourcemaps",
+ ]
- args = [
- "--config",
- rebase_path(
- devtools_location_prepend + "scripts/build/rollup.config.mjs",
- root_build_dir),
- "--input",
- rebase_path(invoker.entrypoint, root_build_dir),
- "--file",
- rebase_path(invoker.output_file_location, root_build_dir),
- "--configSourcemaps",
- ]
-
- outputs = [ invoker.output_file_location ]
+ if (!is_debug) {
+ args += [ "--minify" ]
}
+
+ outputs = [ invoker.output_file_location ]
}
}