fix(plugins): add postinstall patch for ESM-only package exports#16019
Closed
dashed wants to merge 2 commits intoopenclaw:mainfrom
Closed
fix(plugins): add postinstall patch for ESM-only package exports#16019dashed wants to merge 2 commits intoopenclaw:mainfrom
dashed wants to merge 2 commits intoopenclaw:mainfrom
Conversation
bfc1ccb to
f92900f
Compare
431bbb7 to
27fbbcf
Compare
This was referenced Feb 19, 2026
27fbbcf to
bf8bd17
Compare
This was referenced Feb 21, 2026
4c9aabe to
f6aaf84
Compare
8a0229e to
12c0350
Compare
798a6fb to
275fe40
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
da2f6d0 to
ad96cd0
Compare
7a2661d to
eaa81e3
Compare
jiti (the TS/ESM loader used for plugin loading) converts imports to CJS require() internally. Three dependencies (@buape/carbon, osc-progress, @mariozechner/pi-coding-agent) ship export maps with only an "import" condition and no "default" or "require" fallback, causing ERR_PACKAGE_PATH_NOT_EXPORTED at runtime. This silently breaks all plugin loading for any plugin importing from openclaw/plugin-sdk. Add a postinstall script that walks node_modules and adds the missing "default" export condition to any package whose exports have "import" but neither "default" nor "require". The patch is idempotent, has zero runtime cost, and becomes a no-op if upstream packages add CJS support.
Verify the postinstall patch end-to-end: - Reproduce ERR_PACKAGE_PATH_NOT_EXPORTED with ESM-only fixtures - Confirm patchDir resolves the failure - Validate all three affected packages resolve via CJS in real node_modules after postinstall - Verify jiti can resolve @buape/carbon through the patched exports
eaa81e3 to
d4629a2
Compare
Contributor
Author
|
Rebased to latest main (post-v2026.3.26, |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
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
Fixes plugin loading failures caused by ESM-only dependencies that lack CJS-compatible export conditions.
importto CJSrequire()internally. Three dependencies (@buape/carbon,osc-progress,@mariozechner/pi-coding-agent) ship export maps with only an"import"condition — no"default"or"require"fallback — causingERR_PACKAGE_PATH_NOT_EXPORTEDat runtime. This silently breaks all plugin loading for any plugin importing fromopenclaw/plugin-sdk.scripts/patch-esm-exports.cjs) that walksnode_modulesand adds the missing"default"export condition to any package whose exports have"import"but neither"default"nor"require". The patch is idempotent, has zero runtime cost, and becomes a no-op if upstream packages add CJS support.Related issues
Test plan
src/scripts/patch-esm-exports.test.ts) —patchExportslogic,patchDirdirectory walking, edge cases (malformed JSON, string shorthand, idempotency, depth limits, skip dirs), affected package simulationssrc/scripts/patch-esm-exports.e2e.test.ts):ERR_PACKAGE_PATH_NOT_EXPORTEDwith ESM-only fixtures (proves bug exists)patchDirresolves the failure (proves fix works)require.resolvein realnode_modules@buape/carbonthrough patched exportspnpm checkclean (format + typecheck + lint)Greptile Overview
Greptile Summary
Adds a postinstall script (
scripts/patch-esm-exports.cjs) that patches ESM-only dependencies (@buape/carbon,osc-progress,@mariozechner/pi-coding-agent) by adding a"default"export condition to theirpackage.jsonexports maps. This resolvesERR_PACKAGE_PATH_NOT_EXPORTEDerrors when jiti (the runtime TS/ESM loader) convertsimportto CJSrequire()internally.patchExportsfunction handles one-level-deep condition maps (subpath → condition → value), which is sufficient for all three affected packagesrequire.resolveand jiti resolution after patchingConfidence Score: 5/5
Last reviewed commit: f6e58e3
(2/5) Greptile learns from your feedback when you react with thumbs up/down!
Rebase History
d5917d37c54a(post-v2026.3.23)COPY scripts ./scriptsto Dockerfile afterCOPY patchesso postinstall script is available duringpnpm installin Docker builds (install-smokewas failing).330631a0eb39(v2026.3.12)COPY scripts ./scriptsbeforepnpm installfor postinstall to work. Commits:7050c1403822,798a6fba6cc5.eb0758e1722c(v2026.3.7)366e02b9e09c,12c0350a8898.