Open callumacrae opened 8 years ago
factor-bundle is currently optimized for splitting out the common files from the rest of a bundle. Your use case isn't wrong, but I'll need to think a bit about how to support it.
Awesome :tada:
Let me know if there's anything I can do to help :)
Hey!
I effectively want to split out part of a file, instead of splitting out the common parts of two files.
Currently I have bundle.js, which contains everything used on the site. There is some checkout specific logic there that I only want on the checkout, so I want to split that stuff out into bundle-checkout.js, but then run both bundle.js and bundle-checkout.js in the checkout.
With factor-bundle by default, I would be running these files on the main site:
And these on the checkout:
It's pointless for me to have both bundle-common.js and bundle.js!
The best solution I've found so far is to add
require('./main')
to the top of the inputbundle-checkout.js
, which would mean thatbundle.js
is effectively an empty file and I can includebundle-common.js
by itself, but then that generates a junk file.lib.js:
main.js:
checkout.js:
And then the command:
Is there any way to do this without the
require('./main')
and the uselessjunk.js
file?Thanks, and sorry for the long question! I'll turn this into an article once it's been figured out so that nobody asks it again :)