Commit graph

24285 commits

Author SHA1 Message Date
Alex Rickabaugh
80d2cdab8b test: set skipLibCheck on ngcc integration test (#45672)
The ngcc integration test is in an awkward state: it's attempting to test
that the current ngcc can process @angular/core at v12. We need to make a
forwards-incompatible change to the typings of @angular/core, which means
that the compiled typings from the current ngcc won't be compatible with
core as of v12.

To get around this and allow the integration test to have some value, we're
disabling library checking for the time being.

PR Close #45672
2022-04-20 05:45:57 -07:00
Alex Rickabaugh
99b3af4ee6 refactor(compiler-cli): emit isStandalone flag in partial declarations (#45672)
This commit propagates the `isStandalone` flag for a component, directive,
or pipe during partial compilation of a standalone declaration. This flag
allows the linker to properly process a standalone declaration that it
encounters.

PR Close #45672
2022-04-20 05:45:57 -07:00
Alex Rickabaugh
1244a14a36 refactor(compiler-cli): move standalone scope computation out of handler (#45672)
Standalone component scopes were first implemented in the
`ComponentDecoratorHandler` itself, due to an assumption that "standalone"
allowed for a localized analysis of the component's dependencies. However,
this is not strictly true. Other compiler machinery also needs to understand
component scopes, including standalone component scopes. A good example is
the template type-checking engine, which uses a `ComponentScopeReader` to
build full metadata objects (that is, metadata that considers the entire
inheritance chain) for type-checking purposes. Therefore, the
`ComponentScopeReader` should be able to give the scope for a standalone
component.

To achieve this, a new `StandaloneComponentScopeReader` is implemented, and
the return type of `ComponentScopeReader.getScopeForComponent` is expanded
to express standalone scopes. This cleanly integrates the "standalone"
concept into the existing machinery.

PR Close #45672
2022-04-20 05:45:56 -07:00
Alex Rickabaugh
d8086a1dbf refactor(compiler-cli): emit StandaloneFeature for standalone components (#45672)
This commit adds an emit for standalone components of the
`StandaloneFeature`, which will support creation of standalone injectors and
any other mechanisms necessary for standalone component functionality at
runtime.

Using a feature allows for standalone functionality to be tree-shaken in
applications that aren't using them.

PR Close #45672
2022-04-20 05:45:56 -07:00
Alex Rickabaugh
f9f8ef9051 refactor(compiler-cli): emit NgModule dependencies of standalone components (#45672)
This commit expands on the unified dependency tracking in the previous
commit and adds tracking of NgModule dependencies. These are not used for
standard components, but are emitted for standalone components to allow the
runtime to roll up providers from those NgModules into standalone injectors.

PR Close #45672
2022-04-20 05:45:56 -07:00
Alex Rickabaugh
9b35787bb3 refactor(compiler-cli): unify tracked template scope dependencies (#45672)
Previously, the compiler tracked directives and pipes in template scopes
separately. This commit refactors the scope system to unify them into a
single data structure, disambiguated by a `kind` field.

PR Close #45672
2022-04-20 05:45:56 -07:00
Alex Rickabaugh
1527e8f4c0 refactor(core): change component emit to 'dependencies' (#45672)
Previously, the compiler would represent template dependencies of a
component in its component definition through separate fields (`directives`,
`pipes`).

This commit refactors the compiler/runtime interface to use a single field
(`dependencies`). The runtime component definition object still has separate
`directiveDefs` and `pipeDefs`, which are calculated from the `dependencies`
when the definition is evaluated.

This change is also reflected in partially compiled declarations. To ensure
compatibility with partially compiled code already on NPM, the linker
will still honor the old form of declaration (with separate fields).

PR Close #45672
2022-04-20 05:45:56 -07:00
Alex Rickabaugh
046dad1a8d fix(compiler-cli): fix issue with incremental tracking of APIs for pipes (#45672)
`PipeSymbol` contains logic to detect changes in the public API surface of
pipes, which includes the pipe name. However, the pipe handler inadvertently
uses the pipe class name instead of the actual pipe name to initialize the
`PipeSymbol`, which breaks incremental compilation when pipe names change.

There is a test which attempts to verify that this logic is working, but the
test actually passes for a different reason. The test swaps the names of 2
pipes that are both used in a component, and asserts that the component is
re-emitted, theoretically because the public APIs of the pipes is changed.
However, the emit order of the references to the pipes depends on the order
in which they match in the template, which changes when the names are
swapped. This ordering dependency is picked up by the semantic dependency
tracking system, and is what actually causes the component to be re-emitted
and therefore the pipe test to pass in spite of the bug with name tracking.

This commit fixes the `PipeSymbol` initialization to use the correct pipe
name. The test is still flawed in that it's sensitive to the ordering of
pipe emits, but this ordering is due to change soon as a result of the
standalone components work, so this issue will be resolved in a future
commit.

PR Close #45672
2022-04-20 05:45:56 -07:00
Andrew Scott
989e840cce fix(router): Remove unused string type for ActivatedRoute.component (#45625)
BREAKING CHANGE:
The type of `component` on `ActivatedRoute` and `ActivatedRouteSnapshot`
includes `string`. In reality, this is not the case. The component
cannot be anything other than a component class.

PR Close #45625
2022-04-19 20:21:35 -07:00
Mangalraj
4ad7c2e4df docs: Update aio/content/guide/setup-local.md (#45644)
Co-authored-by: George Kalpakas <kalpakas.g@gmail.com>
PR Close #45644
2022-04-19 20:20:39 -07:00
Mangalraj
89f9d28097 docs: correct the example command to install angular (#45644)
PR Close #45644
2022-04-19 20:20:39 -07:00
Paul Gschwendtner
0231a363fe build: preparation for primary branch rename in the Angular repos (#45681)
Preparation for the framework repo as outlined our planning
document.

PR Close #45681
2022-04-19 20:19:46 -07:00
Andrew Scott
6c4d9ebd3a test(common): Fix flaky Location test (#45683)
This test has proven to be flaky. This commit greatly simplifies the
test and moves it to a more appropriate location (pun intended).

PR Close #45683
2022-04-19 20:17:56 -07:00
Saurabh Kamble
5d155950e3 Fix typo (#45680)
PR Close #45680
2022-04-19 09:26:12 -07:00
George Kalpakas
ceffdeda69 docs(common): fix links to locales in i18n guides (#45661)
In PR #42230, the locale file generation process was modified so that
generated locale files are no longer checked into the repository. Update
a few links in the docs that pointed to the previously checked in files
to point to other places where the files exist.

PR Close #45661
2022-04-19 09:17:33 -07:00
Jeremy Elbourn
c6feb0a7ae build: don't assign jelbourn to most review categories (#45668)
Configure pullapprove to not automatically assign jelbourn to most review categories.

PR Close #45668
2022-04-19 09:15:39 -07:00
Louis Gombert
f5299a3b8f docs: update decorators proposal stage and link in glossary (#45669)
PR Close #45669
2022-04-19 09:14:36 -07:00
Andrew Kushnir
63202b9893 test: reset counters before running a styling test (#45670)
This commit updates one of the styling tests to reset perf counters, making it order-independent and non-flaky (previously the test got random failures depending on whether there are other tests invoked before).

PR Close #45670
2022-04-19 09:14:09 -07:00
Andrew Scott
ea8256f43d refactor(router): Move config loader tracking to the RouterConfigLoader (#45656)
This wasn't exactly possible before because the `RouterConfigLoader` was
not an Injectable so there wasn't a straightforward way to share
information between `ApplyRedirects` and the preloader. They each had
their own implementation so they needed to store the values on the
`Route` so they both had access to them. I imagine this was the case
because trying to inject `Router` (to get access to the events) into the
preloader would have caused a circular dependency.

This refactor co-locates the loading details with the loader itself
rather than leaking implementation into the public route config and
mutating the object in an awkward way. This also promotes
`RouterConfigLoader` to a proper `Injectable` so data can be shared
throughout the system.

PR Close #45656
2022-04-18 16:05:45 -07:00
Marko Kaznovac
ec5cb0bb54 docs: use language agnostic mdn urls (#45666)
PR Close #45666
2022-04-18 14:10:16 -07:00
Marko Kaznovac
3477364852 docs: fix mdn links (#45666)
PR Close #45666
2022-04-18 14:10:16 -07:00
Andrew Kushnir
174ce7dd13 feat(core): add ApplicationRef.destroy method (#45624)
This commit implements the `destroy` method on the `ApplicationRef` class. This feature is a preparation for the new logic to bootstrap (and teardown) standalone components (without going through the `NgModuleRef` destroy), which would return an instance of the `ApplicationRef` (the current bootstrap APIs return an instance of the `NgModuleRef`).

PR Close #45624
2022-04-18 14:09:47 -07:00
Andrew Scott
aa966fd715 refactor(router): Use EnvironmentInjector for lazy loading APIs (#45671)
The `EnvironmentInjector` should be used instead of `Injector` for the
lazy loading. A future refactor will further update `RouterOutlet` to
use this injector to create the component rather the deprecated
`ComponentFactoryResolver`.

PR Close #45671
2022-04-18 14:08:43 -07:00
Andrew Scott
eb7661c072 refactor(router): unbundle the lazy loaded routes from the lazy loaded module injector (#45593)
In the standalone world, these concepts will no longer be one and the
same. You can load routes without them being inside an `NgModule` with
`RouterModule.forChild`. In addition, routes will be able to define
their own providers, which will be included in an injector that is not
necessarily lazy loaded.

PR Close #45593
2022-04-18 09:52:56 -07:00
Andrew Scott
d9f550c97f refactor(router): Refactor loaded config to track injectors rather than NgModuleRef (#45593)
The `Injector` is really the piece of information that the `Router` is
interested in keeping track of. Storing the `NgModuleRef` is somewhat
confusing based on how it's used later on. `RouterOutlet` uses it for the
`componentFactoryResolver`, but this is not needed anymore (and deprecated). In
fact, we can get back to the `NgModuleRef` anyways using the injector.
For now, that's what this change does. A different refactor will remove
the use of the `componentFactoryResolver` altogether.

Additionally, in the standalone world, we plan to implement a feature to
allow defining `providers` directly on the `Route`. This means there
won't be an associated `NgModuleRef` so this refactor prepares for that
feature.

PR Close #45593
2022-04-18 09:52:56 -07:00
Alex Rickabaugh
3578e94384 refactor(core): internally support providedIn: environment (#45626)
This commit adds a new internal scope to `R3Injector` for
`EnvironmentInjector`s specifically. This will allow us to scope services to
the environment side of the injector hierarchy specifically, as opposed to
the `'any'` scope which also includes view-side injectors created via
`Injector.create`. For now, this functionality is not exposed publicly, but
is available to use within `@angular/core` only.

PR Close #45626
2022-04-18 09:28:43 -07:00
Alex Rickabaugh
d5a6cd1111 feat(core): implement EnvironmentInjector with adapter to NgModuleRef (#45626)
This commit exposes a new `EnvironmentInjector` abstraction, which
generalizes the "module injector" concept to injectors that are not based on
NgModules.

An EnvironmentInjector is a conceptual analogue of an `NgModuleRef` - it
represents an injector on the former "module" DI hierarchy in Angular (now
renamed to the "environment injector hierarchy"). Environment injectors are
created via the `createEnvironmentInjector` function from a list of
`Provider`s.

For backwards compatibility with current code using `NgModuleRef`,
`EnvironmentInjector`s are wrapped by an adapter `NgModuleRef`
implementation, so injecting `NgModuleRef` always returns the latest
`EnvironmentInjector`, even if that injector was not based on an NgModule.
Conversely, NgModule-based `NgModuleRef`s created via `createNgModuleRef`
are _also_ `EnvironmentInjector`s.

PR Close #45626
2022-04-18 09:28:42 -07:00
Andrew Kushnir
b568a5e708 feat(core): implement importProvidersFrom function (#45626)
This commit implements the `importProvidersFrom` function that allows
extracting a list of `Provider`s from a list of NgModule types. The
R3Injector which implements DI at the "module" level for Angular is
refactored to use this functionality under the hood.

This commit also implements `INJECTOR_INITIALIZER`, a DI multi-provider
token which is used to run initialization logic when an injector is created.

PR Close #45626
2022-04-18 09:28:42 -07:00
Alex Rickabaugh
a5a7fbc173 test(core): fix a crosstalk issue with locale ids (#45626)
Previously there was a test ordering issue with the application_module_spec
tests where the value of `getLocaleId()` depended on the order in which
tests ran. Specifically, `setLocaleId()` lower-cases the current locale ID,
so the measured value in a test depended on whether a previous test had
called `setLocaleId()` (the difference between 'en-US' and 'en-us').

PR Close #45626
2022-04-18 09:28:42 -07:00
Doug Parker
1fe255c76f refactor(compiler): add original_code to goog.getMsg() options (#45606)
This links back each placeholder in a message to the original Angular template span which defines its expression. This is useful for understanding where each placeholder comes from in the context of the full message.

PR Close #45606
2022-04-18 09:26:16 -07:00
Andrew Kushnir
8c83f12daa ci: add more reviewers to the docs-packaging-and-releasing group (#45652)
Currently that group has just 2 reviewers, but we often update the files that belong to that group during the deprecation period. Adding more people would allow to balance the reviews better.

PR Close #45652
2022-04-18 09:24:57 -07:00
Kristiyan Kostadinov
57f8ab2ed8 fix(core): better error message when directive extends a component (#45658)
We throw an error when a directive is trying to extend a component, but we don't actually say which class is responsible which can be difficult to track down. These changes add the two class names to the error message.

PR Close #45658
2022-04-18 09:24:23 -07:00
Kristiyan Kostadinov
b29b95b0f8 fix(devtools): clean up menu layout (#45665)
The menus weren't using the `mat-menu` component correctly which had led to some inconsistent spacing and the need for style overrides. These changes correctly wrap the menu content in `mat-menu-item` which has the added benefit of having keyboard support. I had to keep some of the overrides in order to preserve the dense layout of the menus.

I've also cleaned up the component by:
* Removing some unnecessary styles.
* Switching single-class usages of `ngClass` to `class.` bindings.
* Not using `br` tags for spacing.

PR Close #45665
2022-04-18 09:23:13 -07:00
Renovate Bot
68357104c9 build: lock file maintenance (#45457)
PR Close #45457
2022-04-15 14:38:16 -07:00
dario-piotrowicz
0b6407241c fix(docs-infra): fix aio search-results issue with toolbar and notification (#45579)
use border-top-width instead of padding-top as the strategy for moving
the search-results panel down, this fixes the issue of the panel going
behind the toolbar (which causes either overlapping text in the home
page or the results scrollbar to be hidden behind the toolbar in other
pages)

PR Close #45579
2022-04-15 14:22:14 -07:00
dario-piotrowicz
9e69579440 fix(docs-infra): amend notification close button aria-label (#45579)
move the aria-label used inside the close-button to the button itself
(since otherwise the button's aria-label overrides the childs)

PR Close #45579
2022-04-15 14:22:14 -07:00
dario-piotrowicz
d2436bfc91 feat(docs-infra): add close button to search-results aio panel (#45579)
add a close button to the search-results aio panel so that the user can
conveniently close it via keyboard

this complements the focus trap implemented in PR #44989
(more here: https://github.com/angular/angular/pull/44989#issuecomment-1037287678)

PR Close #45579
2022-04-15 14:22:13 -07:00
ivanwonder
f57e46c538 fix(language-service): two-way binding completion should not remove the trailing quote (#45582)
We allow the path to contain both the `t.BoundAttribute` and `t.BoundEvent` for two-way
bindings but do not want the path to contain both the `t.BoundAttribute` with its
children when the position is in the value span because we would then logically create a path
that also contains the `PropertyWrite` from the `t.BoundEvent`. This early return condition
ensures we target just `t.BoundAttribute` for this case and exclude `t.BoundEvent` children.

Fixes https://github.com/angular/vscode-ng-language-service/issues/1626

PR Close #45582
2022-04-15 13:53:48 -07:00
Andrew Kushnir
c6e0e3f6d3 fix(core): improve multiple components match error (#45645)
This commit improves the error message that is thrown at runtime when multiple components match the same element. Now the error message contains names of classes that represent those components.

PR Close #45645
2022-04-15 13:52:19 -07:00
Andrew Kushnir
2e973121ba test(core): add a test for multiple named interpolations with the same name (#45651)
The test from this commit verifies that i18n logic can handle multiple named interpolations with the same name.

PR Close #45651
2022-04-15 13:51:55 -07:00
Andrew Scott
96fd29c6d2 fix(router): validate lazy loaded configs (#45526)
Lazy loaded configs are not validated at runtime like the initial set of
routes are. This change also validates lazy loaded configs right after
they're loaded.

BREAKING CHANGE: Lazy loaded configs are now also validated once loaded like the
initial set of routes are. Lazy loaded modules which have invalid Route
configs will now error. Note that this is only done in dev mode so
there is no production impact of this change.

Fixes #25431

PR Close #45526
2022-04-15 12:30:44 -07:00
Dmitrij Kuba
f13295f3a3 perf(router): cancel the navigation instantly if at least one resolver doesn't emit any value (#45621)
Recently the navigation was on hold even at least one resolver didn't emit any value and completed, but another ones still are in progress to resolve any value. The changes cancel the navigation instantly if at least one resolver doesn't emit any value and completed.

PR Close #45621
2022-04-15 10:06:26 -07:00
Renovate Bot
770ea926bf build: update dependency @microsoft/api-extractor to v7.22.2 (#45641)
PR Close #45641
2022-04-15 09:27:39 -07:00
Ilya Marchik
b5b0a50294 docs: fix typo (#45637)
Replace wrong mention of 'heroService.delete()' with 'heroService.deleteHero()' because 'heroService.delete()' doesn't exist and 'heroService.deleteHero()' should be mentioned instead

Resolves #45636

PR Close #45637
2022-04-14 16:30:03 -07:00
Renovate Bot
7d2a619812 build: update all non-major dependencies (#45632)
PR Close #45632
2022-04-14 15:02:45 -07:00
Andrew Kushnir
6444a02620 docs: move old changelog entries to a separate file (#45638)
This commit moves all release notes for everything before v11.0.0 to a separate file, so that the changelog can be rendered correctly via GitHub UI.

Closes #45635.

PR Close #45638
2022-04-14 15:01:21 -07:00
George Kalpakas
2f08b8043e build(docs-infra): upgrade cli command docs sources to 5bd17a256 (#45630)
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](0e8f3c34b...5bd17a256):

**Added**
- help/completion.json

PR Close #45630
2022-04-14 15:00:40 -07:00
George Kalpakas
94fba9b047 docs(core): fix typo in View Encapsulation code example (#45629)
Fix closing tag name to match opening one (`</hero-detail>` -->
`<hero-details>`).

PR Close #45629
2022-04-14 15:00:04 -07:00
Dylan Hunn
e0a2248b32 feat(forms): Add a FormRecord type. (#45607)
As part of the typed forms RFC, we proposed the creation of a new FormRecord type, to support dynamic groups with homogenous values. This PR introduces FormRecord, as a subclass of FormGroup.

PR Close #45607
2022-04-14 14:59:10 -07:00
Paul Gschwendtner
f8a1ea0c11 fix(bazel): do not error if files part of srcs are outside of package (#45622)
We recently refactored how the ng package rule deals with static files.
As part of this refactoring, transitive files outside of the current
Bazel package were flagged as errors, while previously this was just
ignored. We need to revert back this behavior (even though code remains
much simpler and predicable now) since sass library targets for example
reference all transtive files in the default info and break packages then

PR Close #45622
2022-04-14 14:58:27 -07:00