Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

index.js not doing what index.ts does

I'm currently building a webapp with angular2 and typescript. I tried to use index.ts so in my code, I could simply use

import {LayoutComponent} from '../layout';

But when I transpile, the javascript engine won't look for index.js but for ./layout so it doesn't work.

Is there a config for the typescript transpiler, something I should configure with systemjs or use another loader like webpack?

like image 703
Jean Gregory Avatar asked Sep 11 '25 16:09

Jean Gregory


1 Answers

I found the cause of this. Typescript is using nodejs module resolution explained here : http://www.typescriptlang.org/docs/handbook/module-resolution.html

But systemjs does not use nodejs resolution. So I need to use ./layout/index to be compatible with systemjs module resolution or use a map entry for every modules. But commonjs does use nodejs resolution so I'm gonna transpile to commonjs and use webpack.

like image 111
Jean Gregory Avatar answered Sep 13 '25 06:09

Jean Gregory