Search code examples
systemjsjspmbabeljs

system.js downloads browser.js which is 2mega bytes


I'm trying to convert require.js project to system.js based one.

On network tab, I see browser.js which is 2MB.
I found it is actually npm/babel-core@5.8.38/browser.js

And I think this is to convert (transpile) javascript file somehow in development.

How do I convert beforehand (probably when bundling) so that I don't have to download 2MB browser.js

I am working with jspm 0.17 and I can go back to 0.16 if I can solve this problem.


Solution

  • You can create a bundle for a module with all its dependencies using systemjs builder

    var Builder = require('systemjs-builder');
    
    var builder = new Builder;
    
    builder.loadConfig('config.js').then(function() {
    
        builder.bundle('module.js', 'module.bundle.js', {minify: false});
    
    });
    

    Then load resulting bundle with a <script> tag before the first time the module is imported.

    You also can make a bundle for all source files like this

    builder.bundle('src/*.js', 'bundle.js')