Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking .bower.json first breaks certain dependencies #40

Closed
tastycode opened this issue Mar 12, 2014 · 2 comments
Closed

Checking .bower.json first breaks certain dependencies #40

tastycode opened this issue Mar 12, 2014 · 2 comments

Comments

@tastycode
Copy link

Trying to get chjj/marked installed with grunt bower-install. I forked it and renamed component.json to bower.json thinking this would fix the error "marked was not injected into your file".

Traced the problem into wiredep, and bower.

Bower writes a package metadata file into .bower.json which doesn't seem to have the "main" attribute that is necessary for wiredep to find the file to inject. (https://github.com/bower/bower/blob/b64d8bfab32b1c7112ce024879b0b7f072c5f80b/lib/core/resolvers/Resolver.js)

After running bower install, here are the two files.

.bower.json

{
  "name": "marked",
  "homepage": "https://github.com/chjj/marked",
  "version": "0.3.2",
  "_release": "0.3.2",
  "_resolution": {
    "type": "version",
    "tag": "v0.3.2",
    "commit": "43db549e31af5ff6e4a3b12e41a23513b9f88c99"
  },
  "_source": "git://github.com/chjj/marked.git",
  "_target": "~0.3.1",
  "_originalSource": "marked"
}

bower.json

{
  "name": "marked",
  "version": "0.3.2",
  "repo": "chjj/marked",
  "description": "A markdown parser built for speed",
  "keywords": ["markdown", "markup", "html"],
  "scripts": ["lib/marked.js"],
  "main": "lib/marked.js",
  "license": "MIT"
}

Because wiredep looks at .bower.json first
https://github.com/stephenplusplus/wiredep/blob/master/lib/detect-dependencies.js#L28

 ['.bower.json',
    'bower.json',
    'component.json',
    'package.json'].forEach(function (configFile) {
    configFile = path.join(config.get('bower-directory'), component, configFile);

    if (!_.isObject(componentConfigFile) && fs.existsSync(configFile)) {
      componentConfigFile = JSON.parse(fs.readFileSync(configFile));
    }

No main is found, and the package doesn't get injected. Switching the position of those two would be easier than tracking down the problem within bower. Why does wiredep look at .bower.json first?

@stephenplusplus
Copy link
Member

Thanks for reporting. .bower.json is preferred first, since it should contain the most data it can find from a Bower package. I've never heard of it failing to include some of the properties, such as main. This sounds like a bug in Bower, but regardless, maybe wiredep shouldn't rely on the .bower.json file. Feel free to send a PR to remove '.bower.json' from the array, otherwise I'll try to get to it soon.

@stephenplusplus
Copy link
Member

Released as 1.3.1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants