3

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

||||||
1

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.

||||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.