Commit Graph

2180 Commits

Author SHA1 Message Date
Pawel Kozlowski 39712bcdb2 test(ivy): get ViewRef.rootNodes should get all root nodes from projectable nodes (#33647)
PR Close #33647
2019-11-11 09:37:38 -08:00
Pawel Kozlowski 9d99c7244f refactor(ivy): simplify getFirstNativeNode processing of LContainer (#33647)
PR Close #33647
2019-11-11 09:37:38 -08:00
Pawel Kozlowski 05d7c575e4 fix(ivy): properly insert views in front of empty views (#33647)
PR Close #33647
2019-11-11 09:37:38 -08:00
Pawel Kozlowski 056236cafd fix(ivy): properly insert views in front of views with an empty element container (#33647)
PR Close #33647
2019-11-11 09:37:38 -08:00
Pawel Kozlowski f63e5d9319 fix(ivy): properly determine the first native node of a view (#33627)
PR Close #33627
2019-11-07 16:50:29 -08:00
Pawel Kozlowski c57759f191 test(ivy): tests for view insertion before another view (#33627)
PR Close #33627
2019-11-07 16:50:29 -08:00
Matias Niemelä 71b400eb7b test(ivy): introduce a benchmark for duplicate map-based style/class bindings (#33608)
Prior to this patch all the styling benchmarks only tested for
template map-based style/class bindings. Because of each of the bindings
being only present in the template, there was no possibility of
there being any duplicate map-based styling bindings.

This benchmark introduces benchmarking for map-based style/class bindings
that are evaluated from both template bindings as well as directives.

This benchmark can be executed by calling:

```
bazel build //packages/core/test/render3/perf:duplicate_map_based_style_and_class_bindings_lib.min_debug.es2015.js

node dist/bin/packages/core/test/render3/perf/duplicate_map_based_style_and_class_bindings_lib.min_debug.es2015.js
```

The benchmark is also run via the `profile_all.js` script (found in
`packages/core/test/render3/perf/`)

PR Close #33608
2019-11-07 20:34:26 +00:00
Matias Niemelä 8d72a37f3e test(ivy): introduce a benchmark for duplicate style/class bindings (#33600)
Prior to this patch all the styling benchmarks only tested for
template-based style/class bindings. Because of each of the bindings
being only present in the template, there was no possibility of
there being any duplicate bindings. This benchmark introduces
style/class bindings being evaluated from both a template and from
various directives.

This benchmark can be executed by calling:

```
bazel build //packages/core/test/render3/perf:duplicate_style_and_class_bindings_lib.min_debug.es2015.js

node dist/bin/packages/core/test/render3/perf/duplicate_style_and_class_bindings_lib.min_debug.es2015.js
```

The benchmark is also run via the `profile_all.js` script (found in
`packages/core/test/render3/perf/`)

PR Close #33600
2019-11-07 17:50:33 +00:00
JoostK bca437617f fix(ivy): match directives on namespaced elements (#33555)
Prior to this change, namespaced elements such as SVG elements would not
participate correctly in directive matching as their namespace was not
ignored, which was the case with the View Engine compiler. This led to
incorrect behavior at runtime and template type checking.

This commit resolved the issue by ignoring the namespace of elements and
attributes like they were in View Engine.

Fixes #32061

PR Close #33555
2019-11-07 15:40:50 +00:00
Andrew Scott 1ebe172c2e fix(ivy): Handle overrides for {providedIn: AModule} in R3TestBed (#33606)
This issue was found when debugging a test failure that was using lazy
loaded modules with the router. When doing this, the router calls
`NgModuleFactory.create` for the loaded module. This module gets a new
injector so the overrides provided in TestBed are not applied unless the
Injectable is in the providers list (which is not the case for
{providedIn...} Injectables).

PR Close #33606
2019-11-07 15:34:19 +00:00
Miško Hevery c25503b142 test(ivy): Have more descriptive names for `LView` (#33449)
When debugging `LView`s it is easy to get lost since all of them have
the same name. This change does three things:

1. It makes `TView` have an explicit type:
  - `Host`: for the top level `TView` for bootstrap
  - `Component`: for the `TView` which represents components template
  - `Embedded`: for the `TView` which represents an embedded template
2. It changes the name of `LView` to `LHostView`, `LComponentView`, and
  `LEmbeddedView` depending on the `TView` type.
3. For `LComponentView` and `LEmbeddedView` we also append the name of
  of the `context` constructor. The result is that we have `LView`s which
  are name as: `LComponentView_MyComponent` and `LEmbeddedView_NgIfContext`.

The above changes will make it easier to understand the structure of the
application when debugging.

NOTE: All of these are behind `ngDevMode` and will get removed in
production application.

PR Close #33449
2019-11-07 15:33:50 +00:00
Andrew Kushnir 39550746f8 fix(ivy): better support for i18n attributes on <ng-container>s (#33599)
Prior to this commit, i18n runtime logic used `elementAttributeInternal` function (that uses `setAttribute` function under the hood) for all elements where i18n attributes are present. However the `<ng-container>` elements in a template may also have i18n attributes and calling `setAttribute` fails, since they are represented as comment nodes in DOM. This commit ensures that we call `setAttribute` on nodes with TNodeType.Element type (that support that operation) only.

PR Close #33599
2019-11-07 01:51:42 +00:00
Greg Magolan 1c22e464b2 build: remove deps on legacy nodejs rules rollup_bundle internals (#33201) (#33607)
The legacy nodejs rules rollup_bundle is now deprecated and will be removed in the nodejs rules 1.0 release due in mid-November. This PR brings in the rules_nodejs internal API deps that ng_rollup_bundle, ng_package and ls_rollup_bundle depend on into this repo to break the dependency. In the future these rules should switch to use the new rollup_bundle via a macro as done in https://github.com/angular/angular/pull/33329 but this is not possible right now due to the complication of having esm5 re-rooted ts_library dependencies.

The es6 sources now have .mjs extensions so they no longer need to be re-rooted to `{package}.es6`. This eliminates the need for the collect_es6_sources() function.

Note: repo has been updated to the newest working version of rollup which is 1.25.2. There is some regression in 1.26.0 which causes the following bundling failure:

```
ERROR: /Users/greg/google/angular/packages/localize/BUILD.bazel:20:1: Optimizing JavaScript packages/localize/localize.umd.min.js [terser] failed (Exit 1) terser.sh failed: error executing command bazel-out/host/bin/external/npm/terser/bin/terser.sh bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.js --output bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.min.js ... (remaining 5 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Parse error at packages/localize/localize.umd.js:491,4
    export * from './src/constants';
    ^
ERROR: Export statement may only appear at top level
    at js_error (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/parse.js:357:11)
    at Dn.visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/scope.js:347:13)
    at Dn._visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:1207:24)
    at AST_Export._walk (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:718:17)
    at walk_body (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:168:17)
    at AST_Function.call (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:430:13)
    at descend (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:1208:21)
    at Dn.visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/scope.js:256:13)
    at Dn._visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:1207:24)
    at AST_Function._walk (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:424:24)
[Function]
Target //packages/localize:npm_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /Users/greg/google/angular/packages/localize/BUILD.bazel:20:1 Optimizing JavaScript packages/localize/localize.umd.min.js [terser] failed (Exit 1) terser.sh failed: error executing command bazel-out/host/bin/external/npm/terser/bin/terser.sh bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.js --output bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.min.js ... (remaining 5 argument(s) skipped)
```

Will leave that for another day.

Terser also updated to 4.3.3. Updating to 4.3.4 (https://github.com/terser/terser/blob/master/CHANGELOG.md) turns comments preservation on by default which increases the size of the //packages/core/test/bundling/todo:bundle.min.js in CI. After bazelbuild/rules_nodejs#1317 terser can be updated to the latest as passing —comments /a^/ to args can turn off all comments for the //packages/core/test/bundling/todo:bundle.min.js size test.

PR Close #33201

PR Close #33607
2019-11-06 19:56:57 +00:00
Matias Niemelä 41560b47c4 refactor(ivy): move all styling configurations into `TNodeFlags` (#33540)
This patch gets rid of the configuration settings present in the
`TStylingContext` array that is used within the styling algorithm
for `[style]`, `[style.prop]`, `[class]` and `[class.name]` bindings.
These configurations now all live inside of the `TNodeFlags`.

PR Close #33540
2019-11-06 19:18:36 +00:00
Pawel Kozlowski e89c2dd8d0 perf(ivy): add ngIf-like directive to the ng_template benchmark (#33595)
PR Close #33595
2019-11-06 18:00:48 +00:00
Matias Niemelä 3297a76195 refactor(ivy): remove TStylingContext locking in favor of firstUpdatePass flag (#33521)
This patch removes the need to lock the style and class context
instances to track when bindings can be added. What happens now is
that the `tNode.firstUpdatePass` is used to track when bindings are
registered on the context instances.

PR Close #33521
2019-11-06 16:19:29 +00:00
Matias Niemelä 5453c4cd96 refactor(ivy): use hex flags instead of binary for TNodeFlags (#33605)
PR Close #33605
2019-11-06 16:12:59 +00:00
JiaLiPassion 8c6fb17d29 build: reference zone.js from source directly instead of npm. (#33046)
Close #32482

PR Close #33046
2019-11-06 00:48:34 +00:00
Greg Magolan 3de72e4124 revert: build: remove deps on legacy nodejs rules rollup_bundle internals (#33201) (#33604)
This reverts commit 0addaab270.

PR Close #33604
2019-11-05 22:48:33 +00:00
Paul Gschwendtner d751ca7596 fix(core): renderer-to-renderer2 migration not migrating methods (#33571)
The `renderer-to-renderer2` migration currently does not work
properly in v9 because the migration relies on the type checker
for detecting references to `Renderer` from `@angular/core`.

This is contradictory since the `Renderer` is no longer
exported in v9 `@angular/core`. In order to make sure that
the migration still works in v9, and that we can rely on the
type checker for the best possible detection, we take advantage
of module augmentation and in-memory add the `Renderer` export
to the `@angular/core` module.

PR Close #33571
2019-11-05 22:05:17 +00:00
Paul Gschwendtner c0ad47a3fb fix(core): undecorated-classes-with-di migration should report config errors (#33567)
Currently TypeScript projects with an invalid tsconfig configuration,
cause the undecorated-classes-with-di migration to throw. Instead we
should gracefully exit the migration (like we do for syntactical
diagnostics), but report that there are configuration issues.

This issue surfaced when testing this migration in combination
with the Angular CLI migrations. One of the CLI migrations currently
causes invalid tsconfig files which then cause this issue in the
undecorated-classes-with-di migration.

PR Close #33567
2019-11-05 21:06:47 +00:00
Greg Magolan 0addaab270 build: remove deps on legacy nodejs rules rollup_bundle internals (#33201)
The legacy nodejs rules rollup_bundle is now deprecated and will be removed in the nodejs rules 1.0 release due in mid-November. This PR brings in the rules_nodejs internal API deps that ng_rollup_bundle, ng_package and ls_rollup_bundle depend on into this repo to break the dependency. In the future these rules should switch to use the new rollup_bundle via a macro as done in https://github.com/angular/angular/pull/33329 but this is not possible right now due to the complication of having esm5 re-rooted ts_library dependencies.

The es6 sources now have .mjs extensions so they no longer need to be re-rooted to `{package}.es6`. This eliminates the need for the collect_es6_sources() function.

Note: repo has been updated to the newest working version of rollup which is 1.25.2. There is some regression in 1.26.0 which causes the following bundling failure:

```
ERROR: /Users/greg/google/angular/packages/localize/BUILD.bazel:20:1: Optimizing JavaScript packages/localize/localize.umd.min.js [terser] failed (Exit 1) terser.sh failed: error executing command bazel-out/host/bin/external/npm/terser/bin/terser.sh bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.js --output bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.min.js ... (remaining 5 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Parse error at packages/localize/localize.umd.js:491,4
    export * from './src/constants';
    ^
ERROR: Export statement may only appear at top level
    at js_error (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/parse.js:357:11)
    at Dn.visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/scope.js:347:13)
    at Dn._visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:1207:24)
    at AST_Export._walk (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:718:17)
    at walk_body (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:168:17)
    at AST_Function.call (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:430:13)
    at descend (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:1208:21)
    at Dn.visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/scope.js:256:13)
    at Dn._visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:1207:24)
    at AST_Function._walk (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:424:24)
[Function]
Target //packages/localize:npm_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /Users/greg/google/angular/packages/localize/BUILD.bazel:20:1 Optimizing JavaScript packages/localize/localize.umd.min.js [terser] failed (Exit 1) terser.sh failed: error executing command bazel-out/host/bin/external/npm/terser/bin/terser.sh bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.js --output bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.min.js ... (remaining 5 argument(s) skipped)
```

Will leave that for another day.

Terser also updated to 4.3.3. Updating to 4.3.4 (https://github.com/terser/terser/blob/master/CHANGELOG.md) turns comments preservation on by default which increases the size of the //packages/core/test/bundling/todo:bundle.min.js in CI. After bazelbuild/rules_nodejs#1317 terser can be updated to the latest as passing —comments /a^/ to args can turn off all comments for the //packages/core/test/bundling/todo:bundle.min.js size test.

PR Close #33201
2019-11-05 20:55:54 +00:00
JiaLiPassion 44623a1161 feat: add a flag in bootstrap to enable coalesce event change detection to improve performance (#30533)
PR Close #30533
2019-11-05 18:58:25 +00:00
Pete Bacon Darwin c5894e08bc feat(common): support loading locales from a global (#33523)
To support compile time localization, we need to be
able to provide the locales via a well known global property.

This commit changes `getLocaleData()` so that it will attempt
to read the local from the global `ng.common.locales` if the
locale has not already been registered via `registerLocaleData()`.

PR Close #33523
2019-11-05 17:27:00 +00:00
Pete Bacon Darwin 7e8eec57f0 refactor(common): move the low level locale registering to core (#33523)
To limit the exposure of the private `LOCALE_DATA` from outside
`@angular/core` this commit exposes private functions in the core
to hide the internal structures better.

* The `registerLocaleData()` implementation has moved from
`@angular/common` to `@angular/core`. A stub that delegates to
core has been left in common for backward compatibility.
* A new `ɵunregisterLocaleData()` function has been provided,
which is particularly useful in tests to clear out registered locales
to prevent subsequent tests from being affected.
* A private export of `ɵregisterLocaleData()` has been removed
from `@angular/common`. This was not being used and is accessible
via `@angular/core` anyway.

PR Close #33523
2019-11-05 17:26:59 +00:00
Matias Niemelä 9c13d6e8e6 refactor(ivy): rename `tView.firstTemplatePass` to `tView.firstCreatePass` (#31270)
PR Close #31270
2019-11-04 21:39:23 +00:00
Matias Niemelä 91147ade2e refactor(ivy): introduce a `firstUpdatePass` flag for `TView` instances (#31270)
This patch introduces a `firstUpdatePass` flag which can be used inside
of instruction code to determine if this is the first time each
instruction is running inside of the update block of a template or
a hostBindings function.

PR Close #31270
2019-11-04 21:39:22 +00:00
Pawel Kozlowski 4ff43e1324 refactor(ivy): remove the getHostNative utility function (#33554)
We already store a reference to a native host of a component
view so we can drop the getHostNative utility function (that
was getting the same reference from another data structure).

PR Close #33554
2019-11-04 20:07:06 +00:00
crisbeto 66725b7b37 perf(ivy): move local references into consts array (#33129)
Follow-up from #32798. Moves the local references array into the component def's `consts` in order to make it compress better.

Before:
```
const _c0 = ['foo', ''];

SomeComp.ngComponentDef = defineComponent({
  template: function() {
    element(0, 'div', null, _c0);
  }
});
```

After:
```
SomeComp.ngComponentDef = defineComponent({
  consts: [['foo', '']],
  template: function() {
    element(0, 'div', null, 0);
  }
});
```

PR Close #33129
2019-11-04 16:30:53 +00:00
Michael Prentice 5437e2da29 refactor(core): typo in undecorated-classes-with-di AOT failure message (#33018)
PR Close #33018
2019-11-04 16:07:26 +00:00
crisbeto c83f5013bf feat(ivy): implement unknown element detection in jit mode (#33419)
In ViewEngine we used to throw an error if we encountered an unknown element while rendering. We have this already for Ivy in AoT, but we didn't in JiT. These changes implement the error for JiT mode.

PR Close #33419
2019-11-04 15:59:10 +00:00
Matias Niemelä f02213a661 build: restore functionality of the micro benchmarks `profile_all.js` script (#33494)
The 4b81bb5c97 patch seemingly broke the
`profile_all.js` file due to the file renaming. This patch restores the
functionality of said script.

PR Close #33494
2019-11-01 17:47:49 +00:00
Pawel Kozlowski 083d48e072 perf(ivy): avoid native node retrieval from LView (#33511)
PR Close #33511
2019-10-31 22:53:29 +00:00
Pawel Kozlowski df1bef31a4 perf(ivy): add new benchmark focused on template creation (#33511)
PR Close #33511
2019-10-31 22:53:29 +00:00
Pawel Kozlowski 4452d6d848 perf(ivy): avoid repeated tNode.initialInputs reads (#33322)
PR Close #33322
2019-10-31 22:46:50 +00:00
Pawel Kozlowski 41caafcaf2 perf(ivy): avoid repeated native node retrieval and patching (#33322)
Before this change instantiating multiple directives on the same
host node would result in repeated RNode retrieval and patching.
This commint re-organises code around directive instance creation
so the host node processing (common to all directives) happens
once and only once.

As the additional benefit the directive instantiation logic gets
centralised in one function (at the expense of patching logic
duplication for root node).

PR Close #33322
2019-10-31 22:46:50 +00:00
Pawel Kozlowski 2c208f98a9 refactor(ivy): in-line postProcessDirective to avoid repeated isComponentDef checks (#33322)
PR Close #33322
2019-10-31 22:46:50 +00:00
Pawel Kozlowski 3ff712a0f5 refactor(ivy): correct typings in instantiateAllDirectives (#33322)
PR Close #33322
2019-10-31 22:46:49 +00:00
Pawel Kozlowski 300d7ca6da test(ivy): remove code duplication from the EmbeddedView.rootNodes tests (#33493)
PR Close #33493
2019-10-30 11:46:09 -07:00
Pawel Kozlowski 563a507315 fix(ivy): descend into ICU containers when collecting rootNodes (#33493)
PR Close #33493
2019-10-30 11:46:09 -07:00
Pawel Kozlowski a5167bd53c fix(ivy): descend into view containers on ng-container when collecting rootNodes (#33493)
PR Close #33493
2019-10-30 11:46:09 -07:00
Pawel Kozlowski 87743f1aa1 fix(ivy): descend into view containers on elements when collecting rootNodes (#33493)
PR Close #33493
2019-10-30 11:46:09 -07:00
Pawel Kozlowski 502fb7e307 fix(ivy): descend into view containers on ng-template when collecting rootNodes (#33493)
PR Close #33493
2019-10-30 11:46:09 -07:00
Paul Gschwendtner f197191a5f refactor(core): better error message for undecorated-classes-with-di migration (#33315)
Currently if one of the project targets could not be analyzed
due to AOT compiler program failures, we gracefully proceed
with the migration. This is expected, but we should not
print a message at the end of the migration that the migration
was _successful_. The migration was only done partially, hence
it's potentially incomplete and we should make it clear that once
the failures are resolved, the migration should be re-run.

PR Close #33315
2019-10-30 11:31:09 -07:00
crisbeto c3e93564d0 perf(ivy): avoid generating selectors array for directives without a selector (#33431)
Now that we've replaced `ngBaseDef` with an abstract directive definition, there are a lot more cases where we generate a directive definition without a selector. These changes make it so that we don't generate the `selectors` array if it's going to be empty.

PR Close #33431
2019-10-29 12:06:15 -07:00
Andrew Kushnir bd40c89688 fix(ivy): handle elements with local refs in i18n blocks (#33415)
Prior to this commit, i18n logic which ensures that elements removed in a translation are also removed in DOM, didn't take into account the fact that elements may have local refs. As a result, remove operation failed, since there is no corresponding tNode found. This commit updates the logic to skip all local refs while going though the list of nodes to ensure that DOM matches elements present in translation.

PR Close #33415
2019-10-29 11:47:28 -07:00
Alan Agius 8b5ca670ad refactor(core): update migrations descriptions (#33440)
With the next version of the CLI we don't need to add logging for the description of the schematic as part of the schematic itself.

This is because now, the CLI will print the description defined in the `migrations.json` file.

See: https://github.com/angular/angular-cli/pull/15951

PR Close #33440
2019-10-28 17:07:50 -07:00
Andrew Scott e483acaa17 fix(ivy): ensure overrides for 'multi: true' only appear once in final providers (#33104)
PR Close #33104
2019-10-28 11:00:31 -07:00
Miško Hevery e16f75db56 refactor(ivy): move `bindingIndex` from `LView` to `LFrame` (#33235)
`bindingIndex` stores the current location of the bindings in the
template function. Because it used to be stored in `LView` that `LView`
was not reentrant. This could happen if a binding was a getter and had
a side-effect of calling `detectChanges()`.

By moving the `bindingIndex` to `LFrame` where all of the global state
is kept in reentrant way we correct the issue.

PR Close #33235
2019-10-28 10:59:29 -07:00
Miško Hevery 7a280b1a21 test(ivy): clean up class_binding perf tests for readability (#33413)
PR Close #33413
2019-10-25 15:18:07 -07:00
Matias Niemelä 5607ad8c62 perf(ivy): apply static styles/classes directly to an element's style/className properties (#33364)
PR Close #33364
2019-10-25 13:56:27 -07:00
Paul Gschwendtner 335854f6bc fix(core): missing-injectable migration should not update type definitions (#33286)
Currently the `missing-injectable` migration seems to add
`@Injectable()` to third-party classes in type definitions.

This not an issue in general since we do not generate broken code
by inserting a decorator into a type definition file. Though, we can
avoid adding the decorator since it won't have any effect and in
general we should not write to non source files of the compilation unit.

PR Close #33286
2019-10-25 13:26:00 -07:00
Paul Gschwendtner 4d23b60d09 fix(core): missing-injectable migration should not migrate providers with "useExisting" (#33286)
We should not migrate the reference from `useExisting`. This is because
developers can only use the `useExisting` value as a token. e.g.

```ts
@NgModule({
  providers: [
    {provide: AppRippleConfig, useValue: rippleOptions},
    {provide: MAT_RIPPLE_OPTIONS, useExisting: AppRippleConfig},
  ]
})
export class AppModule {}
```

In the case above, nothing should be decorated with `@Injectable`. The
`AppRippleConfig` class is just used as a token for injection.

PR Close #33286
2019-10-25 13:26:00 -07:00
Paul Gschwendtner eeecbf28e4 fix(core): missing-injectable migration should handle forwardRef (#33286)
Currently the migration is unable to migrate instances where
the provider definition uses `forwardRef`. Since this is a
common pattern, we should support that from within the migration.

The solution to the problem is adding a foreign function resolver
to the `PartialEvaluator`. This basically matches the usage of
the static evaluation that is used by the ngtsc annotations.

PR Close #33286
2019-10-25 13:26:00 -07:00
Igor Minar 4b81bb5c97 build: add ng_benchmark macro to run perf benchmarks (#33389)
this makes running and profiling tests much easier. Example usage:

```
yarn bazel run --define=compile=aot //packages/core/test/render3/perf:noop_change_detection
```

See README.md update for more info.

PS: I considered moving the ng_rollup bundle into the macro but I didn't want to make
  too many changes in this PR. If we find running benchmarks in this way useful, we
  should refactor the build file more, and move the ng_rollup_bundle targets into the
  macro.

PR Close #33389
2019-10-25 13:13:32 -07:00
crisbeto 14c4b1b205 refactor(ivy): remove ngBaseDef (#33264)
Removes `ngBaseDef` from the compiler and any runtime code that was still referring to it. In the cases where we'd previously generate a base def we now generate a definition for an abstract directive.

PR Close #33264
2019-10-25 13:11:34 -07:00
JoostK 8d15bfa6ee fix(ivy): allow abstract directives to have an invalid constructor (#32987)
For abstract directives, i.e. directives without a selector, it may
happen that their constructor is called explicitly from a subclass,
hence its parameters are not required to be valid for Angular's DI
purposes. Prior to this commit however, having an abstract directive
with a constructor that has parameters that are not eligible for
Angular's DI would produce a compilation error.

A similar scenario may occur for `@Injectable`s, where an explicit
`use*` definition allows for the constructor to be irrelevant. For
example, the situation where `useFactory` is specified allows for the
constructor to be called explicitly with any value, so its constructor
parameters are not required to be valid. For `@Injectable`s this is
handled by generating a DI factory function that throws.

This commit implements the same solution for abstract directives, such
that a compilation error is avoided while still producing an error at
runtime if the type is instantiated implicitly by Angular's DI
mechanism.

Fixes #32981

PR Close #32987
2019-10-25 12:13:23 -07:00
Misko Hevery 6323a35468 test(ivy): support `className` in micro benchmarks (#33392)
The styling algorithm requires that the `RNode` has a `className`
property in order to execute the fast-path. This changes adds the
emulation of this property.

PR Close #33392
2019-10-25 09:17:52 -07:00
Alex Rickabaugh 818c514968 feat(ivy): add a runtime feature to copy cmp/dir definitions (#33362)
This commit adds CopyDefinitionFeature, which supports the case where an
entire decorator (@Component or @Directive) is inherited from parent to
child.

The existing inheritance feature, InheritDefinitionFeature, supports merging
of parent and child definitions when both were originally present. This
merges things like inputs, outputs, host bindings, etc.

CopyDefinitionFeature, on the other hand, compensates for a definition that
was missing entirely on the child class, by copying fields that aren't
ordinarily inherited (like the template function itself).

This feature is intended to only be used as part of ngcc code generation.

PR Close #33362
2019-10-25 09:16:50 -07:00
Matias Niemelä dcdb433b7d perf(ivy): apply [style]/[class] bindings directly to style/className (#33336)
This patch ensures that the `[style]` and `[class]` based bindings
are directly applied to an element's style and className attributes.

This patch optimizes the algorithm so that it...
- Doesn't construct an update an instance of `StylingMapArray` for
  `[style]` and `[class]` bindings
- Doesn't apply `[style]` and `[class]` based entries using
  `classList` and `style` (direct attributes are used instead)
- Doesn't split or iterate over all string-based tokens in a
  string value obtained from a `[class]` binding.

This patch speeds up the following cases:
- `<div [class]>` and `<div class="..." [class]>`
- `<div [style]>` and `<div style="..." [style]>`

The overall speec increase is by over 5x.

PR Close #33336
2019-10-24 17:42:46 -07:00
Miško Hevery 3f195fefa9 test(ivy): improve microbenchmark reporting progress (#33386)
PR Close #33386
2019-10-24 17:00:45 -07:00
Kara Erickson a17cc9beee refactor(core): add links to remaining migration guides (#33385)
PR Close #33385
2019-10-24 16:21:49 -07:00
Miško Hevery 09a2bb839f refactor(ivy): Intruduce LFrame to store global instruction information (#33178)
`LFrame` stores information specifice to the current `LView` As the code
enters and leaves `LView`s we use `enterView()` and `leaveView()`
respectively to build a a stack of `LFrame`s. This allows us to easily
restore the previous `LView` instruction state.

PR Close #33178
2019-10-24 14:42:15 -07:00
Miško Hevery 9ea3430a5b style: correct comments (#33178)
PR Close #33178
2019-10-24 14:42:15 -07:00
Misko Hevery b00189bb9a test(core): support running performance benchmarks in browser (#33340)
PR Close #33340
2019-10-24 14:07:25 -07:00
JoostK a42057d0f8 fix(ivy): support abstract directives in template type checking (#33131)
Recently it was made possible to have a directive without selector,
which are referred to as abstract directives. Such directives should not
be registered in an NgModule, but can still contain decorators for
inputs, outputs, queries, etc. The information from these decorators and
the `@Directive()` decorator itself needs to be registered with the
central `MetadataRegistry` so that other areas of the compiler can
request information about a given directive, an example of which is the
template type checker that needs to know about the inputs and outputs of
directives.

Prior to this change, however, abstract directives would only register
themselves with the `MetadataRegistry` as being an abstract directive,
without all of its other metadata like inputs and outputs. This meant
that the template type checker was unable to resolve the inputs and
outputs of these abstract directives, therefore failing to check them
correctly. The typical error would be that some property does not exist
on a DOM element, whereas said property should have been bound to the
abstract directive's input.

This commit fixes the problem by always registering the metadata of a
directive or component with the `MetadataRegistry`. Tests have been
added to ensure abstract directives are handled correctly in the
template type checker, together with tests to verify the form of
abstract directives in declaration files.

Fixes #30080

PR Close #33131
2019-10-24 12:44:30 -07:00
Misko Hevery 9a5e08f2a7 test(ivy): add styling [class] benchmarks (#33375)
PR Close #33375
2019-10-24 11:13:32 -07:00
Pete Bacon Darwin fde8363e0d feat(ivy): allow the locale to be set via a global property (#33314)
In the post-$localize world the current locale value is defined by setting
`$localize.locale` which is then read at runtime by Angular in the provider
for the `LOCALE_ID` token and also passed to the ivy machinery via`setLocaleId()`.

The $localize compile-time inlining tooling can replace occurrences of
`$localize.locale` with a string literal, similar to how translations
are inlined.

// FW-1639

See https://github.com/angular/angular-cli/issues/15896

PR Close #33314
2019-10-24 10:16:25 -07:00
Misko Hevery a1d7b6bb86 test(ivy): fined tune micro benchmark parameters (#33341)
Decrease `MIN_SAMPLE_DURATION` to make it more likely that we cane fit into single time slice.
Increase `MIN_SAMPLE_COUNT_NO_IMPROVEMENT` to make it more likely to find the best

PR Close #33341
2019-10-23 16:40:51 -07:00
Misko Hevery d40ee6a259 perf(ivy): improve styling performance (#33326)
change the existing implementation from using

```
string.split(/\s+/);
```

to a char scan which performers the same thing.

The reason why `split(/\s+/)` is slow is that:
- `/\s+/` allocates new `RegExp` every time this code executes.
- `RegExp` scans are a lot more expensive because they are more powerful.

PR Close #33326
2019-10-23 16:40:12 -07:00
Miško Hevery bd89626e2e test(ivy): add instructions for deoptigate (#33357)
PR Close #33357
2019-10-23 09:56:42 -07:00
Kapunahele Wong 398ff1e7e7 docs: add ModuleWithProviders deprecation (#33266)
PR Close #33266
2019-10-22 14:35:27 -07:00
Miško Hevery 5632424d04 refactor(ivy): ViewRef needs embededViewRef declaration (#33074)
PR Close #33074
2019-10-22 12:00:21 -07:00
Miško Hevery f1ffd57105 refactor(ivy): rename `getComponentViewByIndex` to `getComponentLViewByIndex` (#33074)
PR Close #33074
2019-10-22 12:00:20 -07:00
Adam Plumer 56731f624a feat(core): add ModuleWithProviders generic type migration (#33217)
Static methods that return a type of ModuleWithProviders currently
do not have to specify a type because the generic falls back to any.
This is problematic because the type of the actual module being
returned is not present in the type information.

Since Ivy uses d.ts files exclusively for downstream packages
(rather than metadata.json files, for example), we no longer have
the type of the actual module being created.

For this reason, a generic type should be added for
ModuleWithProviders that specifies the module type. This will be
required for all users in v10, but will only be necessary for
users of Ivy in v9.

PR Close #33217
2019-10-21 15:53:28 -04:00
Matias Niemelä 29bc3a775f build: fix internal Google closure issue with TS3.6 (#33257)
This patch fixes an internal Google issue that came up with the TS3.6
patch that landed earlier (go/b/142967802).

PR Close #33257
2019-10-18 19:48:03 -04:00
Kara Erickson f289411fa9 docs(core): add migration guide links to schematics (#33258)
Angular v9 schematics should print out a link to the migration
guide associated with each schematic. This way, users have an
easy way to find more information about the automatic code
transformations they will see with `ng update`.

PR Close #33258
2019-10-18 18:18:37 -04:00
crisbeto 1799f621b7 refactor(core): deprecate entryComponents (#33205)
With Ivy the `entryComponents` array isn't necessary anymore. These changes mark it as deprecated so that it can be removed in a future version.

PR Close #33205
2019-10-18 16:29:23 -04:00
JoostK 6958d11d95 feat(ivy): type checking of event bindings (#33125)
Until now, the template type checker has not checked any of the event
bindings that could be present on an element, for example

```
<my-cmp
  (changed)="handleChange($event)"
  (click)="handleClick($event)"></my-cmp>
```

has two event bindings: the `change` event corresponding with an
`@Output()` on the `my-cmp` component and the `click` DOM event.

This commit adds functionality to the template type checker in order to
type check both kind of event bindings. This means that the correctness
of the bindings expressions, as well as the type of the `$event`
variable will now be taken into account during template type checking.

Resolves FW-1598

PR Close #33125
2019-10-18 14:41:53 -04:00
Igor Minar 86e1e6c082 feat: typescript 3.6 support (#32946)
BREAKING CHANGE: typescript 3.4 and 3.5 are no longer supported, please update to typescript 3.6

Fixes #32380

PR Close #32946
2019-10-18 13:15:16 -04:00
vikerman 5dfbcd5631 fix(core): add CLI instructions when localize polyfill is missing (#33199)
PR Close #33199
2019-10-17 19:45:27 -04:00
Matias Niemelä 7b64680670 fix(ivy): ensure map-based interpolation works with other map-based sources (#33236)
Prior to this fix if a map-based class or style binding wrote
its values onto an elemenent, the internal styling context would
not register the binding if the initial value as a `NO_CHANGE`
value. This situation occurs if a directive takes control of the
`class` or `style` input values and then returns a `NO_CHANGE` value
if the initial value is empty.

This patch ensures that all bindings are always registered with the
`TStylingContext` data-structure even if their initial value is
an instance of `NO_CHANGE`.

PR Close #33236
2019-10-17 18:24:10 -04:00
Matias Niemelä f45c43188f fix(ivy): ensure errors are thrown during checkNoChanges for style/class bindings (#33103)
Prior to this fix, all style/class bindings (e.g. `[style]` and
`[class.foo]`) would quietly update a binding value if and when the
current binding value changes during checkNoChanges.

With this patch, all styling instructions will properly check to see
if the value has changed during the second pass of detectChanges()
if checkNoChanges is active.

PR Close #33103
2019-10-17 16:46:49 -04:00
crisbeto 9d54679e66 test: clean up explicit dynamic query usages (#33015)
Cleans up all the places where we explicitly set `static: false` on queries.

PR Close #33015
2019-10-17 16:10:10 -04:00
Andrew Kushnir 7e64bbe5a8 fix(ivy): use container i18n meta if a message is a single ICU (#33191)
Prior to this commit, metadata defined on ICU container element was not inherited by the ICU if the whole message is a single ICU (for example: `<ng-container i18n="meaning|description@@id">{count, select, ...}</ng-container>). This commit updates the logic to use parent container i18n meta information for the cases when a message consists of a single ICU.

Fixes #33171

PR Close #33191
2019-10-17 16:07:07 -04:00
Kara Erickson 1a8bd22fa3 refactor(core): rename ngLocaleIdDef to ɵloc (#33212)
LocaleID defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngLocaleIdDef to loc. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

PR Close #33212
2019-10-17 16:06:16 -04:00
Miško Hevery bb53b6549c refactor(ivy): move all of the instruction state into a singe object (#33093)
Turns out that writing to global state is more expensive than writing to
a property on an object.

Slower:
````
let count = 0;

function increment() {
  count++;
}
```

Faster:
````
const state = {
  count: 0
};

function increment() {
  state.count++;
}
```

This change moves all of the instruction state into a single state object.

`noop_change_detection` benchmark
Pre refactoring: 16.7 us
Post refactoring: 14.523 us (-13.3%)

PR Close #33093
2019-10-17 16:00:55 -04:00
Andrew Kushnir 6f203c9575 fix(ivy): handling className as an input properly (#33188)
Prior to this commit, all `className` inputs were not set because the runtime code assumed that the `classMap` instruction is only generated for `[class]` bindings. However the `[className]` binding also produces the same `classMap`, thus the code needs to distinguish between `class` and `className`. This commit adds extra logic to select the right input name and also throws an error in case `[class]` and `[className]` bindings are used on the same element simultaneously.

PR Close #33188
2019-10-17 14:16:02 -04:00
Miško Hevery 4800fa1c08 refactor(core): tweek micro-benchmarks to make them more consistent (#33207)
```
┌────────────────────────────────────┬─────────┬──────┬───────────┬───────────┬───────┐
│              (index)               │  time   │ unit │ base_time │ base_unit │   %   │
├────────────────────────────────────┼─────────┼──────┼───────────┼───────────┼───────┤
│       directive_instantiate        │  2.474  │ 'us' │   2.507   │   'us'    │ -1.32 │
│        element_text_create         │  1.313  │ 'us' │   1.319   │   'us'    │ -0.45 │
│           interpolation            │ 220.17  │ 'us' │  224.217  │   'us'    │ -1.8  │
│             listeners              │  1.988  │ 'us' │   2.021   │   'us'    │ -1.63 │
│ map_based_style_and_class_bindings │ 17.908  │ 'ms' │  18.523   │   'ms'    │ -3.32 │
│       noop_change_detection        │ 24.851  │ 'us' │  24.874   │   'us'    │ -0.09 │
│          property_binding          │ 218.76  │ 'us' │  216.736  │   'us'    │ 0.93  │
│      property_binding_update       │ 443.175 │ 'us' │  447.686  │   'us'    │ -1.01 │
│      style_and_class_bindings      │  1.053  │ 'ms' │   1.069   │   'ms'    │ -1.5  │
│           style_binding            │ 488.154 │ 'us' │  484.092  │   'us'    │ 0.84  │
└────────────────────────────────────┴─────────┴──────┴───────────┴───────────┴───────┘
```

PR Close #33207
2019-10-17 14:13:16 -04:00
Matias Niemelä 082aed6e46 revert: feat: add a flag in bootstrap to enable coalesce event change detection to improve performance (#30533) (#33230)
This reverts commit 21c1e14385.

PR Close #33230
2019-10-17 12:50:04 -04:00
Matias Niemelä 724707c6e4 feat(ivy): improve debugging experience for styles/classes (#33179)
This patch introduces the `printTable()` and `printSources()`
methods to `DebugStylingContext` which can be used via the
`window.ng.getDebugNode` helpers when debugging an application.

PR Close #33179
2019-10-17 00:35:17 -04:00
Kara Erickson 86104b82b8 refactor(core): rename ngInjectableDef to ɵprov (#33151)
Injectable defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngInjectableDef to "prov" (for "provider", since injector defs
are known as "inj"). This is because property names cannot
be minified by Uglify without turning on property mangling
(which most apps have turned off) and are thus size-sensitive.

PR Close #33151
2019-10-16 16:36:19 -04:00
Kara Erickson cda9248b33 refactor(core): rename ngInjectorDef to ɵinj (#33151)
Injector defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngInjectorDef to inj. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

PR Close #33151
2019-10-16 16:36:19 -04:00
Pawel Kozlowski 3e14c2d02c perf(ivy): limit global state read / write in host bindings (#33195)
PR Close #33195
2019-10-16 14:54:06 -04:00
Pawel Kozlowski aef7dca234 perf(ivy): initialise inputs from static attrs on the first template pass only (#33195)
This change assures that data structures related to initial inputs
(ones set from static attributes) are created only once (during the
first template pass) and no additional runtime checks are done for
subsequent passes.

Additionally this commit changes the data structure used by initial inputs
on TNode - previously initial inputs for a directive were stored at the
directive index in LView. This meant that an array holding initial inputs
was relativelly big and had many null elements (as placeholders for elements,
directives, injector etc.). After the change we only create an array of a size
equal to a number of directives matched on a given TNode.
For the `directive_instantiate` benchmark it boils to allocating a 1-element
array vs. 100-element array previously.

PR Close #33195
2019-10-16 14:54:06 -04:00
JiaLiPassion 21c1e14385 feat: add a flag in bootstrap to enable coalesce event change detection to improve performance (#30533)
PR Close #30533
2019-10-16 14:38:36 -04:00
Miško Hevery d3f3d9b4cb test: Add script which allows running all of the profiling tests and compare results (#33186)
PR Close #33186
2019-10-16 10:22:30 -04:00
Andrew Kushnir 11e04b1892 fix(ivy): avoid DOM element assertions if procedural renderer is used (#33156)
Prior to this commit, Ivy runtime asserted that a given element is an instance of a DOM node. These asserts may not be correct in case custom renderer is used, which operates objects with a shape different than DOM nodes. This commit updates the code to avoid the mentioned checks in case procedural renderer is used.

PR Close #33156
2019-10-15 21:03:29 +00:00
Filipe Silva 30d25f67af feat(core): add postinstall ngcc migration (#32999)
PR Close #32999
2019-10-15 17:54:38 +00:00
Matias Niemelä 1cda80eb3a fix(ivy): ensure sanitizer is not used when direct class application occurs (#33154)
Prior to this patch, if a map-class binding is applied directly then
that value will be incorrectly provided a sanitizer even if there is no
sanitization present for an element.

PR Close #33154
2019-10-15 16:50:43 +00:00