Skip to content

Commit

Permalink
move package.json browser handling to npm repo
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Oct 16, 2014
1 parent b324e9d commit 5ce31e3
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,29 +286,6 @@ function derivePackageConfig(pjson, override) {
if (override)
extend(dpjson, override);

// if there is a "browser" object, convert it into map config for browserify support
if (typeof pjson.browser == 'object') {
dpjson.map = dpjson.map || {};
for (var b in pjson.browser) {
var mapping = pjson.browser[b];
if (typeof mapping != 'string')
continue;
if (b.substr(b.length - 3, 3) == '.js')
b = b.substr(0, b.length - 3);
if (mapping.substr(mapping.length - 3, 3) == '.js')
mapping = mapping.substr(0, mapping.length - 3);

// local maps not supported since this affects the external
// interface for all other modules
// only way to implement is through a module alias replacement
// may be worth considering at some point
if (b.substr(0, 2) == './')
continue;

dpjson.map[b] = dpjson.map[b] || mapping;
}
}

// finally set the derived package.json as the "jspm" property on the package.json
return dpjson;
}
Expand Down Expand Up @@ -456,6 +433,7 @@ exports.download = function(pkg, jspmPackages, options, preload) {

.then(function(fresh) {
// fire off preloading using early getPackageConfig hook if available
// NB this can run in parallel to download with Promise.all
if (endpoint.getPackageConfig)
// we only use the getPackageConfig pjson if
// we are going to run a build, otherwise we use the saved one
Expand Down Expand Up @@ -595,7 +573,7 @@ exports.createMain = function(pkg, pjson, downloadDir) {
// create the main entry point
.then(function() {
lastNamePart = pkg.name.split('/').pop().split(':').pop();
main = typeof pjson.browser == 'string' && pjson.browser || typeof pjson.main == 'string' && pjson.main;
main = typeof pjson.main == 'string' && pjson.main;

if (main) {
if (main.substr(0, 2) == './')
Expand Down

0 comments on commit 5ce31e3

Please sign in to comment.