Externalize library dependencies to remove dist/node_modules#1348
Externalize library dependencies to remove dist/node_modules#1348malhotra5 wants to merge 2 commits into
Conversation
Avoid emitting dependency modules under dist/node_modules during library builds by deriving externals from package dependencies and peers. Co-authored-by: openhands <openhands@all-hands.dev>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Mock-LLM E2E Tests54/54 passed Commit:
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
Assert the library build externalization function preserves package and subpath externals while keeping internal imports bundled. Co-authored-by: openhands <openhands@all-hands.dev>
🛑 Mock-LLM Docker E2E Test Results46/51 passed · 5 skipped · Commit:
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
✅ Mock-LLM E2E Tests54/54 passed Commit:
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
❌ Mock-LLM Docker E2E Test Results41/56 passed · 4 failed · 11 skipped Commit:
🔍 Failure details (4)❌ chromium › settings/mock-llm-model-switch.spec.ts › mock-LLM /model slash command › step 1: configure LLM, create switch-target profile, register trajectory❌ chromium › settings/mock-llm-model-switch.spec.ts › mock-LLM /model slash command › step 1: configure LLM, create switch-target profile, register trajectory❌ chromium › settings/mock-llm-profile-management.spec.ts › active profile deletion + reconciliation › active profile is deletable and reconciliation activates another profile❌ chromium › settings/mock-llm-profile-management.spec.ts › active profile deletion + reconciliation › active profile is deletable and reconciliation activates another profilePosted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
🔶 Mock-LLM Docker E2E Test Results49/54 passed · 5 skipped Commit:
Posted by the Mock-LLM E2E workflow · results are deterministic (scripted LLM responses) |
HUMAN:
AGENT:
This PR was created by an AI agent (OpenHands) on behalf of the user.
Evidence from local testing:
npm cicompleted successfully.npm run build:libcompleted successfully.find dist -path '*node_modules*'returned no paths after the library build.npm run buildcompleted successfully.npm run typecheckcompleted successfully.npx prettier --check vite.config.ts __tests__/vite-config.test.tscompleted successfully.npm test -- __tests__/vite-config.test.tscompleted successfully after updating the config test for function-based externalization.npm pack --jsonreportedhas_dist_node_modules: false, with package size6.23 MB, unpacked size23.3 MB, and4,066entries../node_modules/.bin/agent-canvas --version, verified@openhands/extensions/package.jsonresolves from the normal dependency location, and built a minimal Vite consumer importing@openhands/agent-canvas,@openhands/agent-canvas/terminal, and@openhands/agent-canvas/i18n.Why
The library build was preserving modules while only externalizing React and React Router. As a result, dependency modules such as
react-icons,@openhands/extensions, HeroUI-related packages, and others were emitted intodist/node_modules, duplicating the normal npm dependency tree and increasing install/package size.Summary
dependencies,optionalDependencies, andpeerDependencies.@openhands/extensions/skillsandreact-icons/fa6instead of emitting them underdist/node_modules.posthog-js/reactto its concrete ESM entry so minimal Vite consumers can bundle the library after externalization.Package size / disk footprint impact
Measured with
npm pack --jsonand clean temp installs:@openhands/agent-canvas@1.0.0-rc.11)node_modules/@openhands/agent-canvasdirectorydist/node_modulescontentsNote: the before numbers are from the currently published npm package available during profiling; the branch version is
1.0.0-rc.6, so the exact numbers may shift slightly by release, but the removeddist/node_modulesduplicate is the meaningful delta.Install timing note
Measured in this sandbox with
npm installinto fresh temp projects. The before numbers are from the published npm package profile; the after numbers use a locally packed tarball from this branch, so they are directionally useful but not a perfect registry-to-registry comparison.--no-audit--no-auditThe meaningful end-user improvement from this PR is package payload/disk footprint: the tarball is about 10.44 MB smaller, unpacked package payload is about 38.68 MB smaller, and the installed
@openhands/agent-canvaspackage directory is about 55 MB smaller. Install time may improve on slower networks/disks, but the current dependency graph still dominates totalnpm installtime.Issue Number
N/A
How to Test
Run:
npm ci npm run build:lib find dist -path '*node_modules*' npm run build npm run typecheck npx prettier --check vite.config.ts npm pack --jsonExpected result:
find dist -path '*node_modules*'should produce no output, and the package metadata fromnpm pack --jsonshould not include any files underdist/node_modules/.Optional consumer smoke test:
Video/Screenshots
Not applicable; this is a package/build configuration change. The validation is command-line build and package output listed above.
Type
Notes
The raw public skill files still come from the normal
@openhands/extensionsdependency (for examplenode_modules/@openhands/extensions/skills/...), not from@openhands/agent-canvas/dist/node_modules. This change removes the duplicated build output only.@malhotra5 can click here to continue refining the PR
🐳 Docker images for this PR
• GHCR package: https://github.com/OpenHands/agent-canvas/pkgs/container/agent-canvas
ghcr.io/openhands/agent-canvasghcr.io/openhands/agent-server:1.28.1-pythonopenhands-automation==1.0.0a9114d7679f302faaefca8f391bdb71a5d3731f916Pull (multi-arch manifest)
# Multi-arch manifest — Docker automatically pulls the correct architecture docker pull ghcr.io/openhands/agent-canvas:sha-114d767Run
All tags pushed for this build
About Multi-Architecture Support
sha-114d767) is a multi-arch manifest supporting both amd64 and arm64sha-114d767-amd64) are also available if needed