Commit Graph

5067 Commits

Author SHA1 Message Date
Alex Rickabaugh 27bc7dcb43 feat(ivy): ngtsc compiles @Component, @Directive, @NgModule (#24427)
This change supports compilation of components, directives, and modules
within ngtsc. Support is not complete, but is enough to compile and test
//packages/core/test/bundling/todo in full AOT mode. Code size benefits
are not yet achieved as //packages/core itself does not get compiled, and
some decorators (e.g. @Input) are not stripped, leading to unwanted code
being retained by the tree-shaker. This will be improved in future commits.

PR Close #24427
2018-06-14 14:36:45 -07:00
Igor Minar 674c3def31 revert: refactor(ivy): make return value of define(Component|Directive|Pipe|Injector|Injectable) private (#23371)
This reverts commit 2c09b707ce.
2018-04-13 23:02:29 -07:00
Miško Hevery 2c09b707ce refactor(ivy): make return value of define(Component|Directive|Pipe|Injector|Injectable) private (#23371)
Ivy definition looks something like this:

```
class MyService {
  static ngInjectableDef = defineInjectable({
    …
  });
}
```

Here the argument to `defineInjectable` is well known public contract which needs
to be honored in backward compatible way between versions. The type of the
return value of `defineInjectable` on the other hand is private and can change
shape drastically between versions without effecting backwards compatibility of
libraries publish to NPM. To our users it is effectively an `OpaqueToken`.

By prefixing the type with `ɵ` we are communicating the the outside world that
the value is not public API and is subject to change without backward compatibility.

PR Close #23371
2018-04-13 16:20:25 -07:00
Kara Erickson de3ca56769 fix(ivy): support separate creation mode and update mode execution in runtime (#23292)
PR Close #23292
2018-04-11 15:30:39 -07:00
Miško Hevery 60065935be refactor(ivy): align compiler with runtime (#22921)
Remove `containerRefreshStart` and `containerRefreshEnd` instruction
from the output.

Generate directives as a list in `componentDef` rather than inline into
instructions. This is consistent in making selector resolution runtime
so that translation of templates can follow locality.

PR Close #22921
2018-04-02 15:49:48 -07:00
Kara Erickson 6e5fb99304 refactor(ivy): flatten css selectors (#23074)
PR Close #23074
2018-03-30 15:27:50 -07:00
Veres Lajos de90314304 style: typos fixed - https://github.com/vlajos/misspell-fixer (#22975)
PR Close #22975
2018-03-27 14:51:53 -04:00
Kara Erickson 910a16a1ff refactor(ivy): remove directive references from template (#22986)
PR Close #22986
2018-03-26 22:33:23 -04:00
Igor Minar b43f8bc7d3 feat(core): upgrade rxjs to 6.0.0-alpha.4 (#22573)
PR Close #22573
2018-03-19 21:51:51 -07:00
Igor Minar 0b68a35ff2 build: remove obsolete rollup-test (#22854)
PR Close #22854
2018-03-18 14:03:26 -07:00
Kara Erickson 4f21d373b7 refactor(ivy): move hostBindings calls out of template (#22833)
PR Close #22833
2018-03-18 11:41:39 -07:00
Victor Berchet 0ebd577db4 refactor(compiler): Drop support for the deprecated `<template>`. Use `<ng-template>` instead (#22783)
BREAKING CHANGE:

The `<template>` tag was deprecated in Angular v4 to avoid collisions (i.e. when
using Web Components).

This commit removes support for `<template>`. `<ng-template>` should be used
instead.

BEFORE:

    <!-- html template -->
    <template>some template content</template>

    # tsconfig.json
    {
      # ...
      "angularCompilerOptions": {
        # ...
        # This option is no more supported and will have no effect
        "enableLegacyTemplate": [true|false]
      }
    }

AFTER:

    <!-- html template -->
    <ng-template>some template content</ng-template>

PR Close #22783
2018-03-15 14:52:22 -07:00
Miško Hevery 112431db69 test(ivy): add canonical compiler spec for class/style (#22719)
Adds a stub for `elementStyle` and `elementClass` instruction
with a canonical spec for the compiler. The spec shows the the
compiler should be using `elementStyle` and `elementClass` instruction
in place of `[class]` and `[style]` bindings respectively.
PR Close #22719
2018-03-14 12:59:52 -07:00
Matias Niemelä f5a98f41fe fix(core): remove core animation import symbols (#22692)
This patch removes the deprecated support for animation
symbol imports from @angular/core.

BREAKING CHANGE: it is no longer possible to import
animation-related functions from @angular/core. All
animation symbols must now be imported from @angular/animations.

PR Close #22692
2018-03-14 12:23:51 -07:00
Kara Erickson b1365d1fa8 refactor(ivy): remove directiveRefresh instruction (#22745)
PR Close #22745
2018-03-13 23:29:21 -07:00
Victor Berchet 5dd2b5135d refactor(ivy): rename `bindX()` functions to `interpolationX()` (#22229)
rationale: remove the confusion with `bind()` and `bind0()`

PR Close #22229
2018-02-15 14:20:53 -08:00
Kara Erickson 33b338120c refactor(ivy): move onDestroys out of cleanup (#21650)
PR Close #21650
2018-01-24 22:14:33 -08:00
Kara Erickson 811679a583 refactor(ivy): remove unnecessary Comp.r function (#21650)
PR Close #21650
2018-01-24 22:14:33 -08:00
Kara Erickson 98174758ad refactor(ivy): add type and hooks to directive def (#21650)
PR Close #21650
2018-01-24 22:14:32 -08:00
Marc Laval 0b38a039d0 perf(ivy): add a proper creationOnly scenario to the tree benchmark (#21503)
PR Close #21503
2018-01-19 15:24:06 -08:00
Marc Laval 6397062e22 perf(ivy): set ngDevMode to false in render3 benchmarks (#21502)
PR Close #21502
2018-01-19 15:23:33 -08:00
Kara Erickson e18f1de003 refactor(ivy): remove unnecessary D instruction (#21484)
PR Close #21484
2018-01-19 15:23:17 -08:00
David-Emmanuel Divernois 9b5a485243 perf(ivy): add missing dom element in render3_function tree benchmark (#21476)
Adds a missing <tree> wrapper element in the render3_function tree
benchmark to make it more consistent with other perf tests.

PR Close #21476
2018-01-12 10:48:05 -08:00
Miško Hevery 5eaaac35a8 refactor(ivy): remove `type` from `DirectiveDef` (#21374)
This change makes the code cleaner for the user. It does mean
a little bit more work for us since we have to patch the `type` back
into the `DirectiveDef`. However since the patching happens only once
on startup it should not be significant.

PR Close #21374
2018-01-11 07:02:18 -08:00
Miško Hevery 16232f000f refactor(ivy): merged containerStart/containerEnd (#21374)
This separation is no longer needed since directives are now passed into the `container` as an array rather than as child functions of the `containerStart`

PR Close #21374
2018-01-11 07:02:18 -08:00
Misko Hevery a6d41c47a9 refactor(ivy): move directive into elementStart (#21374)
We used to have a separate `directive` instruction for instantiating
directives. However, such an instruction requires that directives
are created in the correct order, which would require that template
compiler would have knowledge of all dependent directives. This
would break template compilation locality principle.

This change only changes the APIs to expected form but does
not change the semantics. The semantics will need to be corrected
in subsequent commits. The semantic change needed is to
resolve the directive instantiation error at runtime based on
injection dependencies.

PR Close #21374
2018-01-11 07:02:17 -08:00
Kara Erickson 6be9c0466c refactor(core): split up interface files in render3 (#21433)
PR Close #21433
2018-01-10 16:13:44 -08:00
Alex Eagle 2ad92ed254 build(bazel): fix merge conflict between c4f02e2 and ef956a2 (#21453)
PR Close #21453
2018-01-10 12:57:14 -08:00
Misko Hevery ef956a20c3 build: add bazel rulse for benchmarks (#21436)
PR Close #21436
2018-01-10 11:58:53 -08:00
Kara Erickson c516bc3b35 feat(core): add ngOnInit and ngDoCheck support in render3 (#21156)
PR Close #21156
2017-12-27 16:46:56 -06:00
Miško Hevery 5a7bf36723 build: fix circular dep between interface and l_node by merging (#20855)
PR Close #20855
2017-12-21 21:40:58 -08:00
Miško Hevery 66528a21f6 build: fix benchmarks for render3 (#20855)
PR Close #20855
2017-12-21 21:40:58 -08:00
Marc Laval d1de587ce0 feat(core): add renderer factory in render3 (#20855)
PR Close #20855
2017-12-21 21:40:58 -08:00
Miško Hevery 1f5049f30c style: fix formatting errors (#20855)
PR Close #20855
2017-12-21 21:40:58 -08:00
Marc Laval 09e3839994 perf: use style.setProperty instead of setAttribute in render3 and iv benchmarks (#20855)
PR Close #20855
2017-12-21 21:40:58 -08:00
Marc Laval f75296e04e perf: add benchmarks for IV and render3 with functions (tree) (#20855)
PR Close #20855
2017-12-21 21:40:58 -08:00
Marc Laval 0867e85163 perf: add large table and deep tree benchmarks for render3 (#20855)
PR Close #20855
2017-12-21 21:40:58 -08:00
Victor Berchet 0833b59aab refactor(core): add a checkIndex to the compiler view nodes
Each node now has two index: nodeIndex and checkIndex.

nodeIndex is the index in both the view definition and the view data.
checkIndex is the index in in the update function (update directives and update
renderer).

While nodeIndex and checkIndex have the same value for now, having both of them
will allow changing the structure of view definition after compilation (ie for
runtime translations).
2017-10-04 14:55:54 -07:00
Olivier Combe 0f5c70d563 build: update npm dependencies (#19328)
PR Close #19328
2017-09-22 13:20:52 -07:00
Chuck Jazdzewski f96142cd7c build: remove references to `tsc-wrapped` (#19298)
With this commit `ngc` is used instead of `tsc-wrapped` for
collecting metadata and tsickle rewriting and `tsc-wrapped`
is removed from the repository.

`@angular/tsc-wrapped@5` is now deprecated and is no longer
used, updated, or maintained as part as of Angular 5.x.x.

`@angular/tsc-wrapped@4` is still maintained and required by
Angular 4.x.x and will be maintained as long as 4.x.x is in
LTS.

PR Close #19298
2017-09-21 13:55:52 -07:00
Tobias Bosch ca5aebaa6b refactor: update angular to support TypeScript 2.4
Detailed updates:
- rxjs@5.0.x
- tsickle@0.24.x
- typescript@2.4.x
- @bazel/typescript@0.10.0
- protractor@5.1.x
- selenium-webdriver@3.0.x

BREAKING CHANGE:
- the Angular compiler now requires TypeScript 2.4.x.
2017-09-12 10:31:30 -07:00
Miško Hevery fcadbf4bf6 perf: switch angular to use StaticInjector instead of ReflectiveInjector
This change allows ReflectiveInjector to be tree shaken resulting
in not needed Reflect polyfil and smaller bundles.

Code savings for HelloWorld using Closure:

Reflective: bundle.js:  105,864(34,190 gzip)
    Static: bundle.js:  154,889(33,555 gzip)
                            645( 2%)

BREAKING CHANGE:

`platformXXXX()` no longer accepts providers which depend on reflection.
Specifically the method signature when from `Provider[]` to
`StaticProvider[]`.

Example:
Before:
```
[
  MyClass,
  {provide: ClassA, useClass: SubClassA}
]

```

After:
```
[
  {provide: MyClass, deps: [Dep1,...]},
  {provide: ClassA, useClass: SubClassA, deps: [Dep1,...]}
]
```

NOTE: This only applies to platform creation and providers for the JIT
compiler. It does not apply to `@Compotent` or `@NgModule` provides
declarations.

Benchpress note: Previously Benchpress also supported reflective
provides, which now require static providers.

DEPRECATION:

- `ReflectiveInjector` is now deprecated as it will be remove. Use
  `Injector.create` as a replacement.

closes #18496
2017-08-07 15:42:34 -07:00
Chuck Jazdzewski 619e625ee2 refactor(tsc-wrapped): move tsc-wrapped to the packages directory (#18160) 2017-07-21 12:26:16 -05:00
Tobias Bosch e263e19a2a fix(core): don’t stop change detection because of errors
- prevents unsubscribing from the zone on error
- prevents unsubscribing from directive `EventEmitter`s on error
- prevents detaching views in dev mode if there on error
- ensures that `ngOnInit` is only called 1x (also in prod mode)

Fixes #9531
Fixes #2413
Fixes #15925
2017-05-01 18:56:25 -04:00
Tobias Bosch bccfaa46ec fix(core): benchmarks - enable ng1 benchmark again
Also make it match the ng2 benchmark.
2017-04-18 08:28:31 -07:00
Miško Hevery 910c0d9ee7 fix(core): Update types for TypeScript nullability support (#15472) 2017-03-29 09:34:45 -07:00
Victor Berchet a755b715ed feat(router): introduce `ParamMap` to access parameters
The Router use the type `Params` for all of:
- position parameters,
- matrix parameters,
- query parameters.

`Params` is defined as follow `type Params = {[key: string]: any}`

Because parameters can either have single or multiple values, the type should
actually be `type Params = {[key: string]: string | string[]}`.

The client code often assumes that parameters have single values, as in the
following exemple:

```
class MyComponent {
sessionId: Observable<string>;

constructor(private route: ActivatedRoute) {}

ngOnInit() {
    this.sessionId = this.route
      .queryParams
      .map(params => params['session_id'] || 'None');
}
}

```

The problem here is that `params['session_id']` could be `string` or `string[]`
but the error is not caught at build time because of the `any` type.

Fixing the type as describe above would break the build because `sessionId`
would becomes an `Observable<string | string[]>`.

However the client code knows if it expects a single or multiple values. By
using the new `ParamMap` interface the user code can decide when it needs a
single value (calling `ParamMap.get(): string`) or multiple values (calling
`ParamMap.getAll(): string[]`).

The above exemple should be rewritten as:

```
class MyComponent {
sessionId: Observable<string>;

constructor(private route: ActivatedRoute) {}

ngOnInit() {
    this.sessionId = this.route
      .queryParamMap
      .map(paramMap => paramMap.get('session_id') || 'None');
}
}

```

Added APIs:
- `interface ParamMap`,
- `ActivatedRoute.paramMap: ParamMap`,
- `ActivatedRoute.queryParamMap: ParamMap`,
- `ActivatedRouteSnapshot.paramMap: ParamMap`,
- `ActivatedRouteSnapshot.queryParamMap: ParamMap`,
- `UrlSegment.parameterMap: ParamMap`
2017-03-20 09:19:32 -07:00
Tobias Bosch 28ce68a13d refactor(core): view engine - change `BindingType` to `BindingFlags` (#15251) 2017-03-19 12:21:37 -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
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