Commit Graph

1965 Commits

Author SHA1 Message Date
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
Alex Rickabaugh 5d7005eef5 feat(ivy): port the static resolver to use the ReflectionHost (#24862)
Previously, the static resolver did its own interpretation of statements
in the TypeScript AST, which only functioned on TypeScript code. ES5
code in particular would not work with the resolver as it had hard-coded
assumptions about AST structure.

This commit changes the resolver to use a ReflectionHost instead, which
abstracts away understanding of the structural side of the AST. It adds 3
new methods to the ReflectionHost in support of this functionality:

* getDeclarationOfIdentifier
* getExportsOfModule
* isClass

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 2e724ec68b feat(ivy): support host bindings in ngtsc (#24862)
This change adds support for host bindings to ngtsc, and parses them
both from decorators and from the metadata in the top-level annotation.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 76f8f78920 feat(ivy): compile queries in ngtsc (#24862)
This commit adds support for @ContentChild[ren] and @ViewChild[ren] in
ngtsc. Previously queries were ignored.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 6eb6ac7c12 fix(ivy): fix a couple issues with Input/Output compilation (#24862)
PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 9644873023 fix(ivy): ignore imports without ngInjectorDef in r3_injector (#24862)
ngInjectorDef.imports is generated from @NgModule.imports plus
@NgModule.exports. A problem arises as a result, because @NgModule
exports contain not only other modules (which will have ngInjectorDef
fields), but components, directives, and pipes as well. Because of
locality, it's difficult for the compiler to filter these out at
build time.

It's not impossible, but for now filtering them out at runtime will
allow testing of the compiler against complex applications.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh ae4563202c fix(ivy): export NgModuleFactory adapter (#24862)
PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 42d4287153 fix(ivy): ngInjectorDef should copy full imports/exports nodes (#24862)
@NgModule()s get compiled to two fields: ngModuleDef and ngInjectorDef.
Both fields contain imports, as both selector scopes and injectors have
the concept of composed units of configuration. Previously these fields
were generated by static resolution of imports and exports in metadata.

Support for ModuleWithProviders requires they be generated differently.
ngModuleDef's imports/exports are generated as resolved lists of types,
whereas ngInjectorDef's imports should reflect the raw expressions that
the developer wrote in the metadata.

This change modifies the NgModule handler and properly copies raw nodes
for the imports and exports into the ngInjectorDef.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh f9a6a175bf fix(ivy): properly inject all special token types (#24862)
Previously ngtsc had a few bugs handling special token types:

* Injector was not properly translated to INJECTOR
* ChangeDetectorRef was not injected via injectChangeDetectorRef()

This commit fixes these two bugs, and also adds a test to ensure
they continue to work correctly.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 53a16006d6 fix(ivy): export InheritDefinitionFeature (#24862)
PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh 8a986d4642 feat(ivy): statically resolve template expressions (#24862)
This commit adds support for template substitution expressions for
ngtsc static resolution.

PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh e346c3c2f2 refactor(ivy): fix an unnecessarily deep import (#24862)
PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh 60aeee7abf feat(ivy): selector side of ModuleWithProviders via type metadata (#24862)
Within an @NgModule it's common to include in the imports a call to
a ModuleWithProviders function, for example RouterModule.forRoot().
The old ngc compiler was able to handle this pattern because it had
global knowledge of metadata of not only the input compilation unit
but also all dependencies.

The ngtsc compiler for Ivy doesn't have this knowledge, so the
pattern of ModuleWithProviders functions is more difficult. ngtsc
must be able to determine which module is imported via the function
in order to expand the selector scope and properly tree-shake
directives and pipes.

This commit implements a solution to this problem, by adding a type
parameter to ModuleWithProviders through which the actual module
type can be passed between compilation units.

The provider side isn't a problem because the imports are always
copied directly to the ngInjectorDef.

PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh 1008bb6287 fix(ivy): unwrap parenthesized or cast expressions for metadata (#24862)
Metadata in Ivy must be literal. For example,

@NgModule({...})

is legal, whereas

const meta = {...};
@NgModule(meta)

is not.

However, some code contains additional superfluous parentheses:

@NgModule(({...}))

It is desirable that ngtsc accept this form of literal object.

PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh 8a5cd2200a fix(ivy): allow building router with ngtsc (#24862)
This commit adds the ivy-local tag to //packages/router. Since the
router depends on //packages/upgrade, it makes that package
compatible with ngtsc as well.

PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh f58f3dc07a fix(ivy): handle ReadKeyExpr code generation (#24862)
This implements a missing expression type in ngtsc code generation:
that of bracket access to an object property.

PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Eagle 23766b85e9
build: Fix windows tests (#24927)
closes #24927
2018-07-20 10:51:32 -07:00
George Kalpakas 2d38fa104b test(platform-webworker): avoid flakes due to existing `PlatformRef` (#24916)
PR Close #24916
2018-07-20 10:47:17 -07:00
Pawel Kozlowski 56b3f1703e fix(ivy): invoke lifecycle hooks of directives placed on ng-template (#24899)
PR Close #24899
2018-07-20 10:45:51 -07:00
Greg Magolan c438b5eeda build(bazel): turn on preserve-symlinks (#24881)
This change turns on preserve-symlinks in nodejs to verify hermeticity of the Angular build.

BREAKING CHANGE: Use of @angular/bazel rules now requires calling ng_setup_workspace() in your WORKSPACE file.

For example:

local_repository(
    name = "angular",
    path = "node_modules/@angular/bazel",
)

load("@angular//:index.bzl", "ng_setup_workspace")

ng_setup_workspace()

PR Close #24881
2018-07-20 10:37:30 -07:00
cexbrayat 270176bbe4 docs: more info on currency digits (#24661)
Adds an example of using the `currency` pipe with a currency that has no cents like CLP,
which will format the amount with no digits if `digitsInfo` is not provided:

    <!-- outputs CA$14.00 -->
    {{ 14 | currency:'CAD' }}
    <!-- outputs CLP14 -->
    {{ 14 | currency:'CLP' }}

Amends the docs, adds an example and fix an error with a current example.

PR Close #24661
2018-07-20 10:33:06 -07:00
Martin Probst d76531d16e fix(animations): @internal must use JSDoc tags. (#24928)
This change fixes up several comments that accidentally used the JSDoc
tag @internal in regular block comments (`/*` instead of `/**`).

This prevents a problem with Closure Compiler that balks at `@` tags
occuring in regular block comments, because it assumes they were
intended to be tags for the compiler.

When occuring in `/**` JSDoc, tsickle escapes the tags, so they do not
cause problems.

PR Close #24928
2018-07-18 18:18:04 -04:00
cexbrayat 0b28732d77 docs: typos in directives docs (#24665)
Fixes some typos introduced by #23902

PR Close #24665
2018-07-17 16:45:17 -04:00
Alex Eagle 06a33984af build: rename angular_devkit dependency to angular_cli (#24842)
PR Close #24842
2018-07-17 16:44:01 -04:00
Matias Niemelä ba3eb8b654 feat(ivy): properly apply class="", [class], [class.foo] and [attr.class] bindings (#24822)
PR Close #24822
2018-07-17 16:33:25 -04:00
Carlos Ortiz Garcia c8ad9657c9 fix(compiler): i18n_extractor now outputs the correct source file name (#24885)
for non-inline templates

- Non-inline templates used to ouput the path to the component TS file
instead of the path to the original HTML file.
- Inline templates keep the same behavior.

Fixes #24884

PR Close #24885
2018-07-16 16:09:01 -04:00
Matias Niemelä 9be8abd012 build: disable IE web worker tests (#24908)
Travis (saucelabs) has been super flaky when running IE
web worker tests lately. This patch temporarily disables
these tests on IE (not edge) until things get more stable.

PR Close #24908
2018-07-16 16:07:56 -04:00
Pete Bacon Darwin d8c828c9b1 build(docs-infra): implement the 'package' API template (#24631)
PR Close #24631
2018-07-13 19:45:54 -04:00
Brandon Roberts 80a74b450a docs(forms): update form builder API reference (#24693)
PR Close #24693
2018-07-12 16:38:26 -04:00
Alex Rickabaugh 9a6f27c34c fix(ivy): support zero-argument @NgModule() invocations (#24738)
It's possible to declare an argument-less NgModule:

@NgModule() export class Foo {}

Update the @NgModule compiler to support this usage.

PR Close #24738
2018-07-12 16:36:35 -04:00
Alex Rickabaugh d723a69b31 fix(ivy): animations should not be a hard error yet (#24738)
Previously the Ivy template compiler would throw on encountering
an animation binding (e.g. [@anim]). This is unneccessary and
precludes testing existing code. This commit changes the error to a
warning.

PR Close #24738
2018-07-12 16:36:35 -04:00
Alex Rickabaugh d98b1c3bc4 fix(ivy): strip newlines from selectors in .d.ts files (#24738)
When writing selectors as string literal types in .d.ts files,
strip newlines to avoid generating invalid code. Newlines carry
no meaning in selectors anyway.

PR Close #24738
2018-07-12 16:36:35 -04:00
Alex Rickabaugh 02b5087685 build(ivy): enable ngtsc AOT builds for a few packages (#24738)
Turn on AOT builds using ngtsc for:

* animations
* common
* compiler
* compiler-cli
* forms
* platform-browser

PR Close #24738
2018-07-12 16:36:35 -04:00
Alex Rickabaugh 48394c64ae fix(ivy): remove spurious comma in ngtsc-built .d.ts files (#24738)
On accident a comma was emitted between imports when generating .d.ts
files. This commit removes it.

PR Close #24738
2018-07-12 16:36:35 -04:00
Alex Rickabaugh cde0b4b361 fix(ivy): *Def types are private (ɵ) symbols (#24738)
On accident a few of the definition types were emitted as public API
symbols. Much of the Ivy API surface is still prefixed with ɵ,
indicating it's a private API. The definition types should be private
for now.

PR Close #24738
2018-07-12 16:36:35 -04:00
Alex Rickabaugh 9f20dd937a feat(ivy): give ngtsc a basic understanding of ModuleWithProviders (#24738)
This commit changes the @NgModule provider to understand that sometimes
an import will resolve to an object instead of a type, and that object
could be of the ModuleWithProviders type. In that case, the 'ngModule'
property is read, and its value used instead.

This still will not handle ModuleWithProviders references across
compilation units; that work is coming in a future PR.

PR Close #24738
2018-07-12 16:36:35 -04:00
Alex Rickabaugh a1b630ee8f fix(ivy): generate a type parameter for InjectorDef (#24738)
InjectorDef is parameterized on the type of the injector
configuration class (e.g. the @NgModule decorated type). Previously
this parameter was not included when generating .d.ts files that
contained InjectorDefs.

PR Close #24738
2018-07-12 16:36:35 -04:00
Alex Rickabaugh d05d28629d test(common): run common/http tests with Bazel (#24738)
@angular/common/http had tests which were not executed in Bazel. This
commit adds a BUILD.bazel file and ensures the tests pass.

PR Close #24738
2018-07-12 16:36:35 -04:00
Greg Magolan 161ff5c79d feat(bazel): protractor_web_test_suite for release (#24787)
PR Close #24787
2018-07-12 16:34:45 -04:00
mrmeku 71e0df039c feat(bazel): Initial commit of protractor_web_test_suite (#24787)
Co-authored-by: Andrew Z Allen <me@andrewzallen.com>

PR Close #24787
2018-07-12 16:34:45 -04:00
Pawel Kozlowski 0399c6972a refactor(ivy): remove content query creation from directive factories (#24811)
PR Close #24811
2018-07-12 16:32:33 -04:00
Jason Aden 328971ffcc feat(router): add urlUpdateStrategy allow updating the browser URL at the beginning of navigation (#24820)
Fixes #24616

PR Close #24820
2018-07-12 14:40:08 -04:00
Victor Berchet 0b4d85e9f1 fix(common): format fractional seconds (#24844)
fix a bug introduced in #24831

PR Close #24844
2018-07-11 14:32:32 -07:00
Brandon Roberts 05e3e4d71e docs(forms): update API reference for form validators (#24734)
PR Close #24734
2018-07-10 18:52:40 -07:00
Tyler Akins 81a9db2b0a docs(forms): added missing backtick (#24451)
Fixed trivial markdown problem with a missing backtick.

PR Close #24451
2018-07-10 18:51:08 -07:00
sergeome 86d254d386 fix(router): add ability to recover from malformed url (#23283)
Fixes #21468

PR Close #23283
2018-07-10 18:48:52 -07:00
Victor Berchet a527c695aa fix(common): do not round factional seconds (#24831)
fixes #24384

PR Close #24831
2018-07-10 18:48:05 -07:00
vikerman 7d27ecc319
fix(platform-browser): workaround wrong import path generated by ngc for DOCUMENT (#24830) 2018-07-10 17:09:29 -07:00
Kara Erickson 3a19f70d1c refactor(ivy): replace pNextOrParent with TNode props (#24752)
PR Close #24752
2018-07-10 11:12:27 -07:00
Kara Erickson dc1f1295ee fix(ivy): support projecting into dynamic views (#24752)
PR Close #24752
2018-07-10 11:12:27 -07:00
Jeff Burn 0d5f2d3c7e fix(compiler-cli): Use typescript to resolve modules for metadata (#22856)
The current module resolution simply attaches .ts to the import/export path, which does
not work if the path is using Node / CommonJS behavior to resolve to an index.ts file.
This patch uses typescript's module resolution logic, and will attempt to load the original
typescript file if this resolution returns a .js or .d.ts file

PR Close #22856
2018-07-10 11:11:48 -07:00
Vikram Subramanian 197387d05e fix(platform-browser): mark Meta and Title services as tree shakable providers (#24815)
This lets services that use Meta and Title services to be tree shakable and provided in root.

PR Close #24815
2018-07-10 11:11:09 -07:00
Vikram Subramanian 1089261717 fix(core): mark NgModule as not the root if APP_ROOT is set to false (#24814)
Tree shakable providers use the APP_ROOT token to determine where to attach themselves. APP_ROOT gets set on NgModule with BrowserModule irrespective of whether it is actually the root(Ex. in case of SSR app where the shell app is first bootstrapped without BrowserModule being the root module).

This change allows a NgModule with BrowserModule to explicitly mark itself as not the root by setting APP_ROOT token to false. This allows tree shakable providers to be attached to the right rott module.

PR Close #24814
2018-07-10 11:09:36 -07:00
George Kalpakas 3d20c50156 fix(ivy): correctly resolve Array property access (#24664)
PR Close #24664
2018-07-09 15:10:29 -07:00
Olivier Combe dcabb05102 fix(common): use correct currency format for locale de-AT (#24658)
Fixes #24609
PR Close #24658
2018-07-09 15:10:06 -07:00
George Kalpakas 68814040e3 fix(language-service): do not overwrite native `Reflect` (#24299)
Fixes #21420

PR Close #24299
2018-07-09 15:09:16 -07:00
Matias Niemelä 3980640d53 feat(ivy): properly apply style="", [style], [style.foo] and [attr.style] bindings (#24602)
PR Close #24602
2018-07-06 13:51:00 -07:00
George Kalpakas 52d43a99ef fix(service-worker): avoid network requests when looking up hashed resources in cache (#24127)
PR Close #24127
2018-07-06 13:50:37 -07:00
George Kalpakas 45feb10c46 refactor(service-worker): avoid unnecessary operations and remove unused code (#24127)
PR Close #24127
2018-07-06 13:50:37 -07:00
George Kalpakas 250527ca68 feat(service-worker): add support for `?` in SW config globbing (#24105)
The globbing is used in the following sections:
- `assetGroups` > `resources` > `files`/`versionedFiles`
- `assetGroups` > `resources` > `urls`
- `dataGroups` > `urls`
- `navigationUrls`

Query params are ignored for `files`/`versionedFiles` and
`navigationUrls`, but they are still taken into account for
`assetGroups`/`dataGroups` `urls`. To avoid a breaking change, `?` is
matched literally for these patterns.

PR Close #24105
2018-07-06 13:50:17 -07:00
George Kalpakas 787c54736c test: run unit tests in random order (#19904)
PR Close #19904
2018-07-06 13:48:02 -07:00
George Kalpakas c0e2dba07b build: upgrade jasmine to 2.99.x and fix tests (#19904)
PR Close #19904
2018-07-06 13:48:02 -07:00
George Kalpakas e01b539ee5 refactor: infer type for `it()` assertion functions (#19904)
PR Close #19904
2018-07-06 13:48:02 -07:00
George Kalpakas 809e8f742e test: make `NgMatchers` type-aware (#19904)
PR Close #19904
2018-07-06 13:48:02 -07:00
George Kalpakas 00c110b055 build: upgrade jasmine (and related typings) to latest version (#19904)
With these changes, the types are a little stricter now and also not
compatible with Protractor's jasmine-like syntax. So, we have to also
use `@types/jasminewd2` for e2e tests (but not for non-e2e tests).

I also had to "augment" `@types/jasminewd2`, because the latest
typings from [DefinitelyTyped][1] do not reflect the fact that the
`jasminewd2` version (v2.1.0) currently used by Protractor supports
passing a `done` callback to a spec.

[1]: 566e039485/types/jasminewd2/index.d.ts (L9-L15)

Fixes #23952
Closes #24733

PR Close #19904
2018-07-06 13:48:02 -07:00
Greg Magolan 1e74ea9e60 build(bazel): update to rule_nodejs 0.10.0 (#24759)
PR Close #24759
2018-07-06 10:17:36 -07:00
cexbrayat f62876bbcb fix(ivy): pipes are pure by default (#24750)
PR Close #24750
2018-07-06 10:17:17 -07:00
riren 5fe1e74dd3 docs(common): fix in the documentation of PUT (#24528)
PR Close #24528
2018-07-06 10:13:20 -07:00
Sergej f974c48885 docs: describe rounding behaviour of 'DecimalPipe' (#24303)
PR Close #24303
2018-07-06 10:13:00 -07:00
Sarun Intaralawan b72dbc843f docs(router): add `paramsInheritanceStrategy` documentation (#22590)
PR Close #22590
2018-07-06 10:10:01 -07:00
Rafael 8fe8b8fcff docs: fix typos in 'Httpclient' docs (#19127)
PR Close #19127
2018-07-06 10:09:40 -07:00
Alex Rickabaugh b6af8700ce feat(ivy): AOT support for compilation of @Pipes (#24703)
This commit adds support to ngtsc for compilation of the @Pipe
annotation, including support for pipes in @NgModule scopes.

PR Close #24703
2018-07-03 18:36:02 -04:00
Alex Rickabaugh 3d52174bf1 feat(ivy): JIT support for compilation of @Pipes (#24703)
Adds support for compiling @Pipe in JIT mode, along with tests
to verify that certain aspects of compilation are correct.

PR Close #24703
2018-07-03 18:36:02 -04:00
Alex Rickabaugh dbdcfed2bd feat(ivy): support pipe compilation from local metadata (#24703)
This updates the r3_pipe_compiler to not depend on global analysis,
and to produce ngPipeDef instructions in the same way that the other
compilers do. It's a precursor to JIT and AOT implementations of
@Pipe compilation.

PR Close #24703
2018-07-03 18:36:02 -04:00
Alex Rickabaugh ffbacdf4ac fix(ivy): export the true ComponentDef/DirectiveDef types (not internal) (#24703)
This was a bug introduced in a previous commit.

PR Close #24703
2018-07-03 18:36:02 -04:00
Igor Minar e3064d5432 feat: typescript 2.9 support (#24652)
PR Close #24652
2018-07-03 13:32:06 -07:00
Alex Rickabaugh 0c3738a780 feat(ivy): support templateUrl for ngtsc (#24704)
This commit adds support for templateUrl in component templates within
ngtsc. The compilation pipeline is split into sync and async versions,
where asynchronous compilation invokes a special preanalyze() phase of
analysis. The preanalyze() phase can optionally return a Promise which
will delay compilation until it resolves.

A ResourceLoader interface is used to resolve templateUrls to template
strings and can return results either synchronously or asynchronously.
During sync compilation it is an error if the ResourceLoader returns a
Promise.

Two ResourceLoader implementations are provided. One uses 'fs' to read
resources directly from disk and is chosen if the CompilerHost doesn't
provide a readResource method. The other wraps the readResource method
from CompilerHost if it's provided.

PR Close #24704
2018-07-03 13:31:44 -07:00
Kevin Villela 0922228024 fix(core): use addCustomEqualityTester instead of overriding toEqual (#22983)
This propagates other custom equality testers added by users. Additionally, if
an Angular project is using jasmine 2.6+, it will allow Jasmine's custom object
differ to print out pretty test error messages.

fixes #22939

PR Close #22983
2018-07-03 08:35:15 -07:00
Kara Erickson a294e0dd79 fix(ivy): correct position for re-projected containers (#24721)
PR Close #24721
2018-07-02 14:38:12 -07:00
Rob Wormald 3553977bd7 feat(core): add support for ShadowDOM v1 (#24718)
add a new ViewEncapsulation.ShadowDom option that uses the v1 Shadow DOM API to provide style encapsulation.

PR Close #24718
2018-07-02 14:37:41 -07:00
Kara Erickson d243baf48a refactor(ivy): remove pChild from LNode (#24705)
PR Close #24705
2018-06-29 06:44:08 -07:00
Trotyl ff84c5c4da fix(common): properly update collection reference in NgForOf (#24684)
closes #24155

PR Close #24684
2018-06-29 06:43:44 -07:00
Peter Mihalik 87ddbdf919 docs(core): rephrase doc for Injector.get (#24670)
PR Close #24670
2018-06-29 06:43:18 -07:00
Ben Lesh 9803cb011e feat(ivy): Add InheritanceDefinitionFeature to support directive inheritance (#24570)
- Adds InheritanceDefinitionFeature to ivy
- Ensures that lifecycle hooks are inherited from super classes whether they are defined as directives or not
- Directives cannot inherit from Components
- Components can inherit from Directives or Components
- Ensures that Inputs, Outputs, and Host Bindings are inherited
- Ensures that super class Features are run

PR Close #24570
2018-06-29 06:42:40 -07:00
Jeremy Elbourn 13d60eac61 fix(platform-browser): add missing deps for HammerGesturesPlugin (#24682)
PR Close #24682
2018-06-28 15:13:11 -07:00
Kara Erickson 99bdd257a6 fix(ivy): support projecting containers into containers (#24695)
PR Close #24695
2018-06-28 15:01:42 -07:00
Miško Hevery 0ede987ced feat(ivy): Support resource resolution in JIT mode. (#24637)
Used to resolve resource URLs on `@Component` when used with JIT compilation.

```
@Component({
  selector: 'my-comp',
  templateUrl: 'my-comp.html', // This requires asynchronous resolution
})
class MyComponnent{
}

// Calling `renderComponent` will fail because `MyComponent`'s `@Compenent.templateUrl`
// needs to be resolved because `renderComponent` is synchronous process.
// renderComponent(MyComponent);

// Calling `resolveComponentResources` will resolve `@Compenent.templateUrl` into
// `@Compenent.template`, which would allow `renderComponent` to proceed in synchronous manner.
// Use browser's `fetch` function as the default resource resolution strategy.
resolveComponentResources(fetch).then(() => {
  // After resolution all URLs have been converted into strings.
  renderComponent(MyComponent);
});

```

PR Close #24637
2018-06-28 14:59:48 -07:00
Miško Hevery 71100e6d72 feat(core): add support for using async/await with Jasmine (#24637)
Example:
```
it('...', await(async() => {
  doSomething();
  await asyncFn();
  doSomethingAfter();
}));
```

PR Close #24637
2018-06-28 14:59:48 -07:00
Alex Rickabaugh 01e7ff682c test(ivy): todo app only includes reflect-metadata in JIT mode (#24677)
Previously the todo app imported reflect-metadata, since it is a dependency
of JIT and the todo app tests run in both JIT and AOT modes. However, the
code doesn't get tree-shaken away in AOT mode.

This change adds a target //packages/core/test/bundling/util:reflect_metadata
which, depending on whether the compile flag is in JIT or AOT mode, either
includes reflect-metadata or is a no-op.

Not including reflect-metadata gets the compressed todo bundle down to 12.5 kB.

PR Close #24677
2018-06-28 17:51:42 -04:00
Alex Rickabaugh 34c42836cf test(ivy): move hello_world and todo fully to ngtsc (#24677)
ngtsc is sufficiently capable now that it can compile hello_world
and todo and achieve equivalent results to ngc in ivy (global) mode.

Bundle sizes:
hello_world - 3.0 kB
todo        - 14.7 kB

PR Close #24677
2018-06-28 17:51:42 -04:00
Alex Rickabaugh 50d4a4fe5c fix(compiler): fix a few non-tree-shakeable code patterns (#24677)
This change makes @angular/compiler more tree-shakeable by changing
an enum to a const enum and by getting rid of a top-level map that
the tree-shaker was seeing as a reference which caused r3_identifiers
to be retained.

This drops a few hundred bytes of JS from tree-shaken ngtsc compiled
apps.

PR Close #24677
2018-06-28 17:51:42 -04:00
Alex Rickabaugh ef1c6d8c26 feat(ivy): dummy handler for @Pipe to cause decorator removal (#24677)
Currently ngtsc does not compile @Pipe. This has a side effect
of not removing the @Pipe decorator.

This adds a dummy DecoratorHandler that compiles @Pipe into an
empty ngPipeDef. Eventually this will be replaced with a full
implementation, but for now this solution allows compield code
to be tree-shaken properly.

PR Close #24677
2018-06-28 17:51:42 -04:00
Alex Rickabaugh 2ecaa40e64 build(ivy): run latest build-optimizer on ngtsc compiled code (#24677)
Previously the repo was depending on an old version of build optimizer.
This change updates to the latest (an RC release in the CLI package).

Additionally, this changes the behavior of ng_rollup_bundle to apply
the optimizer to ngtsc compiled code, and configures it to treat the
@angular/compiler package as side-effect-free.

This results in a substantial size reduction of ngtsc compiled code.

PR Close #24677
2018-06-28 17:51:42 -04:00
Alex Rickabaugh fc4dc35426 feat(ivy): strip all Angular decorators in compiled classes (#24677)
Previously ngtsc removed the class-level decorators (@Component,
etc) but left all the ancillary decorators (@Input, @Optional,
etc).

This changes the transform to descend into the members of decorated
classes and remove any Angular decorators, not just the class-level
ones.

PR Close #24677
2018-06-28 17:51:41 -04:00
Alex Rickabaugh 104d30507a feat(ivy): able to compile @angular/core with ngtsc (#24677)
@angular/core is unique in that it defines the Angular decorators
(@Component, @Directive, etc). Ordinarily ngtsc looks for imports
from @angular/core in order to identify these decorators. Clearly
within core itself, this strategy doesn't work.

Instead, a special constant ITS_JUST_ANGULAR is declared within a
known file in @angular/core. If ngtsc sees this constant it knows
core is being compiled and can ignore the imports when evaluating
decorators.

Additionally, when compiling decorators ngtsc will often write an
import to @angular/core for needed symbols. However @angular/core
cannot import itself. This change creates a module within core to
export all the symbols needed to compile it and adds intelligence
within ngtsc to write relative imports to that module, instead of
absolute imports to @angular/core.

PR Close #24677
2018-06-28 17:51:41 -04:00
Olivier Combe 39c8baea31 fix(common): use correct ICU plural for locale mk (#24659)
PR Close #24659
2018-06-27 15:03:34 -07:00
George Kalpakas abed2cd52c refactor(upgrade): fix examples for `strictPropertyInitialization` and remove internal comments (#18487) (#18487)
PR Close #18487

PR Close #18487
2018-06-27 15:01:47 -07:00
Kapunahele Wong 22758912a0 docs(aio): tech edits to upgrade-lazy (#18487) (#18487)
PR Close #18487

PR Close #18487
2018-06-27 15:01:47 -07:00
Peter Bacon Darwin bb6b59128f docs(upgrade): use a class for upgraded service (#18487) (#18487)
This makes the resulting use in Angular more ideomatic, since we can just
use the class type as the injection indicator.

PR Close #18487

PR Close #18487
2018-06-27 15:01:47 -07:00
Peter Bacon Darwin 4258c3d1df docs(upgrade): fix sub-ordered-list syntax (#18487) (#18487)
We must always use 1., 2. etc, to indicate ordered lists, even for sub-lists.
We can change the sublist to display as a., b. etc, via CSS.

PR Close #18487

PR Close #18487
2018-06-27 15:01:47 -07:00
Georgios Kalpakas 70156bc4ed docs(upgrade): add guide about `downgradeModule()` (#18487) (#18487)
PR Close #18487

PR Close #18487
2018-06-27 15:01:47 -07:00
Georgios Kalpakas 2ac2ab7ff6 docs(upgrade): add API docs for `downgradeModule()` (#18487) (#18487)
PR Close #18487

PR Close #18487
2018-06-27 15:01:47 -07:00
Georgios Kalpakas ca0a55f4ee docs(upgrade): add API docs for `propagateDigest` (#18487) (#18487)
PR Close #18487

PR Close #18487
2018-06-27 15:01:47 -07:00
Georgios Kalpakas 0b3d25d67e docs(upgrade): update API docs for upgrade/static (#18487) (#18487)
PR Close #18487

PR Close #18487
2018-06-27 15:01:47 -07:00
Georgios Kalpakas 922908818f test: minor improvements in examples e2e tests script (#18487) (#18487)
PR Close #18487

PR Close #18487
2018-06-27 15:01:47 -07:00
Pawel Kozlowski 50fb13fb09 fix(ivy): report results to appropriate content queries (#24673)
PR Close #24673
2018-06-27 14:20:34 -07:00
Kara Erickson fe8fcc834c refactor(ivy): remove dynamicParent from LNode (#24678)
PR Close #24678
2018-06-27 14:14:46 -07:00
Alex Rickabaugh 855e8ad9f6 fix(ivy): use closure-safe field name for JIT of ngInjectableDef (#24632)
PR Close #24632
2018-06-26 10:56:54 -07:00
Alex Rickabaugh 89c442270a feat(ivy): generate ngInjectorDef for @NgModule in JIT mode (#24632)
This commit takes advantage of the @angular/compiler work for ngInjectorDef
in AOT mode in order to generate the same definition in JIT mode.

PR Close #24632
2018-06-26 10:56:53 -07:00
Alex Rickabaugh ae9418c7de feat(ivy): generate ngInjectorDef for @NgModule in AOT mode (#24632)
This change generates ngInjectorDef as well as ngModuleDef for @NgModule
annotated types, reflecting the dual nature of @NgModules as both compilation
scopes and as DI configuration containers.

This required implementing ngInjectorDef compilation in @angular/compiler as
well as allowing for multiple generated definitions for a single decorator in
the core of ngtsc.

PR Close #24632
2018-06-26 10:56:53 -07:00
Miško Hevery 166d90d2a9 ci: fix broken build 2018-06-25 11:36:35 -07:00
Judy Bogart 7d318743c1 docs: test doc for decorator templates (#23902) (#23902)
PR Close #23902

PR Close #23902
2018-06-25 10:49:31 -07:00
Judy Bogart 2a68ba4cbb docs: fix misdirected group links (#24569)
PR Close #24569
2018-06-25 10:03:42 -07:00
Judy Bogart d244523ae6 docs: test api doc for pipes (#24141)
PR Close #24141
2018-06-25 09:37:30 -07:00
George Kalpakas 7d1f9c8a7c build: upgrade AngularJS typings (#24583)
Previously, we were using [@types/angularjs][1], which is deprecated and
outdated (hasn't been updated for over two years). This PR switches to
[@types/angular][2], which is regularly updated (based on the
definitions on [DefinitelyTyped][3]).

[1]: https://www.npmjs.com/package/@types/angularjs
[2]: https://www.npmjs.com/package/@types/angular
[3]: https://github.com/DefinitelyTyped/DefinitelyTyped

PR Close #24583
2018-06-25 09:30:46 -07:00
Marc Laval f229449c67 refactor(ivy): insert embedded views immediately (#24629)
PR Close #24629
2018-06-25 07:58:33 -07:00
Vikram Subramanian 6e20e0aac8 fix(animations): set animations styles properly on platform-server (#24624)
Animations styles weren't getting properly set on platform-server because of erroneous checks and absence of reflection of style property to attribute on the server.

The fix corrects the check for platform and explicitly reflects the style property to the attribute.

PR Close #24624
2018-06-25 07:58:11 -07:00
Pawel Kozlowski 1e139d4339 refactor(ivy): rename, limit usage of global vars (#24604)
PR Close #24604
2018-06-25 07:57:52 -07:00
Rado Kirov c95437f15d build(bazel): Turning on strictPropertyInitialization for Angular. (#24572)
All errors for existing fields have been detected and suppressed with a
`!` assertion.

Issue/24571 is tracking proper clean up of those instances.

One-line change required in ivy/compilation.ts, because it appears that
the new syntax causes tsickle emitted node to no longer track their
original sourceFiles.

PR Close #24572
2018-06-25 07:57:13 -07:00
Georgi Parlakov 39c7769c9e docs(core): typo in static injector tests (#24548)
PR Close #24548
2018-06-25 07:56:56 -07:00
Alex Rickabaugh 7b2b1afe71 fix(ivy): support inputs/outputs in decorator metadata in JIT (#24565)
PR Close #24565
2018-06-21 13:14:10 -07:00
Alex Rickabaugh 7d3fd4d655 fix(ivy): inject() no longer uses default value parameters (#24565)
inject() was changed in da31db7 to not take a default value parameter,
so injectable_compiler_2 should not request the use of one when
using inject().

PR Close #24565
2018-06-21 13:14:10 -07:00
Alex Rickabaugh 10da6a45c6 refactor(ivy): first pass at extracting ReflectionHost for abstract reflection (#24541)
ngtsc needs to reflect over code to property compile it. It performs operations
such as enumerating decorators on a type, reading metadata from constructor
parameters, etc.

Depending on the format (ES5, ES6, etc) of the underlying code, the AST
structures over which this reflection takes place can be very different. For
example, in TS/ES6 code `class` declarations are `ts.ClassDeclaration` nodes,
but in ES5 code they've been downleveled to `ts.VariableDeclaration` nodes that
are initialized to IIFEs that build up the classes being defined.

The ReflectionHost abstraction allows ngtsc to perform these operations without
directly querying the AST. Different implementations of ReflectionHost allow
support for different code formats.

PR Close #24541
2018-06-21 13:13:49 -07:00
Olivier Combe 84272e2227 feat(ivy): runtime i18n (#24037)
PR Close #24037
2018-06-21 13:13:30 -07:00
Pawel Kozlowski 3e1a3b2e32 fix(ivy): support queries for views inserted in lifecycle hooks (#24587)
Closes #23707

PR Close #24587
2018-06-20 16:51:14 -07:00
Pawel Kozlowski 1e6a226703 test(ivy): ngTemplateOutlet runtime integration test (#24587)
PR Close #24587
2018-06-20 16:51:14 -07:00
Marc Laval 8b8168262d fix(ivy): nested ngFor should be supported (#24564)
PR Close #24564
2018-06-20 16:50:37 -07:00
Matias Niemelä e8354edcd2 test(animations): properly reference body node for SSR environments (#23300)
PR Close #23300
2018-06-20 11:00:41 -07:00
Brandon Roberts 5b76f04b7f docs: More edits (#24255)
PR Close #24255
2018-06-19 10:53:13 -07:00
Brandon Roberts a57825acf3 docs: More form control API edits (#24255)
PR Close #24255
2018-06-19 10:53:13 -07:00
Brandon Roberts efc7639352 docs: Added multicast to observable descriptions (#24255)
PR Close #24255
2018-06-19 10:53:13 -07:00
Brandon Roberts 3e26cabe02 docs: formatting (#24255)
PR Close #24255
2018-06-19 10:53:13 -07:00
Brandon Roberts 9d114c052a docs: More form control API references fixes (#24255)
PR Close #24255
2018-06-19 10:53:13 -07:00
Brandon Roberts 43e61c25e1 docs(docs-infra): Update with review changes (#24255)
PR Close #24255
2018-06-19 10:53:13 -07:00
Brandon Roberts 4e1493a1d6 docs(forms): update API reference for FormControl (#24255)
PR Close #24255
2018-06-19 10:53:13 -07:00
cexbrayat f3625e424b test(common): rename keyvalue e2e test (#24489)
PR Close #24489
2018-06-14 16:55:17 -07:00
Miško Hevery ccbda9de65 fix(core): Injector correctly honors the @Self flag (#24520)
Injector was incorrectly returning instance from parent injector even
when `@Self` was specified.

PR Close #24520
2018-06-14 16:42:07 -07:00
Alex Rickabaugh 27bc7dcb43 feat(ivy): ngtsc compiles @Component, @Directive, @NgModule (#24427)
This change supports compilation of components, directives, and modules
within ngtsc. Support is not complete, but is enough to compile and test
//packages/core/test/bundling/todo in full AOT mode. Code size benefits
are not yet achieved as //packages/core itself does not get compiled, and
some decorators (e.g. @Input) are not stripped, leading to unwanted code
being retained by the tree-shaker. This will be improved in future commits.

PR Close #24427
2018-06-14 14:36:45 -07:00
Alex Rickabaugh 0f7e4fae20 style(ivy): defeat clang format issue (#24479)
clang-format (on mac) has taken a disliking to this particular line, and
rewrites one of the ɵ characters to an invalid Unicode sequence.

PR Close #24479
2018-06-14 14:15:58 -07:00
Alex Rickabaugh a45fad3dd9 fix(ivy): keep JIT symbol table and r3_identifiers in sync (#24479)
At runtime in JIT mode, when the compiler writes a reference to a symbol that symbol
is resolved through a symbol table named angularCoreEnv in render3/jit/environment.
Previously, this symbol table was not kept up-to-date with the Ivy instruction set
and the names of symbols the compiler could reference.

This change brings the symbol table in sync, and also adds a test that verifies every
symbol the compiler can reference is available at runtime in the symbol table.

PR Close #24479
2018-06-14 14:15:58 -07:00