browserify / factor-bundle

factor browser-pack bundles into common shared bundles
Other
402 stars 27 forks source link

Handling the "nothing in common" case #42

Closed ghostwords closed 9 years ago

ghostwords commented 9 years ago

Should factor-bundle return null / not write out anything when there is nothing in common? It currently seems to return an empty bundle (when used as a plugin at least):

(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})({},{},[]);
terinjokes commented 9 years ago

I think it's better to write out something than to have missing file.

ghostwords commented 9 years ago

To provide some background, I have a number of source directories, each of which contains one or more entry files. I am programmatically factoring out shared modules on a per-directory basis, without knowing which directories have shared modules and which do not. It feels off to have empty common bundles hang around.

ghostwords commented 9 years ago

Here is my WIP build tool, if you'd like to see: https://github.com/ghostwords/chameleon/blob/3eaa2e70e0ca746ab421a199680bca873e5cc11e/tools/build.js

By the way, I just discovered that factor-bundle doesn't yet work with watchify, which is a real showstopper ...

jgoz commented 9 years ago

I think it's better to write out something than to have missing file.

Agreed. Writing an empty file out makes the bundling process predictable, which means you can reliably put a script tag into a page for that bundle without worrying about 404s.