Closed jedierikb closed 8 years ago
moreover, it does not look like libraries' bower.json main:['this.js', 'that.js']
are being honored?
@jedierikb can you refer to #7, and tell me whether it resolved your problem?
p.s. in fact, browserify-bower
already supported mainfile array, you can check related codes here.
When I try to load in a bower.json file with an array for main, it only loads in the first file. Regarding the code you linked to, if I test it like so:
['file_one.js', 'file_two.js'].filter(function(file) { return /\.js$/.test(file); })[0]
the function only returns file_one.js. I expected it to concatenate the files?
For example, I would like to be able to get all of the .js files from this project's main: https://github.com/amsul/pickadate.js/blob/master/bower.json or, using your tool, pick and choose which .js files I would like to include.
Apologies if I am missing something or doing something wrong and this is already supported or should be done differently.
It only support one main file now, that I thought it should be. I'll try to enhance it ASAP.
Well, it seems leading to some related problem when I tried to support multiple main files. I need more time to resolve it.
@jedierikb well, I gave up to support multiple mainfile directly.
Bower spec requires Only one file per filetype
, so it's difficult to get a consistent behavior for multiple files per filetype.
To reference another file instead of the first one in the main, you can turn to specify it like comp_name/sub_dir/sub_name
in your conf, which I called submodule
and was already supported.
How do I pass in & specify the conf / submodule? Could you provide an example of how to do this? Sorry, I cannot figure it out. Thanks.
In fact, you can find it in the README:
b.plugin('browserify-bower', {
require: ['*', 'base62/lib/base62', 'base62/xxx:xxx'],
external: {
exclude: ['comp1', 'comp2']
},
alias: ['base62/lib/base62:base62'], // or alias: { 'base62/lib/base62':'base62', ... }
mainfiles: { // specify the main file for packages without a bower.json
'base62': 'main.js'
}
});
here, base62
is an alias for submodule base62/lib/base62
, and we specified a manifile main.js
for it.
pls try it, and any problem pls let me know.
works. makes sense. much thanks.
You're welcome. ;-)
According to bower spec, mainfiles can include multiple files https://github.com/bower/spec/blob/master/json.md#main http://stackoverflow.com/questions/20391742/what-is-the-main-file-property-when-doing-bower-init
However, with your utility we cannot provide a list of mainfiles for a library. This is problematic when libraries needed require developers to pick and choose a few different files.