Skip to content

Commit 2189d8a

Browse files
committed
fix: bundle bug
1 parent e3e8f38 commit 2189d8a

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

apps/agent-tars/forge.config.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const keepModules = new Set([
2323
'@mixmark-io/domino',
2424
'@modelcontextprotocol/sdk',
2525
]);
26-
const needSubDependencies = ['@modelcontextprotocol/sdk'];
26+
const needSubDependencies = ['@tavily/core', '@modelcontextprotocol/sdk'];
2727
const keepLanguages = new Set(['en', 'en_GB', 'en-US', 'en_US']);
2828
const ignorePattern = new RegExp(
2929
`^/node_modules/(?!${[...keepModules].join('|')})`,
@@ -95,13 +95,13 @@ async function cleanSources(
9595
const moduleRoot = getModuleRoot(projectRoot, item);
9696

9797
if (fs.existsSync(moduleRoot)) {
98-
console.log('copy_current_node_modules', moduleRoot);
98+
// console.log('copy_current_node_modules', moduleRoot);
9999
return cp(moduleRoot, path.join(buildPath, 'node_modules', item), {
100100
recursive: true,
101101
});
102102
}
103103
} catch (error) {
104-
console.error('copy_current_node_modules', error);
104+
console.error('copy_current_node_modules_error', error);
105105
return;
106106
}
107107

@@ -116,21 +116,20 @@ async function cleanSources(
116116
console.log('subDependencies', subDependencies);
117117
await Promise.all(
118118
subDependencies.map((subDependency) => {
119-
console.log(
120-
'target_dir',
121-
path.join(buildPath, 'node_modules', subDependency.name),
122-
);
123119
const targetDir = path.join(
124120
buildPath,
125121
'node_modules',
126122
subDependency.name,
127123
);
128124
const sourceDir = subDependency.path;
129125
if (!fs.existsSync(targetDir) && fs.existsSync(sourceDir)) {
130-
console.log('copy_current_node_modules', sourceDir);
131-
return cp(sourceDir, targetDir, {
132-
recursive: true,
133-
});
126+
try {
127+
return cp(sourceDir, targetDir, {
128+
recursive: true,
129+
});
130+
} catch (e) {
131+
console.error('copy_current_node_modules_error', sourceDir, e);
132+
}
134133
}
135134
return;
136135
}),

apps/agent-tars/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
}
3939
},
4040
"dependencies": {
41+
"@tavily/core": "0.3.1",
4142
"@agent-infra/mcp-server-commands": "workspace:*",
4243
"@agent-infra/mcp-server-filesystem": "workspace:*",
43-
"@agent-infra/mcp-server-browser": "workspace:*",
44-
"@tavily/core": "0.3.1"
44+
"@agent-infra/mcp-server-browser": "workspace:*"
4545
},
4646
"devDependencies": {
4747
"@modelcontextprotocol/sdk": "^1.7.0",

apps/ui-tars/forge.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,12 @@ async function cleanSources(
106106
const moduleRoot = getModuleRoot(projectRoot, item);
107107

108108
if (fs.existsSync(moduleRoot)) {
109-
console.log('copy_current_node_modules', moduleRoot);
110109
return cp(moduleRoot, path.join(buildPath, 'node_modules', item), {
111110
recursive: true,
112111
});
113112
}
114113
} catch (error) {
115-
console.error('copy_current_node_modules', error);
114+
console.error('copy_current_node_modules_error', error);
116115
return;
117116
}
118117

@@ -133,7 +132,6 @@ async function cleanSources(
133132
}
134133

135134
if (fs.existsSync(subDependency.path)) {
136-
console.log('copy_current_node_modules', subDependency.path);
137135
return cp(
138136
subDependency.path,
139137
path.join(buildPath, 'node_modules', subDependency.name),

packages/common/electron-build/src/getPackageDependencies.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,26 @@ import { dirname } from 'path';
1111
import { findUpSync } from './findUp';
1212

1313
export const getModuleRoot = (cwd: string, pkgName: string): string => {
14-
const moduleEntryPath = dirname(
15-
require.resolve(`${pkgName}/package.json`, {
16-
paths: [cwd || process.cwd()],
17-
}),
18-
);
19-
14+
let moduleEntryPath;
15+
try {
16+
moduleEntryPath = dirname(
17+
require.resolve(`${pkgName}/package.json`, {
18+
paths: [cwd || process.cwd()],
19+
}),
20+
);
21+
} catch (error) {
22+
moduleEntryPath = dirname(
23+
require.resolve(pkgName, {
24+
paths: [cwd || process.cwd()],
25+
}),
26+
);
27+
console.warn(
28+
'Failed to read package.json:',
29+
error,
30+
'new_entry_path',
31+
moduleEntryPath,
32+
);
33+
}
2034
let pkgPath = findUpSync('package.json', {
2135
cwd: moduleEntryPath,
2236
});
@@ -71,7 +85,7 @@ export async function getExternalPkgsDependencies(
7185
for (const pkgName of pkgNames) {
7286
try {
7387
const moduleRoot = getModuleRoot(cwd, pkgName);
74-
console.log('moduleRoot', moduleRoot);
88+
// console.log('moduleRoot', moduleRoot);
7589

7690
const walker = new Walker(moduleRoot);
7791
// These are private so it's quite nasty!

0 commit comments

Comments
 (0)