Search code examples
javascripttypescriptangularsystemjs

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?


Solution

  • 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.