Search code examples
angularsystemjs

How To Import app/index.js instead of app?


How can I configure systemjs to download app/index.js instead of app/?

I'm developing an angular2 application. When I test it with ng it works perfectly. But then I test it in the deployment server (a python webserver) I got an error. main.js tries to download app and the server returns an empty response and not app/index.js.

Since I don't have control over the webserver, I'm trying to map systemjs to get app/index.js instead of app/. I've tried adding this configuration to system-config.js:

var map = {
    'app': 'app/index.js'
};

// ...

System.config({ map: map, packages: packages });

But it doesn't do anything. Also, I tried with:

var packages = {
  'app': {
    main: 'index'
  }
};

// ...

System.config({ map: map, packages: packages });

And nothing, they don't cause any effect.


Solution

  • Give full path in your html as below

    System.import('app/index.js').catch(function(err){ console.error(err); });