Commit Graph

701 Commits

Author SHA1 Message Date
Igor Minar 9c210281d4 feat(compiler): emit @__PURE__ or @pureOrBreakMyCode annotations in the generated code (#41096)
This change marks all relevant define* callsites as pure, causing the compiler to
emmit either @__PURE__ or @pureOrBreakMyCode annotation based on whether we are
compiling code annotated for closure or terser.

This change is needed in g3 where we don't run build optimizer but we
need the code to be annotated for the closure compiler.

Additionally this change allows for simplification of CLI and build optimizer as they
will no longer need to rewrite the generated code (there are still other places where
a build optimizer rewrite will be necessary so we can't remove it, we can only simplify it).

PR Close #41096
2021-03-08 10:30:08 -08:00
Sagar Pandita c1a93fcf32 docs: remove augury resource (#41107)
Partially addresses #41030.

PR Close #41107
2021-03-08 10:00:13 -08:00
Andrew Kushnir 4637df5551 test(forms): add integration test app to keep track of payload size (#41045)
This commit adds a Forms-based test app into the `integration` folder to have an ability to measure and keep
track of payload size for the changes in Forms package.

PR Close #41045
2021-03-05 09:45:42 -08:00
Joey Perrott f93eae7708 build: update to rules_nodejs@3.2.1 (#40972)
Update to the latest version of rules_nodejs.

PR Close #40972
2021-02-24 08:00:03 -08:00
Alan Agius c362205882 build: update test to use new zone.js entry-points (#40823)
In CLI version 12, the old style of imports is no longer supported.

PR Close #40823
2021-02-24 07:58:29 -08:00
George Kalpakas a4c00c2148 build: upgrade `webdriver-manager` to v12.1.8 (#40756)
ChromeDriver now supports Apple Silicon ARM processors.
`webdriver-manager` versions 12.1.7 and earlier will, however,
incorrectly download the arm64 ChromeDriver regardless of the
system's architecture. This results in failure to run Protractor tests
on macOS with the error: `spawn Unknown system error -86`

This commit fixes the problem by upgrading `webdriver-manager` to
version 12.1.8, which includes a fix.
See also https://stackoverflow.com/questions/65618558.

PR Close #40756
2021-02-17 06:52:31 -08:00
George Kalpakas defd6b4230 build: use correct path for local dependencies in `ivy-i18n` integration project (#40756)
Previously, the paths to some local dependencies in the `ivy-i18n`
integration project were pointing to non-generic bazel files that would
normally not exist on a user's machine.

This commit changes these paths to relative paths pointing to build
artifacts that are guaranteed to exist (once the necessary build
commands have been executed).

PR Close #40756
2021-02-17 06:52:31 -08:00
George Kalpakas 7d931d3e04 build: ensure integration projects use root `webdriver-manager` (#40756)
Ensure that all integration projects use `webdriver-manager` from the
root `node_modules/`. See acfd0edd38 for
more details.

PR Close #40756
2021-02-17 06:52:31 -08:00
George Kalpakas 43ecf8a77b feat(platform-server): allow shimming the global env sooner (#40559)
`@angular/platform-server` provides the foundation for rendering an
Angular app on the server. In order to achieve that, it uses a
server-side DOM implementation (currently [domino][1]).

For rendering on the server to work as closely as possible to running
the app on the browser, we need to make DOM globals (such as `Element`,
`HTMLElement`, etc.), which are normally provided by the browser,
available as globals on the server as well.

Currently, `@angular/platform-server` achieves this by extending the
`global` object with the DOM implementation provided by `domino`. This
assignment happens in the [setDomTypes()][2] function, which is
[called in a `PLATFORM_INITIALIZER`][3]. While this works in most cases,
there are some scenarios where the DOM globals are needed sooner (i.e.
before initializing the platform). See, for example, #24551 and #39950
for more details on such issues.

This commit provides a way to solve this problem by exposing a
side-effect-ful entry-point (`@angular/platform-server/init`), that
shims the `global` object with DOM globals. People will be able to
import this entry-point in their server-rendered apps before
bootstrapping the app (for example, in their `main.server.ts` file).
(See also [#39950 (comment)][4].)

In a future update, the [`universal` schematics][5] will include such an
import by default in newly generated projects.

[1]: https://www.npmjs.com/package/domino
[2]: https://github.com/angular/angular/blob/0fc8466f1be392917e0c/packages/platform-server/src/domino_adapter.ts#L17-L21
[3]: https://github.com/angular/angular/blob/0fc8466f1be392917e0c/packages/platform-server/src/server.ts#L33
[4]: https://github.com/angular/angular/issues/39950#issuecomment-747598403
[5]: https://github.com/angular/angular-cli/blob/cc51432661eb4ab4b6a3/packages/schematics/angular/universal

PR Close #40559
2021-02-12 08:55:25 -08:00
George Kalpakas 177eab2260 ci: add integration test for Angular Elemens with SSR (#40559)
This commit adds an integration test that uses `@angular/elements` with
`@angular/platform-server` in order to highlight a current
incompatibility. The issue will be fixed in a subsequent commit.

PR Close #40559
2021-02-12 08:55:25 -08:00
Joey Perrott 696f7bccfe fix(bazel): update build tooling for latest changes in rules_nodejs (#40710)
Update the build tooling to handle the changes in the latest version of rules_nodejs.

PR Close #40710
2021-02-09 10:48:43 -08:00
Joey Perrott 34de89acbd fix(bazel): update integration test to use rules_nodejs@3.1.0 (#40710)
Update the integraiton tests for bazel to the latest rules_nodejs version.

PR Close #40710
2021-02-09 10:48:43 -08:00
Joey Perrott cffb00ec11 build: update bazel rules_nodejs to 2.3.3 (#40581)
Updates to rules_nodejs@2.3.3 to take advantage of windows specific fixes.
rules_nodejs@2.3.3 was created as a patch specifically with a fix for
the issues we found updating to rules_nodejs@2.2.2.

PR Close #40581
2021-01-26 15:07:04 -08:00
Alexey Elin cf02cf1e18 docs: remove duplicated the (#40434)
PR Close #40434
2021-01-14 11:33:57 -08:00
Andrew Scott 4e6d69cc85 Revert "build: update bazel rules_nodejs to 2.3.2 (#40367)" (#40395)
This reverts commit c9de7daae4.
Causes CI failures. PR was not meant to be merged (merge label was
supposed to be removed)

PR Close #40395
2021-01-11 12:51:11 -08:00
Joey Perrott c9de7daae4 build: update bazel rules_nodejs to 2.3.2 (#40367)
Updates to rules_nodejs@2.3.2 to take advantage of windows
specific fixes.

PR Close #40367
2021-01-11 10:46:18 -08:00
George Kalpakas 0153cd0d28 build: remove redundant `node_repositories` dictionary from `node_repositories` rules (#40151)
According to a [discussion with Alex Eagle][1], the `node_repositories`
dictionary is no longer necessary, since the `node_repositories` rule
will ensure all Node.js versions are available.

From the [`node_repositories` docs][2]:

> By default, if this attribute has no items, we’ll use a list of all
> public NodeJS releases.

[1]: https://angular-team.slack.com/archives/C042EU9T5/p1606841390116500?thread_ts=1606838958
[2]: https://bazelbuild.github.io/rules_nodejs/Built-ins.html#node_repositories-node_repositories

PR Close #40151
2021-01-08 09:37:51 -08:00
Joey Perrott ee6b8a7afb Revert "build: update bazel rules_nodejs to version 2.3.1 (#39636)" (#40174)
This reverts commit 68cf012f7a.

PR Close #40174
2020-12-17 09:29:42 -08:00
JiaLiPassion 68cf012f7a build: update bazel rules_nodejs to version 2.3.1 (#39636)
Update the version `rules_nodejs` to 2.3.1, so the `npm_package.pack` rule
can now work on windows os.

PR Close #39636
2020-12-14 11:29:33 -08:00
Misko Hevery bc6e6691e9 Revert "build: update bazel rules_nodejs to version 2.3.1 (#39636)"
This reverts commit eee878c00e.
2020-12-08 11:06:22 -08:00
JiaLiPassion eee878c00e build: update bazel rules_nodejs to version 2.3.1 (#39636)
Update the version `rules_nodejs` to 2.3.1, so the `npm_package.pack` rule
can now work on windows os.

PR Close #39636
2020-12-08 09:15:46 -08:00
Charles Lyding 4def19f39f test(compiler-cli): add TypeScript 4.1 typings integration test (#39571)
This change adds a typings test identical to the TypeScript 4.0 test but using TypeScript 4.1 instead.

PR Close #39571
2020-11-25 11:10:01 -08:00
Marcono1234 3e1e5a15ba docs: update links to use HTTPS as protocol (#39718)
PR Close #39718
2020-11-20 12:52:16 -08:00
Bjarki ce604b909b test(core): rename ivy-trusted-types integration test to trusted-types (#39614)
Since there won't be a ViewEngine-specific integration test, we don't
need the Ivy prefix.

PR Close #39614
2020-11-19 12:16:41 -08:00
Bjarki 569086a974 test(core): add e2e tests to ivy-trusted-types integration test (#39614)
Make sure that all Trusted Types-relevant sinks that can appear in an
Angular template (e.g. not <script>, since it's forbidden) continue to
work as expected with correct sanitization semantics, without
introducing Trusted Types violations.

PR Close #39614
2020-11-19 12:16:39 -08:00
Bjarki c2298512b3 test(core): enforce Trusted Types in ivy-trusted-types integration test (#39614)
Enforce Trusted Types in the ivy-trusted-types integration test by
setting an appropriate CSP header in the project's angular.json.

PR Close #39614
2020-11-19 12:16:38 -08:00
Bjarki 4dcf51a233 test(core): enable ivy-trusted-types integration test (#39614)
Add ivy-trusted-types to the list of enabled unit tests in
integration/BUILD.bazel

PR Close #39614
2020-11-19 12:16:37 -08:00
Bjarki 6e1708a2eb test(core): make ivy-trusted-types similar to other integration tests (#39614)
- @angular dependencies point to ../../dist
- use absolute versions for other dependencies
- add a yarn.lock
- create ci-specific targets
- make karma and protractor use correct Chrome binary

PR Close #39614
2020-11-19 12:16:36 -08:00
Bjarki fc0ee5be5f test(core): create ivy-trusted-types integration test (#39614)
Create an integration test for testing support for Trusted Types in Ivy.
Generated with:

```
yarn ng new ivy-trusted-types -g --skip-install --style css --routing --strict
```

PR Close #39614
2020-11-19 12:16:35 -08:00
JiaLiPassion f8956adb73 build: update zone.js version to 0.11.3 (#39317)
Update the version of `zone.js` from 0.10.3 to 0.11.3 inside
Angular repo.

PR Close #39317
2020-11-12 13:51:29 -08:00
Alan Agius 599ca34eda test(compiler-cli): remove typescript 3.9 tests (#39586)
We remove these tests because TypeScript 3.9 is no longer supported and G3 is currently on TS4.0

PR Close #39586
2020-11-06 15:26:51 -08:00
George Kalpakas bdce7698fc fix(elements): update the view of an `OnPush` component when inputs change (#39452)
As with regular Angular components, Angular elements are expected to
have their views update when inputs change.

Previously, Angular Elements views were not updated if the underlying
component used the `OnPush` change detection strategy.

This commit fixes this by calling `markForCheck()` on the component
view's `ChangeDetectorRef`.

NOTE:
This is similar to how `@angular/upgrade` does it:
3236ae0ee1/packages/upgrade/src/common/src/downgrade_component_adapter.ts (L146).

Fixes #38948

PR Close #39452
2020-11-06 09:31:46 -08:00
George Kalpakas c1907809a8 test(elements): add integration tests for Angular Elements using `ShadowDom` (#39452)
Previously, the project used for running integration tests for Angular
Elements declared a component that used `ShadowDom` for view
encopsulation, but it did not include any tests to verify that the view
was updated correctly.

This commit adds the missing tests.

PR Close #39452
2020-11-06 09:31:46 -08:00
Igor Minar 904b213954 build: update to @angular/cli@11.0.0-rc.0 (#39432)
This updates just the cli packages, the material and cdk packages
will be updated separately.

PR Close #39432
2020-10-29 13:47:12 -07:00
Alan Agius dd0ba3f4ab docs: rename `ng xi18n` to `ng extract-i18n` (#39337)
In Angular CLI version 11, xi18n has been changed from `ng xi18n` to `ng extract-i18n`.

PR Close #39337
2020-10-28 14:42:27 -07:00
JoostK 3c6edcdf93 fix(core): do not error when `ngDevMode` is undeclared (#39415)
In production mode, the `ngDevMode` global may not have been declared.
This is typically not a problem, as optimizers should have removed all
usages of the `ngDevMode` variables. This does however require the
bundler/optimizer to have been configured in a certain way, as to allow
for `ngDevMode` guarded code to be removed.

As an example, Terser can be configured to remove the `ngDevMode`
guarded code using the following configuration:

```js
const terserOptions = {
  // ...
  compress: {
    // ...
    global_defs: require('@angular/compiler-cli').GLOBAL_DEFS_FOR_TERSER,
  }
}
```

(Taken from https://github.com/angular/angular/issues/31595#issuecomment-519129090)

If this is not done, however, the bundle should still work (albeit with
larger code size due to missed tree-shaking opportunities). This commit
adds a check for whether `ngDevMode` has been declared, as it is a
top-level statement that executes before `ngDevMode` has been initialized.

Fixes #31595

PR Close #39415
2020-10-27 10:45:18 -07:00
Misko Hevery ffd4161797 docs(core): Add documentation on debugging size regression failures (#39301)
PR Close #39301
2020-10-22 09:35:48 -07:00
Bjarki cfac8e0764 build: upgrade karma to version 4.4.0 (#39180)
Upgrade the karma dependency to version 4.4.0 in the root package.json
and in integration tests. Compared to version 4.3.0, which most of the
packages were previously depending on, it has the following changes:

Bug Fixes
- runner: remove explicit error on all tests failed

Features
- client: Add trusted types support
- Preprocessor can return Promise
- config: add failOnSkippedTests option.
- config: clientDisplayNone sets client elements display none.
- deps: Remove core-js dependency.

The motivation for upgrading the package is the Trusted Types support
that it adds, which is necessary to enable Trusted Types in Angular's
unit tests.

PR Close #39180
2020-10-20 16:27:54 -07:00
JiaLiPassion d37939623f test(zone.js): test zone.js package with tgz (#38649)
Zone.js 0.11.0 release an empty bundle, and now the npm_package tests all target
bazel rule `npm_package`, but not `npm_package.pack`, and these two rules may
generate different results, for example, Zone.js 0.11.0's issue is `package.json`
define files array which make the bundle only include the files in the files array.
So this PR install the zone.js package from the archive generated from `npm_package.pack` rule.

PR Close #38649
2020-10-19 08:06:11 -07:00
Andrew Kushnir 8fd25d9614 docs: remove IE10 references from comments in the code (#39090)
PR Close #39090
2020-10-13 15:51:49 -07:00
Andrew Kushnir a051d97429 test(core): remove IE10 reference from `browserslist` files (#39090)
This commit updates `browserslist` files to exclude IE10 references.

PR Close #39090
2020-10-13 15:51:49 -07:00
Greg Magolan 42a164f522 build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#39182)
Updates to rules_nodejs 2.2.0. This is the first major release in 7 months and includes a number of features as well
as breaking changes.

Release notes: https://github.com/bazelbuild/rules_nodejs/releases/tag/2.0.0

Features of note for angular/angular:

* stdout/stderr/exit code capture; this could be potentially be useful

* TypeScript (ts_project); a simpler tsc rule that ts_library that can be used in the repo where ts_library is too
  heavy weight

Breaking changes of note for angular/angular:

* loading custom rules from npm packages: `ts_library` is no longer loaded from `@npm_bazel_typescript//:index.bzl`
  (which no longer exists) but is now loaded from `@npm//@bazel/typescript:index.bzl`

* with the loading changes above, `load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")` is
  no longer needed in the WORKSPACE which also means that yarn_install does not need to run unless building/testing
  a target that depends on @npm. In angular/angular this is a minor improvement as almost everything depends on @npm.

* @angular/bazel package is also updated in this PR to support the new load location; Angular + Bazel users that
  require it for ng_package (ng_module is no longer needed in OSS with Angular 10) will need to load from
  `@npm//@angular/bazel:index.bzl`. I investigated if it was possible to maintain backward compatability for the old
  load location `@npm_angular_bazel` but it is not since the package itself needs to be updated to load from
  `@npm//@bazel/typescript:index.bzl` instead of `@npm_bazel_typescript//:index.bzl` as it depends on ts_library
  internals for ng_module.

* runfiles.resolve will now throw instead of returning undefined to match behavior of node require

Other changes in angular/angular:

* integration/bazel has been updated to use both ng_module and ts_libary with use_angular_plugin=true.
  The latter is the recommended way for rules_nodejs users to compile Angular 10 with Ivy. Bazel + Angular ViewEngine is
  supported with @angular/bazel <= 9.0.5 and Angular <= 8. There is still Angular ViewEngine example on rules_nodejs
  https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_view_engine on these older versions but users
  that want to update to Angular 10 and are on Bazel must switch to Ivy and at that point ts_library with
  use_angular_plugin=true is more performant that ng_module. Angular example in rules_nodejs is configured this way
  as well: https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular. As an aside, we also have an
  example of building Angular 10 with architect() rule directly instead of using ts_library with angular plugin:
  https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_bazel_architect.

NB: ng_module is still required for angular/angular repository as it still builds ViewEngine & @angular/bazel
also provides the ng_package rule. ng_module can be removed in the future if ViewEngine is no longer needed in
angular repo.

* JSModuleInfo provider added to ng_module. this is for forward compat for future rules_nodejs versions.

PR Close #39182
2020-10-08 11:54:59 -07:00
Joey Perrott c214cad2b4 Revert "build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#37727)" (#39097)
This reverts commit db56cf18ba.

PR Close #39097
2020-10-02 10:56:53 -07:00
Greg Magolan db56cf18ba build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#37727)
Updates to rules_nodejs 2.2.0. This is the first major release in 7 months and includes a number of features as well
as breaking changes.

Release notes: https://github.com/bazelbuild/rules_nodejs/releases/tag/2.0.0

Features of note for angular/angular:

* stdout/stderr/exit code capture; this could be potentially be useful

* TypeScript (ts_project); a simpler tsc rule that ts_library that can be used in the repo where ts_library is too
  heavy weight

Breaking changes of note for angular/angular:

* loading custom rules from npm packages: `ts_library` is no longer loaded from `@npm_bazel_typescript//:index.bzl`
  (which no longer exists) but is now loaded from `@npm//@bazel/typescript:index.bzl`

* with the loading changes above, `load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")` is
  no longer needed in the WORKSPACE which also means that yarn_install does not need to run unless building/testing
  a target that depends on @npm. In angular/angular this is a minor improvement as almost everything depends on @npm.

* @angular/bazel package is also updated in this PR to support the new load location; Angular + Bazel users that
  require it for ng_package (ng_module is no longer needed in OSS with Angular 10) will need to load from
  `@npm//@angular/bazel:index.bzl`. I investigated if it was possible to maintain backward compatability for the old
  load location `@npm_angular_bazel` but it is not since the package itself needs to be updated to load from
  `@npm//@bazel/typescript:index.bzl` instead of `@npm_bazel_typescript//:index.bzl` as it depends on ts_library
  internals for ng_module.

* runfiles.resolve will now throw instead of returning undefined to match behavior of node require

Other changes in angular/angular:

* integration/bazel has been updated to use both ng_module and ts_libary with use_angular_plugin=true.
  The latter is the recommended way for rules_nodejs users to compile Angular 10 with Ivy. Bazel + Angular ViewEngine is
  supported with @angular/bazel <= 9.0.5 and Angular <= 8. There is still Angular ViewEngine example on rules_nodejs
  https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_view_engine on these older versions but users
  that want to update to Angular 10 and are on Bazel must switch to Ivy and at that point ts_library with
  use_angular_plugin=true is more performant that ng_module. Angular example in rules_nodejs is configured this way
  as well: https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular. As an aside, we also have an
  example of building Angular 10 with architect() rule directly instead of using ts_library with angular plugin:
  https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_bazel_architect.

NB: ng_module is still required for angular/angular repository as it still builds ViewEngine & @angular/bazel
also provides the ng_package rule. ng_module can be removed in the future if ViewEngine is no longer needed in
angular repo.

* JSModuleInfo provider added to ng_module. this is for forward compat for future rules_nodejs versions.
  @josephperrott, this touches `packages/bazel/src/external.bzl` which will make the sync to g3 non-trivial.

PR Close #37727
2020-10-01 15:34:36 -07:00
Joey Perrott 93c3d8f9fd fix(platform-webworker): remove platform-webworker and platform-webworker-dynamic (#38846)
Remove @angular/platform-webworker and @angular/platform-webworker-dynamic
as they were deprecated in v8

BREAKING CHANGE: @angular/platform-webworker and @angular/platform-webworker-dynamic
have been removed as they were deprecated in v8

PR Close #38846
2020-09-30 09:13:59 -04:00
Joey Perrott 930eeaf177 fix(bazel): fix integration test for bazel building (#38629)
Update the API used to request a timestamp.  The previous API we relied on for this
test application, worldclockapi.com no longer serves times and simply 403s on all
requests.  This caused our test to timeout as the HTTP request did not handle a failure
case.  By moving to a new api, the HTTP request responds as expected and timeouts
are corrected as there is not longer a pending microtask in the queue.

PR Close #38629
2020-08-28 11:16:40 -07:00
Alan Agius 0fc44e0436 feat(compiler-cli): add support for TypeScript 4.0 (#38076)
With this change we add support for TypeScript 4.0

PR Close #38076
2020-08-24 13:06:59 -07:00
Andrew Scott 945751e2e8 ci: disable closure size tracking test (#38449)
We should define ngDevMode to false in Closure, but --define only works in the global scope.
With ngDevMode not being set to false, this size tracking test provides little value but a lot of
headache to continue updating the size.

PR Close #38449
2020-08-13 11:41:13 -07:00
JiaLiPassion 8fbf40bf40 feat(core): update reference and doc to change `async` to `waitAsync`. (#37583)
The last commit change `async` to `waitForAsync`.
This commit update all usages in the code and also update aio doc.

PR Close #37583
2020-08-03 12:54:13 -07:00
Charles Lyding 6f6102d8ad fix(compiler): add PURE annotation to getInheritedFactory calls (#38291)
Currently the `getInheritedFactory` function is implemented to allow
closure to remove the call if the base factory is unused.  However, this
method does not work with terser.  By adding the PURE annotation,
terser will also be able to remove the call when unused.

PR Close #38291
2020-07-30 16:53:52 -07:00