jspm / npm

NPM Location Service
19 stars 34 forks source link

Browser map not applied to module replacements (jspm 0.17) #121

Closed adamburgess closed 8 years ago

adamburgess commented 8 years ago

(continued from https://github.com/jspm/jspm-cli/issues/1548)

Works on jspm 0.16, doesn't on 0.17.

test project: https://github.com/AdamBurgess/test-browser-config-jspm test npm package: npm:test-browser-config / https://github.com/AdamBurgess/test-browser-config

Basically, the npm package has a browser object like so:

"browser": {
  "./lib/node.js": "./lib/browser.js",
  "remapped-dep": "hello-world-classic"
}

The test project is not much more than npm init -y && npm install jspm@0.17.0-beta.7 && jspm init -y && jspm install npm:test-browser-config, and then a file src/main.js which imports that npm module.

In 0.16, to my knowledge requiring remapped-dep would be hard-changed in files to hello-world-classic, which worked (but wasn't ideal, I presume) In 0.17, nothing is remapped. Importing the package fails in browser as it cannot find remapped-dep.

Removing the second part of the if-statement at https://github.com/jspm/npm/blob/4cf97a6e07aa9066fe7c73fb6116bd24fa6a484d/lib/node-conversion.js#L134-L138 fixes the problem. The comment mentions https://github.com/systemjs/systemjs/issues/937 - as this is now marked as fixed, is it okay to remove those lines?