惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 司徒正美
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
月光博客
月光博客
量子位
大猫的无限游戏
大猫的无限游戏
Stack Overflow Blog
Stack Overflow Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
P
Proofpoint News Feed
B
Blog RSS Feed
美团技术团队
腾讯CDC
C
Check Point Blog
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
J
Java Code Geeks
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
feat: bundle plugin npm dependencies · openclaw/openclaw@...
steipete · 2026-05-22 · via Recent Commits to openclaw:main

@@ -108,6 +108,70 @@ function assertPluginNpmRuntimeBuildExists(plan) {

108108

assertPackageFilesDoNotExcludeRequiredRuntimeArtifacts(plan);

109109

}

110110111+

function hasPackageRuntimeDependencies(packageJson) {

112+

return (

113+

Object.keys(packageJson.dependencies ?? {}).length > 0 ||

114+

Object.keys(packageJson.optionalDependencies ?? {}).length > 0

115+

);

116+

}

117+118+

function shouldBundleDependencies(value) {

119+

return value === true || value === "1" || value === "true";

120+

}

121+122+

function installPackageLocalBundledDependencies(params) {

123+

const packageJson = params.packageJson;

124+

if (packageJson.bundleDependencies !== true || !hasPackageRuntimeDependencies(packageJson)) {

125+

return () => {};

126+

}

127+128+

const shrinkwrapPath = path.join(params.packageDir, "npm-shrinkwrap.json");

129+

if (!fs.existsSync(shrinkwrapPath)) {

130+

throw new Error(

131+

`package-local bundled dependency install requires npm-shrinkwrap.json for ${params.pluginDir}`,

132+

);

133+

}

134+135+

const nodeModulesPath = path.join(params.packageDir, "node_modules");

136+

if (fs.existsSync(nodeModulesPath)) {

137+

throw new Error(

138+

`package-local bundled dependency install refuses to replace existing node_modules for ${params.pluginDir}`,

139+

);

140+

}

141+142+

console.error(`[plugin-npm-publish] installing bundled dependencies for ${params.pluginDir}`);

143+

const result = spawnSync(

144+

"npm",

145+

[

146+

"install",

147+

"--omit=dev",

148+

"--omit=peer",

149+

"--legacy-peer-deps",

150+

"--ignore-scripts",

151+

"--no-audit",

152+

"--no-fund",

153+

"--package-lock=false",

154+

"--loglevel=error",

155+

],

156+

{

157+

cwd: params.packageDir,

158+

env: process.env,

159+

stdio: ["ignore", "ignore", "inherit"],

160+

},

161+

);

162+

if (result.error) {

163+

throw result.error;

164+

}

165+

if ((result.status ?? 1) !== 0) {

166+

throw new Error(

167+

`package-local bundled dependency install failed for ${params.pluginDir} with exit ${result.status ?? 1}`,

168+

);

169+

}

170+

return () => {

171+

fs.rmSync(nodeModulesPath, { recursive: true, force: true });

172+

};

173+

}

174+111175

export function resolveAugmentedPluginNpmPackageJson(params) {

112176

const repoRoot = path.resolve(params.repoRoot ?? ".");

113177

const packageDir = resolvePackageDir(repoRoot, params.packageDir);

@@ -147,6 +211,11 @@ export function resolveAugmentedPluginNpmPackageJson(params) {

147211

...(plan.runtimeSetupEntry ? { runtimeSetupEntry: plan.runtimeSetupEntry } : {}),

148212

},

149213

};

214+

if (shouldBundleDependencies(params.bundleDependencies)) {

215+

packageJson.bundleDependencies = true;

216+

delete packageJson.bundledDependencies;

217+

delete packageJson.devDependencies;

218+

}

150219

const changed = JSON.stringify(packageJson) !== JSON.stringify(plan.packageJson);

151220

return {

152221

packageJsonPath,

@@ -155,6 +224,7 @@ export function resolveAugmentedPluginNpmPackageJson(params) {

155224

changed,

156225

packageJson,

157226

pluginDir: plan.pluginDir,

227+

bundleDependencies: shouldBundleDependencies(params.bundleDependencies),

158228

reason: changed ? "package-local-runtime" : "unchanged",

159229

};

160230

}

@@ -290,13 +360,15 @@ export function resolveAugmentedPluginNpmManifest(params) {

290360

export function withAugmentedPluginNpmManifestForPackage(params, callback) {

291361

const repoRoot = path.resolve(params.repoRoot ?? ".");

292362

const packageDir = resolvePackageDir(repoRoot, params.packageDir);

363+

const bundleDependencies = shouldBundleDependencies(params.bundleDependencies);

293364

const resolvedManifest = resolveAugmentedPluginNpmManifest({

294365

repoRoot,

295366

packageDir,

296367

});

297368

const resolvedPackageJson = resolveAugmentedPluginNpmPackageJson({

298369

repoRoot,

299370

packageDir,

371+

bundleDependencies,

300372

});

301373302374

if (

@@ -332,7 +404,15 @@ export function withAugmentedPluginNpmManifestForPackage(params, callback) {

332404

);

333405

writeJsonFile(resolvedPackageJson.packageJsonPath, resolvedPackageJson.packageJson);

334406

}

407+

let cleanupBundledDependencies = () => {};

335408

try {

409+

if (bundleDependencies && resolvedPackageJson.packageJson) {

410+

cleanupBundledDependencies = installPackageLocalBundledDependencies({

411+

packageDir,

412+

packageJson: resolvedPackageJson.packageJson,

413+

pluginDir: resolvedPackageJson.pluginDir ?? path.basename(packageDir),

414+

});

415+

}

336416

return callback({

337417

...resolvedManifest,

338418

packageDir,

@@ -341,6 +421,7 @@ export function withAugmentedPluginNpmManifestForPackage(params, callback) {

341421

packageJsonApplied: resolvedPackageJson.changed && Boolean(resolvedPackageJson.packageJson),

342422

});

343423

} finally {

424+

cleanupBundledDependencies();

344425

if (originalManifest !== undefined) {

345426

fs.writeFileSync(resolvedManifest.manifestPath, originalManifest, "utf8");

346427

}

@@ -372,17 +453,23 @@ function parseRunArgs(argv) {

372453373454

function main(argv = process.argv.slice(2)) {

374455

const { packageDir, command, args } = parseRunArgs(argv);

375-

return withAugmentedPluginNpmManifestForPackage({ packageDir }, ({ packageDir: cwd }) => {

376-

const result = spawnSync(command, args, {

377-

cwd,

378-

env: process.env,

379-

stdio: "inherit",

380-

});

381-

if (result.error) {

382-

throw result.error;

383-

}

384-

return result.status ?? 1;

385-

});

456+

return withAugmentedPluginNpmManifestForPackage(

457+

{

458+

packageDir,

459+

bundleDependencies: process.env.OPENCLAW_PLUGIN_NPM_BUNDLE_DEPENDENCIES,

460+

},

461+

({ packageDir: cwd }) => {

462+

const result = spawnSync(command, args, {

463+

cwd,

464+

env: process.env,

465+

stdio: "inherit",

466+

});

467+

if (result.error) {

468+

throw result.error;

469+

}

470+

return result.status ?? 1;

471+

},

472+

);

386473

}

387474388475

if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {