angular-ui / bootstrap-bower

This is a bower repository to hold Angular UI Bootstrap releases.
http://angular-ui.github.com/bootstrap/
158 stars 326 forks source link

package.json's main array breaks debowerify #52

Closed doxxx closed 9 years ago

doxxx commented 9 years ago

After installing using npm install angular-ui-bootstrap, gulp debowerify chokes on the package.json's main value:

path.js:146
      throw new TypeError('Arguments to path.resolve must be strings');
      ^
TypeError: Arguments to path.resolve must be strings
    at Object.win32.resolve (path.js:146:13)
    at c:\dev\ffxiv-craft-opt-web\node_modules\browserify\node_modules\browser-resolve\node_modules\resolve\lib\async.js:151:37
    at fs.js:334:14
    at c:\dev\ffxiv-craft-opt-web\node_modules\debowerify\node_modules\bower\node_modules\bower-json\node_modules\graceful-fs\graceful-fs.js:104:5
    at c:\dev\ffxiv-craft-opt-web\node_modules\debowerify\node_modules\bower\node_modules\bower-registry-client\node_modules\graceful-fs\graceful-fs.js:104:5
    at c:\dev\ffxiv-craft-opt-web\node_modules\debowerify\node_modules\bower\node_modules\bower-config\node_modules\graceful-fs\graceful-fs.js:104:5
    at c:\dev\ffxiv-craft-opt-web\node_modules\watchify\node_modules\chokidar\node_modules\readdirp\node_modules\graceful-fs\graceful-fs.js:104:5
    at FSReqWrap.oncomplete (fs.js:95:15)

If I manually change the installed package.json's value from a list to a string, debowerify is happy again.

pskaarup commented 9 years ago

I can confirm this is a issue. The simple fix is to change

"main": ["./ui-bootstrap-tpls.js"],

to:

"main": "./ui-bootstrap-tpls.js",

I don't know if this will have issues with other builders but fixes issues with browserify/browserify-shim/debowerify

rvanbaalen commented 9 years ago

As far as I know an array is a perfectly valid value for the main property. Seems like an issue woth debowerify.

pskaarup commented 9 years ago

https://docs.npmjs.com/files/package.json has following to say on the main field

main

The main field is a module ID that is the primary entry point to your program. That is, if your package is named foo, and a user installs it, and then does require("foo"), then your main module's exports object will be returned.

This should be a module ID relative to the root of your package folder.

For most modules, it makes the most sense to have a main script and often not much else.

Refers to ID as a relative path.

pskaarup commented 9 years ago

Sorry to keep posting but i did look it up a few places. https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json says

A string representing the name of a program module that is located in one of the top-level module directories specified by lib. Defaults to "main".

and http://browsenpm.org/package.json uses string as value for main

rvanbaalen commented 9 years ago

It's nice that you're comparing all sorts of tools, assuming that they all do the same based on the fact that they have a corresponding filename, package.json.

This is a bower repository which has a bower package.json and following the bower documentation, it's perfectly fine to have an array as a value for main:

http://bower.io/docs/creating-packages/

main string or array: The primary acting files necessary to use your package.

pskaarup commented 9 years ago

If it isn't a npm module, don't distribute it over npm. angular-bootstrap-npm works with browserify etc.

rvanbaalen commented 9 years ago

We didn't distribute to npm. Someone else did.