angular: Using module.id with component makes it not load

I am trying the ‘hero’ example on angular.io and using JSPM to load my scripts (non-bundled). To get relative urls for my templates, i tried the method in #2383 and added moduleId: module.id to my component.

import {Component} from 'angular2/core';
import {Hero} from "./hero";

@Component({
    selector: 'my-hero-detail',
    inputs: ['hero'],
    moduleId: module.id,
    templateUrl:'heroes.html'
})

However, doing so and then running the app, makes the html stuck at ‘Loading…’ with no errors in the console.

Screenshot: angular_2_quickstart

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 19 (3 by maintainers)

Most upvoted comments

module.id is provided by the commonjs module. So you have to set the compilerOptions.module in your tsconfig.json to commonjs in order to activate the relative paths feature. With JSPM and Typescript you can set the "module": "commonjs" property in the typescriptOptions of the typescript plugin.

It seems like even the “module”: “commonjs” option in place the issue still exists when bundling with systemjs-builder.