Bauer Override Dependency

I have an application written in Backbone with Marionette and some other dependencies, managed with a gazebo :

{ "name": "admin", "version": "0.1.1", "main": "public/javascripts/app.js", "dependencies": { "lodash": "~2.4.1", "console-polyfill": "~0.1.0", "jquery": "~2.1.1", "normalize-css": "~2.1.2", "marionette": "~1.7.4", "bootstrap": "~3.1.1", "font-awesome": "~4.1.0", "backbone-pageable": "~1.4.5", "moment": "~2.5.1", "swag": "~0.6.1", "jquery-form": "~3.46.0", "jquery-file-upload": "~9.5.7", "underscore.string": "~2.3.3", "bootstrap-switch": "~3.0.1", "joint": "~0.9.0" }, "overrides": { "backbone": { "dependencies": { "lodash": "*", "jquery": "*" }, "main": "backbone.js" }, "backbone.wreqr": { "dependencies": { "backbone": "*" }, "main": "lib/amd/backbone.wreqr.js" }, "backbone-pageable": { "dependencies": { "backbone": "*" }, "main": "lib/backbone-pageable.js" }, "jquery-file-upload": { "dependencies": { "jquery": "*" }, "main": [ "js/vendor/jquery.ui.widget.js", "js/jquery.iframe-transport.js", "js/jquery.fileupload.js" ] }, "underscore.string": { "dependencies": { "lodash": "*" }, "main": "lib/underscore.string.js" }, "joint": { "dependencies": { "lodash": "*" }, "main": "dist/joint.clean.js" } }, "resolutions": { "jquery": "~2.1.1" } } 

I want to add Joint.js ( http://www.jointjs.com/ ), which depends on lodash (a replacement underscore ), but I cannot figure out how to replace this in my configuration, since Marionette, Backbone and some others libraries are directly dependent on underscore. Thus, underlining the load overrides lodash, and the application cannot start correctly.

+6
source share
1 answer

I changed the order and put lodash as the last dependency, and it worked.

Also, as a solution, it is possible to have a bell hook, as indicated in the following answer fooobar.com/questions/122250 / ...

We had a similar situation where we had a basic Underscore dependency in bower.json , but instead we used Lo-Dash, so Bower unnecessarily pulled Underscore for each installation. We have automatic checks of conformity of third-party licenses, therefore we did not want that we actually do not use.

I understand that this is not quite what they are intended for, but Bower's installation hooks can be used to clean up unnecessary fingerprints after installation (at least until Bower gets the kind of "thank you" solution that you hinted at). In your .bowerrc :

 { "directory": "app/bower_components", "scripts": { "postinstall": "rm -rf app/bower_components/underscore" } } 

This is a little hack, but it works.

+4
source

Source: https://habr.com/ru/post/970868/


All Articles