[DRAFT] Add exports to make package usable as a library#194
[DRAFT] Add exports to make package usable as a library#194marceljuenemann wants to merge 1 commit intodfinity:mainfrom
Conversation
|
Thank you for contributing! Unfortunately this repository does not accept external contributions yet. We are working on enabling this by aligning our internal processes and our CI setup to handle external contributions. However this will take some time to set up so in the meantime we unfortunately have to close this Pull Request. We hope you understand and will come back once we accept external PRs. — The DFINITY Foundation |
There was a problem hiding this comment.
Pull request overview
This PR adds TypeScript declaration files (.d.ts) to enable the package to be used as a library with proper type support. Currently, the published package lacks these declaration files, making it difficult to use with TypeScript projects.
Changes:
- Enabled TypeScript declaration file generation in tsconfig.json
- Added package.json "types" field pointing to the main declaration file
- Added package.json "exports" field with subpath exports for main entry point and submodules (ecdsa, schnorr, signer)
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tsconfig.json | Enables generation of TypeScript declaration files and source maps |
| package.json | Adds types field and exports configuration for library usage with proper TypeScript support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -3,6 +3,25 @@ | |||
| "version": "1.0.1", | |||
| "type": "module", | |||
| "main": "index.js", | |||
There was a problem hiding this comment.
The "main" field should be updated to point to "dist/index.js" instead of "index.js" to be consistent with the new exports field and the actual build output directory. Without this change, older package managers that don't support the "exports" field will look for a file at the root that doesn't exist.
| "main": "index.js", | |
| "main": "dist/index.js", |
| "types": "./dist/signer/index.d.ts", | ||
| "import": "./dist/signer/index.js" | ||
| } | ||
| }, |
There was a problem hiding this comment.
The package.json is missing a "files" field to specify which files should be included in the published package. Since "dist/" is listed in .gitignore and there's no .npmignore file, npm will exclude the dist directory from the published package by default. This would make the package unusable. Add a "files" field that includes "dist" to ensure the compiled code and type definitions are published.
| }, | |
| }, | |
| "files": [ | |
| "dist" | |
| ], |
|
@marceljuenemann Thanks for the patch, I'm working on getting things set up on our side such that we can accept contributions to this repository. |
|
@marceljuenemann thank you for that! It was bothering me for a while too (see snippet)... While we wait, I opened this using your code: Please let me know if you have comments/additions |
Currently there are no .d.ts files in the published package. This means you can't use this package as a library.
You might want to have more exports like
ecdsa/secp256k1, I just added a couple to prove the concept, let me know if you want me to add all.