3751 Commits

Author SHA1 Message Date
Pete Bacon Darwin
ed12d7e949 test(ivy): ngcc - improve and use the MockLogger ()
Previously the console logger was being used in integration tests
leading to lots of output during test runs.

PR Close 
2019-04-08 09:48:20 -07:00
Pawel Kozlowski
38a3a5a1f1 refactor(ivy): remove unused code related to listeners clanup ()
PR Close 
2019-04-08 09:47:55 -07:00
Alan Agius
902a53a4f6 feat(bazel): update the build to use the new architect api ()
With this change the builder has been updated to use the latest architect API and make it compatable with the latest CLI

Fixes https://github.com/angular/angular-cli/issues/14082

PR Close 
2019-04-08 09:47:34 -07:00
Paul Gschwendtner
6d35c5094a test(core): add test for template variable object property assignment ()
The `template-var-assignment` schematic currently complains if someone
assigns a value to a template variable. This will no longer work with Ivy, but
it should be totally fine to update a property of the template variable if it refers
to an object. This commit adds a test that ensures that we don't incorrectly report
any failure for such property writes in bound events.

PR Close 
2019-04-08 09:46:57 -07:00
Paul Gschwendtner
4a2fb86b1e refactor(core): polish failure messages for template-var-assignment schematic ()
Improves the failure messages for the `template-var-assignment` schematic. After manual
testing of the schematic it's not quite clear for developers what the failure message means
without any context. The schematic now also references a short markdown file mentioning
what needs to be changed, but eventually this document needs to be expanded with more
information and context of the reasoning behind this change within Ivy.

PR Close 
2019-04-08 09:46:57 -07:00
Pete Bacon Darwin
e02684e609 fix(compiler-cli): ensure LogicalProjectPaths always start with a slash ()
Previously, if a matching rootDir ended with a slash then the path
returned from `logicalPathOfFile()` would not start with a slash,
which is inconsistent.

PR Close 
2019-04-08 09:46:16 -07:00
Matias Niemelä
ec56354306 fix(ivy): ensure parent/sub-class components evaluate styling correctly ()
The new styling algorithm in angular is designed to evaluate host
bindings stylinh priority in order of directive evaluation order. This,
however, does not work with respect to parent/sub-class directives
because sub-class host bindings are run after the parent host bindings
but still have priority. This patch ensures that the host styling bindings
for parent and sub-class components/directives are executed with respect
to the styling algorithm prioritization.

Jira Issue: FW-1132

PR Close 
2019-04-05 16:49:52 -07:00
JoostK
5c13feebfd test(ivy): verify ngOnDestroy is called for tree-shakeable providers ()
This test verifies that Ivy's module injector does not suffer from
 to prevent regressing on this behavior going forward.

PR Close 
2019-04-05 09:40:00 -07:00
JoostK
30b04424a3 fix(core): call ngOnDestroy for tree-shakeable providers ()
Prior to this change, any provider that was independently resolved using
its InjectableDef would not be considered when destroying the module it
was requested from. This commit provides a fix for this issue by storing
the resolved provider in the module's list of provider definitions.

Fixes 

PR Close 
2019-04-05 09:40:00 -07:00
Rado Kirov
f8cdda63d4 refactor: uniformly access all index sigs with index access. ()
Follow-up to https://github.com/angular/angular/pull/28937

A build-time check to enforce this is part of tsetse -
https://tsetse.info/property-renaming-safe but I don't know how to turn
it on for this repositories bazel builds.

PR Close 
2019-04-05 09:34:26 -07:00
Judy Bogart
b6f48dbe19 docs: correct route path description ()
PR Close 
2019-04-04 15:40:59 -07:00
Carlos Ortiz García
609024f93d fix(core): Deprecate TestBed.get(...):any ()
Adds an overload to TestBed.get making parameters strongly typed and
deprecated previous signature that accepted types `any`. The function
still returns `any` to prevent build breakages, but eventually stronger
type checks will be added so a future Angular version will break builds
due to additional type checks.
See previous breaking change - 

Issue 

PR Close 
2019-04-04 15:32:23 -07:00
Greg Magolan
9c056b974a build(bazel): tslib.js still required in ts_devserver & ts_web_test_suite for schematics ()
PR Close 
2019-04-04 14:27:05 -07:00
Greg Magolan
c0ec8425c2 build(bazel): remove unnecessary scripts from ts_devserver & ts_web_test_suite in bazel schematics ()
PR Close 
2019-04-04 14:27:05 -07:00
Greg Magolan
2e66ddfdce fix(bazel): add configuration_env_vars = ["compile"] to generated @npm//@angular/bazel/bin:ngc-wrapped nodejs_binary ()
PR Close 
2019-04-04 14:27:04 -07:00
Greg Magolan
7fbe138b1f build(bazel): update to nodejs rules 0.27.10 ()
PR Close 
2019-04-04 14:27:04 -07:00
Keen Yee Liau
2bd9214435 fix(bazel): remove karma-jasmine from ts_web_test_suite ()
It's not needed.

PR Close 
2019-04-04 14:26:11 -07:00
Filipe Silva
96b76dc3f1 fix(core): add missing migration to npm package ()
While running `ng update @angular/core --next`, the following error would be displayed:

```
Cannot find module '....\node_modules\@angular\core\schematics\migrations\template-var-assignment\index'
```

This happened because the Schematics migration was referenced, but not included.

This commit fixes that bug by including the migration in the Bazel npm package dependencies.

PR Close 
2019-04-04 10:51:19 -07:00
Ben Lesh
699ecac2c2 refactor(ivy): Add i18n create op codes debug info ()
Simply adds a `debug` property to the array of create opcodes while inside
`readCreateOpCodes` in i18n. This `debug` property has a property called `operations`
that is a human-readable list of operations that will be performed, as derived
from the op codes themselves, and the view it's acting upon.

PR Close 
2019-04-03 15:54:42 -07:00
Alan
9810c6c0f9 fix(bazel): support running ng-add on minimal applications ()
Minimal applications don't have `test` and `e2e` targets but we are not currently checking if they exists.

Fixes 

PR Close 
2019-04-03 15:30:46 -07:00
Pete Bacon Darwin
3246399bff fix(ivy): ngcc - show logging via CLI by default ()
The new logger implementation caused a regression where
by default the ngcc CLI did not output any logging messages.

PR Close 
2019-04-03 15:27:39 -07:00
Vani
a6809e0e7d docs: update location API docs ()
PR Close 
2019-04-02 16:11:28 -07:00
Carlos Ortiz García
afd4a4ed4d feat(core): Add "AbstractType<T>" interface ()
This new interface will match classes whether they are abstract or
concrete. Casting as `AbstractType<MyConcrete>` will return a type that
isn't newable. This type will be used to match abstract classes in the
`get()` functions of `Injector` and `TestBed`.
Type isn't used yet so this isn't a breaking change.

Issue 

PR Close 
2019-04-02 16:07:22 -07:00
JoostK
60afe88bcc feat(ivy): do not emit empty providers/imports for defineInjector ()
The defineInjector function specifies its providers and imports array to
be optional, so if no providers/imports are present these keys may be
omitted. This commit updates the compiler to only generate the keys when
necessary.

PR Close 
2019-04-02 16:03:54 -07:00
JoostK
2d372f48db feat(ivy): exclude declarations from injector imports ()
Prior to this change, a module's imports and exports would be used verbatim
as an injectors' imports. This is detrimental for tree-shaking, as a
module's exports could reference declarations that would then prevent such
declarations from being eligible for tree-shaking.

Since an injector actually only needs NgModule references as its imports,
we may safely filter out any declarations from the list of module exports.
This makes them eligible for tree-shaking once again.

PR Close 
2019-04-02 16:03:54 -07:00
JoostK
45c6360e5a feat(ivy): emit module scope metadata using pure function call ()
Prior to this change, all module metadata would be included in the
`defineNgModule` call that is set as the `ngModuleDef` field of module
types. Part of the metadata is scope information like declarations,
imports and exports that is used for computing the transitive module
scope in JIT environments, preventing those references from being
tree-shaken for production builds.

This change moves the metadata for scope computations to a pure function
call that patches the scope references onto the module type. Because the
function is marked pure, it may be tree-shaken out during production builds
such that references to declarations and exports are dropped, which in turn
allows for tree-shaken any declaration that is not otherwise referenced.

Fixes , FW-1035

PR Close 
2019-04-02 16:03:54 -07:00
Pete Bacon Darwin
6b39c9cf32 fix(compiler-cli): ngcc - cope with processing entry-points multiple times ()
With the new API, where you can choose to only process the first
matching format, it is possible to process an entry-point multiple
times, if you pass in a different format each time.

Previously, ngcc would always try to process the typings files for
the entry-point along with processing the first format of the current
execution of ngcc. But this meant that it would be trying to process
the typings a second time.

Now we only process the typings if they have not already been
processed as part of processing another format in another
even if it was in a different execution of ngcc.

PR Close 
2019-04-02 15:59:34 -07:00
Alex Eagle
b14537a004 fix(bazel): use //:tsconfig.json as the default for ng_module ()
This matches the behavior of ts_library

PR Close 
2019-04-02 15:57:11 -07:00
Paul Gschwendtner
7c8f4e3202 feat(core): template-var-assignment update schematic ()
Introduces a new update schematic called "template-var-assignment"
that is responsible for analyzing template files in order to warn
developers if template variables are assigned to values.

The schematic also comes with a driver for `tslint` so that the
check can be used wtihin Google.

PR Close 
2019-04-02 15:47:32 -07:00
Paul Gschwendtner
15eb1e0ce1 refactor(core): stronger type for resolved angular decorators ()
PR Close 
2019-04-02 15:47:32 -07:00
Paul Gschwendtner
780081def0 refactor(core): move schematic typescript logic to utility package ()
PR Close 
2019-04-02 15:47:32 -07:00
Ben Lesh
5a724b34bd refactor(ivy): move instructions ()
- moves all publicly exported instructions to their own files
- refactors namespace instructions to set state in `state.ts`
- no longer exports * from `instructions.ts`.
- `instructions.ts` renamed to `shared.ts` (old `shared.ts` contents folded in to `instructions.ts`)
- updates `all.ts` to re-export from public instruction files.

PR Close 
2019-04-02 15:47:02 -07:00
Alex Eagle
03d914a6c2 build: hide @angular/http for Angular v8 ()
Currently our plan is to skip the publish, docgen, and update steps for this package.
During RC, we'll determine if the breaking change is too difficult for users, in which case we might restore the package for another major.

PR Close 
2019-04-02 10:55:31 -07:00
JoostK
98f8b0f328 fix(ivy): ngcc - properly handle aliases class expressions ()
In ES2015, classes could have been emitted as a variable declaration
initialized with a class expression. In certain situations, an intermediary
variable suffixed with `_1` is present such that the variable
declaration's initializer becomes a binary expression with its rhs being
the class expression, and its lhs being the identifier of the intermediate
variable. This structure was not recognized, resulting in such classes not
being considered as a class in `Esm2015ReflectionHost`.

As a consequence, the analysis of functions/methods that return a
`ModuleWithProviders` object did not take the methods of such classes into
account.

Another edge-case with such intermediate variable was that static
properties would not be considered as class members. A testcase was added
to prevent regressions.

Fixes 

PR Close 
2019-04-02 10:50:46 -07:00
Pete Bacon Darwin
9f54d76ef5 refactor(upgrade): use Bazel packages to avoid symlinks in the source ()
Previously we had to share code between upgrade/dynamic and upgrade/static
by symlinking the `src` folder, which allowed both packages to access
the upgrade/common files.

These symlinks are always problematic on Windows, where we had to run
a script to re-link them, and restore them.

This change uses Bazel packages to share the `upgrade/common` code,
which avoids the need for symlinking the `src` folder.

Also, the Windows specific scripts that fixup the symlinks have also
been removed as there is no more need for them.

PR Close 
2019-04-02 10:38:01 -07:00
Ben Lesh
e5201f92fc refactor(platform-browser): rename _singleTagWhitelist ()
PR Close 
2019-04-02 10:37:29 -07:00
Ben Lesh
3487055d10 refactor(compiler): rename INTERPOLATION_BLACKLIST_REGEXPS ()
PR Close 
2019-04-02 10:36:26 -07:00
Ben Lesh
d11b0c0c41 refactor(compiler): update docs ()
PR Close 
2019-04-02 10:28:52 -07:00
Ben Lesh
1293da1cf7 refactor(core): update docs ()
PR Close 
2019-04-02 10:28:23 -07:00
Greg Magolan
7c1f73ac7b build(bazel): update to nodejs rules 0.27.9 ()
PR Close 
2019-04-02 10:27:14 -07:00
Pete Bacon Darwin
63013f1aeb fix(ivy): support finding the import of namespace-imported identifiers ()
Currently there is no support in ngtsc for imports of the form:

```
import * as core from `@angular/core`

export function forRoot(): core.ModuleWithProviders;
```

This commit modifies the `ReflectionHost.getImportOfIdentifier(id)`
method, so that it supports this kind of return type.

PR Close 
2019-04-01 16:06:14 -07:00
cexbrayat
1f469cd7bb docs: improve formatDate description ()
PR  reworded the description, making it less obvious that the value to format can be a `Date`.

PR Close 
2019-04-01 15:14:50 -07:00
Alex Rickabaugh
7041e61562 perf(ivy): basic incremental compilation for ngtsc ()
This commit introduces a mechanism for incremental compilation to the ngtsc
compiler.

Previously, incremental information was used in the construction of the
ts.Program for subsequent compilations, but was not used in ngtsc itself.

This commit adds an IncrementalState class, which tracks state between ngtsc
compilations. Currently, this supports skipping the TypeScript emit step
when the compiler can prove the contents of emit have not changed.

This is implemented for @Injectables as well as for files which don't
contain any Angular decorated types. These are the only files which can be
proven to be safe today.

See ngtsc/incremental/README.md for more details.

PR Close 
2019-04-01 15:13:56 -07:00
Alex Rickabaugh
7316212c1e test(ivy): support multiple compilations in the ngtsc test env ()
This commit adds support for compiling the same program repeatedly in a way
that's similar to how incremental builds work in a tool such as the CLI.

* support is added to the compiler entrypoint for reuse of the Program
  object between compilations. This is the basis of the compiler's
  incremental compilation model.

* support is added to wrap the CompilerHost the compiler creates and cache
  ts.SourceFiles in between compilations.

* support is added to track when files are emitted, for assertion purposes.

* an 'exclude' section is added to the base tsconfig to prevent .d.ts
  outputs from the first compilation from becoming inputs to any subsequent
  compilations.

PR Close 
2019-04-01 15:13:56 -07:00
Alex Rickabaugh
aaa16f286d feat(ivy): performance trace mechanism for ngtsc ()
This commit adds a `tracePerformance` option for tsconfig.json. When
specified, it causes a JSON file with timing information from the ngtsc
compiler to be emitted at the specified path.

This tracing system is used to instrument the analysis/emit phases of
compilation, and will be useful in debugging future integration work with
@angular/cli.

See ngtsc/perf/README.md for more details.

PR Close 
2019-04-01 15:13:55 -07:00
Alex Rickabaugh
3e569767e3 fix(ivy): avoid remote scoping if it's not actually required ()
Currently, ngtsc decides to use remote scoping if the compilation of a
component may create a cyclic import. This happens if there are two
components in a scope (say, A and B) and A directly uses B. During
compilation of B ngtsc will then note that if B were to use A, a cycle would
be generated, and so it will opt to use remote scoping for B.

ngtsc already uses the R3TargetBinder to correctly track the imports that
are actually required, for future cycle tracking. This commit expands that
usage to not trigger remote scoping unless B actually does consume A in its
template.

PR Close 
2019-04-01 15:13:35 -07:00
Jason Aden
f9497bf28b fix(router): adjust setting navigationTransition when a new navigation cancels an existing one ()
Prior to this change, if a navigation was ongoing and a new one came in, the router could get into a state where `router.currentNavigation` was `null` even though a navigation was executing. This change moves where we set the `currentNavigation` value so it's inside a `switchMap`. This solves the problem because the `finally` on the `switchMap` had been setting `currentNavigation` to `null` but the new `currentNavigation` value would have already been set. Essentially this was a timing problem and is resolved with this change.

Fixes  

PR Close 
2019-04-01 12:11:55 -07:00
Pete Bacon Darwin
8d3d75e454 feat(compiler-cli): ngcc - make logging more configurable ()
This allows CLI usage to filter excessive log messages
and integrations like webpack plugins to provide their own logger.

// FW-1198

PR Close 
2019-04-01 11:53:28 -07:00
Pete Bacon Darwin
39345b6fae style(compiler-cli): ensure FFR type is implemented correctly ()
PR Close 
2019-04-01 11:53:08 -07:00
Pete Bacon Darwin
06859f1335 refactor(compiler-cli): track visited source files in PartialEvaluator ()
PR Close 
2019-04-01 11:53:08 -07:00