componentjs / component

frontend package manager and build tool for modular web applications
https://github.com/componentjs/guide
MIT License
4.55k stars 305 forks source link

support npm and component not working with try block #570

Closed bodokaiser closed 10 years ago

bodokaiser commented 10 years ago

To support component and browserify/npm I wanted to do:

try {
  // for component
  var emitter = require('emitter');
  var domify  = require('domify');
} catch(e) {
 // for npm/browserify
  var emitter = require('component-emitter');
  var domify = require('component-domify');
}

Unfortunately this crashes the build process. I say crashes because I not even get an error. The error is undefined.

jonathanong commented 10 years ago

for this particular case, you can just do

var emitter = require('component-emitter')
var domify = require('domify')

but generally, you should try/catch one at a time

bodokaiser commented 10 years ago

Both solutions worked out. Thank you!

What is the actual reason why it is not possible to use one try/catch for everything? Also why do you suggest to use try/catch over using <usernam>-<package> all the time?

timaschew commented 10 years ago

for me the is-browser npm & component module is a nice solution: https://github.com/ForbesLindesay/is-browser

Here you can find some other solutions: https://github.com/component/component/wiki/Component-and-npm

bodokaiser commented 10 years ago

Ah okay. So I will use the full names and when not possible the 'module.component' test.

Am 21.05.2014 um 10:35 schrieb Anton Wilhelm notifications@github.com:

for me the is-browser npm & component module is a nice solution: https://github.com/ForbesLindesay/is-browser

Here you can find some other solutions: https://github.com/component/component/wiki/Component-and-npm

— Reply to this email directly or view it on GitHub.

timaschew commented 10 years ago

the full name trick only works if the module is published to the npm registry with this style <user>-<name> that's the reason why @jonathanong said:

for this particular case

bodokaiser commented 10 years ago

Yeah but it will work also when the package has the same name like as the component (the case with superagent).

Am 21.05.2014 um 11:03 schrieb Anton Wilhelm notifications@github.com:

the full name trick only works if the module is pushed to the npm registry with this style -

— Reply to this email directly or view it on GitHub.