Skip to content

Commit 124539b

Browse files
fix(devtools): bundle devtools package to avoid resolution errors (google-gemini#27250)
1 parent ec4910f commit 124539b

2 files changed

Lines changed: 11 additions & 25 deletions

File tree

esbuild.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const external = [
6363
'@lydell/node-pty-win32-arm64',
6464
'@lydell/node-pty-win32-x64',
6565
'@github/keytar',
66-
'@google/gemini-cli-devtools',
6766
];
6867

6968
const baseConfig = {
@@ -110,13 +109,20 @@ const cliConfig = {
110109
__dirname,
111110
'packages/cli/src/patches/http-proxy-agent.ts',
112111
),
112+
'@google/gemini-cli-devtools': path.resolve(
113+
__dirname,
114+
'packages/devtools/src/index.ts',
115+
),
113116
...commonAliases,
114117
},
115118
metafile: true,
116119
};
117120

118121
const workerConfig = {
119122
...baseConfig,
123+
banner: {
124+
js: `const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);`,
125+
},
120126
entryPoints: {
121127
'worker/worker-entry': path.join(
122128
path.dirname(require.resolve('ink')),
@@ -125,6 +131,8 @@ const workerConfig = {
125131
},
126132
outdir: 'bundle',
127133
define: {
134+
__filename: '__chunk_filename',
135+
__dirname: '__chunk_dirname',
128136
'process.env.NODE_ENV': JSON.stringify(
129137
process.env.NODE_ENV || 'production',
130138
),

scripts/copy_bundle_assets.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -85,29 +85,7 @@ if (existsSync(builtinSkillsSrc)) {
8585
console.log('Copied built-in skills to bundle/builtin/');
8686
}
8787

88-
// 5. Copy DevTools package so the external dynamic import resolves at runtime
89-
const devtoolsSrc = join(root, 'packages/devtools');
90-
const devtoolsDest = join(
91-
bundleDir,
92-
'node_modules',
93-
'@google',
94-
'gemini-cli-devtools',
95-
);
96-
const devtoolsDistSrc = join(devtoolsSrc, 'dist');
97-
if (existsSync(devtoolsDistSrc)) {
98-
mkdirSync(devtoolsDest, { recursive: true });
99-
cpSync(devtoolsDistSrc, join(devtoolsDest, 'dist'), {
100-
recursive: true,
101-
dereference: true,
102-
});
103-
copyFileSync(
104-
join(devtoolsSrc, 'package.json'),
105-
join(devtoolsDest, 'package.json'),
106-
);
107-
console.log('Copied devtools package to bundle/node_modules/');
108-
}
109-
110-
// 6. Copy bundled chrome-devtools-mcp
88+
// 5. Copy bundled chrome-devtools-mcp
11189
const bundleMcpSrc = join(root, 'packages/core/dist/bundled');
11290
const bundleMcpDest = join(bundleDir, 'bundled');
11391
if (!existsSync(bundleMcpSrc)) {
@@ -120,7 +98,7 @@ if (!existsSync(bundleMcpSrc)) {
12098
cpSync(bundleMcpSrc, bundleMcpDest, { recursive: true, dereference: true });
12199
console.log('Copied bundled chrome-devtools-mcp to bundle/bundled/');
122100

123-
// 7. Copy Extension Examples
101+
// 6. Copy Extension Examples
124102
const extensionExamplesSrc = join(
125103
root,
126104
'packages/cli/src/commands/extensions/examples',

0 commit comments

Comments
 (0)