linkleonard
linkleonard

Reputation: 93

Extracting vendor libraries from factor-bundle

I am creating a semi-automatic build pipeline for my application using npm, Gulp, and browserify. This is what I'm trying to accomplish:

I'm having trouble combining browserify and browserify-shim for my application. In my webpage, I include vendor.js, common.js, and page1.js. When I try to load the page and my script is trying to require('bootstrap'), an exception is thrown here:

// Part of bootstrap.js
if (typeof jQuery === 'undefined') {
  throw new Error('Bootstrap\'s JavaScript requires jQuery')
}

I expect to have to tell browserify-shim that bootstrap depends on jquery, that it expects jquery's export to be bound to the jQuery variable. I attempted to do this in my package.json.

I'm having trouble pinpointing exactly what is going wrong. I've tried various permutations of values to go into bootstrap's shim (jquery:jQuery, jquery:$, jquery) to no avail. I've also tried including and omitting various values in the browser path. I also tried building the vendor bundle via the command line using: ./node_modules/.bin/browserify -r jquery -r bootstrap > vendor.js, but the same error comes up on the browser. A lot of questions have been asked about browserify-shim and factor-bundle, but none of them address anyone trying to combine the two.

I have created a repository that demonstrates the issue here. Steps to install and reproduce are in the README. https://github.com/linkleonard/browserify-shim-factor-bundle

Upvotes: 1

Views: 139

Answers (0)

Related Questions