Commit Graph

42 Commits

Author SHA1 Message Date
Chuck Jazdzewski ddb766e456 feat(compiler): do not evaluate metadata expressions that can use references (#18001) 2017-07-13 16:16:56 -07:00
Victor Berchet 448d9f9f46 test(compiler): add a test for components not part of any `NgModule` 2017-06-26 13:24:36 -07:00
Chuck Jazdzewski 3097083277 feat(compiler-cli): new compiler api and command-line using TypeScript transformers 2017-06-23 16:18:44 -07:00
Chuck Jazdzewski 4352dd27c4 fix(compiler): avoid emitting self importing factories
Fixes: #17389
2017-06-21 16:19:43 -07:00
Tobias Bosch 90b0713e32 refactor(compiler): don’t write summaries for jit by default
The default is false externally but true internally at Google.
2017-06-09 15:58:53 -07:00
Chuck Jazdzewski 230255f887 feat(compiler-cli): produce template diagnostics error messages (#17125)
Refactoring the compiler to use transformers moves the code generation
after type-checking which suppresses the errors TypeScript would
generate in the user code.

`TypeChecker` currently produces the same factory code that was
generated prior the switch to transfomers, getting back the same
diagnostics as before. The refactoring will allow the code to
diverge from the factory code and allow better diagnostic error
messages than was previously possible by type-checking the factories.
2017-06-01 10:13:50 -07:00
Tobias Bosch eba59aaf87 refactor(compiler): add ability to produce stub .ngfactory / .ngsummary files (#16963)
These files are needed so that:
- user code can compile even without real codegen
- as tsc transformers cannot create but only change existing files
  in the transformation pipeline.
2017-05-23 14:40:50 -06:00
Chuck Jazdzewski 27761b4500 fix(compiler): do not report type errors for arguments with `@Inject` (#16222)
Fixes #15424
2017-05-23 11:53:38 -06:00
Tobias Bosch 5af143e8e4 refactor(compiler): allow sync AOT compilation (#16832).
AOT compilation can be executed synchronously now,
if the `ReosurceLoader` returns a string directly
(and no `Promise`).
2017-05-23 10:41:23 -06:00
Tobias Bosch 50abca4583 refactor(compiler): don’t rely on global reflector (#16832)
Using the global reflector made it impossible
to compile multiple programs at the same time.
2017-05-23 10:41:23 -06:00
Tobias Bosch de8d7c65f2 refactor(compiler): emit OutputAst and not sources (#16832)
This is in preparation for creating typescript nodes
directly from `OutputAst` nodes.
2017-05-23 10:41:23 -06:00
Tobias Bosch 6123b9c0c6 refactor(compiler): make `OutputAst` contain the moduleName, not the filePath (#16832).
The goal of this change is to simplify the emitters,
as we will soon create a new one to emit TypeScript nodes directly.
2017-05-23 10:41:23 -06:00
Tobias Bosch 5afaa39e68 refactor(compiler): produce more dense generated code (#16666)
This changes the formatting to be less verbose but still
tries to be readable.
2017-05-11 10:28:48 -07:00
Tobias Bosch ce1d7c4a6e refactor: use view engine also for `NgModuleFactory`s (#16658)
* refactor(core): provide error message in stack for reflective DI

Fixes #16355

* fix(compiler): make AOT work with `noUnusedParameters`

Fixes #15532

* refactor: use view engine also for `NgModuleFactory`s

This is a prerequisite for being able to mock providers
in AOTed code later on.
2017-05-11 10:26:02 -07:00
Chuck Jazdzewski b9521b568f feat(compiler): support a non-null postfix assert (#16672)
Template expressions can now use a post-fix `!` operator
that asserts the target of the operator is not null. This is
similar to the TypeScript non-null assert operator. Expressions
generated in factories will be generated with the non-null assert
operator.

Closes: #10855
2017-05-11 10:15:54 -07:00
Tobias Bosch 547c363473 feat: add .ngsummary.ts files to support AOT unit tests
Design doc: https://docs.google.com/document/d/1VmTkz0EbEVSWfEEWEvQ5sXyQXSCvtMOw4t7pKU-jOwc/edit?usp=sharing
2017-05-05 13:23:53 -04:00
Tobias Bosch c946a929b7 refactor(compiler): simplify AOT tests 2017-05-02 15:51:54 -07:00
Miško Hevery 5293794316 fix: turn on nullability in the code base. 2017-04-18 12:07:33 -07:00
Chuck Jazdzewski 38a7e0d1c7 fix(compiler): ignore calls to unresolved symbols in metadata
This only shows up in the language service. Calls to symbols
that are not resolve resulted in null instead of being resolved
causing the language service to see exceptions when the null
was not expected such as in the animations array.

Fixes #15969
2017-04-17 14:36:08 -07:00
Tobias Bosch 86396a43e9 Revert "fix(compiler): ignore calls to unresolved symbols in metadata (#15970)"
This reverts commit ce47d33cd9.
2017-04-14 11:20:12 -07:00
Chuck Jazdzewski ce47d33cd9 fix(compiler): ignore calls to unresolved symbols in metadata (#15970)
This only shows up in the language service. Calls to symbols
that are not resolve resulted in null instead of being resolved
causing the language service to see exceptions when the null
was not expected such as in the animations array.

Fixes #15969
2017-04-14 09:02:32 -07:00
Miško Hevery 09d9f5fe54 fix(compiler): Update types for TypeScript nullability support 2017-04-10 15:26:33 -06:00
Tobias Bosch 8ef621ad2a fix(compiler): fix inheritance for AOT with summaries (#15583)
Allows to inherit ctor args, lifecycle hooks and statics from a class
in another compilation unit. 
Will error if trying to inherit from a class in another compilation unit 
that has an `@Component` / `@Directive` / `@Pipe` / `@NgModule`.
2017-03-30 14:51:29 -07:00
Chuck Jazdzewski d438b88f19 fix(compiler): ignore errors when evaluating base classes (#15560)
Fixes #15536
2017-03-28 13:32:34 -07:00
Chuck Jazdzewski 0dda01e37c fix(compiler): correctly handle when `toString` is exported (#15430)
Fixes #15420
2017-03-23 13:38:01 -07:00
Aliaksei Kuncevic de87c47dd9 docs: spelling errors 2017-03-22 21:28:24 -07:00
Chuck Jazdzewski 90d2518d9a fix(compiler): look for flat module resources using declaration module path (#15367)
`ngc` would look for flat module resources relative to the flat module index.
`ngc` now looks for flat module resources relative to the `.d.ts` file that declarates
the component.

Fixes #15221

PR Close #15367
2017-03-21 19:05:03 -05:00
Tobias Bosch 764e90f9bb fix(compiler): don’t call `check` if we don’t need to (#15322)
If a directive has not bindings nor has a `ngDoCheck` / `ngOnInit`
lifecycle hook, don’t generate a `check` call.

This does not have an impact on the behavior, but produces
less code.

PR Close #15322
2017-03-20 22:36:20 -05:00
Tobias Bosch 9429032da1 feat(upgrade): use `ComponentFactory.inputs/outputs/ngContentSelectors` (#15214)
DEPRECATION:
- the arguments `inputs` / `outputs` / `ngContentSelectors` of `downgradeComponent`
  are no longer used as Angular calculates these automatically now.
- Compiler.getNgContentSelectors is deprecated. Use
  ComponentFactory.ngContentSelectors instead.
2017-03-17 13:52:50 -05:00
Tobias Bosch 791534f2f4 feat(core): expose `inputs`, `outputs` and `ngContentSelectors` on `ComponentFactory`. (#15214)
E.g. for a component like this:
```
@Component({
  template: ‘<ng-content select=“child”></ng-content>’
})
class MyComp {
  @Input(‘aInputName’)
  aInputProp: string;

  @Output(‘aEventName’)
  aOuputProp: EventEmitter<any>;
}
```

the `ComponentFactory` will now contain the following:
- `inputs = {aInputProp: ‘aInputName’}`
- `outputs = {aOutputProp: ‘aOutputName’}`
- `ngContentSelectors = [‘child’]`
2017-03-17 13:52:41 -05:00
Tobias Bosch 8415910375 fix(compiler): add an empty content for source file of non mapped code. (#15246)
Before this when using ngc, tools tried to load `ng://…<component>.ts`
if `…<component>.ts` was the source file of a template.

PR Close #15246
2017-03-17 13:48:09 -05:00
Tobias Bosch 994089d36b fix(compiler): always use `ng://` prefix for sourcemap urls (#15218)
Fixes:
- In G3, filePaths don’t start with a `/` and therefore became relative.
- Always using the `ng://` prefix groups angular resources in the same
  way for AOT and JIT.
2017-03-16 17:33:17 -07:00
Tobias Bosch 492153a986 fix(compiler): make sourcemaps work in AOT mode
Inlcuded fixes:
- include preamble in generated source map
- always add a mapping for line/col 0 so that the
  generated sourcemap is not sparse
- use a uniue sourceUrl for inline templates even
  in the AOT case
2017-03-16 12:56:56 -07:00
Chuck Jazdzewski cd981499f9 Revert "feat(core): expose `inputs`, `outputs` and `ngContentSelectors` on `ComponentFactory`."
This reverts commit 1171f91a80.
2017-03-15 13:23:10 -07:00
Chuck Jazdzewski c439742a54 Revert "feat(upgrade): use `ComponentFactory.inputs/outputs/ngContentSelectors`"
This reverts commit a3e32fb7e1.
2017-03-15 13:22:54 -07:00
Tobias Bosch a3e32fb7e1 feat(upgrade): use `ComponentFactory.inputs/outputs/ngContentSelectors`
DEPRECATION:
- the arguments `inputs` / `outputs` / `ngContentSelectors` of `downgradeComponent`
  are no longer used as Angular calculates these automatically now.
- Compiler.getNgContentSelectors is deprecated. Use
  ComponentFactory.ngContentSelectors instead.
2017-03-15 11:42:12 -07:00
Tobias Bosch 1171f91a80 feat(core): expose `inputs`, `outputs` and `ngContentSelectors` on `ComponentFactory`.
E.g. for a component like this:
```
@Component({
  template: ‘<ng-content select=“child”></ng-content>’
})
class MyComp {
  @Input(‘aInputName’)
  aInputProp: string;

  @Output(‘aEventName’)
  aOuputProp: EventEmitter<any>;
}
```

the `ComponentFactory` will now contain the following:
- `inputs = {aInputProp: ‘aInputName’}`
- `outputs = {aOutputProp: ‘aOutputName’}`
- `ngContentSelectors = [‘child’]`
2017-03-15 11:42:12 -07:00
Chuck Jazdzewski b00fe20afd fix(compiler): support interface types in injectable constuctors (#14894)
Fixes #12631
2017-03-15 09:24:56 -07:00
Tobias Bosch 5c34066058 fix(compiler): only warn for `@Injectable` classes with invalid args.
In v2.x, users had to annotate classes that they intended to use as tokens with `@Injectable`. This is no longer required in v4.x for tokens,
and we now require the constructor parameters of classes annotated
with `@Injectable` to be statically analyzable by ngc.

This commit reduces the error into a warning
if the constructor parameters do not meet this condition.

DEPRECATION:
- Classes annotated with `@Injectable` but whose constructor’s parameter types
  are not statically analyzable by ngc will produce a warning.

Closes #15003
2017-03-14 19:52:53 -07:00
Tobias Bosch cdc882bd36 feat: introduce source maps for templates (#15011)
The main use case for the generated source maps is to give
errors a meaningful context in terms of the original source
that the user wrote.

Related changes that are included in this commit:

* renamed virtual folders used for jit:
  * ng://<module type>/module.ngfactory.js
  * ng://<module type>/<comp type>.ngfactory.js
  * ng://<module type>/<comp type>.html (for inline templates)
* error logging:
  * all errors that happen in templates are logged
    from the place of the nearest element.
  * instead of logging error messages and stacks separately,
    we log the actual error. This is needed so that browsers apply
    source maps to the stack correctly.
  * error type and error is logged as one log entry.

Note that long-stack-trace zone has a bug that 
disables source maps for stack traces,
see https://github.com/angular/zone.js/issues/661.

BREAKING CHANGE:

- DebugNode.source no more returns the source location of a node.  

Closes 14013
2017-03-14 09:16:15 -07:00
Jason Aden bebedfed24 build: build modules and examples for karma 2017-03-08 17:35:20 -08:00
Jason Aden 3e51a19983 refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00