-
Notifications
You must be signed in to change notification settings - Fork 12
get rid of package.json
"main" field lookup in module loader
#16
Comments
👍 "main": "<lib-name>.js" examples:
Also, just by looking at some other popular libraries on cdnjs, there are many others too which use this pattern for specifying the entry point. |
What if a module has multiple entry point files, like node.js and
|
yuk, all of my projects have a |
@rvagg exactly. I've something similar. Also, for all my modules in a package, I just proxy things in index.js. Too many
If possible, does it make sense to have imports that require the file with its name same as the directory name (maybe fallback to index.js or index.js overrides this - either way it should be fine)? But this might further increase that extra disk read mentioned at the top. |
I see index.js somewhat similar to init.py in python... |
Related to ES6 modules, #5, and following a lengthy discussion in npm/npm#8222. Obviously, I'm not talking about
require()
here, changing it would be insane. But since ES6 module loader would be completely different, we might as well consider to get rid of that. That's why:package.json
doesn't make sense anymore with ES6 modules, because it's a CommonJS name.config
(.config/package.json npm/npm#8159), and this implicit dependency in all loaders only makes it harderInstead of this, I suggest everyone to just use
/index.js
in ES6 modules. Maybe use/lib/index.js
as a fallback (since most of the packages define"main": "lib/index.js"
anyway, but I'm not sure if it's worth it.The text was updated successfully, but these errors were encountered: