Address ESM compatibility issues#37
Conversation
Update package.json and TypeScript configuration to properly support ES modules. Modify hashing and index modules to use ESM-compatible imports/exports.
There was a problem hiding this comment.
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
moduleResolutionandverbatimModuleSyntax - Updated all import statements to include
.jsfile 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.
- 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
There was a problem hiding this comment.
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.
|
are we properly dogfooding imports now? |
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
left a comment
There was a problem hiding this comment.
lgtm but tests need to pass
| "removeComments": true, | ||
| "rootDir": "src", | ||
| "module": "es2022", | ||
| "moduleResolution": "node", |
There was a problem hiding this comment.
FYI this should probably be node16 so it respects export maps & what not
Update package.json and TypeScript configuration to properly support ES modules. Modify hashing and index modules to use ESM-compatible imports/exports.