A better way to expose `jQuery`, `Tether`, and more on Meteor 1.3 global?

Right now I use bootstrap 4 and jQuery from npm modules.

bootstrap 4 need Tether already defined on global namespace.
This steps for Tether and bootstrap aren´t enough:

npm install tether
npm install bootstrap@4.0.0-alpha.2
...
import Tether from 'tether`;
import 'bootstrap';
...

Still throught a boostrap error: https://github.com/twbs/bootstrap/issues/19005#issuecomment-193182379

I solved creating a meteor 1.3 only package named globals:

package.js

Package.describe({
  summary: 'Per project globals',
  version: '1.0.0'
});

Package.onUse(function(api) {
  api.versionsFrom('1.2.1');
  api.use('ecmascript');
  api.mainModule('index.js', 'client');
});

index.js

import jQuery from 'jquery';
import Tether from 'tether';

global.jQuery = global.$ = global.jquery = jQuery;
global.Tether = Tether;

Is a best or recommended way to do this???

1 Like

How about this article?

I’m using angular2-meteor, which might change things. However, I got bootstrap and tether working together by putting the following in client\compatibility\bootstrap.js:

Tether = require('tether'); require('bootstrap');

Interesting so the way to add globals is to avoid import/export syntax and use require, great I’ve just created a package because I wasn’t sure how to do that.

Edit: you could also do this seems to work great
import StarRating from '../../ui/components/star-rating/star-rating.jsx';
window.StarRating = StarRating;