豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 7ba63a8

Browse files
szuendOrKoN
andauthored
chore(build): add devtools-formatter-worker.ts bundle (#792)
The `devtools-formatter-worker` is a separate entrypoint from the MCP entrypoint. It is identical to the upstream `front_end/entrypoints/formatter_worker/formatter_worker-entrypoint.js` and a required part to make source mapping, formatting and other AST-based DevTools features work. The implementation consists of 3 parts: 1) A trivial `devtools-formatter-worker.ts` file that imports the DevTools entrypoint. 2) A new bundle output, bundling everything that needs to run in the worker. 3) A call that initializes the `FormatterWorkerPool` with the custom entrypoint. Otherwise we'd use the unbundled entrypoint from `chrome-devtools-frontend` not available to us at runtime. Note that we could improve code splitting in the future as some things like `core/common` are now bundled twice. --------- Co-authored-by: Alex Rudenko <OrKoN@users.noreply.github.com>
1 parent 1e0ee69 commit 7ba63a8

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

rollup.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,11 @@ export default [
185185
return false;
186186
},
187187
),
188+
bundleDependency(
189+
'./build/src/third_party/devtools-formatter-worker.js',
190+
{
191+
inlineDynamicImports: true,
192+
},
193+
(_source, _importer, _isResolved) => false,
194+
),
188195
];

src/DevtoolsUtils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ DevTools.I18n.DevToolsLocale.DevToolsLocale.instance({
138138
});
139139
DevTools.I18n.i18n.registerLocaleDataForTest('en-US', {});
140140

141+
DevTools.Formatter.FormatterWorkerPool.FormatterWorkerPool.instance({
142+
forceNew: true,
143+
entrypointURL: import.meta
144+
.resolve('./third_party/devtools-formatter-worker.js'),
145+
});
146+
141147
export interface TargetUniverse {
142148
/** The DevTools target corresponding to the puppeteer Page */
143149
target: DevTools.SDKTarget;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// eslint-disable-next-line no-restricted-imports
8+
import '../../node_modules/chrome-devtools-frontend/front_end/entrypoints/formatter_worker/formatter_worker-entrypoint.js';

src/third_party/devtools.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export {
1818
Issue,
1919
Target as SDKTarget,
2020
DebuggerModel,
21+
Formatter,
2122
Foundation,
2223
TargetManager,
2324
MarkdownIssueDescription,

tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"node_modules/chrome-devtools-frontend/front_end/core/protocol_client",
3434
"node_modules/chrome-devtools-frontend/front_end/core/root",
3535
"node_modules/chrome-devtools-frontend/front_end/core/sdk",
36+
"node_modules/chrome-devtools-frontend/front_end/entrypoints/formatter_worker",
3637
"node_modules/chrome-devtools-frontend/front_end/foundation/foundation.ts",
3738
"node_modules/chrome-devtools-frontend/front_end/foundation/Universe.ts",
3839
"node_modules/chrome-devtools-frontend/front_end/generated",
@@ -60,6 +61,8 @@
6061
"node_modules/chrome-devtools-frontend/front_end/models/trace",
6162
"node_modules/chrome-devtools-frontend/front_end/models/workspace",
6263
"node_modules/chrome-devtools-frontend/front_end/panels/issues/IssueAggregator.ts",
64+
"node_modules/chrome-devtools-frontend/front_end/third_party/acorn",
65+
"node_modules/chrome-devtools-frontend/front_end/third_party/codemirror",
6366
"node_modules/chrome-devtools-frontend/front_end/third_party/i18n",
6467
"node_modules/chrome-devtools-frontend/front_end/third_party/intl-messageformat",
6568
"node_modules/chrome-devtools-frontend/front_end/third_party/legacy-javascript",
@@ -68,5 +71,8 @@
6871
"node_modules/chrome-devtools-frontend/front_end/third_party/third-party-web",
6972
"node_modules/chrome-devtools-frontend/mcp"
7073
],
71-
"exclude": ["node_modules/chrome-devtools-frontend/**/*.test.ts"]
74+
"exclude": ["node_modules/chrome-devtools-frontend/**/*.test.ts"],
75+
"files": [
76+
"node_modules/chrome-devtools-frontend/front_end/third_party/acorn/package/dist/acorn.mjs"
77+
]
7278
}

0 commit comments

Comments
 (0)