fix(pkg): ship compiled dist/ instead of TypeScript sources#72
Open
qianhaoq wants to merge 1 commit intoTencent:mainfrom
Open
fix(pkg): ship compiled dist/ instead of TypeScript sources#72qianhaoq wants to merge 1 commit intoTencent:mainfrom
qianhaoq wants to merge 1 commit intoTencent:mainfrom
Conversation
Problem: The published tarball only contains .ts sources (index.ts, src/**/*.ts) and openclaw.extensions points to ./index.ts. The OpenClaw host has to transpile ~34 files via jiti on every startup. In a local measurement this added ~5s of main-thread CPU to every openclaw invocation, and likely contributes to the Docker startup hangs reported in Tencent#40 (high CPU, never becomes healthy before the healthcheck times out). The repo already has a tsconfig.json that emits to dist/ and a build script, but dist/ is not listed in "files" and openclaw.extensions still points at ./index.ts, so none of this reaches consumers. Fix: - package.json files: ship dist/ (excluding sourcemaps), drop src/ and index.ts so we don't double-ship source. - package.json main: ./dist/index.js for tools that respect it. - package.json openclaw.extensions: ./dist/index.js so the host loads the compiled entry instead of transpiling at runtime. prepublishOnly already runs `npm run typecheck && npm run build`, so dist/ is produced before publish; no CI change needed. Effect on a local install (openclaw 2026.4.14): openclaw plugins list: 7.4s -> 3.0s openclaw (bare): 7.2s -> 2.8s Tarball size drops from ~197kB unpacked to ~188kB and no longer exposes source. Build output is reproducible via `npm run build`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Publish the compiled
dist/output and pointopenclaw.extensionsat./dist/index.js, so the OpenClaw host no longer has to transpile ~34 TypeScript files via jiti on every startup.Fixes #71 (see that issue for the full diagnosis and CPU profile).
Why
The repo already has a working
tsconfig.json(emits todist/) andprepublishOnlyalready runstsc. Butdist/is not listed inpackage.json#filesandopenclaw.extensionsstill points at./index.ts, so consumers receive only TS sources. That forces the host to invoke jiti on every boot — locally measured at ~5.2s of main-thread CPU out of 7.3s total foropenclaw plugins list. This likely contributes to the Docker startup hang in #40 (healthcheck never passes because the CPU-bound transpile happens before the gateway reports healthy).Change
Two fields in
package.json:files: shipdist/(exclude.mapfiles), dropsrc/andindex.ts.openclaw.extensions:./dist/index.jsinstead of./index.ts.main: ./dist/index.jsfor tools that honor it.No build script or CI change needed —
prepublishOnlyalready producesdist/.Measured effect
Local install, OpenClaw 2026.4.14, plugin built with this PR's layout and reinstalled:
openclaw plugins listopenclaw(bare)jiti no longer appears in the top frames of the CPU profile.
Tarball: ~197kB → ~188kB unpacked, and no longer ships source.
Test plan
npm install && npm run buildproducesdist/index.jsanddist/src/**/*.js.npm pack --dry-runshowsdist/and no.tsfiles.openclaw plugins install <tarball>and verifyopenclaw plugins listreports entry path ending indist/index.jsand statusloaded.