Commit Graph

13851 Commits

Author SHA1 Message Date
Kara Erickson 9b93bd625f fix(ivy): ensure views created in constructors dont break queries (#29983)
Previous to this change, we assumed embedded views could only be created after
their parent template node had completed processing. As a result, we only set
up query logic for containers after directives on the node were created.
However, this assumption didn't take into account the case where a directive
on a template node could create views in its constructor.

This commit fixes query logic to work with views created in constructors.
In that case, we need to create a query container before the new view is
rendered so query results in the view aren't lost. But since the query container
is created before directives have completed processing, we also have to ensure
that query results gathered later on the template node are inserted before that
query container. Otherwise, query results in embedded views will clobber query
results on template nodes.

This splice mode may be slightly slower than the normal matching for queries on
containers, but we should only fall back to this strategy in the edge case where
views are created in constructors. (We should encourage developers to create
views in ngOnInit instead).

PR Close #29983
2019-04-19 10:01:32 -07:00
George Kalpakas 1f8325d6c4 ci(docs-infra): increase wait for SW on all origins to avoid CI flakes (#29988)
In #29953, the wait period for SW on localhost was increased to avoid CI
flakes for the PWA score tests.

This commit expands the fix to non-localhost origins to avoid flakes in
the `aio_monitoring` job, when CircleCI VMs/network are slow.
(For reference, example failures: [289127], [289238])

[289127]: https://circleci.com/gh/angular/angular/289127
[289238]: https://circleci.com/gh/angular/angular/289238

PR Close #29988
2019-04-19 09:59:36 -07:00
George Kalpakas 5650e3847b build(docs-infra): make tsconfig path detection in `switch-to-ivy` more robust (#29989)
In light of #29926, that will change the path of `tsconfig.app.json`,
this commit switches from a hard-coded `tsconfig.app.json` path to
looking it up in `angular.json` (to be more future-proof).

PR Close #29989
2019-04-19 09:46:48 -07:00
George Kalpakas 11eef85133 build(docs-infra): change `build-with-ivy` script to `switch-to-ivy` (#29989)
Previously, the `build-with-ivy` script could be used to build the `aio`
project with Ivy (once it had been prepared with `ivy-ngcc`, etc.) and
then restored the configuration (e.g. `tsconfig.json`) to non-ivy mode.

As a result, it was not useful for running other commands (e.g. unit/e2e
tests) in Ivy mode.

This commit renames the script to `switch-to-ivy` and employs a
different model (similar to `ng-packages-installer`), where the project
is setup to run in Ivy mode and then all subsequent commands are
executed in that mode (until restored).

Since this is currently only used on CI, there is no automatic way to
switch back to non-ivy mode (but it could be implemented in the future
if needed).

Finally, the script now modifies `src/tsconfig.app/json` instead of
`tsconfig.json` to ensure that the `angularCompilerOptions` are not
ignored/overwritten. This is also closer to what the cli generates
with the `--enable-ivy` option.

PR Close #29989
2019-04-19 09:46:48 -07:00
George Kalpakas f957c7c1cd ci(docs-infra): use pre-ivy packages in `test_aio_local_ivy` to test ngcc (#29989)
To better test ngcc (in addition to Ivy) on angular.io, change the
`test_aio_local_ivy` CircleCI job to use the pre-ivy Angular packages
(and have ngcc transform them to Ivy ones).

PR Close #29989
2019-04-19 09:46:48 -07:00
George Kalpakas e575892774 refactor(docs-infra): remove unnecessary cast to `any` (#29989)
PR Close #29989
2019-04-19 09:46:48 -07:00
Andrew Kushnir f9bb53a761 fix(ivy): allow TestBed.createComponent to create components in isolation (#29981)
Prior to this change, components created via TestBed.createComponent in the same test were placed into the same root context, which caused problems in conjunction with fixture.autoDetectChanges usage in the same test. Specifically, change detection was triggered immediately for created component (starting from the 2nd one) even if it was not required/desired. This commit makes Ivy and VE behavior consistent: now every component created via TestBed.createComponent is isolated from each other. Current solution uses host element id naming convention, which is not ideal, but helps avoid public API surface changes at this point (we might revisit this approach later).

Note: this commit also adds extra tests to verify bootstrap and change detection behavior in case of multiple components in `bootstrap` array in @NgModule, to make sure this behavior is aligned between Ivy and VE.

PR Close #29981
2019-04-19 09:45:52 -07:00
Paul Gschwendtner c1d5fbd0ad refactor(core): static-query template strategy should not parse stylesheets (#29876)
Currently the `template-strategy` for the static query migration uses the
Angular compiler in order to determine the query timing. This is problematic
as the AngularCompilerProgram also collects metadata for referenced
component stylesheets which aren't necessarily present. e.g. in a CLI
project the component can reference a Sass file. It's not guaranteed
that the standalone Angular compiler plugin supports Sass without
custom logic that is brought in by the Angular CLI webpack plugin.

In order to avoid any failures for invalid stylesheets, we just disable
normalizing of all referenced stylesheets.

PR Close #29876
2019-04-18 18:22:09 -07:00
Paul Gschwendtner ca591641c7 refactor(core): allow developers to select static-query migration strategy (#29876)
Currently there are two available migration strategies for the `static-query`
schematic. Both have benefits and negatives which depend on what the
developer prefers. Since we can't decide which migration strategy is the
best for a given project, the developer should be able to select a specific
strategy through a simple choice prompt.

In order to be able to use prompts in a migration schematic, we need to
take advantage of the "inquirer" package which is also used by the CLI
schematic prompts (schematic prompts are usually only statically defined
in the schema). Additionally the schematic needs to be made "async"
because with prompts the schematic can no longer execute synchronously
without implementing some logic that blocks the execution.

PR Close #29876
2019-04-18 18:22:09 -07:00
Paul Gschwendtner 2ba799ddc7 fix(bazel): do not typecheck core schematic files (#29876)
Currently for Angular Bazel projects, NGC needs to be run in the
"postinstall" NPM script in order to generate required summary files.

We need to update the postinstall `tsconfig` to not check/re-build the
`@angular/core` schematic code which has transitive dependencies
which are only available inside of a CLI project. As this is not guaranteed
to be the case with Angular Bazel projects, we need to make sure that
we don't check/re-build these files.

PR Close #29876
2019-04-18 18:22:09 -07:00
Kevin Newman 22294dfad1 docs(animations): fixed some closing brackets on query animation page (#29854) (#29855)
PR Close #29855
2019-04-18 18:19:48 -07:00
Ahsan Ayaz d1b7d36646 docs: add Muhammad Ahsan Ayaz to GDE contributors group (#29838)
PR Close #29838
2019-04-18 18:18:16 -07:00
Keen Yee Liau 0629ebd9e9 build(bazel): Bump CLI and @angular-devkit/* to v8 beta 15 (#29966)
PR Close #29966
2019-04-18 13:53:33 -07:00
jenniferfell 45c2429d30 docs: create skeleton deprecation summary to land so other writers can contribute in parallel (#29979)
PR Close #29979
2019-04-18 13:50:22 -07:00
Brandon 78146c1890 docs: update extra options available for RouterModule.forRoot() method (#29846)
PR Close #29846
2019-04-17 17:25:31 -07:00
Filipe Silva e1f51eaa55 feat(compiler-cli): export tooling definitions (#29929)
PR Close #29929
2019-04-17 17:23:01 -07:00
Filipe Silva e5905bb035 fix(core): use shakeable global definitions (#29929)
The `ngDevMode` and `ngI18nClosureMode` are special in that they should be set to `false` on production builds in order to shake out code associated with it.

Angular CLI does this in 5fc1f2499c/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts (L279-L282).

But in https://github.com/angular/angular/pull/28689 the toplevel usage was changed from `ngDevMode` to `global['ngDevMode']` (and the same for `ngI18nClosureMode`). This indirection prevents the static analysis in Terser from effecting the replacement.

PR Close #29929
2019-04-17 17:23:01 -07:00
Alex Eagle b9251fd707 build: Remove cc_binary dependency on brotli (#29912)
Just use the JavaScript port instead. We don't care about speed since we compress once as a build step.

PR Close #29912
2019-04-17 17:20:16 -07:00
Brad Green c0ec1d63ff docs: update product-alerts.component.1.ts (#29917)
Make the example match the generated output seen in StackBlitz as shown https://next.angular.io/getting-started#input step 2 "Open product-alerts.component.ts."

PR Close #29917
2019-04-17 16:49:21 -07:00
Alan Agius 4bde40f7c2 fix(core): don't include a local `EventListener` in typings (#29809)
With dts bundles, `core.d.ts` will include an `EventListener` class as it's used in 303eae918d/packages/core/src/debug/debug_node.ts (L32)

This will conflict with the DOM EventListener, as anything in `core.d.ts` which is using the DOM EventListener will fallback in using the one defined in the same module and hence build will fail because their implementation is different.

With this change, we rename the local `EventListener` to `DebugEventListener`, the later one is non exported.

Fixes #29806

PR Close #29809
2019-04-17 16:45:35 -07:00
Greg Magolan 4271d35dc4 build(bazel): fix missing deps in ts_devserver targets under /modules/playground/src/web_workers (#29799)
PR Close #29799
2019-04-17 13:02:03 -07:00
Greg Magolan 506f478f08 build(bazel): fix deps of test (#29799)
PR Close #29799
2019-04-17 13:02:03 -07:00
Greg Magolan 8a3a556c0c build(bazel): fix failure in http_server target due to transitive npm deps (#29799)
PR Close #29799
2019-04-17 13:02:03 -07:00
Greg Magolan ce2713f5b1 build(bazel): remove @ts-api-guardian_deps yarn_install (#29799)
PR Close #29799
2019-04-17 13:02:03 -07:00
Greg Magolan 7edfcf948f build(bazel): update to nodejs rules 0.27.12 and pin versions in @angular/bazel peer deps and for @bazel/schematics (#29799)
PR Close #29799
2019-04-17 13:02:03 -07:00
JoostK 83291f01b0 fix(ivy): let ngtsc unwrap expressions when resolving `forwardRef` (#29886)
Previously, ngtsc would fail to resolve `forwardRef` calls if they
contained additional parenthesis or casts. This commit changes the
behavior to first unwrap the AST nodes to see past such insignificant
nodes, resolving the issue.

Fixes #29639

PR Close #29886
2019-04-17 12:52:34 -07:00
JoostK 725148a44d feat(ivy): let ngtsc statically evaluate `Array.concat` calls (#29887)
Previously, only static evaluation of `Array.slice` was implemented in
ngtsc's static evaluator. This commit adds support for `Array.concat`.

Closes #29835

PR Close #29887
2019-04-17 12:49:13 -07:00
Andrew Kushnir 696e520842 fix(ivy): make metadata calls side-effect free in Closure (#29947)
When compiling Angular classes, the compiler may decide to append statements with specific metadata that's only required for JIT. This includes things like decorator metadata as well as NgModule scope data.

When the compiler generates such calls, the call sites are marked with Uglify's PURE annotation, so the optimizer will remove them in production builds. However, Closure does not have the PURE (or similar) annotation. We have a utility function `noSideEffects` in the runtime for this purpose. This commit wraps `setClassMetadata` and `setNgModuleScope` function bodies in `noSideEffect` closures to allow Closure remove them.

PR Close #29947
2019-04-17 12:20:51 -07:00
Pawel Kozlowski 5fee9daa5b fix(ivy): properly coalesce event handler in presence of queries (#29957)
The `TNode.cleanup` data structure can contain sequences of 4-element
sequence of entries (event handlers, directive outputs) mixed with
2-element sequence of entries (QueryList cleanup). Before this fix
we would always skip 4 elements in the `TNode.cleanup` while looking
up event handler cleanups. 4-element skips are not correct in case
of query cleanup presence and this commit corrects the algorithm to
jump 4 or 2 elements depending on a type of cleanup encountered.

PR Close #29957
2019-04-17 12:20:00 -07:00
Keen Yee Liau 1a56cd5c0b fix(language-service): Use proper types instead of any (#29942)
PR Close #29942
2019-04-17 12:17:13 -07:00
George Kalpakas 60e9d2da4f ci(docs-infra): increase wait for SW on localhost to avoid CI flakes (#29953)
The server used for testing on localhost has less optimizations (e.g.
serves uncompressed files), so we need to wait longer the ServiceWorker
to be loaded and registered to allow Lighthouse to reliably detect it,
especially on slower environments (e.g. CI).

Related: https://github.com/GoogleChrome/lighthouse/issues/5527#issuecomment-483710849

Fixes #29910

PR Close #29953
2019-04-17 12:14:39 -07:00
George Kalpakas ca9b3eed9e refactor(docs-infra): switch `test-pwa-score.js` to async/await (#29953)
PR Close #29953
2019-04-17 12:14:39 -07:00
Keen Yee Liau a48d288ff8 build(language-service): no need to bootstrap init_node_spec.js (#29937)
PR Close #29937
2019-04-17 12:13:39 -07:00
Kara Erickson d9c39dcab0 fix(ivy): directiveInject should fall back to inject (#29948)
If a component has its definition set by defineComponent (as opposed to
JIT getter), then it will generate a factory that uses directiveInject()
to retrieve its dependencies. This can be problematic in test code because
tests could use the injection utility before bootstrapping the component,
and directiveInject() relies on the view having been created.

This commit tweaks directiveInject() to fall back to inject() if the view
has not been created. This will allow injection to work in tests even if
it is called before the component is bootstrapped.

PR Close #29948
2019-04-16 19:31:46 -07:00
Kara Erickson ca2462cff7 fix(ivy): support providing components and dirs in tests (#29945)
Previous to this commit, providing a component or directive in a test
module without @Injectable() would throw because the injectable factory
would not be found. Providing components in tests in addition to declaring
or importing them is not necessary, but it should not throw an error.

This commit ensures factory data is saved when component defs and directive
defs are created, which allows them to be processed by the module injector.

Note that bootstrapping is still required for this setup to work because
directiveInject() does not support cases where the view has not been
created. This case will be handled in a future commit.

PR Close #29945
2019-04-16 19:14:17 -07:00
Alex Rickabaugh ab6036272c release: cut the v8.0.0-beta.13 release 2019-04-16 15:18:42 -07:00
Kara Erickson 1794a8e42a fix(ivy): coalesced listeners should preventDefault if any returns false (#29934)
We had a bug where event.preventDefault() was not always called if listeners
were coalesced. This is because we were overwriting the previous listener's
result every time we called the next listener, so listeners early in the chain
that returned false would be ignored and preventDefault would not be called.

This commit fixes that issue, so now preventDefault() is called if any listener
in a coalesced chain returns false. This brings us in line with View Engine
behavior.

PR Close #29934
2019-04-16 13:36:27 -07:00
Filipe Silva 86a3f90954 fix(compiler-cli): pass config path to ts.parseJsonConfigFileContent (#29872)
The config path is an optional argument to `ts.parseJsonConfigFileContent`. When passed, it is added to the returned object as `options.configFilePath`, and `tsc` itself passes it in.

The new TS 3.4 [incremental](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html) build functionality relies on this property being present: 025d826339/src/compiler/emitter.ts (L56-L57)

When using The compiler-cli `readConfiguration` the config path option isn't passed, preventing consumers (like @ngtools/webpack) from obtaining a complete config object.

This PR fixes this omission and should allow JIT users of @ngtools/webpack to set the `incremental` option in their tsconfig and have it be used by the TS program.

I tested this in JIT and saw a small decrease in build times in a small project. In AOT the incremental option didn't seem to be used at all, due to how `ngc` uses the TS APIs.

Related to https://github.com/angular/angular-cli/issues/13941.

PR Close #29872
2019-04-16 13:36:08 -07:00
Filipe Silva 2bfb6a02e2 fix(router): support non-NgFactory promise in loadChildren typings (#29832)
PR Close #29832
2019-04-16 10:46:12 -07:00
hpawe01 bd3164f88a docs: use correct values from `code-example` in i18n (#29920)
PR Close #29920
2019-04-16 10:31:16 -07:00
Jurgen Van de Moere b3edf494a4 docs(service-worker): fix small typo in devops guide (#29866)
PR Close #29866
2019-04-16 10:30:52 -07:00
Andrew Kushnir 5f1b6372c7 fix(ivy): multi provider override support in TestBed (#29919)
Overriding multi provider values (providers with `multi: true` flag) via TestBed require additional handling: all existing multi-provider values for the same token should be removed from the override list, so that they are not included into the final value of a given provider. This commit adds this logic to make sure we handle multi providers correctly.

PR Close #29919
2019-04-16 10:28:40 -07:00
Kristiyan Kostadinov 5d824c4153 fix(ivy): DebugNode.properties not preserving type of values (#29914)
Fixes the `DebugNode.properties` casting all of the values to a string.

This PR resolves FW-1253.

PR Close #29914
2019-04-16 09:50:44 -07:00
Yun Peng ca755a6b72 build: Fix label name (#29777)
Fix the following error with future Bazel version:
```
 Invalid label: invalid target name 'internal/npm_package:npm_package.bzl': target names may not contain ':'
```

PR Close #29777
2019-04-16 09:50:19 -07:00
Matias Niemelä 2deac0a412 perf(ivy): cache multiple reads to an element's stylingContext (#29818)
Because the styling context may be stored in a different location
and be apart of a sub array, reading the styling context each time
a host binding is evaluated is costly. This patch ensures that the
active styling context is cached so that multiple interactions with
styling bindings can easily retrieve the styling context efficiently.

PR Close #29818
2019-04-16 09:49:32 -07:00
Alex Rickabaugh 9147092a15 Revert "feat(ivy): use i18n locale data to determine the plural form of ICU expressions (#29249)" (#29918)
This reverts commit 6a8cca7975.

PR Close #29918
2019-04-15 16:55:51 -07:00
George Kalpakas 8027b3e19b ci(docs-infra): temporarily lower the min required PWA score for localhost tests (#29911)
The PWA score tests have been occasionally failing on CI recently
(possibly due to CI VM/network issues).

This commit temporarily disables them, until we investigate the
root-cause and/or put a work-around in place.

The PWA score tests are still run against the deployed versions (which
don't suffer as much) or PRs with public previews (as part of the
`test_aio_preview` job) and on upstream builds (as part of the
`deploy_aio` job).

Related to #29910.

[1]: https://github.com/angular/angular/blob/3a836c362/.circleci/config.yml#L390

PR Close #29911
2019-04-15 12:34:42 -07:00
Filipe Silva 3a836c362d build(docs-infra): convert `search-worker.js` to TypeScript (#29764)
PR Close #29764
2019-04-15 11:14:04 -07:00
Filipe Silva ee603a3b01 build(docs-infra): update to CLI 8 beta.13 (#29764)
PR Close #29764
2019-04-15 11:14:04 -07:00
Paul Gschwendtner b0c1282fbe refactor(core): migrations do not properly handle multiple templates in source file (#29841)
Currently if there are multiple source files within a given
TypeScript source file, only the last template in the source
file is checked as we store templates in a `Map` with the
source file paths as keys.

This is problematic as multiple templates can live within the
same source file and we therefore accidentally overwrite
existing entries in the resolved templates map.

PR Close #29841
2019-04-15 11:13:39 -07:00