-
Notifications
You must be signed in to change notification settings - Fork 14
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
Use default keyword as the main #17
Conversation
README.md
Outdated
@@ -55,7 +55,7 @@ Here’s a complete `package.json` example, for a hypothetical module named `@mo | |||
|
|||
Within the `"exports"` object, the keys are concatenated on the end of the name field, e.g. `import utc from '@momentjs/moment/timezones/utc'` is formed from `'@momentjs/moment'` + `'/timezones/utc'`. | |||
|
|||
The main entrypoint is therefore the empty string, `"": "./src/moment.mjs"`. For modules that desire to export *only* a single entrypoint, e.g. `import request from 'request'`, the `"exports"` key itself can be set to the entrypoint: | |||
The main entrypoint is therefore the empty string, `"default": "./src/moment.mjs"`. For modules that desire to export *only* a single entrypoint, e.g. `import request from 'request'`, the `"exports"` key itself can be set to the entrypoint: |
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.
Shouldn’t still say “empty string” here.
One thing that was brought up in another thread: If we switch |
"." is definitely nicer than "". @MylesBorins what are your thoughts here? |
But then what would the docs say? The left hand side is no longer string concatenation. Another option is to just split this all up into two keywords: "nodejs": {
"exportsMain": "./index.mjs",
"exports": {
"/stub": "./dist/stub.mjs"
}
} |
The docs would say "the LHS needs to start with a dot which will be replaced with the package name". I think that's almost as simple as pure concat. |
Okay, I can get behind that. If we need to add a separate “mode” field anyway though, should we consider just keeping the main and deep exports as separate properties? Or wrap it all under a |
Superseded by #20. |
As discussed in #16, I think this polishes the aesthetics of this proposal.