2

I have an Angular2 systemjs lazy load error for when I do a bundle for production

I have an angular2 app that uses typescript, html5 and systemjs.

When I run my lazy load modules locally it all works fine. But when I create the production files eg bundle for release. Then the lazy loading modules / routes don't work.

The app still loads and other non lazy loading routes work. But for my terms page for example I get this error in the console log:

Uncaught (in promise): TypeError: System.import is not a function

I had an attempt at updating my system.config for bundles, but to be honest I havent got a clue.

This is my attempt (system.config file):

declare var System: SystemJSLoader.System;

System.config(JSON.parse('<%= SYSTEM_CONFIG_DEV %>'));

System.config({
    bundles: {
      'ModuleTerms.bundle.js': ['app/components/terms/terms.module.js']
    }
});

*This was for my terms and conditions page e.g. ModuleTerms. This page works fine locally, but seems to break when in the bundle and I navigate to it e.g. /terms.

I think theres some sort of setting I need to do.

Let me know if you need to see any other code.

AngularM
  • 15,982
  • 28
  • 94
  • 169
  • 1
    Give a try to angular-cli. It's build almost magically and you don't have to worry about bundles. If you won't, I think you must provide information about your bundle process. Configs, technologies and what more you think should be useful. – Bruno João Dec 10 '16 at 16:13
  • @vinagreti I'm currently using systemjs to bundle my code and create a build package. This is the github I'm using: https://github.com/mgechev/angular-seed How can I use angular-cli with this app? – AngularM Dec 10 '16 at 17:24

0 Answers0