Skip to content

Convert TypeScript package to ESM-only#261

Open
Arechii wants to merge 1 commit into
masterfrom
typescript-esm-only
Open

Convert TypeScript package to ESM-only#261
Arechii wants to merge 1 commit into
masterfrom
typescript-esm-only

Conversation

@Arechii
Copy link
Copy Markdown
Contributor

@Arechii Arechii commented Apr 30, 2026

Summary

  • Switches the npm package @blueyerobotics/protocol-definitions from CommonJS to ESM-only output.
  • tsconfig.json: module/moduleResolution set to NodeNext, target raised to ES2022.
  • package.json: adds "type": "module" and an exports map (types + import); drops main.
  • CI Generate step: adds --ts_proto_opt=esModuleInterop=true and --ts_proto_opt=importSuffix=.js so ts-proto emits relative imports with .js extensions, which NodeNext ESM requires.

🤖 Generated with Claude Code

Switches the npm package from CommonJS to ESM-only output.

- tsconfig.json: module/moduleResolution NodeNext, target ES2022
- package.json: adds "type": "module" and "exports" map; drops "main"
- CI Generate: adds esModuleInterop=true and importSuffix=.js so
  ts-proto emits relative imports with .js extensions for NodeNext

Breaking change for CommonJS consumers (require() is blocked by the
exports map); a major version bump should accompany this before
publishing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the @blueyerobotics/protocol-definitions npm package build output from CommonJS to ESM-only, aligning the TypeScript compiler and ts-proto generation with Node’s ESM/NodeNext requirements.

Changes:

  • Update TypeScript compilation to module/moduleResolution: NodeNext and raise target to ES2022.
  • Convert the npm package to ESM-only via "type": "module" and an exports map (dropping the previous main entrypoint).
  • Adjust CI generation to emit .js-suffixed relative imports and enable esModuleInterop in ts-proto output.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
tsconfig.json Switches TS compiler settings to NodeNext ESM output and ES2022 target.
package.json Declares ESM-only package semantics and defines an exports map for the entrypoint/types.
.github/workflows/ci-typescript.yaml Updates ts-proto generation options to be compatible with NodeNext ESM resolution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
Comment on lines +10 to +15
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
Comment thread package.json
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants