The newest version (3.1.0) broke some of my dependencies.
For example, I bundle video.js which is built with grunt-browserify. The first line of their dist/video.js has a umd wrapper around browserify's browser-pack prelude:
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.videojs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
There are two problematic lines in the browser-pack prelude:
var a=typeof require=="function"&&require;
var i=typeof require=="function"&&require;
Version 3.1.0 of this plugin transforms these lines into:
var a='function'=="function"&&require;
var i='function'=="function"&&require;
This breaks the code at run time inside a browser with strict mode enabled, since there's no global require function.
For now, I've pinned my version of rollup-plugin-commonjs to =3.0.2, so that my builds keep working.
I have not yet found the time to set up a full reproduction case, but this is the general idea:
- Create
foo.js and bundle it with browserify. (In practice, we'd get the bundled foo.js from an npm dependency.)
- Create
bar.js that imports from the built foo.js and bundle it with rollup.
- Load
bar.js inside a browser.
The newest version (3.1.0) broke some of my dependencies.
For example, I bundle video.js which is built with
grunt-browserify. The first line of theirdist/video.jshas aumdwrapper around browserify'sbrowser-packprelude:There are two problematic lines in the
browser-packprelude:var a=typeof require=="function"&&require;var i=typeof require=="function"&&require;Version 3.1.0 of this plugin transforms these lines into:
var a='function'=="function"&&require;var i='function'=="function"&&require;This breaks the code at run time inside a browser with strict mode enabled, since there's no global
requirefunction.For now, I've pinned my version of
rollup-plugin-commonjsto=3.0.2, so that my builds keep working.I have not yet found the time to set up a full reproduction case, but this is the general idea:
foo.jsand bundle it with browserify. (In practice, we'd get the bundledfoo.jsfrom an npm dependency.)bar.jsthatimports from the builtfoo.jsand bundle it with rollup.bar.jsinside a browser.