0.1.0 • Published 7 years ago

system-smart v0.1.0

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

system-smart

Smart bundle genrator for systemjs/builder

Use

Generate smart bundles

    var Builder = require('systemjs-builder');
    require('system-smart');

    var builder = new Builder(/* ... */);

    builder
        .smart(['entrypoint-a.js', 'entrypoint-b.js' /* , 'other entrypoints'*/], './dist')
        .then(result => {
            // result =
            [
                { // entrypoint-a.js
                    hash: '[SHA1]', // content hash
                    name: '[SHA1].bundle.js', // output filename
                    path: '/path/to/dist/[SHA1].bundle.js', // output dest
                    source: '...',
                    sourceMap: '...',
                    modules: [ 'entrypoint-a.js', /* depencies */ ]
                },
                { // entrypoint-b.js
                    hash: '[SHA1]', // content hash
                    name: '[SHA1].bundle.js', // output filename
                    path: '/path/to/dist/[SHA1].bundle.js', // output dest
                    source: '...',
                    sourceMap: '...',
                    modules: [ 'entrypoint-b.js', /* depencies */ ]
                },
                { // Smart bundles
                    hash: '[SHA1]', // content hash
                    name: '[SHA1].bundle.js', // output filename
                    path: '/path/to/dist/[SHA1].bundle.js', // output dest
                    source: '...',
                    sourceMap: '...',
                    modules: [ /* commond depencies */ ]
                },
                // More smart bundles
            ]
        })

Add bundles to systemjs configuration

    javascript
    SystemJS.config({
        bundles: {
            'dist/[SHA1].bundle.js': [ 'entrypoint-a.js', /* depencies */ ],
            'dist/[SHA1].bundle.js': [ 'entrypoint-b.js', /* depencies */ ],
            'dist/[SHA1].bundle.js': [ /* commond depencies */ ],
            // [outputDir + result.name]: result.modules
        }
    });