Bootstrap: Add dependencies to package.json and bower.json

Created on 26 Aug 2015  路  19Comments  路  Source: twbs/bootstrap

In order to let people npm or bower install bootstrap, we should make sure that the package files are updated with the necessary dependencies.

I see two deps (could be that a missed one):

  • jQuery
  • tether

Once the package files are updated we should also remove jQuery and tether from the vendor dir and link to the bower or npm version in the tests.

In order to get completely rid of the vendor folder, we could also add qunit as a dev dependency to the package.json.

X-ref #17201

js meta v4

Most helpful comment

For those currently using bootstrap v4.0.0-alpha.2 through npm you could require Tether as a global instead of a module:

global.Tether = require('tether');

I know it's not perfect, but it's better than placing an empty function on a global Tether variable.

All 19 comments

jQuery is already listed as a dependency. Tether isn't though, and we should fix that.

we should also remove jQuery and tether from the vendor dir and link to the bower or npm version in the tests.

Meh. We don't currently use npm for client-side dependencies. And we definitely don't want to hook into Bower, since it kinda sucks and isn't too actively developed these days.

jQuery is already listed as a dependency. Tether isn't though, and we should fix that.

jQuery is indeed listed in the bower file, but it's still missing in the package file ... I only see jQuery listed under the jspm deps in the package file.

but it's still missing in the package file

Like I said:

We don't currently use npm for client-side dependencies.

@cvrebert If you list npm as one of the possible ways to install bootstrap (which you're doing in the v4 docs) you should make sure all deps can be resolved correctly, no?

Actually we already list npm in the v3 docs (since last year), and nobody seems to have complained about jQuery not being in package.json's dependencies until now...
I can't think of a particular reason not to include it though, so I guess I'm not opposed adding it.
CC: @twbs/team

Probably not a lot of people were using npm to install bootstrap since it wasn't exporting any useful js modules. With the js rewrite of v4 and combined with the rise of tools like browserify and webpack that may change ... Also, like you said I don't think it would do any harm if we add deps to the package file.

X-Ref: #17273

I'm :+1: on this one for the same reasons @vejersele listed.

Absolutely :+1: it would also be very useful to use Bootstrap's JS components with ECMAScript 6 import syntax, e.g.

import {Popover, Modal} from 'bootstrap'

and use them without even knowing they depend on jQuery or Tether.

:+1: for supporting the import syntax.

I am currently trying to include Collapse plugin only and despite being able to load the plugin itself, I have no idea how to satisfy it's requirement for jQuery (despite jQuery being imported right above it) in an ES6 (Babelified) project.

+1 Same issue here since alpha 2

Why is tether a dependency if the user doesn't plan on using tooltips? Will this be solved in the final release / compiled version?

I started doing the initial legwork on proper (/better) modularization (and dependency management) of the v4 Bootstrap modules today and should have an PR up for review / thoughts some time next week.

Meanwhile @reustle you could mock window.Tether with window.Tether = function (){} to get past the dependency.

@petetnt I imported the library so it is satisfied for now, I was more curious if the dependency was going to be required in the final release. It seems weird that Bootstrap would need a hard dependency on another library (besides jQuery), especially if it is for a feature you aren't using (tooltips).

@I just stumbled on another problem. The check of the Tether object being on the global window context (if (window.Tether === undefined)) will always fail if Tether is used within a module loader context.

Tethers distributed version uses the universal module approach (see https://github.com/HubSpot/tether/blob/master/dist/js/tether.js#L3), so there won't be any global if it detects a module environment.

It also seems as though other files may need to be changed. Even when jQuery and tether are installed via npm manually, util.js throws an error because it can't find jQuery in the global scope on line 169.

Fixed by #18575 & #19427.
Going to say that #19017 covers the module system problems.

For those currently using bootstrap v4.0.0-alpha.2 through npm you could require Tether as a global instead of a module:

global.Tether = require('tether');

I know it's not perfect, but it's better than placing an empty function on a global Tether variable.

The error persists using CDN version.
Not installing via npm or bower.

@hougasian You want #19017.

Was this page helpful?
0 / 5 - 0 ratings