flaviait / ng2-jspm-template

A template for a quick development workflow with angular 2 and jspm
MIT License
14 stars 3 forks source link

Optimize import handling for templates and styles once TS properly supports it #10

Closed DorianGrey closed 8 years ago

DorianGrey commented 8 years ago

Follow-up for the workaround in https://github.com/flaviait/ng2-jspm-template/pull/8 - atm., this works around a problem of the typescript compiler picking up files although a specialized loader is specified, causing compiler errors if there is no specific module definition. The workaround generates these definitions using the full path, which works, but is kinda... unlikely.

Corresponding issue: https://github.com/Microsoft/TypeScript/issues/6615

Properly supporting these loader-mechanisms is currently on the [roadmap for typescript v2 (https://github.com/Microsoft/TypeScript/milestones/TypeScript%202.0), and we should adopt our code once this support is available.

DorianGrey commented 8 years ago

With the recent merge, we're now using Typescript 2 (beta). I've implemented loading templates via plugin-text in this branch. However, we're not merging it now, since there are two problems with it:

  1. Hot reloading the template does not work yet (see https://github.com/capaj/systemjs-hot-reloader/issues/91)
  2. Most IDEs (e.g. Intellij IDEA) are still complaining about importing the templates using something like import template from "./template.html";. The complaint aims at a missing default export declaration, although it exists. A workaround for this is to use require inline, like:
@Component({
  selector: "app",
  directives: [ROUTER_DIRECTIVES],
  pipes: [TranslatePipe],
  styles: [styles],
  template: require("./app.template.html")
})
export class App { ...}