Commit Graph

14862 Commits

Author SHA1 Message Date
crisbeto 02491a6ce8 refactor(ivy): move classMap interpolation logic internally (#31211)
Adds the new `classMapInterpolate1` through `classMapInterpolate8` instructions which handle interpolations inside the `class` attribute and moves the interpolation logic internally. This allows us to remove the `interpolationX` instructions in a follow-up PR.

These changes also add an error if an interpolation is encountered inside a `style` tag (e.g. `style="width: {{value}}"`). Up until now this would actually generate valid instructions, because `styleMap` goes through the same code path as `classMap` which does support interpolation. At runtime, however, `styleMap` would set invalid styles that look like `<div style="0:w;1:i;2:d;3:t;4:h;5::;7:1;">`. In `ViewEngine` interpolations inside `style` weren't supported either, however there we'd output invalid styles like `<div style="unsafe">`, even if the content was trusted.

PR Close #31211
2019-07-02 11:07:14 -07:00
JoostK dca713c087 test(ivy): verify equality of ngBaseDef metadata between compiler and core (#31210)
There's no build time dependency from @angular/core to @angular/compiler,
so core can't directly refer to compiler types. To overcome this limitation,
there's a facade layer defined in the compiler and duplicated in core,
such that during runtime all types will correctly align.

There's a testcase in the compiler that verifies that all such facade types
are compatible across core and compiler, such that the core types can't get
misaligned with the actual definitions in the compiler. This suite of
tests were missing the `R3BaseMetadataFacade` facade type, so it was possible
for this type to get out of sync.

PR Close #31210
2019-07-02 11:06:46 -07:00
JoostK eb6281f5b4 fix(ivy): include type parameter for `ngBaseDef` declaration (#31210)
When a class uses Angular decorators such as `@Input`, `@Output` and
friends without an Angular class decorator, they are compiled into a
static `ngBaseDef` field on the class, with the TypeScript declaration
of the class being altered to declare the `ngBaseDef` field to be of type
`ɵɵBaseDef`. This type however requires a generic type parameter that
corresponds with the type of the class, however the compiler did not
provide this type parameter. As a result, compiling a program where such
invalid `ngBaseDef` declarations are present will result in compilation
errors.

This commit fixes the problem by providing the generic type parameter.

Fixes #31160

PR Close #31210
2019-07-02 11:06:46 -07:00
Greg Magolan a4a423a083 build: fix build failures with worker mode cache and @types/events (#31325)
Errors observed only in tests on CircleCI — was not reproducible locally.

```
ERROR: /home/circleci/ng/packages/http/test/BUILD.bazel:3:1: Compiling TypeScript (devmode) //packages/http/test:test_lib failed (Exit 1): tsc_wrapped failed: error executing command
  (cd /home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/execroot/angular && \
  exec env - \
    BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 \
    PATH=/bin:/usr/bin:/usr/local/bin \
  bazel-out/host/bin/external/npm/@bazel/typescript/bin/tsc_wrapped @@bazel-out/k8-fastbuild/bin/packages/http/test/test_lib_es5_tsconfig.json)
Execution platform: //tools:rbe_ubuntu1604-angular
Compilation failed Error: missing input digest for /home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/execroot/angular/external/npm/node_modules/@types/events/index.d.ts.

ERROR: /home/circleci/ng/packages/benchpress/test/BUILD.bazel:3:1: Compiling TypeScript (devmode) //packages/benchpress/test:test_lib failed (Exit 1): tsc_wrapped failed: error executing command
  (cd /home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/execroot/angular && \
  exec env - \
    BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 \
    PATH=/bin:/usr/bin:/usr/local/bin \
  bazel-out/host/bin/external/npm/@bazel/typescript/bin/tsc_wrapped @@bazel-out/k8-fastbuild/bin/packages/benchpress/test/test_lib_es5_tsconfig.json)
Execution platform: //tools:rbe_ubuntu1604-angular
Compilation failed Error: missing input digest for /home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/execroot/angular/external/npm/node_modules/@types/events/index.d.ts

ERROR: C:/codefresh/volume/angular/packages/compiler/test/css_parser/BUILD.bazel:3:1: Compiling TypeScript (devmode) //packages/compiler/test/css_parser:css_parser_lib failed (Exit 1):
tsc_wrapped.exe failed: error executing command
  cd C:/users/containeradministrator/_bazel_containeradministrator/zquin2l6/execroot/angular
  SET PATH=C:\msys64\usr\bin;C:\msys64\bin;C:\Windows;C:\Windows\System32;C:\Windows\System32\WindowsPowerShell\v1.0
    SET RUNFILES_MANIFEST_ONLY=1
  bazel-out/host/bin/external/npm/@bazel/typescript/bin/tsc_wrapped.exe @@bazel-out/x64_windows-fastbuild/bin/packages/compiler/test/css_parser/css_parser_lib_es5_tsconfig.json
Execution platform: @bazel_tools//platforms:host_platform
Compilation failed Error: missing input digest for C:/users/containeradministrator/_bazel_containeradministrator/zquin2l6/execroot/angular/external/npm/node_modules/@types/events/index.
d.ts
```

PR Close #31325
2019-07-01 14:16:43 -07:00
Greg Magolan ba5b3af077 build(bazel): update //packages/bazel/test/ngc-wrapped:ngc_test test (#31325)
after update to rules_nodejs 0.32.1, @types are no longer automatically discovered by ngc-wrapped (which uses parts of ts_library) so this test needed updating so that the types files it generates is added as an explicit dep

PR Close #31325
2019-07-01 14:16:42 -07:00
Greg Magolan 64e7af4e43 build(bazel): add build --incompatible_list_based_execution_strategy_selection=false flag (#31325)
This option is changed to true in Bazel 0.27 and exposes a possible
regression in Bazel 0.27.0.
Error observed is in npm_package target `//packages/common/locales:package`:
```
ERROR: /home/circleci/ng/packages/common/locales/BUILD.bazel:13:1: Assembling
npm package packages/common/locales/package failed: No usable spawn strategy found
for spawn with mnemonic SkylarkAction.  Your --spawn_strategyor --strategy flags
are probably too strict. Visit https://github.com/bazelbuild/bazel/issues/7480 for
migration advises
```
Suspect is https://github.com/bazelbuild/rules_nodejs/blob/master/internal/npm_package/npm_package.bzl#L75-L82:
```
 execution_requirements = {
    # Never schedule this action remotely because it's not computationally expensive.
    # It just copies files into a directory; it's not worth copying inputs and outputs to a remote worker.
    # Also don't run it in a sandbox, because it resolves an absolute path to the bazel-out directory
    # allowing the .pack and .publish runnables to work with no symlink_prefix
    # See https://github.com/bazelbuild/rules_nodejs/issues/187
    "local": "1",
},
```

PR Close #31325
2019-07-01 14:16:42 -07:00
Greg Magolan d2d84c4460 build(bazel): remove deprecated rules_nodejs NodeModuleInfo provider (#31325)
PR Close #31325
2019-07-01 14:16:42 -07:00
Greg Magolan 29f5582af5 build: disable must-use-promises check in ts_library tsetse for tests as... (#31325)
...tsetse now falsely asserting on  some lines in a few tests such as packages/core/schematics/test/injectable_pipe_migration_spec.ts.

```
    await runMigration();
    expect(tree.readContent('/index.ts'))
```

it asserts that "await is required on promise" on the 2nd line when there is no promise there

PR Close #31325
2019-07-01 14:16:42 -07:00
Greg Magolan 63bdfca580 build(bazel): cleanup entry_point target (#31325)
PR Close #31325
2019-07-01 14:16:42 -07:00
Greg Magolan 361109d80f build: update to rules_nodejs 0.32.2 (#31325)
Brings in ts_library fixes required to get angular/angular building after 0.32.0:
typescript: exclude typescript lib declarations in node_module_library transitive_declarations
typescript: remove override of @bazel/tsetse (+1 squashed commit)

@npm//node_modules/foobar:foobar.js labels changed to @npm//:node_modules/foobar/foobar.js with fix for bazelbuild/rules_nodejs#802

also updates to rules_rass commit compatible with rules_nodejs 0.32.0

PR Close #31325
2019-07-01 14:16:42 -07:00
Greg Magolan b7a099d27e build(bazel): update to bazel 0.27.0 and fix compat in @angular/bazel package (#31325)
ctx.actions.declare_file now used in @angular/bazel ng_module rule as ctx.new_file is now deprecated. Fixes error:

```
        File "ng_module.bzl", line 272, in _expected_outs
                ctx.new_file(ctx.genfiles_dir, (ctx.label.name ..."))
Use ctx.actions.declare_file instead of ctx.new_file.
Use --incompatible_new_actions_api=false to temporarily disable this check.
```

This can be worked around with incompatible_new_actions_api flag but may as well fix it proper so downstream doesn't require this flag due to this code.

Also, depset() is no longer iterable by default without a flag. This required fixing in a few spots in @angular/bazel.

fix: foo

PR Close #31325
2019-07-01 14:16:42 -07:00
Alan f83dfd6f5a fix(core): handle `undefined` meta in `injectArgs` (#31333)
In the recent versions of the CLI we introduced a ctor downleveler tranformer for VE JIT builds based on the one found in tsickle, to fix the TDZ issue of `forwardRef`.

However this caused a regression as the injector is not handling that a position `paramType` can be undefined. Which is bubbled down to c6b29f4c6d/packages/core/src/di/injector_compatibility.ts (L162) and will crash c6b29f4c6d/packages/core/src/di/injector_compatibility.ts (L174-L186)

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

PR Close #31333
2019-07-01 10:11:08 -07:00
Pete Bacon Darwin dd36f3ac99 feat(ivy): ngcc - handle top-level helper calls in CommonJS (#31335)
Some formats of CommonJS put the decorator helper calls
outside the class IIFE as statements on the top level of the
source file.

This commit adds support to the `CommonJSReflectionHost`
for this format.

PR Close #31335
2019-07-01 10:09:41 -07:00
Philippe Martin 0d6fd134d4 docs(core): update link to external i18n doc (#31353)
PR Close #31353
2019-07-01 10:08:53 -07:00
artem-galas bbb27b5517 docs: change order of Angular Elements article (#30521)
PR Close #30268

PR Close #30521
2019-06-28 12:22:45 -07:00
Pawel Kozlowski 7ca611cd12 fix(ivy): properly handle re-projection with an empty set of nodes to re-project (#31306)
PR Close #31306
2019-06-28 12:21:37 -07:00
Andrew Kushnir c12b6fa028 fix(ivy): attach host element for views created via TestBed.createComponent (#31318)
Prior to this commit, host element of a view created via TestBed.createComponent was not attached to the component's host, making it problematic to use TestBed.createComponent API in component factories, which might be used for testing purposes only. This behavior is observed in google3 app tests and was supported by VE, so this commit aligns Ivy and VE.

PR Close #31318
2019-06-28 12:20:53 -07:00
Ayaz Hafiz a29dc961a2 feat(bazel): allow passing a custom bazel compiler host to ngc compile (#31341)
Enable users to pass a custom Bazel CompilerHost to use for an Angular
compilation. This supports users who must override the TypeScript
compiler host.

PR Close #31341
2019-06-28 12:18:20 -07:00
Alex Rickabaugh 0de5d79bf6 Revert "fix(router): adjust UrlTree redirect to replace URL if in eager update (#31168)" (#31344)
This reverts commit 15e397816f.

Reason: it broke an internal g3 app.

PR Close #31344
2019-06-28 11:40:27 -07:00
George Kalpakas f57e77eeb4 build(docs-infra): upgrade cli command docs sources to 9edecc522 (#31331)
Updating [angular#master](https://github.com/angular/angular/tree/master) from [cli-builds#master](https://github.com/angular/cli-builds/tree/master).

##
Relevant changes in [commit range](e819d9b77...9edecc522):

**Modified**
- help/build.json
- help/doc.json

##

PR Close #31331
2019-06-28 09:27:13 -07:00
Brandon 2b5d52fbdc docs: add tests for lazy loading angularjs example (#30622)
PR Close #30622
2019-06-28 09:26:49 -07:00
crisbeto 81332150aa perf(ivy): chain host binding instructions (#31296)
Adds chaining to the `property`, `attribute` and `updateSyntheticHostBinding` instructions when they're used in a host binding.

This PR resolves FW-1404.

PR Close #31296
2019-06-28 09:26:20 -07:00
Santosh Yadav c6b29f4c6d docs: added svg example (#30559)
Fixes #30441

PR Close #30559
2019-06-27 15:56:26 -07:00
George Kalpakas 261dc04d8e fix(docs-infra): detect docregions on more file types (`pug`, `svg`, `yml`) (#30559)
PR Close #30559
2019-06-27 15:56:26 -07:00
Jason Aden 15e397816f fix(router): adjust UrlTree redirect to replace URL if in eager update (#31168)
Without this change when using UrlTree redirects in `urlUpdateStrategy="eager"`, the URL would get updated to the target location, then redirected. This resulted in having an additional entry in the `history` and thus the `back` button would be broken (going back would land on the URL causing a new redirect).

Additionally, there was a bug where the redirect, even without `urlUpdateStrategy="eager"`, could create a history with too many entries. This was due to kicking off a new navigation within the navigation cancelling logic. With this PR the new navigation is pushed to the next tick with a `setTimeout`, allowing the page being redirected from to be cancelled before starting a new navigation.

Related to #27148

PR Close #31168
2019-06-27 15:54:20 -07:00
Stepan Suvorov f96a81a818 docs: fix example misprints (#31284)
PR Close #31284
2019-06-27 15:53:25 -07:00
Olivier Combe 4f38419e33 fix(ivy): handle ICU expressions in `executeActionOnNode` (#31313)
When `walkTNodeTree` was refactored, the case of ICU expressions was forgotten (because it was handled in the `else` previously).
This PR fixes that to handle it like `ElementContainer`.

FW-1411 #resolve
PR Close #31313
2019-06-27 15:53:10 -07:00
George Kalpakas 119004c7d4 ci: add branch info to CircleCI failure notifications (#31319)
PR Close #31319
2019-06-27 15:52:14 -07:00
Pete Bacon Darwin d171006083 fix(ivy): ngtsc - NgtscCompilerHost should cope with directories that look like files (#31289)
The TS compiler is likely to test paths with extensions and try to
load them as files. Therefore `fileExists()` and methods that rely
on it need to be able to distinguish between real files and directories
that have paths that look like files.

This came up as a bug in ngcc when trying to process `ngx-virtual-scroller`,
which relies upon a library called `@tweenjs/tween.js`.

PR Close #31289
2019-06-27 12:34:51 -07:00
George Kalpakas 19e8570ac0 refactor(service-worker): remove redundant cache operation (#30977)
At this point, the response will have been cached (or scheduled to be
cached) in other code paths, so caching it again is redundant.

PR Close #30977
2019-06-27 09:52:29 -07:00
George Kalpakas 93abc35213 fix(service-worker): cache opaque responses when requests exceeds timeout threshold (#30977)
PR Close #30977
2019-06-27 09:52:29 -07:00
George Kalpakas d7be38f84b fix(service-worker): cache opaque responses in data groups with `freshness` strategy (#30977)
Previously, (presummably due to a typo) the `okToCacheOpaque` argument
of `DataGroup#cacheResponse()` was essentially never taken into account
(since opaque responses have a non-200 status code and thus `res.ok` is
always false).

This commit fixes the typo, which allows opaque responses to be cached
when `okToCacheOpaque` is true (i.e. in data groups using the
`freshness` strategy).

Fixes #30968

PR Close #30977
2019-06-27 09:52:29 -07:00
George Kalpakas 2d38623974 refactor(service-worker): make the caching behavior more explicit (#30977)
This commit doesn't change the behavior wrt caching, but it makes it
more explicit that only non-timed-out responses are cached. In case of a
timeout, `res` would be set to a programmatically created 504
`Response`, so `cacheResponse()` (which checks for `res.ok`) would not
have cached it anyway, but this makes change makes it more explicit (and
more similar to the equivalent part in [handleFetchWithFreshness()][1]).

[1]: https://github.com/angular/angular/blob/2b4d5c754/packages/service-worker/worker/src/data.ts#L379-L388

PR Close #30977
2019-06-27 09:52:28 -07:00
George Kalpakas 5306330d85 test(service-worker): better simulate opaque requests (#30977)
Previously, opaque responses where handled a little differently than
other responses from the mock server. More specifically, they were not
tracked (so no assertions could be made for them) and their
[`Body` mixin][1] methods (such as `arrayBuffer()`, `json()`, `text()`)
would throw an error due to `body` being `null`.

This commit ensures opaque responses are also captured on the mock
server and also changes `Body` mixin methods to better simulate the
[spec'd behavior][2].

(These improvements will be necessary to test caching of opaque
responses in a subsequent commit.)

[1]: https://developer.mozilla.org/en-US/docs/Web/API/Body
[2]: https://fetch.spec.whatwg.org/#concept-body-consume-body

PR Close #30977
2019-06-27 09:52:28 -07:00
George Kalpakas c150354464 test(service-worker): properly reset mock server state for each test (#30977)
PR Close #30977
2019-06-27 09:52:28 -07:00
George Kalpakas 7217525da4 test(service-worker): simplify test helpers (#30977)
PR Close #30977
2019-06-27 09:52:28 -07:00
George Kalpakas b6e8d19313 test(service-worker): remove obsolete async test helpers (#30977)
Jasmine natively supports returning promises from spec functions for
quite some time now. We don't need special async helpers.

PR Close #30977
2019-06-27 09:52:28 -07:00
Alan 6c0cca093a docs: couple of small UI fixes throughout some documents (#31155)
PR Close #31155
2019-06-27 09:51:28 -07:00
Kristiyan Kostadinov f2360aab9d fix(ivy): incorrect namespace for root node created through ViewContainerRef (#31232)
Currently in Ivy whenever we encounter a new namespace, we set it in the global state so that all subsequent nodes are created under the same namespace. Next time a template is run the namespace will be reset back to HTML.

This breaks down if the last node that was rendered was under the SVG or MathML namespace and we create a component through `ViewContainerRef.create`, because the next template function hasn't run yet and it hasn't had the chance to update the namespace. The result is that the root node of the new component will retain the wrong namespace and may not end up rendering at all (e.g. if we're trying to show a `div` inside the SVG namespace). This issue has the potential to affect a lot of apps, because all components inserted through the router also go through `ViewContainerRef.create`.

PR Close #31232
2019-06-27 09:50:52 -07:00
George Kalpakas d7b4172678 build(docs-infra): upgrade cli command docs sources to e819d9b77 (#31307)
Updating [angular#master](https://github.com/angular/angular/tree/master) from [cli-builds#master](https://github.com/angular/cli-builds/tree/master).

##
Relevant changes in [commit range](01a7186bb...e819d9b77):

**Modified**
- help/generate.json

##

PR Close #31307
2019-06-27 09:50:20 -07:00
Kara Erickson 641a4ea763 release: cut the v8.1.0-rc.0 release 2019-06-26 14:06:11 -07:00
Kara Erickson da4f7fbe1b docs: release notes for the v8.0.3 release 2019-06-26 13:56:16 -07:00
Joey Perrott 9c87d223ee ci: target default pool for linux RBE executions (#31297)
PR Close #31297
2019-06-26 13:31:36 -07:00
Paul Gschwendtner 2be061a96e docs: add "ivy" and "zone.js" to known scopes in contributing guide (#31291)
Currently the contributing guide misses entries for the `ivy` and `zone.js`
scopes. This commit adds these to the contributing guide as it is useful
for new contributors to know which scopes are supported.

PR Close #31291
2019-06-26 13:30:23 -07:00
George Kalpakas 3851544674 style: fix code style in several files (#31295)
These files have not been formatted properly, due to issues in the
`gulp format*` tasks. See previous commits (or #31295) for more details.

PR Close #31295
2019-06-26 13:29:29 -07:00
George Kalpakas 6b7b4ee891 build: fix formatting tasks by ignoring the `zone.js/` directory (#31295)
This was causing issues, because `zone.js` looks like a JS file (despite
it being a directory). The contents of `zone.js/` are still matched by
the globs (it is only the directory itself that is excluded).

Related to #30962.

PR Close #31295
2019-06-26 13:29:29 -07:00
George Kalpakas 279e74603e refactor: move negative glob patterns of files to format close to their positive counterparts (#31295)
This makes it easier to identify which files in directory will be
included and which will be ignored.

PR Close #31295
2019-06-26 13:29:29 -07:00
George Kalpakas 8503901746 build: downgrade `gulp-clang-format` to 1.0.23 (#31295)
The `gulp format*` tasks have been broken since 5eb742621. These include
the `gulp format:enforce` task, which is what runs on CI to enforce
consistent code style. Here is what (I believe) happened:

- I assume formatting was failing in 5eb742621 (moving `zone.js` into
  `angular/angular`). The reason must have been that
  [this glob pattern][1] matches `packages/zone.js/` (which is a
  directory) and passes it to `clang-format` claiming it is a file.
- I further assume that in an attempt to fix the issue,
  `gulp-clang-format` was updated to the latest version (1.0.27) in
  5eb742621.
- `gulp format:enforce` stopped complaining, so everyone thought
  formatting was fine and moved on.
- Formatting still wasn't fine, but the task completed successfully
  nevertheless 😱
- The reason is that angular/gulp-clang-format@55b697c5c (and subsequent
  commits) changed the way the `done()` callback was called, leaving it
  to `clang-format` to call it (while previously it was also called when
  the associated stream ended).
- In the old version of `clang-format` that we are using (1.0.41), there
  is a bug (which has been fixed in angular/clang-format@4cce2c4ee):
  The callback is not called
  [unless the process exits with an error][2].

One can also see that the `gulp format:enforce` task is not completed in
`gulp lint`. Example output from [build 374722][3]:

```
yarn gulp lint
...
Starting 'format:enforce'...
Starting 'validate-commit-messages'...
...
Finished 'validate-commit-messages' after 833 ms
Starting 'tools:build'...
Finished 'tools:build' after 1.75 s
Starting 'tslint'...
Finished 'tslint' after 19 s
Done in 21.82s.
```

Notice that all tasks have a corresponding "Finished X` log, except for
`format:enforce`.

For reference:
The problem was originally reported by @ocombe on Slack ([discussion][4]).

---
This commit fixes the issue by downgrading `gulp-clang-format` to
1.0.23. The linting failures due to formatting issues will be addressed
in subsequent commits.

[1]: https://github.com/angular/angular/blob/a8f3b317f/tools/gulp-tasks/format.js#L13
[2]: https://github.com/angular/clang-format/blob/b8c7df0b7/index.js#L95
[3]: https://circleci.com/gh/angular/angular/374722
[4]: https://angular-team.slack.com/archives/C042EU9T5/p1561480241191000

PR Close #31295
2019-06-26 13:29:29 -07:00
Paul Gschwendtner e01d697eed build: filter out changelog entries for zone.js from framework changelog (#31277)
We don't want to show entries for the `zone.js` scope in the main framework
changelog file. The zone.js changelog will be handled separately within the
`packages/zone.js` folder. (see [here](https://github.com/angular/angular/pull/31277#issuecomment-505934681))

PR Close #31277
2019-06-26 09:23:02 -07:00
Paul Gschwendtner 59d2edfebe build: allow "zone.js" as scope for commit messages (#31277)
Adds `zone.js` as valid scope for commit messages. This
is necessary because the `zone.js` repository has been
moved into the mono-repo and future changes should be
categorized properly through commit messages.

Currently the pre-commit git hook or CircleCI will fail when
`zone.js` is used as commit scope.

PR Close #31277
2019-06-26 09:23:02 -07:00