4 ms·
I use browserify and I'm happy with it, but I have one question that perhaps someone can answer : how can I develop a library with different modules, say lib/m
by oulipo 12y ago
I use browserify and I'm happy with it, but I have one question that perhaps someone can answer :
how can I develop a library with different modules, say lib/module/func, lib/module/other, and compile the library as static, then import it in another project and be able to require lib/module/other from the other project using only the compiled lib?
- ghostwords 12y agoI believe you are looking for https://github.com/substack/node-browserify#external-requires https://github.com/substack/node-browserify#external-require... and/or https://github.com/substack/node-browserify#multiple-bundles https://github.com/substack/node-browserify#multiple-bundles
- mattdesl 12y agoWhy compile the module? Browserify lets you use a module's CommonJS export, so the only build step is at the application level. Utils etc should not be built except for non-node users (umd).
- oulipo 12y agoIt would allow to distribute and package the library simply, rather than having to checkout the library in the other projects dir and have weird require(../../lib/module/other)
- mattdesl 12y agoWe must be doing different things. If I start getting relative paths like that, I usually pull it out into a separate module. I can understand bundling a bunch of modules together for UMD builds, but if you need to bundle all of your NPM/browserifiable modules for other browserify apps, you are probably going about it the wrong way..
- lobster_johnson 12y agoJust package the library as an NPM module -- that's the reason why Browserify exists, after all -- then reference it in the other project's package.json file. If it's private (not open source), you can still reference it via Git or a private NPM repository.