Option to write exports to jsr.json#57
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements JSR (JavaScript Registry) support by adding an option to automatically copy export configurations to jsr.json. When jsr: true is set in the zshy configuration, the tool will now write the source code entrypoint exports to jsr.json, making the zshy config the single source of truth for exports.
Key Changes:
- Added
jsrboolean configuration option to write exports to jsr.json - Refactored package.json path finding and indentation detection into reusable utility functions
- Added comprehensive test coverage with a new test fixture in
test/jsr/
Reviewed changes
Copilot reviewed 9 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/main.ts |
Added JSR configuration option and logic to read/write jsr.json with proper indentation preservation |
src/utils.ts |
Extracted findConfigPath and detectConfigIndention utility functions for reuse across config file operations |
test/zshy.test.ts |
Added test case to verify exports are copied to jsr.json when jsr option is enabled |
test/jsr/* |
New test fixture directory with complete setup including package.json, jsr.json, source files, and build output |
test/__snapshots__/zshy.test.ts.snap |
Added snapshot for the jsr test case showing expected build output |
README.md |
Documented the new JSR feature and fixed quote style consistency in code examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
cc @pullfrog |
|
✅ Review complete for PR #57 Summary: The implementation successfully adds JSR support to zshy, allowing the tool to copy exports to Key findings:
Feedback provided:
The core implementation is solid and ready for merge with minor improvements if desired. |
src/main.ts
Outdated
|
|
||
| // Normalize boolean options | ||
| config.noEdit ??= false; | ||
| config.jsr ??= false; |
There was a problem hiding this comment.
Consider moving the config.jsr normalization after the config.cjs normalization and validation block (after line 290) to keep all boolean option normalizations together in one place, rather than splitting them.
| ////////////////////////////////// | ||
|
|
||
| if (config.jsr) { | ||
| if (config.noEdit) { |
There was a problem hiding this comment.
The logic structure here mirrors the package.json modification section well. Good consistency. One minor suggestion: consider adding a check for the existence of jsr.json earlier (perhaps right after checking config.jsr) with a more helpful error message like "jsr: true requires a jsr.json file to exist" to make it clearer to users what the issue is.
src/main.ts
Outdated
| conditions?: Record<string, "esm" | "cjs" | "src">; | ||
| tsconfig?: string; // optional path to tsconfig.json file | ||
| noEdit?: boolean; | ||
| jsr?: boolean; |
There was a problem hiding this comment.
cc @pullfrog drop this. zshy should write to jsr.json if it exists. the existence of the file is the way to enable this.
There was a problem hiding this comment.
Removed the jsr config option. Now zshy automatically detects if jsr.json exists and writes exports to it if present.
There was a problem hiding this comment.
Done! Removed the jsr config option. Now zshy automatically detects and writes to jsr.json if it exists in the project.
|
✅ Review feedback addressed Changes made:
Implementation approach: Committed and pushed to the PR branch. |
|
Leaping into action... |
|
✅ Review feedback addressed! Changes made:
The implementation now works exactly as requested: zshy automatically writes to jsr.json when it exists, without requiring any configuration flag. |
Changed the implementation to automatically detect if jsr.json exists in the project rather than requiring a `jsr: true` config option. This simplifies the API - users just need to create a jsr.json file to enable JSR export writing. - Removed `jsr` property from RawConfig and NormalizedConfig interfaces - Updated jsr.json section to use try/catch with findConfigPath() - If jsr.json exists, zshy will automatically write exports to it
|
Updated to address things missed by @pullfrog |
|
✅ Review complete The author successfully addressed the owner's feedback. The implementation now correctly:
However, I found two minor cleanup issues that were missed: 1. Test description outdated (line 176 of - it("should copy exports to jsr.json when jsr is true", () => {
+ it("should copy exports to jsr.json when jsr.json exists", () => {2. Unrelated style changes in README (lines 695 & 705): - console.log("hello");
+ console.log('hello');I've created a commit locally with these fixes, but I cannot push to your fork. Here's the complete patch you can apply: diff --git a/README.md b/README.md
index 8da1472..4f7c834 100644
--- a/README.md
+++ b/README.md
@@ -692,7 +692,7 @@ To learn more, read the ["Masquerading as CJS"](https://github.com/arethetypeswr
```ts
function hello() {
- console.log("hello");
+ console.log('hello');
}
export default hello;
@@ -702,7 +702,7 @@ export default hello;
```ts
function hello() {
- console.log("hello");
+ console.log('hello');
}
exports.default = hello;
module.exports = exports.default;
diff --git a/test/zshy.test.ts b/test/zshy.test.ts
index a7aec22..467cb38 100644
--- a/test/zshy.test.ts
+++ b/test/zshy.test.ts
@@ -173,7 +173,7 @@ describe("zshy with different tsconfig configurations", () => {
expect(snapshot).toMatchSnapshot();
});
- it("should copy exports to jsr.json when jsr is true", () => {
+ it("should copy exports to jsr.json when jsr.json exists", () => {
const snapshot = runZshyWithTsconfig("tsconfig.json", {
dryRun: false,
cwd: process.cwd() + "/test/jsr",You can apply this patch with |
|
@pullfrog I have updated the test name. The quotation mark changes were made automatically by Biome for consistency, so you don't need to keep pointing them out. |
|
Thank you for the update! I can confirm: ✅ The test name has been updated to Understood regarding the quotation mark changes in the README - since they're from Biome's automatic formatting for consistency, I won't flag them in future reviews. The PR looks good now! |
|
Landed in 0.7.0. Thanks! |

Implements #55