fix(opencode): rename bin entry to .cjs for ESM compatibility - #28342
fix(opencode): rename bin entry to .cjs for ESM compatibility#28342qiushile wants to merge 4 commits into
Conversation
The bin/opencode launcher uses CommonJS require() syntax but package.json declares "type": "module" (ESM). Node.js fails with "require is not defined" when running the binary in ESM mode. Renaming to .cjs tells Node.js to treat this file as CommonJS regardless of the package type, which is the standard approach for mixed CJS/ESM packages.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #28343
Type of change
What does this PR do?
The
bin/opencodelauncher uses CommonJSrequire()syntax, butpackage.jsondeclares"type": "module". Node.js resolves the file as ESM and fails withReferenceError: require is not defined.Renaming to
.cjstells Node.js to treat the launcher as CommonJS regardless of the package type, which is the standard approach for mixed CJS/ESM packages.How did you verify your code works?
Verified
node bin/opencode.cjs --versionreturns1.15.5successfully on Linux x64 with Node.js v24.Screenshots / recordings
N/A (no UI changes)
Checklist