Angular 2: system import application does not work without file extension

I'm pretty new with Angular and systemjs, but I will try to be as specific as possible.

I work with angularjs2 and typescript. I will compile .ts files using tsconfig.json. Here is my configuration:

enter image description here

Next, I want to download my application through my index.html using systemjs. But my import does not accept init without an extension (below, my init, which really works):

System.config({ transpiler: 'typescript' }); System.import('src/app.ts'); 

I have to mention the .ts extension (the same problem in ts files when I want to import handmade components).
Did I forget something? The documentation is a bit rough for beginners regarding the first configurations.
Moreover, I have all my scripts named in <head> (system.js, typescript.js, angular2.dev.js)

+7
angular systemjs
source share
4 answers

I had a similar problem, only the difference is that I am not using angular

@ Nicholas pointed in the right direction, you need to add "defaultExtension", for me the following configuration did the trick:

 packages: { '.': { defaultJSExtensions: 'js' } }, 

You can learn more about how to configure systemjs on github

+4
source share

I am learning a new version of AngularJS and every time I needed to configure t SystemJS, I use this configuration on my index page.

 System.config({ packages: { app: { format: 'register', defaultExtension: 'js' } } }); 

You need to say that your extension for SystemJS loads your modules, I support it.

+3
source share

On a rolling start to angularjs, they do not mention that the package names MUST match. I took the time to figure it out.

 System.config({ packages: { WHATEVER: { format: 'register', defaultExtension: 'js' } } }); System.import('WHATEVER/app'); 
+1
source share

I would recommend using the process described in the Angular 5-minute Quickstart Guide . I'm not sure what it was around when this question was asked. It is required that all your modules load correctly.

-one
source share

All Articles