Skip to content

Add hint key in package.json to detemine what file to load in browser #2047

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

Merged
merged 1 commit into from
Oct 22, 2016

Conversation

nazar-pc
Copy link
Contributor

In my framework I have a convenient feature that allows to automatically call AMD modules with RequireJS by their name. For instance, after redux installation I'm supposed to be able to do require(['redux'], ...) anywhere in my app and it should just work.

In order for above feature to work I'm using different keys from both bower.json and package.json in order to determine which file should be used by RequireJS to map package name alias there.

With Redux correct path is dist/redux.js (minified version can be inferred from here), but there is no single key with this value in current package.json. Existing keys are pointing to files that either doesn't work in any browser except recent Safari (ES2015 modules) or CommonJS-compatible file.

There was a key browser in jQuery's package.json in past, so I decided that this is a good candidate to use.

I'm currently checking following keys (based on package.json files of other popular projects) with priority from higher to lower:

  • browser
  • jspm.main
  • main

@timdorr
Copy link
Member

timdorr commented Oct 22, 2016

Sure, shouldn't hurt. Thanks!

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.

2 participants