Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

systemjs-builder can not work

Tags:

gulp

I have a problem when use systemjs-builder to build my app.
This is structure of my app.

enter image description here

And this is function to build:

var systemjsBuild = {
        map: {
            'angular2': '../node_modules/angular2',
            'rxjs': '../node_modules/rxjs'
        },
        packages: {
          dist: {
            format: 'register',
            defaultExtension: 'js'
          }
        }
    };


function buildSJS () {
   var builder = new Builder('dist');
   builder.config(systemjsBuild);
   builder.loader.defaultJSExtensions = true;
   builder
          .bundle('main', 'build/main.js', 
            {
                 minify: true,
                 globalDefs: { DEBUG: false }
            })
            .then(function () {
                 console.log('Build complete');
                 done();
             })
             .catch(function (ex) {
                 console.log('error', ex);
                 done('Build failed.');
             });
   }  

But It can not work,

error [Error: Unable to calculate canonical name to bundle file:///E:/myapp/node_modules/angular2/core.js

And if I run serve-dev with root is dist, angular2/core.js load content is content of index.html file.
index.html

<body>
    <script src="assets/bundle.js"></script>
    <script>
        System.config({
        packages: {        
          app: {
            format: 'register',
            defaultExtension: 'js'
          }
        },
        map: {
            'angular2': '../node_modules/angular2'
        }
      });
      System.import('main.js')
            .then(null, console.error.bind(console));
    </script>
  </body>

Please help me, thanks

like image 585
ThuyNguyen Avatar asked Jan 26 '26 00:01

ThuyNguyen


1 Answers

I think you should be setting the baseURL to below the module path so the baseURL to a folder that includes the build folder within it.

like image 117
PoX Avatar answered Jan 29 '26 14:01

PoX



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!