Commit Graph

15571 Commits

Author SHA1 Message Date
Pete Bacon Darwin 2cdb3a079d feat(ivy): i18n - implement compile-time inlining (#32881)
This commit implements a tool that will inline translations and generate
a translated copy of a set of application files from a set of translation
files.

PR Close #32881
2019-10-09 13:19:38 -07:00
crisbeto d5b87d32b0 perf(ivy): move attributes array into component def (#32798)
Currently Ivy stores the element attributes into an array above the component def and passes it into the relevant instructions, however the problem is that upon minification the array will get a unique name which won't compress very well. These changes move the attributes array into the component def and pass in the index into the instructions instead.

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

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

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

A couple of cases that this PR doesn't handle:
* Template references are still in a separate array.
* i18n attributes are still in a separate array.

PR Close #32798
2019-10-09 13:16:55 -07:00
Pete Bacon Darwin b2b917d2d8 feat(ngcc): expose `--create-ivy-entry-points` option on ivy-ngcc (#33049)
This allows a postinstall hook to generate the same
output as the CLI integration does.

See https://github.com/angular/angular/pull/32999#issuecomment-539937368

PR Close #33049
2019-10-09 13:16:16 -07:00
Pawel Kozlowski 9f0c549bc8 perf(ivy): avoid memory allocation in the isAnimationProp check (#32997)
Accessing a string's character at index allocates a new, single character string.
A better (faster) check is to use `charCodeAt` that doesn't trigger allocation.

This simple change speeds up the element_text_create benchmark by ~7%.

PR Close #32997
2019-10-08 13:02:11 -07:00
Pawel Kozlowski affae99b22 perf(ivy): add static attributes to the element_text_create benchmark (#32997)
PR Close #32997
2019-10-08 13:02:11 -07:00
Alex Rickabaugh ed711418f1 style(bazel): fix 2 unformatted .bzl files 2019-10-08 10:45:48 -07:00
Alex Eagle c653a16b57 build: load build_bazel_rules_nodejs through external (#33041)
PR Close #33041
2019-10-08 10:24:41 -07:00
Greg Magolan 64823f561c build: add history-server to @angular/bazel schematics (#32889)
The history_server rule is not longer shipped with rules_nodejs as it has been replaced by auto-generated rule `load("@npm//history-server:index.bzl", "history_server")` which requires the user to add history-server to their package.json.

PR Close #32889
2019-10-08 09:27:11 -07:00
Greg Magolan e1d07b2fd2 build: add JSEcmaScripModuleInfo provider to ng_module (#32889)
PR Close #32889
2019-10-08 09:27:11 -07:00
Alex Eagle cdfbda3d3b build: add missing http-server dep to bazel example (#32889)
Also update rules_nodejs 0.38.0->0.38.1

PR Close #32889
2019-10-08 09:27:11 -07:00
Paul Gschwendtner 78ada980a6 ci: avoid postinstall error when building material-unit-tests job (#32889)
The components repository updated to rules_nodejs#0.38.0 before Angular Bazel did.
To do this, the `@angular/bazel` v0.38.0 compatibility changes were patched on postinstall.

This now conflicts because we install a `@angular/bazel` version in the `material-unit-tests` job
that already includes these compatibility changes. This would result in the patch being a noop
for which the `patch` command throws an error.

We can remove this once components can install a released version of `@angular/bazel` that is
compatible with `rules_nodejs#0.38.0`.

PR Close #32889
2019-10-08 09:27:11 -07:00
Paul Gschwendtner 3830f6fc14 ci: update material-unit-test commit (#32889)
Updates the `material-unit-test` job to run tests against
the latest commit of the Angular Components repository.

We need to update to a version where components already
updated to `rules_nodejs#0.38.0`.

PR Close #32889
2019-10-08 09:27:11 -07:00
Alex Eagle f783244ad1 build: update to rules_nodejs 0.38 (#32889)
PR Close #32889
2019-10-08 09:27:11 -07:00
crisbeto 2265cb5938 refactor(core): remove deprecated Renderer (#33019)
Removes the `Renderer` and related symbols which have been deprecated since version 4.

BREAKING CHANGES:
* `Renderer` has been removed. Use `Renderer2` instead.
* `RenderComponentType` has been removed. Use `RendererType2` instead.
* `RootRenderer` has been removed. Use `RendererFactory2` instead.

PR Close #33019
2019-10-08 09:23:00 -07:00
Danny Skoog c507dda21a docs: correct sentence in AoT compiler guide (#33020)
PR Close #33020
2019-10-07 13:13:57 -07:00
Koala 40d87dd801 docs: fix accessibility lint rules (#32661)
Add and fix accessibility rules, bump codelyzer to support pseudo events
for template-click-events-have-key-events rule.

PR Close #32661
2019-10-07 11:22:48 -07:00
Santosh Yadav 0ce8621196 docs: add dotnettricks to training (#32771)
PR Close #32771
2019-10-07 11:03:03 -07:00
Atef Ben Ali 2089727db9 docs: add missing parenthesis (#31041)
PR Close #31041
2019-10-07 11:02:33 -07:00
Paul Gschwendtner c1bb88603e fix(common): expand type for "ngForOf" input to work with strict null checks (#31371)
Currently the `ngForOf` input accepts `null` or `undefined` as valid
values. Although when using strict template input type checking
(which will be supported by `ngtsc`), passing `null` or `undefined`
with strict null checks enabled causes a type check failure because
the type for the `ngForOf` input becomes too strict if strict null checks
are enabled. The type of the input needs to be expanded to also accept
`null` or `undefined` to behave consistently regardless of the
`strictNullChecks` flag.

This is necessary because whenever strict input type checking is enabled
by default, most of the Angular projects that use `*ngFor` with the async pipe
will either need to disable template type checking or strict null checks
because the `async` pipe returns `null` if the observable hasn't been
emitted yet.

See for example how this affects the `angular/components` repository and
how much bloat the workaround involves: https://github.com/angular/components/pull/16373/files#r296942696.

PR Close #31371
2019-10-07 11:01:22 -07:00
LASLEDJ fee28e20bb feat(forms): formGroupName and formArrayName also accepts a number (#32607)
For consistency, `FormGroupName` and `FormaArrayName` also accepts a
number as input's type like `FormControlName`

Closes https://github.com/angular/angular/issues/32436

PR Close #32607
2019-10-07 11:00:49 -07:00
Kristiyan Kostadinov 3efb060127 fix(ivy): unable to bind style zero (#32994)
Fixes not being able to bind zero as a value in style bindings.

Fixes #32984.

PR Close #32994
2019-10-07 11:00:19 -07:00
JoostK c61e4d7841 fix(ivy): process nested animation metadata (#32818)
In View Engine, animation metadata could occur in nested arrays which
would be flattened in the compiler. When compiling a component for Ivy
however, the compiler no longer statically evaluates a component's
animation metadata and is therefore unable to flatten it statically.
This resulted in an issue to find animations at runtime, as the metadata
was incorrectly registered with the animation engine.

Although it would be possible to statically evaluate the animation
metadata in ngtsc, doing so would prevent reusable animations exported
from libraries from being usable as ngtsc's partial evaluator is unable
to read values inside libraries. This is unlike ngc's usage of static
symbols represented in a library's `.metadata.json`, which explains how
the View Engine compiler is able to flatten the animation metadata
statically.

As an alternative solution, the metadata flattening is now done in the
runtime during the registration of the animation metadata with the
animation engine.

Fixes #32794

PR Close #32818
2019-10-07 10:51:37 -07:00
Santosh Yadav 393398e6f5 build(docs-infra): update in-memory-we-api and karma-jasmine-html-reporter version (#32892)
The `karma-jasmine-html-reporter` update also includes a fix for
taras42/karma-jasmine-html-reporter#31.

Fixes #29802

PR Close #32892
2019-10-07 10:51:19 -07:00
George Kalpakas e007918e35 refactor(forms): refactor `Validators.email()` regexp for easier comparison with WHATWG version (#32961)
As mentioned in the previous commit, the regexp used by
`Validators.email()` is a slightly enhanced version of the
[WHATWG one](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address).

This commit refactors the regexp (without changing its behavior) to make
it more closely match the format of WHATWG version, so that it is easier
for people to compare it against the WHATWG one and understand the
differences.

The main changes were:
- Changing the order of characters/character classes inside `[...]`;
  e.g. `[A-Za-z]` --> `[a-zA-Z]`
- Mark all groups as non-capturing (since we do not use the captured
  values); e.g. `(foo)` --> `(?:foo)`
  (This could theoretically also have a positive performance impact, but
  I suspect JavaScript engines are already optimizing away capturing
  groups when they are not used.)

PR Close #32961
2019-10-07 10:51:00 -07:00
George Kalpakas 3c2770bfc7 docs(forms): expand e-mail validation description (#32961)
Previously, there was no documentation of what `Validators.email()`
expects as a valid e-mail address, making it difficult for people to
determine whether it covers their requirements or not. Even more so that
the used pattern slightly deviates from the
[WHATWG version](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address).
One's only option was to look at the source code and try to decipher the
regexp pattern.

This commit adds a high-level description of the validator and mentions
its similarity to and differences from the WHATWG version. It also adds
a brief explanation of the regexp's behavior and references for more
information in the source code to provide more context to
maintainers/users trying to understand the implementation in the future.

Fixes #18985
Fixes #25186
Closes #32747

PR Close #32961
2019-10-07 10:51:00 -07:00
Andrew Kushnir 90fb5d9f7a fix(ivy): generate ng-reflect properties for i18n attributes (#32989)
Prior to this change, ng-reflect properties were not created in case an attribute was marked as translatable (for ex. `i18n-title`). This commit adds the logic to generate ng-reflect for such cases.

PR Close #32989
2019-10-07 10:50:44 -07:00
cexbrayat d18289fa9c fix(ivy): missing schematics field in localize package (#33025)
The schematics added in #32791 is currently failing as the package.json does not reference it.

```
> ng add @angular/localize@9.0.0-next.9
+ @angular/localize@9.0.0-next.9
added 1 package from 1 contributor in 6.745s
Installed packages for tooling via npm.
The package that you are trying to add does not support schematics. You can try using a different version of the package or contact the package author to add ng-add support.
```

PR Close #33025
2019-10-07 10:21:29 -07:00
Andrew Kushnir bad3434337 fix(ivy): avoid exposing `ng` with Closure Compiler enhanced optimizations (#33010)
Prior to this commit, the `ng` was exposed in global namespace, which turned out to be problematic when minifying code with Closure, since it sometimes clobber our `ng` global. This commit aligns Ivy debugging tools behavior with existing logic in "platform-browser" package (packages/platform-browser/src/dom/util.ts#L31) by avoiding `ng` in global namespace when Closure Compiler is used.

PR Close #33010
2019-10-07 10:19:54 -07:00
Charles Lyding 0119f46daf fix(core): set migration schematic versions to valid semver versions (#32991)
PR Close #32991
2019-10-04 13:54:39 -07:00
Charles Lyding f8eca840ee fix(core): update migration descriptions with links to AIO documentation (#32991)
PR Close #32991
2019-10-04 13:54:39 -07:00
Kristiyan Kostadinov 7f6429d802 refactor: re-enable dynamic queries migration (#32992)
Re-enables the dynamic queries migration, now that we have all of the necessary framework changes in place.

Also moves the logic that identifies static queries out of the compiler and into the static queries migration, because that's the only place left that's using it.

PR Close #32992
2019-10-04 13:54:09 -07:00
cexbrayat 94b9b7e154 docs(core): update static flag documentation (#32993)
Followup to #32720 that removed the logic that statically determines whether a query is dynamic.
This updates the docs to reflect that, and mentions that the flag now defaults to false.

PR Close #32993
2019-10-04 13:53:55 -07:00
JiaLiPassion 3a53e2c960 fix(core): ngNoopZone should have the same signature with ngZone (#32068)
Close #32063

PR Close #32068
2019-10-04 11:48:12 -07:00
Alan 01677b21b6 refactor(core): add `createMigrationCompilerHost` (#32827)
Current we need to create and override certain compiler host methods in every schematic because schematics use a virtual fs. We this change we extract this logic to a common util.

PR Close #32827
2019-10-04 11:45:35 -07:00
Pawel Kozlowski 60047037a3 perf(ivy): attempt rendering initial styling only if present (#32979)
PR Close #32979
2019-10-04 11:44:57 -07:00
Pawel Kozlowski e6881b5b42 perf(ivy): limit TNode.inputs reads on first template pass (#32979)
PR Close #32979
2019-10-04 11:44:57 -07:00
Pawel Kozlowski 8593d0d52e perf(ivy): increase number of created views in the element_text_create benchmark (#32979)
PR Close #32979
2019-10-04 11:44:57 -07:00
JiaLiPassion 53d13c3fc6 refactor: rename unpatched event flag in Zone from `BLACK_LISTED_EVENTS` to `UNPATCHED_EVENTS` (#29617)
Closes #28529

PR Close #29617
2019-10-04 08:44:58 -07:00
George Kalpakas 442f323a32 ci: shorten the display name of `init_environment` steps that are shown in all jobs (#32998)
The `init_environment` custom command is used in almost all other jobs.
The this is implemented in CircleCI is that the steps of the command are
inlined into the other jobs.

Some of the `init_environment` commands are quite long and (since the
default display name for a step is its command) they clutter the
CircleCI UI. Additionally, multiple related commands are shown as
separate steps, which makes it more difficult to get to the actual steps
of a job.

This commit improves this by:
1. Defining explicit, short names for steps with long commands.
2. Grouping multiple related steps into one.

PR Close #32998
2019-10-04 08:39:20 -07:00
George Kalpakas 480b775ba7 build(docs-infra): update @angular/* to 9.0.0-next.9 (#32923)
PR Close #32923
2019-10-04 08:27:21 -07:00
George Kalpakas 32b16de8ea build(docs-infra): align config with what cli generates for new apps (#32923)
This is mainly to avoid some warning when building the app, such as:

```
WARNING in .../angular/aio/src/environments/environment.archive.ts is
part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your
tsconfig.
```

(Not turning on `fullTemplateTypeCheck` due to lots of errors.)

PR Close #32923
2019-10-04 08:27:21 -07:00
George Kalpakas ea9245446f refactor(docs-infra): replace `System.import()` with `import()` (#32923)
`System.import()` has been deprecated in webpack and produces the
following warning when building the app:

```
WARNING in ./src/app/custom-elements/code/pretty-printer.service.ts
System.import() is deprecated and will be removed soon. Use import()
instead.
```

Switching to `import()` to get rid of the warning.

Fixes #30365
Closes #30419

PR Close #32923
2019-10-04 08:27:21 -07:00
George Kalpakas ad753d3fa7 build(docs-infra): pin terser to 4.3.2 to avoid optimization bug (#32923)
This commit pins terser to version 4.3.2 (instead of 4.3.4 which it is
currently resolved to) to avoid this bug: terser/terser#470

See https://github.com/angular/angular/pull/32923#issuecomment-537370090
for more details.

PR Close #32923
2019-10-04 08:27:21 -07:00
George Kalpakas 7c9219f029 build(docs-infra): upgrade @angular/cli to 9.0.0-next.6 (#32923)
PR Close #32923
2019-10-04 08:27:21 -07:00
George Kalpakas eb72cecc42 build(docs-infra): turn on Ivy (#32923)
The angular.io project uses Angular and CLI v9, which by default turns
on Ivy mode. However, since ec4381dd4, we explicitly opt out of Ivy.

This commit removes the `enabledIvy: false` configuration, thus allowing
the default behavior of having Ivy on.

NOTE:
This commit only changes the angular.io projects. The docs examples need
to be updated separately (first to Angular and CLI v9 and then to Ivy).

PR Close #32923
2019-10-04 08:27:21 -07:00
George Kalpakas bc886a64a7 build(docs-infra): update current payload sizes (#32923)
PR Close #32923
2019-10-04 08:27:21 -07:00
George Kalpakas 75fd407bbd build: avoid error in `build-packages-dist.sh` (#32923)
Not sure why it works on other people's environments, but after
217db9b21 I started getting the following error when running
`scripts/build-packages-dist.sh` (on Windows):

```
ERROR: C:/.../angular/packages/bazel/docs/BUILD.bazel:3:1: Generating Skylark documentation dir for docs (3 files) failed (Exit 1)
Traceback (most recent call last):
  File "c:\...\temp\Bazel.runfiles_u_l5te\runfiles\io_bazel_skydoc\skydoc\main.py", line 335, in <module>
    main(sys.argv)
  File "c:\...\temp\Bazel.runfiles_u_l5te\runfiles\io_bazel_skydoc\skydoc\main.py", line 303, in main
    load_symbols = load_sym_extractor.extract(bzl_file)
  File "c:\...\temp\Bazel.runfiles_u_l5te\runfiles\io_bazel_skydoc\skydoc\load_extractor.py", line 110, in extract
    load_symbols = self._extract_loads(bzl_file)
  File "c:\...\temp\Bazel.runfiles_u_l5te\runfiles\io_bazel_skydoc\skydoc\load_extractor.py", line 38, in _extract_loads
    tree = ast.parse(f.read(), bzl_file)
  File "C:\...\.windows-build-tools\python27\lib\ast.py", line 37, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "packages/bazel/src/ng_package/ng_package.bzl", line 39
    print("[ng_package.bzl]", *args)
                              ^
SyntaxError: invalid syntax
```

It seems expected, because `print` is not a function, so
`print(foo, *args)` is interpreted as printing a tuple (where `*args` is
invalid syntax). Not sure why it doesn't break on other people's
machines :/

This change makes the verbose logs a little less pretty, but that
shouldn't be a big issue (given that it is an opt-in feature and it can
always be overwritten locally, if necessary).

PR Close #32923
2019-10-04 08:27:21 -07:00
Keen Yee Liau adb562bca6 fix(language-service): create StaticReflector once only (#32543)
The creation of StaticReflector in createMetadataResolver() is a very expensive operation because it involves numerous module resolutions.
To make matter worse, since the API of the Reflector does not provide the ability to invalidate its internal caches, it has to be destroyed and recreated on *every* program change.
This has a HUGE impact on performance.
This PR fixes this problem by carefully invalidating all StaticSymbols in a file that has changed, thereby reducing the overhead of recomputation on program change.

PR Close #32543
2019-10-03 15:02:03 -07:00
crisbeto 900d0055e0 feat(core): make static query flag optional (#32986)
This is a re-submit of #32686.

Switches back to having the static flag be optional on ViewChild and ContentChild queries, in preparation for changing its default value.

PR Close #32986
2019-10-03 14:02:47 -07:00
crisbeto 7806596fba feat(core): default to dynamic queries (#32720)
These changes switch to defaulting the `static` flag on `ViewChild` and `ContentChild` queries to `false`, in addition to removing the logic that statically determines whether a query is dynamic.

PR Close #32720
2019-10-03 12:26:21 -07:00