Skip to content

Address ESM compatibility issues#37

Merged
iwillspeak merged 10 commits into
mainfrom
feature/esm-fix
Sep 15, 2025
Merged

Address ESM compatibility issues#37
iwillspeak merged 10 commits into
mainfrom
feature/esm-fix

Conversation

@iwillspeak

Copy link
Copy Markdown
Contributor

Update package.json and TypeScript configuration to properly support ES modules. Modify hashing and index modules to use ESM-compatible imports/exports.

Update package.json and TypeScript configuration to properly support
ES modules. Modify hashing and index modules to use ESM-compatible
imports/exports.
@iwillspeak iwillspeak requested review from abbottdev, Copilot, gdclare and snus-kin and removed request for abbottdev and Copilot September 15, 2025 13:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the project to properly support ES modules (ESM) by modifying TypeScript configuration, package exports, and import/export statements throughout the codebase. The changes address compatibility issues when using the package as an ES module.

  • Added ESM-compatible TypeScript compiler options including moduleResolution and verbatimModuleSyntax
  • Updated all import statements to include .js file extensions for proper ESM resolution
  • Replaced enum shorthand values with their full qualified names for better compatibility

Reviewed Changes

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

File Description
tsconfig.release.json Added ESM-compatible TypeScript compiler options
package.json Updated main entry point, exports configuration, and build tooling for ESM
src/index.ts Modified imports to use .js extensions and updated enum references
src/hashing.ts Updated imports and enum references to use fully qualified names

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread package.json Outdated
Comment thread package.json
- Add new module-import.test.ts to verify ESM compatibility
- Update functional and unit tests for improved coverage
- Modify documentation files and hash-server sample
- Ensure proper module loading across different environments
@iwillspeak iwillspeak requested a review from Copilot September 15, 2025 14:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread tsconfig.release.json
Comment thread package.json
Comment thread package.json Outdated
Comment thread __tests__/unit/module-import.test.ts Outdated
@snus-kin

Copy link
Copy Markdown
Contributor

are we properly dogfooding imports now?

iwillspeak and others added 3 commits September 15, 2025 15:36
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Replace simple @grpc/grpc-js mock with comprehensive mock
- Add makeGenericClientConstructor mock to support ts-proto generated clients
- Include credentials.createSsl and Metadata mocks
- Resolves 'ClassifierServiceClient is not a constructor' test failures
- All tests now pass (33/33) after ts-proto migration

This completes the ESM compatibility fix by ensuring test mocks
work correctly with the new ts-proto generated gRPC clients.

@snus-kin snus-kin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm but tests need to pass

Comment thread samples/hash-server/index.ts
@iwillspeak iwillspeak enabled auto-merge (squash) September 15, 2025 15:19
@iwillspeak iwillspeak disabled auto-merge September 15, 2025 15:19
@iwillspeak iwillspeak enabled auto-merge (squash) September 15, 2025 15:19
Comment thread __tests__/unit/module-import.test.ts
@iwillspeak iwillspeak merged commit 8f67053 into main Sep 15, 2025
7 checks passed
@iwillspeak iwillspeak deleted the feature/esm-fix branch September 15, 2025 15:40
Comment thread tsconfig.release.json
"removeComments": true,
"rootDir": "src",
"module": "es2022",
"moduleResolution": "node",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

FYI this should probably be node16 so it respects export maps & what not

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.

8 participants