Commit Graph

457 Commits

Author SHA1 Message Date
Miško Hevery bb53b6549c refactor(ivy): move all of the instruction state into a singe object (#33093)
Turns out that writing to global state is more expensive than writing to
a property on an object.

Slower:
````
let count = 0;

function increment() {
  count++;
}
```

Faster:
````
const state = {
  count: 0
};

function increment() {
  state.count++;
}
```

This change moves all of the instruction state into a single state object.

`noop_change_detection` benchmark
Pre refactoring: 16.7 us
Post refactoring: 14.523 us (-13.3%)

PR Close #33093
2019-10-17 16:00:55 -04:00
Paul Gschwendtner d1323b5c8f test: improve missing-injectable migration test case in ng-update integration test (#33223)
Improves the `missing-injectable` migration test case in the
`ng_update_migrations` integration test by adding scenarios
for the recent changes that have been made to the migration.

e.g. 5557dec120

PR Close #33223
2019-10-17 14:14:28 -04:00
Paul Gschwendtner 06093559a2 test: update angular cli version for ng_update_migrations integration test (#33223)
Updates the Angular CLI version in the `ng_update_migrations`
integration test. Since refactorings are made to the `ng update`
command implementation, we want to make sure that everything
works as expected for the migrations in version 9.

PR Close #33223
2019-10-17 14:14:28 -04:00
Matias Niemelä 082aed6e46 revert: feat: add a flag in bootstrap to enable coalesce event change detection to improve performance (#30533) (#33230)
This reverts commit 21c1e14385.

PR Close #33230
2019-10-17 12:50:04 -04:00
Matias Niemelä e9ee6859e3 revert: build: remove vendored Babel typings (#33176) (#33215)
This reverts commit 4c63e6ba04.

PR Close #33215
2019-10-17 00:24:25 -04:00
Kara Erickson cda9248b33 refactor(core): rename ngInjectorDef to ɵinj (#33151)
Injector defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngInjectorDef to inj. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

PR Close #33151
2019-10-16 16:36:19 -04:00
JiaLiPassion 21c1e14385 feat: add a flag in bootstrap to enable coalesce event change detection to improve performance (#30533)
PR Close #30533
2019-10-16 14:38:36 -04:00
Alex Eagle 4c63e6ba04 build: remove vendored Babel typings (#33176)
These were getting included in the @angular/localize package.
Instead, patch the upstream files to work with TS typeRoots option

See bazelbuild/rules_nodejs#1033

PR Close #33176
2019-10-16 12:54:28 -04:00
Kara Erickson fc93dafab1 refactor(core): rename ngModuleDef to ɵmod (#33142)
Module defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngModuleDef to mod. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

PR Close #33142
2019-10-14 23:08:10 +00:00
Pete Bacon Darwin f433d6604b feat(ivy): i18n - support source locale inlining (#33101)
Add a new flag to `localize-translate` that allows the
source locale to be specified. When this locale is
provided an extra copy of the files is made for this
locale where the is no translation but all the calls to
`$localize` are stripped out.

Resolves FW-1623

PR Close #33101
2019-10-14 20:32:57 +00:00
Greg Magolan 0004896ff9 build: update to nodejs rules 0.38.3 (#33073)
All providers now loaded from "@build_bazel_rules_nodejs//:providers.bzl".

PR Close #33073
2019-10-14 20:25:57 +00:00
Greg Magolan 5e694e519b build: update to nodejs rules 0.38.2 (#33073)
Some changes in rules_nodejs providers folded into @angular/bazel package:
* `NodeModuleSources` renamed to `NpmPackageInfo` and now loaded from `//internal/common:npm_package_info.bzl`
* `collect_node_modules_aspect` renamed to `node_modules_aspect`
* new JS provider `JSNamedModuleInfo` now available and ng_module provides it using the `js_named_module_info` factory function
* sources_aspect has also been removed so the use of the `node_sources` legacy provider has been replaced with `JSNamedModuleInfo`.

PR Close #33073
2019-10-14 20:25:57 +00:00
Pete Bacon Darwin 868b3f9463 test(ivy): i18n - run integration test in es2015 mode (#33097)
The new CLI build pipeline will automatically downlevel
ES2015 to ES5 if the tsconfig compilation is set to
ES2015.

This change ensures that the compile-time inlining of
translations handles both the ES2015 code and the
downleveled ES5 code.

PR Close #33097
2019-10-14 16:33:39 +00:00
George Kalpakas 1a34fbce25 fix(ngcc): rename the executable from `ivy-ngcc` to `ngcc` (#33140)
Previously, the executable for the Angular Compatibility Compiler
(`ngcc`) was called `ivy-ngcc`. This would be confusing for users not
familiar with our internal terminology, especially given that we call it
`ngcc` in all our docs and presentations.

This commit renames the executable to `ngcc` and replaces `ivy-ngcc`
with a script that errors with an informative message (prompting the
user to use `ngcc` instead).

Jira issue: [FW-1624](https://angular-team.atlassian.net/browse/FW-1624)

PR Close #33140
2019-10-14 16:29:14 +00:00
Pete Bacon Darwin f640a4a494 fix(ivy): i18n - turn on legacy message-id support by default (#33053)
For v9 we want the migration to the new i18n to be as
simple as possible.

Previously the developer had to positively choose to use
legacy messsage id support in the case that their translation
files had not been migrated to the new format by setting the
`legacyMessageIdFormat` option in tsconfig.json to the format
of their translation files.

Now this setting has been changed to `enableI18nLegacyMessageFormat`
as is a boolean that defaults to `true`. The format is then read from
the `i18nInFormat` option, which was previously used to trigger translations
in the pre-ivy angular compiler.

PR Close #33053
2019-10-10 13:58:30 -07:00
Pete Bacon Darwin 009cab8dce test(ivy): i18n - add compile time translation to integration test (#32881)
PR Close #32881
2019-10-09 13:19:38 -07:00
Pete Bacon Darwin 2cdb3a079d feat(ivy): i18n - implement compile-time inlining (#32881)
This commit implements a tool that will inline translations and generate
a translated copy of a set of application files from a set of translation
files.

PR Close #32881
2019-10-09 13:19:38 -07:00
Pete Bacon Darwin b2b917d2d8 feat(ngcc): expose `--create-ivy-entry-points` option on ivy-ngcc (#33049)
This allows a postinstall hook to generate the same
output as the CLI integration does.

See https://github.com/angular/angular/pull/32999#issuecomment-539937368

PR Close #33049
2019-10-09 13:16:16 -07:00
Alex Eagle cdfbda3d3b build: add missing http-server dep to bazel example (#32889)
Also update rules_nodejs 0.38.0->0.38.1

PR Close #32889
2019-10-08 09:27:11 -07:00
Alex Eagle f783244ad1 build: update to rules_nodejs 0.38 (#32889)
PR Close #32889
2019-10-08 09:27:11 -07:00
crisbeto 2265cb5938 refactor(core): remove deprecated Renderer (#33019)
Removes the `Renderer` and related symbols which have been deprecated since version 4.

BREAKING CHANGES:
* `Renderer` has been removed. Use `Renderer2` instead.
* `RenderComponentType` has been removed. Use `RendererType2` instead.
* `RootRenderer` has been removed. Use `RendererFactory2` instead.

PR Close #33019
2019-10-08 09:23:00 -07:00
JiaLiPassion 53d13c3fc6 refactor: rename unpatched event flag in Zone from `BLACK_LISTED_EVENTS` to `UNPATCHED_EVENTS` (#29617)
Closes #28529

PR Close #29617
2019-10-04 08:44:58 -07:00
Pete Bacon Darwin fca3e79415 test(ivy): i18n - add legacy-id-mode integration test (#32937)
PR Close #32937
2019-10-03 12:12:55 -07:00
Pete Bacon Darwin 32e315755b test(ivy): add runtime translations to integration test app (#32867)
PR Close #32867
2019-10-02 14:52:00 -07:00
Alan Agius 668f57abaa build: update rxjs to 6.5.3 (#32812)
PR Close #32812
2019-10-01 14:56:45 -07:00
Greg Magolan c1346462db build: update to nodejs rules 0.37.1 (#32151)
This release includes a ts_config runfiles fix so also cleaning up the one line work-around from #31943.

This also updates to upstream rules_webtesting browser repositories load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl", "browser_repositories") to fix a breaking change in the chromedriver distro. This bumps up the version of chromium to the version here: https://github.com/bazelbuild/rules_webtesting/blob/master/web/versioned/browsers-0.3.2.bzl

PR Close #32151
2019-09-25 11:29:12 -07:00
Matias Niemelä a2e890e4f7 refactor(ivy): get rid of styling cleanup functions outside of styling code (#32591)
Prior to this patch, each time `advance()` would run (or when a
templateFn or hostBindings code exits) then the core change detection
code would check to see whether the styling data needs to be reset. This
patch removes that functionality and places everything inside of the
scheduled styling exit function. This means that each time one or more
styling bindings run (even if the value hasn't changed) then an exit
function will be scheduled and that will do all the cleanup.

PR Close #32591
2019-09-16 14:12:48 -07:00
Matias Niemelä 4f41473048 refactor(ivy): remove styling state storage and introduce direct style writing (#32591)
This patch is a final major refactor in styling Angular.

This PR includes three main fixes:

All temporary state taht is persisted between template style/class application
and style/class application in host bindings is now removed.
Removes the styling() and stylingApply() instructions.
Introduces a "direct apply" mode that is used apply prop-based
style/class in the event that there are no map-based bindings as
well as property collisions.

PR Close #32259

PR Close #32591
2019-09-16 14:12:48 -07:00
Pete Bacon Darwin 2bf5606bbe feat(ivy): i18n - reorganize entry-points for better reuse (#32488)
This is a refactoring that moves the source code around to provide a better
platform for adding the compile-time inlining.

1. Move the global side-effect import from the primary entry-point to a
   secondary entry-point @angular/localize/init.

   This has two benefits: first it allows the top level entry-point to
   contain tree-shakable shareable code; second it gives the side-effect
   import more of an "action" oriented name, which indicates that importing
   it does something tangible

2. Move all the source code into the top src folder, and import the localize
   related functions into the localize/init/index.ts entry-point.

   This allows the different parts of the package to share code without
   a proliferation of secondary entry-points (i.e. localize/utils).

3. Avoid publicly exporting any utilities at this time - the only public
   API at this point are the global `$localize` function and the two runtime
   helpers `loadTranslations()` and `clearTranslations()`.
   This does not mean that we will not expose additional helpers for 3rd
   party tooling in the future, but it avoid us preemptively exposing
   something that we might want to change in the near future.

Notes:

It is not possible to have the `$localize` code in the same Bazel package
as the rest of the code. If we did this, then the bundled `@angular/localize/init`
entry-point code contains all of the helper code, even though most of it is not used.

Equally it is not possible to have the `$localize` types (i.e. `LocalizeFn`
and `TranslateFn`) defined in the `@angular/localize/init` entry-point because
these types are needed for the runtime code, which is inside the primary
entry-point. Importing them from `@angular/localize/init` would run the
side-effect.

The solution is to have a Bazel sub-package at `//packages/localize/src/localize`
which contains these types and the `$localize` function implementation.
The primary `//packages/localize` entry-point imports the types without
any side-effect.
The secondary `//packages/localize/init` entry-point imports the `$localize`
function and attaches it to the global scope as a side-effect, without
bringing with it all the other utility functions.

BREAKING CHANGES:

The entry-points have changed:

* To attach the `$localize` function to the global scope import from
`@angular/localize/init`. Previously it was `@angular/localize`.

* To access the `loadTranslations()` and `clearTranslations()` functions,
import from `@angular/localize`. Previously it was `@angular/localize/run_time`.

PR Close #32488
2019-09-12 15:35:34 -07:00
Filipe Silva 5f095a501e fix(core): initialize global ngDevMode without toplevel side effects (#32079)
Fix #31595

PR Close #32079
2019-09-11 20:31:14 -04:00
Matias Niemelä 53dbff66d7 revert: refactor(ivy): remove styling state storage and introduce direct style writing (#32259)
This reverts commit 15aeab1620.
2019-09-11 15:24:10 -07:00
Matias Niemelä 15aeab1620 refactor(ivy): remove styling state storage and introduce direct style writing (#32259) (#32596)
This patch is a final major refactor in styling Angular.

This PR includes three main fixes:

All temporary state taht is persisted between template style/class application
and style/class application in host bindings is now removed.
Removes the styling() and stylingApply() instructions.
Introduces a "direct apply" mode that is used apply prop-based
style/class in the event that there are no map-based bindings as
well as property collisions.

PR Close #32259

PR Close #32596
2019-09-11 16:27:10 -04:00
Matias Niemelä c84c27f7f4 revert: refactor(ivy): remove styling state storage and introduce direct style writing (#32259) 2019-09-10 18:08:05 -04:00
Matias Niemelä 3b37469735 refactor(ivy): remove styling state storage and introduce direct style writing (#32259)
This patch is a final major refactor in styling Angular.

This PR includes three main fixes:

All temporary state taht is persisted between template style/class application
and style/class application in host bindings is now removed.
Removes the styling() and stylingApply() instructions.
Introduces a "direct apply" mode that is used apply prop-based
style/class in the event that there are no map-based bindings as
well as property collisions.

PR Close #32259
2019-09-10 15:54:58 -04:00
ayazhafiz a391aebbcf feat(language-service): add definitions for styleUrls (#32464)
Adds support for `styleUrls` definitions in the same way `templateUrl`
definitions are provided; clicking on styleUrl will take a user to the
respective file.

Unifies some code in determining a URL definition. We first check if a
url is a `templateUrl`; if it's not, we check that it's a `styleUrl` or
return no definitions.

PR Close #32464
2019-09-09 16:04:14 -04:00
George Kalpakas 8296f6b681 test(ngcc): print an informative message when an integration test fails (#32427)
PR Close #32427
2019-09-09 15:55:14 -04:00
George Kalpakas e36e6c85ef perf(ngcc): process tasks in parallel in async mode (#32427)
`ngcc` supports both synchronous and asynchronous execution. The default
mode when using `ngcc` programmatically (which is how `@angular/cli` is
using it) is synchronous. When running `ngcc` from the command line
(i.e. via the `ivy-ngcc` script), it runs in async mode.

Previously, the work would be executed in the same way in both modes.

This commit improves the performance of `ngcc` in async mode by
processing tasks in parallel on multiple processes. It uses the Node.js
built-in [`cluster` module](https://nodejs.org/api/cluster.html) to
launch a cluster of Node.js processes and take advantage of multi-core
systems.

Preliminary comparisons indicate a 1.8x to 2.6x speed improvement when
processing the angular.io app (apparently depending on the OS, number of
available cores, system load, etc.). Further investigation is needed to
better understand these numbers and identify potential areas of
improvement.

Inspired by/Based on @alxhub's prototype: alxhub/angular@cb631bdb1
Original design doc: https://hackmd.io/uYG9CJrFQZ-6FtKqpnYJAA?view

Jira issue: [FW-1460](https://angular-team.atlassian.net/browse/FW-1460)

PR Close #32427
2019-09-09 15:55:13 -04:00
ayazhafiz 1716b91334 feat(language-service): add script to rebuild, refresh Angular dist (#32515)
The Language Service integration tests should reinstall the Angular
distribution every time it is built. Adds a `yarn build-dist`
convinience script so building the distribution doesn't have to
happen on the repo root. This new script also refreshes the installed
modules. Building is expesnive, so it is not bundled with testing
scripts.

PR Close #32515
2019-09-06 18:28:06 -04:00
Pete Bacon Darwin a9ff48e67f fix(core): improve the "missing `$localize`" error message (#32491)
We need to be clearer to developers who upgrade to v9 (next) and get this
error, why they have a problem and what they have to do about it.

Once we have a better CLI schematics story, where this import will be
included by default in new applications and a CLI migration will add it
when upgrading apps to v9, we could simplify or remove this error message.

PR Close #32491
2019-09-05 18:09:27 -04:00
Matias Niemelä 7cc4225eb9 fix(ivy): ensure binding ordering doesn't mess up when a `NO_CHANGE` value is encountered (#32143)
Prior to this fix if a `NO_CHANGE` value was assigned to a binding, or
an interpolation value rendererd a `NO_CHANGE` value, then the presence
of that value would cause the internal counter index values to not
increment properly. This patch ensures that this doesn't happen and
that the counter/bitmask values update accordingly.

PR Close #32143
2019-09-04 11:54:19 -07:00
Keen Yee Liau f6e88cd659 fix(language-service): Use ts.CompletionEntry for completions (#32375)
This is a prerequisite to fix a bug in template completions whereby
completion of the string `ti` for the variable `title` results in
`tititle`.

This is because the position where the completion is requested is used
to insert the completion text. This is incorrect. Instead, a
`replacementSpan` should be used to indicate the span of text that needs
to be replaced. Angular's own `Completion` interface is insufficient to
hold this information. Instead, we should just use ts.CompletionEntry.

Also added string enum for `CompletionKind`, which is similar to
ts.ScriptElementKind but contains more info about HTML entities.

PR Close #32375
2019-09-04 11:53:14 -07:00
Kara Erickson 89434e09c2 refactor(core): move Meta methods that only have one version from DomAdapter (#32408)
PR Close #32408
2019-09-03 11:59:39 -07:00
Kara Erickson 970b58b13f refactor(core): move server-only DomAdapter methods into ServerRenderer (#32408)
PR Close #32408
2019-09-03 11:59:39 -07:00
Pete Bacon Darwin 9a55eaf10d test: make cli-hello-world-ivy-minimal/debug-test.sh executable (#31609)
PR Close #31609
2019-08-30 12:53:26 -07:00
Pete Bacon Darwin 8cdfcc5489 test(ivy): add cli-hello-world-ivy-i18n integration test (#31609)
This test uses localization in the `AppComponent` component:

* an `i18n` attribute in the template
* a call to the `$localize` tag in the component constructor

PR Close #31609
2019-08-30 12:53:26 -07:00
Pete Bacon Darwin a7f61e63fa refactor(ivy): remove `i18nConfigureLocalize` instruction (#31609)
This has been replaced by the `loadTranslations()` function in
`@angular/localize/run_time`.

PR Close #31609
2019-08-30 12:53:26 -07:00
Pete Bacon Darwin fa79f51645 refactor(ivy): update the compiler to emit `$localize` tags (#31609)
This commit changes the Angular compiler (ivy-only) to generate `$localize`
tagged strings for component templates that use `i18n` attributes.

BREAKING CHANGE

Since `$localize` is a global function, it must be included in any applications
that use i18n. This is achieved by importing the `@angular/localize` package
into an appropriate bundle, where it will be executed before the renderer
needs to call `$localize`. For CLI based projects, this is best done in
the `polyfills.ts` file.

```ts
import '@angular/localize';
```

For non-CLI applications this could be added as a script to the index.html
file or another suitable script file.

PR Close #31609
2019-08-30 12:53:26 -07:00
Misko Hevery 1537791f06 perf(core): Make `PlatformLocation` tree-shakable (#32154)
Convert `PlatformLocation` into a tree-shakable provider.

PR Close #32154
2019-08-29 21:51:56 -07:00
Paul Gschwendtner 288e5d894d test: add integration test for undecorated-classes-with-di migration (#32349)
Adds tests for the `undecorated-classes-with-di` migration to the
`ng_update_migrations` integration test.

PR Close #32349
2019-08-29 12:34:44 -07:00
Paul Gschwendtner b48dd52494 test: add integration test for missing-injectable migration (#32349)
Adds a new test to the `ng_update_migrations` that ensures
that the `missing-injectable` migration works properly in a
real CLI project. Additionally this ensures that the
`missing-injectable` and `undecorated-classes-with-di` migrations
play nicely together.

PR Close #32349
2019-08-29 12:34:43 -07:00