-
Notifications
You must be signed in to change notification settings - Fork 51
fix: Add exports for module compatibility #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,20 @@ | |
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"main": "./index.js", | ||
"types": "./index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./index.d.ts", | ||
"import": "./index.js", | ||
"require": "./index.js" | ||
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can just put one line But this all conflicts with the PR for adding ESM support #104 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true. I will resolve if any PR for ESM merged first. For dual format support, we would need "import" and "require" both eventually. |
||
}, | ||
"./*": { | ||
"types": "./*.d.ts", | ||
"import": "./*.js", | ||
"require": "./*.js" | ||
} | ||
}, | ||
"files": [ | ||
"cosmos/", | ||
"cosmos_proto/", | ||
|
@@ -40,8 +54,7 @@ | |
"prepare-publishing": "./scripts/prepare-publishing.sh", | ||
"build": "rm -rf ./build && tsc && npm run prepare-publishing" | ||
}, | ||
"dependencies": { | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@cosmology/telescope": "^1.12.20", | ||
"@types/node": "^15.6.2", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields will be completely ignored once
"exports"
exists so they don't actually do anything.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are used by consumer projects with
"moduleResolution": "node"
. We can keep both for better compatibility.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The author of https://cmdcolin.github.io/posts/2025-01-12-pureesm says
So there might be value in keeping both