browserify / factor-bundle

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

Support -r/.require(...) #18

Closed andreypopp closed 9 years ago

AndrewIngram commented 10 years ago

I'm assuming this ticket means you want to be able to require('your-entry-point') in your page's JavaScript? I have the same need.

My entry point scripts tend to expose a single init function that takes in parameters from the rendered html, ie I do this at the bottom of my document:

<script>
    $(function() {
        var config = {foo: 'bar'};
        var init = require('my/module/name');
        init(config);
    });
</script>

If I'm weren't using factor-bundle, I'd simply use bundle.require(moduleSourcePath, {expose: 'my/module/name'}); for each entry point in my project. But I can't figure out a way to get the same results using factor-bundle.

terinjokes commented 10 years ago

We do b.require(moduleSourcePath, {expose: 'my/module/name', entry: true}) and require like normal.