You can use one of these options:
CommonJS
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs", // this line
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
}
component:
@Component({
moduleId: module.id,
selector: 'header',
templateUrl: 'header.component.html',
styleUrls: ['header.component.css']
})
SystemJS
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "system", // this line
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
}
component:
declare var __moduleName: any;
@Component({
moduleId: __moduleName,
selector: 'header',
templateUrl: 'header.component.html',
styleUrls: ['header.component.css']
})
There are also special loaders to load your html without specifying module
option (https://github.com/angular/angular/issues/6053#issuecomment-222341010)
Webpack users can use require('./some-template.html') - see
https://angular.io/docs/ts/latest/guide/webpack.html for an example of
how to use this.
SystemJS has the ability to use loaders for text in a similar fashion
- https://github.com/systemjs/plugin-text
See also