arian / partition-bundle

A browserify plugin to partition your modules in different bundles
114 stars 18 forks source link

`loadjs` call required for entry to execute? #16

Closed mAAdhaTTah closed 8 years ago

mAAdhaTTah commented 8 years ago

I'm generating my entry file with gulp using the browserify api:

var gulp = require('gulp');
var browserify = require('browserify');
var gutil = require('gulp-util');

gulp.task('default', ['scripts']);

gulp.task('scripts', function () {
    return browserify({debug: false})
        .plugin('partition-bundle', {
            'map': {
                'app.js': ['./js/app.js']
            },
            'output': './build/js/',
            'url': 'url/to/build/js'
        })
        .bundle()
        .on('error', gutil.log);
});

However, if I include the file directly:

<script src="url/to/build/js/app.js"></script>

app.js doesn't execute. It appears to just be defined. If I include a loadjs call directly after:

<script>
    loadjs(['./js/app.js']);
</script>

then it executes. Based on the documentation, this isn't expected behavior. Am I doing something wrong or is there an issue here?

arian commented 8 years ago

You're right it's not entirely clear from the readme.

You can pass a main option that will automatically do the loadjs(['./foobar']) for you.

For example

gulp.task('scripts', function () {
    return browserify({debug: false})
        .plugin('partition-bundle', {
            'map': {
                'app.js': ['./js/app']
            },
            'main': './js/app', // <-- this
            'output': './build/js/',
            'url': 'url/to/build/js'
        })
        .bundle()
        .on('error', gutil.log);
});