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

Add "main" to package.json for easier import #16

Closed
raffazizzi opened this issue Feb 13, 2016 · 4 comments
Closed

Add "main" to package.json for easier import #16

raffazizzi opened this issue Feb 13, 2016 · 4 comments

Comments

@raffazizzi
Copy link

Many JS packaging systems look for "main" in package.json to import modules. This makes it possible to just import 'jquery-xpath' instead of using the full path to the JS file.

Would it be possible to add it? The following should be sufficient.

{ "main" : "jquery.xpath.js" }
@ilinsky
Copy link
Owner

ilinsky commented Feb 23, 2016

How do you mean "to just import"? Do you plan to use the library in NodeJS environment?

@raffazizzi
Copy link
Author

I am developing in a NodeJS environment and using browserify.

To import the module now I do:

require('node_modules/jquery-xpath/jquery.xpath');

while I think with sufficient information in package.json, I should just be able to use the package name like I do for other deps:

require('jquery-xpath');

@raffazizzi
Copy link
Author

To clarify, the second way of requiring the library is not just shorter, but it means that in case you update the location of your jquery.xpath.js in your package, my code won't break as long as the new location is reflected in your package.json

@ajmacdonald
Copy link

@ilinsky FYI the version on npmjs hasn't been updated to include the "main" entry

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

No branches or pull requests

3 participants