Commit Graph

11029 Commits

Author SHA1 Message Date
Alex Rickabaugh 0d1d5898e3 fix(bazel): allow compile_strategy to be (privately) imported (#25080)
compile_strategy() is used to decide whether to build Angular code
using ngc (legacy) or ngtsc (local). In order for g3 BUILD rules
to switch properly and allow testing of Ivy in g3, they need to
import this function.

This commit removes the _ prefix which allows the function to be
imported.

PR Close #25080
2018-07-26 16:38:09 -07:00
Alex Rickabaugh 6fe865b080 fix(ivy): don't use a custom ts.CompilerHost for ngtsc (#25080)
ngtsc used to have a custom ts.CompilerHost which delegated to the plain
ts.CompilerHost. There's no need for this wrapper class and it causes
issues with CLI integration, so delete it.

PR Close #25080
2018-07-26 16:38:09 -07:00
Alex Rickabaugh e0c0c44d99 fix(ivy): allow relative imports of .d.ts files (#25080)
ngtsc used to assume that all .d.ts dependencies (that is, third party
packages) were imported via an absolute module path. It turns out this
assumption isn't valid; some build tools allow relative imports of
other compilation units.

In the absolute case, ngtsc assumes (and still does) that all referenced
types are available through the entrypoint from which an @NgModule was
imported. This commit adds support for relative imports, in which case
ngtsc will use relative path resolution to determine the imports.

PR Close #25080
2018-07-26 16:38:09 -07:00
Alex Rickabaugh 13a0d527f6 fix(ivy): correctly write cross-file references (#25080)
There is a bug in the existing handling for cross-file references.
Suppose there are two files, module.ts and component.ts.

component.ts declares two components, one of which uses the other.
In the Ivy model, this means the component will get a directives:
reference to the other in its defineComponent call.

That reference is generated by looking at the declared components
of the module (in module.ts). However, the way ngtsc tracks this
reference, it ends up comparing the identifier of the component
in module.ts with the component.ts file, detecting they're not in
the same file, and generating a relative import.

This commit changes ngtsc to track all identifiers of a reference,
including the one by which it is declared. This allows toExpression()
to correctly decide that a local reference is okay in component.ts.

PR Close #25080
2018-07-26 16:38:09 -07:00
Alex Rickabaugh ed7aa1c3e5 fix(ivy): force new imports for .d.ts files (#25080)
When ngtsc encounters a reference to a type (for example, a Component
type listed in an NgModule declarations array), it traces the import
of that type and attempts to determine the best way to refer to it.

In the event the type is defined in the same file where a reference
is being generated, the identifier of the type is used. If the type
was imported, ngtsc has a choice. It can use the identifier from the
original import, or it can write a new import to the module where the
type came from.

ngtsc has a bug currently when it elects to rely on the user's import.
When writing a .d.ts file, the user's import may have been elided as
the type was not referred to from the type side of the program. Thus,
in .d.ts files ngtsc must always assume the import may not exist, and
generate a new one.

In .js output the import is guaranteed to still exist, so it's
preferable for ngtsc to continue using the existing import if one is
available.

This commit changes how @angular/compiler writes type definitions, and
allows it to use a different expression to write a type definition than
is used to write the value. This allows ngtsc to specify that types in
type definitions should always be imported. A corresponding change to
the staticallyResolve() Reference system allows the choice of which
type of import to use when generating an Expression from a Reference.

PR Close #25080
2018-07-26 16:38:09 -07:00
Alex Rickabaugh f902b5ec59 feat(ivy): resolve forwardRef() for queries (#25080)
@ContentChild[ren] and @ViewChild[ren] can contain a forwardRef() to a
type. This commit allows ngtsc to unwrap the forward reference and
deal with the node inside.

It includes two modes of support for forward reference resolution -
a foreign function resolver which understands deeply nested forward
references in expressions that are being statically evaluated, and
an unwrapForwardRef() function which deals only with top-level nodes.

Both will be useful in the future, but for now only unwrapForwardRef()
is used.

PR Close #25080
2018-07-26 16:38:09 -07:00
Victor Berchet 48d7205873
release: cut the v6.1.0 release 2018-07-25 14:23:40 -07:00
Miško Hevery e1c6fd5453 Revert "feat(core): add support for using async/await with Jasmine" (#25096)
This reverts commit f6829aba55e07609e312b4f67dbc9dbbf36e4e46.

PR Close #25096
2018-07-25 11:44:56 -07:00
Adrien Samson 968f153491 fix(router): Fix _lastPathIndex in deeply nested empty paths (#22394)
PR Close #22394
2018-07-25 11:27:28 -07:00
Pawel Kozlowski 1e28495c89 fix(ivy): update compiler with latest runtime for view queries (#25061)
PR Close #25061
2018-07-25 10:39:30 -07:00
Johan CHOUQUET 0bcf20c9fa docs(animations): typo fix in the comments (#22652)
PR Close #22652
2018-07-25 10:13:18 -07:00
Daniel cf81823b07 docs: refactor style guide example 03-06 (#24996)
docs: refactor style guide example 03-06


docs: refactor style guide example 03-06


docs: refactor style guide example 03-06


PR Close #24996
2018-07-25 08:04:12 -07:00
Victor Berchet d4ac9698ba
Revert "docs: refactor style guide example 03-06 (#24996)"
This reverts commit 65e18dc1bf.
2018-07-24 22:11:30 -07:00
Daniel c205516f0d docs: refactor ngmodules example (#25072)
PR Close #25072
2018-07-24 21:03:38 -07:00
Daniel 777bd412b2 docs: replace angular/http with HttpClient (#25068)
PR Close #25068
2018-07-24 20:54:44 -07:00
Daniel 1e79014fc4 docs: replace angular/http with HttpClient (#25066)
PR Close #25066
2018-07-24 20:51:50 -07:00
Daniel Sogl d0c066a223 docs: replaced old angular/http example (#25065)
PR Close #25065
2018-07-24 20:47:20 -07:00
Daniel 65e18dc1bf docs: refactor style guide example 03-06 (#24996)
PR Close #24996
2018-07-24 20:46:07 -07:00
Olivier Combe 1ceddb6290 fix(ivy): support re-order embedded templates (#24805)
PR Close #24805
2018-07-24 16:41:05 -07:00
Olivier Combe 22731a7588 refactor(ivy): split i18nInterpolation into 8 functions (#24805)
PR Close #24805
2018-07-24 16:41:05 -07:00
Olivier Combe 72dd10f78f refactor(ivy): cleanup runtime i18n code (#24805)
Fixes #24785

PR Close #24805
2018-07-24 16:41:05 -07:00
Victor Berchet c0e3852384 Revert "build: update to newer circleCI bazel remote cache proxy (#25054)" (#25076)
This reverts commit d6016f1d1d.

PR Close #25076
2018-07-24 16:05:58 -07:00
Wei Huang 2cb0f68a7b test(bazel): allow no sandbox for protractor tests (#24906)
It specifies --no-sandbox flag when running the protractor tests as
root. This is needed for running the tests inside a docker container.

PR Close #24906
2018-07-24 08:28:03 -07:00
Greg Magolan 8450e0ab2f build(bazel): fix broken travis CI (#24788)
PR Close #24788
2018-07-24 08:26:16 -07:00
Greg Magolan e38b2b502c build(bazel): //modules/benchmarks/src/largetable/render3:perf bazel protractor test (#24788)
PR Close #24788
2018-07-24 08:26:16 -07:00
Marc Laval 445b9a5627 feat(ivy): support ViewContainerRef.createComponent() (#24997)
PR Close #24997
2018-07-24 08:23:23 -07:00
Stefanie Fluin d523630ea2 docs(aio): cleanup aalert, callout, subsection use and author style (#24986)
PR Close #24986
2018-07-24 08:22:14 -07:00
Alex Eagle d6016f1d1d build: update to newer circleCI bazel remote cache proxy (#25054)
it fixes the error we currently get on CI

PR Close #25054
2018-07-24 08:20:28 -07:00
cexbrayat be3cca4fd5
docs: tests for number/percent/currency pipe (#25028)
Will avoid errors in examples like the one fixed in #24661

Closes #25028
2018-07-23 13:18:23 -07:00
Matias Niemelä 169e9dd2c8 feat(ivy): bridge compile instructions to include sanitization helpers (#24938)
PR Close #24938
2018-07-23 08:49:52 -07:00
Pawel Kozlowski 13f3157823 fix(ivy): update content query compilation to latest runtime (#24957)
PR Close #24957
2018-07-23 08:45:50 -07:00
Pete Bacon Darwin edef58f466 build(docs-infra): ensure all API headings are sentence cased (#24949)
Closes #24880

PR Close #24949
2018-07-23 08:43:07 -07:00
Arun Kumar 7c89af34a9 docs: square odds example in rxjs guide (#24947)
Added argument type to filter function of rxjs. Fixed the
return value of filtering of odd numbers

PR Close #24947
2018-07-23 08:41:58 -07:00
Mateusz Karkula bd576bb83f docs: fix multicasting example in observable guide (#24911)
PR Close #24911
2018-07-23 08:40:45 -07:00
Maicon Wagner 168c2a645b docs: add Truly-UI to resources (#24615)
PR Close #24615
2018-07-23 08:39:35 -07:00
Dario Braun 7729bb2bdc docs: fix instructions for switching directories (#24439)
docs: fix instructions for switching directories


PR Close #24439
2018-07-23 08:38:10 -07:00
Kelly Marchewa 426324513d docs: update rxjs link to version 6 (#24269)
PR Close #24269
2018-07-23 08:36:51 -07:00
Daniel 4d6f467fea docs: refactor style guide example 01-01 (#22738)
docs: refactor style guide example 01-01


PR Close #22738
2018-07-23 08:35:37 -07:00
Vikram Subramanian 6b859daea4 fix(core): stop reusing provider definitions across NgModuleRef instances (#25022)
Fixes #25018.

Instantiating a NgModuleRef from NgModuleFactory reuses the NgModuleDefinition if it is already present. However the NgModuleDefinition has a providers array which modified when tree shakable providers are instantiated. This corrupts the provider definitions the next time the same factory is used to create a new NgModuleRef - Two provider definitions can end up with the same index anf the injector could potentially return a completely wrong object for a provider token.

This scenario is more likely on the server where the same NgModuleFactory is reused across requests.

The fix clones the cached NgModuleDefinition so that any tree shakable providers added later do not affect the cached copy.

PR Close #25022
2018-07-23 08:13:29 -07:00
Judy Bogart 7960d1879d
docs: technical review incorporated (#24744)
closes #24744
2018-07-20 12:40:00 -07:00
Judy Bogart f1ab394218
docs: add api doc to commonly queried elements 2018-07-20 12:39:10 -07:00
Alex Eagle 86203736e9 fix(service-worker): don't include sourceMappingURL in ngsw-worker (#24877)
Fixes #23596

PR Close #24877
2018-07-20 11:49:46 -07:00
Alex Rickabaugh 41ef75869c fix(ivy): types in .d.ts files should account for generics (#24862)
Ivy definition types have a generic type which specifies the return
type of the factory function. For example:

static ngDirectiveDef<NgForOf, '[ngFor][ngForOf]'>

However, in this case NgForOf itself has a type parameter <T>. Thus,
writing the above is incorrect.

This commit modifies ngtsc to understand the genericness of NgForOf and
to write the following:

static ngDirectiveDef<NgForOf<any>, '[ngFor][ngForOf]'>

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 2b8b647006 fix(ivy): export injectElementRef (#24862)
PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh ed1db40322 fix(ivy): use 'typeof' and 'never' for type metadata (#24862)
Previously ngtsc would use a tuple of class types for listing metadata
in .d.ts files. For example, an @NgModule's declarations might be
represented with the type:

[NgIf, NgForOf, NgClass]

If the module had no declarations, an empty tuple [] would be produced.

This has two problems.

1. If the class type has generic type parameters, TypeScript will
complain that they're not provided.

2. The empty tuple type is not actually legal.

This commit addresses both problems.

1. Class types are now represented using the `typeof` operator, so the
above declarations would be represented as:

[typeof NgIf, typeof NgForOf, typeof NgClass].

Since typeof operates on a value, it doesn't require generic type
arguments.

2. Instead of an empty tuple, `never` is used to indicate no metadata.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh d3594fc1c5 fix(ivy): correctly export all *Def symbols as private (#24862)
Previously, some of the *Def symbols were not exported or were exported
as public API. This commit ensures every definition type is in the
private export namespace.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 9fd70c9715 refactor(ivy): run the compiler compliance tests against ngtsc (#24862)
This commit moves the compiler compliance tests into compiler-cli,
and uses ngtsc to run them instead of the custom compilation
pipeline used before. Testing against ngtsc allows for validation
of the real compiler output.

This commit also fixes a few small issues that prevented the tests
from passing.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh b7bbc82e3e fix(ivy): wrap non-statement assignment expressions in parentheses (#24862)
Previously, when translating an assignment expression (e.g. x = 3), the
translator would always print the statement as X = Y. However, if the
expression is included in a larger expression (X = (Y = Z)), the
translator would print "X = Y = Z" without regard for the outer
expression context.

Now, the translator understands when it's printing an expression
statement (X = Y;) vs an expression in a larger context (X = (Y = Z);)
and encapsulates the latter in parentheses.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 139f5b3672 fix(ivy): references track the identifier they were discovered under (#24862)
Previously, references had the concept of an identifier, but would not
properly detect whether the identifier should be used or not when
generating an expression. This change fixes that logic.

Additionally, now whenever an identifier resolves to a reference (even
one imported from another module) as part of resolving an expression,
the reference is updated to use that identifier. This ensures that for
a class Foo declared in foo.ts, but referenced in an expression in
bar.ts, the Reference returned includes the identifier from bar.ts,
meaning that writing an expression in bar.ts for the Reference will not
generate an import.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 6f8ec256ef fix(ivy): detect ngOnChanges as a non-static method (#24862)
Previously ngtsc had a bug where it would only detect the presence of
ngOnChanges as a static method. This commit flips the condition and only
recognizes ngOnChanges as a non-static method.

PR Close #24862
2018-07-20 11:48:36 -07:00