-
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
Prioritize index.js before module.js #5
Comments
Yeah, we were hesitated to add that note there. It is true that we might not be able to do so. Initial analysis of existing npm pkgs suggested the following:
Other alternatives were:
Ultimate, we will have to make a decision on this. If the decision is that |
In my opinion, making the module field required is the best option, as
ideally that field should be defined in every module anyways.
|
I agree with you. And in fact part of the stats that we have gather, is aligned with your thoughts, considering that 85% of those 116k "latest packages" analyzed, have an explicit |
In that case, you may want to at least for now remove that part of the
proposal so it does not give a bad first impression. It can always be added
back later.
|
Or better yet because it is a good idea to make writing packages easier and would impact only ~100 packages, you could mark it as optional and state concerns about it rather than just delete it. |
Yeah I think this is the best course of action without reading the files. It will also kind of "force" package maintainers who want to distribute ES2015 code to actually pay attention to their |
The defined behavior of using
module.js
as a stand-in for amodule
field inpackage.json
is problematic. Consider the following case:main
ormodule
field defined inpackage.json
index.js
module.js
require
orimport
is run on this moduleAccording to your resolution rules, as I understand them, Node would attempt to parse this module as a standard ES module. However, if this module is indeed not coded with the standard ES module syntax, this
require
will fail.That is backwards-incompatible behavior. I suggest that
module.js
is only interpreted as amodule
field inpackage.json
if:main
field is undefinedmodule
field in undefinedindex.js
file exists in the root directory of the packageThe text was updated successfully, but these errors were encountered: