Excluding a vendor bundle is also excluding a dependency

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Excluding a vendor bundle is also excluding a dependency

arnaldop
I have the following lines in dandelion.properties:

bundle.includes=jquery,jqueryui,bootstrap-3.2.0
bundle.excludes=bootstrap3

My reason for this is that I want to use Bootstrap 3.2.0 (my own bundle) instead of Bootstrap 3.0.3 (vendor bundle).

I noticed that the above lines are causing both bootstrap3 and jquery to be excluded.

Additionally I tried to add jquery as a dependency to another bundle like this:

{
    "bundle" : "export-dropdown",
    "dependencies" : [ "jquery" ],
    "assets": [
        {
            "name": "export-dropdown",
            "version": "1.0",
            "type": "js",
            "locations": {
                "cdn": "/js/export-dropdown.js"
            }
        }
    ]
}

I also tried adding the jquery files manually to the bundle instead of using the dependencies option.

How can I use my own version of Bootstrap 3 and still have jQuery in my application?

Code available at https://github.com/arnaldop/enhanced-pet-clinic.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Excluding a vendor bundle is also excluding a dependency

Thibault Duchateau
Administrator
This post was updated on .
Hi,

I would advise to override the existing "bootstrap3" bundle as follows.

Place a new your-custom-bootstrap3-bundle.json file under src/main/resources/dandelion:
{
    "bundle" : "your-custom-bootstrap3-bundle",
    "dependencies" : [ "jquery" ],
    "assets": [
		{
		    "name": "bootstrap3",
		    "version": "3.2.0",
		    "type": "js",
		    "locations": {
		        "cdn": "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.js"
		    }
		},       
        {
            "name": "bootstrap3",
            "version": "3.2.0",
            "type": "css",
            "locations": {
                "cdn": "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css"
            }
        }
    ]
}

Indeed, if you exclude a bundle before overriding it, you will exclude its dependencies as well. Maybe this mechanism needs to be update, I need to think about it...

Note that the name of the bundle doesn't matter but both asset names and types do. Today, that is how you can properly override bundles.

As a consequence, your dandelion.properties file would look like this:
bundle.includes=jquery,jqueryui,your-custom-bootstrap3-bundle

Regards,
Thibault.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Excluding a vendor bundle is also excluding a dependency

arnaldop
My vote would be for only the specific bundle to be excluded, not its dependencies.

In my case, excluding bootstrap caused the jquery dependency to be excluded also, even though I included the jquery-ui bundle which has jquery as a dependency.

If I wanted to exclude the dependency also, I'd have to specify that explicitly.

Symbolically:

A -- depends on --> B <-- depends on -- C

So if I include A and B and exclude C, why should A lose their common B dependency?

Anyway, that's my vote based only on my scenario, and it could be missing other use cases.

Thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Excluding a vendor bundle is also excluding a dependency

Thibault Duchateau
Administrator
Hi,

It seems logical to me too.
Thanks for your feedback!

Much work certainly remains to be done! :-)

Regards,
Thibault.
Loading...