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

Use default keyword as the main #17

Closed
wants to merge 2 commits into from

Conversation

guybedford
Copy link
Contributor

As discussed in #16, I think this polishes the aesthetics of this proposal.

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:
Copy link
Collaborator

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.

@jkrems
Copy link
Owner

jkrems commented Dec 6, 2018

One thing that was brought up in another thread: If we switch "/path" to "./path", the key for the default file could also be ".". Would that change things? Or would we still want a keyword?

@guybedford
Copy link
Contributor Author

"." is definitely nicer than "".

@MylesBorins what are your thoughts here?

@GeoffreyBooth
Copy link
Collaborator

One thing that was brought up in another thread: If we switch "/path" to "./path", the key for the default file could also be ".". Would that change things? Or would we still want a keyword?

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"
  }
}

@jkrems
Copy link
Owner

jkrems commented Dec 6, 2018

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.

@GeoffreyBooth
Copy link
Collaborator

the LHS needs to start with a dot which will be replaced with the package name

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 nodejs.module property or something?

@guybedford
Copy link
Contributor Author

Superseded by #20.

@guybedford guybedford closed this Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants