Closed ccoenen closed 8 years ago
this is what i came up with:
// Brocfile.js
var packagejson = require('./package.json');
var thirdPartyNPMLibs = Object.keys(packagejson.dependencies); // awesome: just put it in package.json, and it's there :)
appJs = fastBrowserify(appJs, {
browserify: {
debug: true
},
bundles: {
'app.js': {
entryPoints: ['app.js'],
externals: thirdPartyNPMLibs // <-- these will not be in app.js
},
'npm.js': {
entryPoints: [],
require: thirdPartyNPMLibs // <-- instead, they will be in npm.js, a file with no entryPoint :)
}
}
});
that last one is now separated in two distinct calls to fastBrowserify(), and one gets a WatchedDir and the other an UnwatchedDir - i'm happy.
This would be a nice wiki entry as I'm sure it's something that other people will want to do.
@ccoenen I created a wiki entry for this:
https://github.com/caleb/broccoli-fast-browserify/wiki/Separate-app-and-3rd-party-bundles
Do you think that looks good?
It looks almost like mine! Thank you!
Disclaimer: this may be an odd setup. I am not offended if you don't find the time debugging my quirky setup. In that case: please feel free to close this issue on sight ;-)
I would like to have two output files. One should contain all the 3rd party libs from NPM and one should contain my "personal" code. My index.html file contains two script tags, one for npm.js and one for app.js.
Right now, i process a
npm.browserify
file through broccoli-fast-browserify (bfb from now on). And i process my own code through a combination of other thins but not through bfb. I made this work by exposing therequire
function to the window scope.The downside is, that i have to manually require all my libs in the npm.browserify by hand, so that they can be picked up. I would love to make this setup work "right". Especially because the manual dual-require is error-prone. Also, the
window.require = require
doesn't feel "right".