Commit Graph

439 Commits

Author SHA1 Message Date
Kara Erickson 27e2039630 fix(compiler): update compiler to generate new slot allocations (#25607)
PR Close #25607
2018-08-22 21:08:39 -04:00
Alex Rickabaugh 5c95b4b3a3 feat(ivy): support enum values in static resolution (#25619)
This commit adds support for enumeration values. An enumeration value
is now a first-class return value of the resolver, which provides both
a Reference to the enum type itself and the name of the value from that
enum. Resolving an enum itself returns a Map<string, EnumValue>.

PR Close #25619
2018-08-22 19:30:23 -04:00
Pete Bacon Darwin 7500f0eafb feat(ivy): find all packages to be compiled by ngcc (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
Pete Bacon Darwin 68acc5b355 feat(ivy): compile all package formats in ngcc (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
Pete Bacon Darwin 7d3b70c2af fix(ivy): ngcc is resilient to bad source-map comments (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
Pete Bacon Darwin 7ce291c72a feat(ivy): implement `Esm5ReflectionHost.getGenericArityOfClass()` (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
Pete Bacon Darwin 6ae1e63c89 refactor(ivy): rename `Esm2015ReflectionHost` to `Fesm2015ReflectionHost` (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
Alex Rickabaugh d33e0091df fix(ivy): emit generic types when needed in defs in .d.ts file (#25406)
Ivy definitions in .d.ts files often reference the type of a class.
Sometimes, those classes have generic type parameters. When this is
the case, ngtsc needs to emit generic type parameters in the .d.ts
files (usually by passing 'any').

PR Close #25406
2018-08-22 19:28:56 -04:00
George Kalpakas b97d770e60 feat(ivy): add support for typings in ngcc (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
George Kalpakas a3158bff27 refactor(ivy): minor re-organization of ngcc `PackageTransformer#transform` (#25406)
In preparation of adding support for transforming `.d.ts` files.

PR Close #25406
2018-08-22 19:28:56 -04:00
George Kalpakas d6e91ba545 feat(ivy): support getting the corresponding `.d.ts` file in ngcc (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
George Kalpakas cdb0215d0b test(ivy): clean up ngcc spec (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
George Kalpakas 396766104b refactor(ivy): rename spec files to match corresponding source files (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
George Kalpakas e77f0fd6e6 refactor(ivy): export ngcc import prefix into constant (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
George Kalpakas cdd4c9be63 feat(ivy): support custom prefix for imports in `DtsFileTransformer` (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
George Kalpakas 29705dd8f2 refactor(ivy): make `ReflectionHost` a parameter of `Renderer` (#25406)
PR Close #25406
2018-08-22 19:28:56 -04:00
George Kalpakas ea68ba048a refactor(ivy): minor refactorings (#25406)
PR Close #25406
2018-08-22 19:28:55 -04:00
George Kalpakas 9081efa961 feat(ivy): enable processing of esm5 format in ngcc (#25406)
PR Close #25406
2018-08-22 19:28:55 -04:00
George Kalpakas 9e179cb311 fix(ivy): correctly detect classes in ngcc `Esm5ReflectionHost` (#25406)
PR Close #25406
2018-08-22 19:28:55 -04:00
George Kalpakas 3211432d2a feat(ivy): add support for esm2015 and esm5 in ngcc `PackageParser` (#25406)
Since non-flat module formats (esm2015, esm5) have different structure
than their flat counterparts (and since we are operating on JS files
inside `node_modules/`, we need to configure TS to include deeply nested
JS files (by specifying a sufficiently high `maxNodeModuleJsDepth`).

Remains to be determined if this has any (noticeable) performance
implications.

PR Close #25406
2018-08-22 19:28:55 -04:00
George Kalpakas a7134dbc37 refactor(ivy): remove unused arg from ngcc `Analyzer` (#25406)
PR Close #25406
2018-08-22 19:28:55 -04:00
Pete Bacon Darwin a528636f56 fix(ivy): allow `FunctionExpression` to indicate a method declaration (#25406)
In some code formats (e.g. ES5) methods can actually be function
expressions. For example:

```js
function MyClass() {}
// this static method is declared as a function expression
MyClass.staticMethod = function() { ... };
```

PR Close #25406
2018-08-22 19:28:55 -04:00
Pete Bacon Darwin f87b499dde feat(ivy): implement `getDefinitionOfFunction` on ES2015 and ES5 reflection hosts (#25406)
PR Close #25406
2018-08-22 19:28:55 -04:00
Alex Rickabaugh a45f2bfb8f feat(ivy): use the ReflectionHost to resolve parameters and initializers (#25406)
ngtsc's static resolver can evaluate function calls where parameters
have default values. In TypeScript code these default values live on the
function definition, but in ES5 code the default values are represented
by statements in the function body.

A new ReflectionHost method getDefinitionOfFunction() abstracts over
this difference, and allows the static reflector to more accurately
evaluate ES5 code.

PR Close #25406
2018-08-22 19:28:55 -04:00
Marc Laval 6176974832 test(compiler-cli): fix failing test after bad merge (#25599)
PR Close #25599
2018-08-21 11:30:42 -07:00
Pawel Kozlowski 11e2d9da1a feat(ivy): add support to template local refs in the compiler (#25576)
Fixes #23316

PR Close #25576
2018-08-20 16:24:56 -07:00
Kara Erickson 21a14407f6 refactor(ivy): generate vars in component defs (#25562)
PR Close #25562
2018-08-20 11:08:10 -07:00
Kara Erickson f2aa9c6a7f refactor(ivy): use generated consts value to set binding index (#25533)
PR Close #25533
2018-08-17 14:32:55 -07:00
Miško Hevery 116946fb11 style: tslint enforces no debugger statements left behind (#25532)
PR Close #25532
2018-08-16 16:00:22 -07:00
Kara Erickson 6482f6f0fe refactor(ivy): separate container into 2 instructions (#25509)
PR Close #25509
2018-08-16 13:47:14 -07:00
Greg Magolan 9605456b66 build: refactor ambient node & jasmine types so they are only included where needed (#25491)
PR Close #25491
2018-08-16 13:46:43 -07:00
Miško Hevery 9ee6702fa9 refactor(ivy): remove short instruction names as they provide no value (#25493)
PR Close #25493
2018-08-16 11:04:34 -07:00
Ben Lesh a0a29fdd27 feat(ivy): Add AOT handling for bare classes with Input and Output decorators (#25367)
PR Close #25367
2018-08-14 16:36:18 -07:00
Alex Rickabaugh 26066f282e fix(ivy): consider exported modules from other compilation scopes (#25425)
PR Close #25425
2018-08-14 14:23:24 -07:00
Alex Rickabaugh b40c437379 fix(ivy): ensure factory statements are emitted correctly (#25425)
A small bug caused base factory variable statements for @Component to
not be emitted properly. At the same time as this is fixed, those
statements are now emitted as const.

PR Close #25425
2018-08-14 14:23:24 -07:00
Kara Erickson 4a4d6fb0e6 test(ivy): compiler compliance tests should support ? (#25435)
PR Close #25435
2018-08-10 17:12:18 -07:00
Pawel Kozlowski 2d759927d4 feat(ivy): add support for ng-container in the compiler (#25383)
PR Close #25383
2018-08-09 13:13:04 -07:00
Alex Rickabaugh 33fd7e0784 fix(ivy): export NgModuleFactory via r3_symbols for core factories (#25392)
When @angular/core is compiled by ngtsc, a factory file is generated
for ApplicationModule, that is currently invalid because r3_symbols
does not export NgModuleFactory. This change fixes that issue and
ensures the generated ngfactory file for @angular/core is valid.

PR Close #25392
2018-08-09 09:58:13 -07:00
Alex Rickabaugh 2befc65777 fix(ivy): ngtsc should pay attention to declaration order (#25392)
When generating the 'directives:' property of ngComponentDef, ngtsc
needs to be conscious of declaration order. If a directive being
written into the array is declarated after the component currently
being compiled, then the entire directives array needs to be wrapped
in a closure.

This commit fixes ngtsc to pay attention to such ordering issues
within directives arrays.

PR Close #25392
2018-08-09 09:58:13 -07:00
Alex Rickabaugh 6f085f8610 fix(ivy): add missing exportAs field to ngDirectiveDef (#25392)
This commit includes the missing exportAs field from @Directive and
propagates it into the ngDirectiveDef.

PR Close #25392
2018-08-09 09:58:13 -07:00
Alex Rickabaugh 5be186035f feat(ivy): enable inheritance of factory functions in definitions (#25392)
This commit creates an API for factory functions which allows them
to be inherited from one another. To do so, it differentiates between
the factory function as a wrapper for a constructor and the factory
function in ngInjectableDefs which is determined by a default
provider.

The new form is:

factory: (t?) => new (t || SomeType)(inject(Dep1), inject(Dep2))

The 't' parameter allows for constructor inheritance. A subclass with
no declared constructor inherits its constructor from the superclass.
With the 't' parameter, a subclass can call the superclass' factory
function and use it to create an instance of the subclass.

For @Injectables with configured providers, the factory function is
of the form:

factory: (t?) => t ? constructorInject(t) : provider();

where constructorInject(t) creates an instance of 't' using the
naturally declared constructor of the type, and where provider()
creates an instance of the base type using the special declared
provider on @Injectable.

PR Close #25392
2018-08-09 09:58:13 -07:00
Alex Rickabaugh fba276d3d1 fix(ivy): use a single constant pool per source file (#25392)
Previously, ngtsc used a new ConstantPool for each decorator
compilation. This could result in collisions between constants in the
top-level scope.

Now, ngtsc uses a single ConstantPool for each source file being
compiled, and merges the constant statements into the file after the
import section.

PR Close #25392
2018-08-09 09:58:13 -07:00
Alex Eagle a3f1e2cb42 style: format .bzl files with buildifier (#23544)
PR Close #23544
2018-08-08 13:12:07 -07:00
Ádám Lippai c6e5b971d6 fix(compiler-cli): use the oldProgram option in watch mode (#21364)
The performCompilation() is always called with an undefined oldProgram option (even in watch mode).
This was regression introduced in: 957be960d2

Partial fix, discovered in: #21361

PR Close #21364
2018-08-07 11:58:38 -07:00
Alex Rickabaugh fefc860f35 fix(ivy): fix bug with banana-in-a-box expressions in nested templates (#25321)
Inside of a nested template, an attempt to generate code for a banana-
in-a-box expression would cause a crash in the _AstToIrVisitor, as it
was not handling the case where a write would be generated to a local
variable.

This change supports such a mode of operation.

PR Close #25321
2018-08-07 11:45:32 -07:00
Victor Berchet 795e1e8a38 test(ivy): improve error message for the compiler compliance test (#25291)
before:

```
Expected to find features 'import * as i0 from "@angular/core";
import { Directive, Input } from '@angular/core';

```

after:

```
Failed to find "template" after "...Component_Factory() { return new
MyComponent(); }," in:
'import * as i0 from "@angular/core";
import { Directive, Input } from '@angular/core';```

```

PR Close #25291
2018-08-05 15:31:19 -07:00
Victor Berchet 1e7ca22078 refactor(ivy): make all directives public by default (#25291)
To match the View Engine behavior.

We should make this configurable so that the node injector is tree shaken when
directives do not need to be published.

PR Close #25291
2018-08-05 15:31:19 -07:00
Kara Erickson 79a9c71422 test(ivy): remove unnecessary common import (#25297)
PR Close #25297
2018-08-03 14:34:02 -07:00
Alex Rickabaugh eb999300d9 test(ivy): run compiler compliance tests without rebuilding core,common (#25248)
Previously the compiler compliance tests ran and built test code with
real dependencies on @angular/core and @angular/common. This meant that
any changes to the compiler would result in long rebuild processes
for tests to rerun.

This change removes those dependencies and causes test code to be built
against the fake_core stub of @angular/core that the ngtsc tests use.
This change also removes the dependency on @angular/common entirely, as
locality means it's possible to reference *ngIf without needing to link
to an implementation.

PR Close #25248
2018-08-03 13:08:51 -07:00
Alex Rickabaugh 0822dc70f2 feat(ivy): generate .ngfactory stubs if requested (#25176)
Existing bootstrap code in the wild depends on the existence of
.ngfactory files, which Ivy does not need. This commit adds the
capability in ngtsc to generate .ngfactory files which bridge
existing bootstrap code with Ivy.

This is an initial step. Remaining work includes complying with
the compiler option to specify a generated file directory, as well
as presumably testing in g3.

PR Close #25176
2018-08-03 09:42:06 -07:00