Add hint key in package.json to detemine what file to load in browser #2047
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 dorequire(['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
andpackage.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 currentpackage.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'spackage.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: