thlorenz / browserify-shim

📩 Makes CommonJS incompatible files browserifyable.
MIT License
933 stars 87 forks source link

Browserify's require, browser aliases, and browserify-shim do not mix. #130

Closed sandinmyjoints closed 9 years ago

sandinmyjoints commented 9 years ago

Minimal repro: https://github.com/sandinmyjoints/browserify-shim-repro

npm run bundle:norequire works. npm run bundle:require does not, but it'd be awesome if it did. Is it possible?

sandinmyjoints commented 9 years ago

Possibly related to https://github.com/thlorenz/browserify-shim/issues/121.

webgefrickel commented 9 years ago

I can confirm this issue. I just tried to split up a large bundle into two files, vendor.js (3rd-party-stuff) and main.js (custom stuff), trying to use the commands:

browserify -r 3rdparty-nonshimmed -r 3rdparty-shimmed vendor.js -o vendor.pack.js
browserify -x 3rdparty-nonshimmed -x 3rdparty-shimmed main.js -o main.pack.js

vendor.js being an empty file, and main.js with sth. like:

var lib = require('3rdparty-nonshimmed'); 
var shimlib = require('3rdparty-shimmed');

console.log(lib, shimlib);

I get the same error as in @sandinmyjoints provided repo:

Error: Cannot find module '3rdparty-shimmed' from '...'

I tried with -t browserify-shim as well, even though this should be handled through the package.json config, no help as well.

bendrucker commented 9 years ago

There's too much going on in #121 for me to parse. But this is the exact same issue as #152. I looked pretty thoroughly into that this morning and confirmed that b-shim isn't being called in that scenario.