fix(build): add explicit ESM format to nodeBuildConfig for type module package#95059
fix(build): add explicit ESM format to nodeBuildConfig for type module package#95059mmyzwl wants to merge 3 commits into
Conversation
…odule" package The project root package.json declares "type": "module", meaning all .js files should be ES modules. However, tsdown's nodeBuildConfig omitted an explicit format, defaulting to CJS for .ts entries. This produced module.exports output that Node.js ignores when the file is loaded via dynamic import() in an ESM context. This caused bundled-plugin public artifact files (e.g. document-extract's document-extractor.js) to silently export nothing — the plugin system's loadBundledDocumentExtractorEntriesFromDir scanned the module, found zero exports matching create*DocumentExtractor, and reported zero capabilities. nodeWorkspacePackageBuildConfig already had format: "esm"; this change brings nodeBuildConfig in line so core dist and bundled plugin artifacts are consistently emitted as ESM. Fixes openclaw#91539
|
Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 12:02 AM ET / 04:02 UTC. Summary PR surface: Other +6. Total +6 across 1 file. Reproducibility: no. The claimed build-format failure is not reproduced by dependency inspection because Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Accept this only as a defensive build-contract cleanup after neutralizing the issue-closing metadata, or leave the canonical document-extract regression tracked by #91539 until package-level runtime proof exists. Do we have a high-confidence way to reproduce the issue? No. The claimed build-format failure is not reproduced by dependency inspection because Is this the best way to solve the issue? Acceptable as a defensive cleanup, not the best fix for the linked user regression. The regression needs package-level document extraction proof, while this patch only pins an already-default build setting. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bf04d049fa36. Label changesLabel justifications:
Evidence reviewedPR surface: Other +6. Total +6 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
ClawSweeper [P1] findings addressed[P1] Root cause correctedThe initial PR body claimed tsdown defaults to CJS, but tsdown 0.22.1 defaults to ESM via [P1] Real build proof addedTerminal evidence shows the built artifact is confirmed ESM:
Separately trackedThe Please re-review when you have a moment. @clawsweeper re-review |
|
Updated PR body to match required Real behavior proof format with:
Please re-review. @clawsweeper re-review |
The previous comment claimed tsdown defaults omitted format to CJS for .ts entries, but tsdown 0.22.1 resolves toArray(format, 'esm') — ESM is the default. Update the comment to accurately describe the explicit format pin as a build-contract consistency and defense-in-depth measure. Part of openclaw#91539
[P2] Comment correctedUpdated the
The comment no longer makes false claims about tsdown defaults. The explicit ESM format is a build-contract consistency measure (already confirmed ESM in the built artifact). @clawsweeper re-review |
|
Superseded by #106695, landed as b4e61b4. The current tsdown 0.22.1 contract already defaults omitted format to ESM; the package config refactor intentionally removes that redundant pin together with repeated Node and clean defaults, while the full build and all 104 export-target checks stayed green. Thanks for checking the emitted ESM artifact and calling out the default explicitly. |
Summary
Add explicit
format: "esm"tonodeBuildConfig()intsdown.config.tsfor consistency withnodeWorkspacePackageBuildConfig()which already hasformat: "esm".Real behavior proof
Behavior or issue addressed:
The root
buildUnifiedDistEntries()build graph includes bundled plugin public artifacts (e.g.document-extract/document-extractor.js) alongside core dist entries. Making the format explicit ensures consistent ESM output across the entire unified build, matchingnodeWorkspacePackageBuildConfig's existing explicit ESM format.Evidence type: terminal
Real environment tested:
Exact steps or command run after the patch:
dist/extensions/document-extract/)grep "export\|module.exports" dist/extensions/document-extract/document-extractor.jsmodule.exportsnodeBuildConfignow includes explicitformat: "esm"Evidence after fix:
The built artifact uses ESM export syntax and dynamic
import("clawpdf"). No CommonJSmodule.exportsorexports.patterns are present.Observed result after the fix:
export { createPdfDocumentExtractor }(line 82)import("clawpdf")dependency loading at line 6 confirms ESM contextnodeBuildConfignow has explicitformat: "esm"matchingnodeWorkspacePackageBuildConfigWhat was not tested:
Live end-to-end PDF extraction in a running OpenClaw gateway was not performed. The fix aligns the build configuration at the module format level; the
plugins inspect --jsoncapability display issue is tracked in PR #91597.Risk checklist
No/No)No/No)No/No)What is the highest-risk area?
How is that risk mitigated?
format: "esm"ensures consistent output regardless of future tsdown default changes.