Skip to content

Add ngc option to inline templates for libraries. #16157

@filipesilva

Description

@filipesilva

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Angular library authors should inline templates (html/css) to ensure overall compatibility between different consumer types.

This can be done with a fairly simple script, but it has a few pitfalls:

  • special care must be taken to maintain sourcemap lines (inline over TS sources before ngc).
  • unit testing requires a separate module.id based setup to load templates into karma.
  • no watch mode.

Expected behavior

Since inlining is heavily encouraged for library AOT compilation, it should be included as an option for ngc (e.g. angularCompilerOptions.inlineTemplates).

Minimal reproduction of the problem with instructions
An example library can be found at https://github.com/filipesilva/angular-quickstart-lib.

What is the motivation / use case for changing the behavior?
Less work for everyone building and shipping components, one less point of failure.

  • Angular version: 4.x

  • Language: [ TypeScript 2.x ]

/cc @IgorMinar @jasonaden

Metadata

Metadata

Assignees

Labels

area: coreIssues related to the framework runtimefeatureIssue that requests a new feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions