-
- Notifications
You must be signed in to change notification settings - Fork 19
Exports main #41
Exports main #41
Conversation
| @guybedford can you update the commits to have a namespace e.g. |
d2a9c45 to 61a215f Compare 61a215f to 10290e9 Compare
ljharb left a comment
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.
Per comment on the issue; without extension lookup i don’t think we should merge this.
Per the issue discussion, this PR doesn’t involve extension lookup. Even if extension lookup is added, this PR would still apply. |
| I disagree; with extension lookup, there's no need for an additional field at all, since the file extension would determine parsing goal (and a separate field to override parse goal per extension would continue to be useful). |
As was noted in that thread, a single field only works if the two files are side-by-side differing only in extension, e.g. |
| @GeoffreyBooth in that model, you'd transpile/copy two files, and have |
That’s a much bigger burden on developers, to have essentially two build pipelines. Also there are a lot of developers who will want to use About the only advantage
For all these reasons and a few I can’t think of at the moment, we judge |
| It's a fair point that even with extension lookup, we might still want a way to have an alternative "main". However, since deep imports are important as well, imo it's not really sufficient unless we can provide an alternative root directory for the package, ie, Re (Another alternative is to not use a Every build tool already implements node's searching algorithm - in practice this has proven to not be a hardship. Similarly, loaders would need to expose a way for build tools to tap into their resolution algorithm, otherwise they wouldn't work for build tools anyways (unrelated to extension searching). |
| @ljharb As you know, one of the goals of the import file specifier resolution proposal was to support ESM in The
I support a way to map extensions, whether via some new |
| I agree they shouldn't be required to use Your desire - to avoid using I'm going to continue blocking PRs that I don't think are a good fit - half measures are worse than none imo. For me, the goal of "let people not use |
| not entirely in the same context but this addresses the points of mjs because of course mjs has to keep coming up again and again :( please read this: nodejs/modules#253 (comment) i see absolutely no reason for node to encourage any file extension for new stmr files besides |
Since we both agree that users shouldn’t be required to use |
Refs: nodejs/modules#180 PR-URL: nodejs#6 Reviewed-By: Myles Borins <MylesBorins@google.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Refs: nodejs/modules#180 PR-URL: nodejs#6 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Refs: nodejs/modules#180 PR-URL: nodejs#6 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Refs: nodejs/modules#180 PR-URL: nodejs#6 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
PR-URL: nodejs#6 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
PR-URL: nodejs#6 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Myles Borins <mylesborins@google.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
a4955e2 to 7c92011 Compare 9301a06 to e721cd2 Compare 484d1fb to 7efc53d Compare c7fa700 to d69f765 Compare 335d584 to 9a343ce Compare 3a00b51 to bc101f6 Compare fd5b55a to 3a40599 Compare 6fe40a4 to d9cdfd8 Compare
This supports the package.json "exports" main to allow dual mode workflows, as described in nodejs/modules#273.
In addition some minor refinements around file extension handling are provided as well, specifically disabling support for
.nodeand.jsonmains in CommonJS packages when loaded from ESM.