Skip to content
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

add exports field to package.json #659

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
"main": "dist/a11y-dialog.js",
"module": "dist/a11y-dialog.esm.js",
"types": "dist/a11y-dialog.d.ts",
"exports": {
".": {
Copy link
Author

Choose a reason for hiding this comment

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

When you do import A11yDialog from 'a11y-dialog' you get ./dist/a11y-dialog.esm.js, and when you do const A11yDialog = require('a11y-dialog) you get ./dist/a11y-dialog.js

"import": "./dist/a11y-dialog.esm.js",
"require": "./dist/a11y-dialog.js",
"types": "./dist/a11y-dialog.d.ts"
},
"dist/*.esm.js": "./dist/*.esm.js",
"dist/*.js": "./dist/*.js",
Comment on lines +17 to +18
Copy link
Author

Choose a reason for hiding this comment

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

If someone is importing using an exact extension, give them what they asked for

"dist/*": {
"import": "./dist/*.esm.js",
"require": "./dist/*.js",
"types": "./dist/*.d.ts"
},
Comment on lines +19 to +23
Copy link
Author

Choose a reason for hiding this comment

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

Otherwise if the extension is omitted, use the appropriate extension depending on import or require

"package.json": "./package.json"
Copy link
Author

Choose a reason for hiding this comment

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

general best practice to allow importing your package.json

},
"keywords": [
"modal",
"dialog",
Expand Down