Commit Graph

2772 Commits

Author SHA1 Message Date
Pete Bacon Darwin 4b4f565df1 docs: fix links to docs with ambiguous paths (#41788)
These docs were linking directly to docs that have ambiguous paths.
These changes ensure that these links are not affected by the
disambiguation processing of those docs.

PR Close #41788
2021-04-26 12:12:00 -07:00
Kristiyan Kostadinov 18b33e79d3 perf(core): avoid storing LView in __ngContext__ (#41358)
Currently we save a reference to an `LView` on most DOM nodes created by Angular either by saving
the `LView` directly in the `__ngContext__` or by saving the `LContext` which has a reference to
the `LView`. This can be a problem if the DOM node is retained in memory, because the `LView` has
references to all of the child nodes of the view, as well as other internal data structures.

Previously we tried to resolve the issue by clearing the `__ngContext__` when a node is removed
(see https://github.com/angular/angular/pull/36011), but we decided not to proceeed, because it can
slow down destruction due to a megamorphic write.

These changes aim to address the issue while reducing the performance impact by assigning a unique
ID when an `LView` is created and adding it to `__ngContext__`. All active views are tracked in
a map where their unique ID is used as the key. We don't need to worry about leaks within that map,
because `LView`s are an internal data structure and we have complete control over when they are
created and destroyed.

Fixes #41047.

PR Close #41358
2021-04-26 09:31:41 -07:00
Alan Agius 30a24b6bf5 test: use `global` util instead of `global` property. (#41739)
`global` property is not available in the browser, previously this was polyfilled through core-js.

(cherry picked from commit 827cf41386dcd7e496e107d6b32c54281bc935f1)

PR Close #41739
2021-04-26 09:29:58 -07:00
Kristiyan Kostadinov de4fafb818 refactor(core): add single type for injector token (#41580)
Currently we have a lot of places where we repeat the type `Type<T>|AbstractType<T>|InjectionToken<T>` which makes it cumbersome to add another type or to type something else with the same signature.

These changes add a new type that can be used instead.

Fixes #39792.

PR Close #41580
2021-04-22 10:47:12 -07:00
Andrew Kushnir 3ceb3dea67 refactor(core): replace loadLContext with getLContext calls (#41606)
This commit refactors the code to replace `loadLContext` with `getLContext` calls. The only difference between these two functions is that the `loadLContext` supports throwing an error in case `LContext` can not be found. The investigation performed in #41525 revealed that throwing while retrieving `LContext` might have undesirable performance implications, so we should avoid that to make sure there are no accidental perf regressions in other parts of code that used `loadLContext`. Moreover, in most of the places the `loadLContext` was already called in a mode that prevented an error from being thrown, so this refactoring should have no effect on the actual behavior.

PR Close #41606
2021-04-22 10:46:12 -07:00
Kristiyan Kostadinov 73824d5337 fix(compiler): not generating update instructions for ng-template inside alternate namespaces (#41669)
We have a check that determines whether to generate property binding instructions for an `ng-template`. The check looks at whether the tag name is exactly `ng-template`, but the problem is that if the tag is placed in a non-HTML namespace (e.g. `svg`), the tag name will actually be `:namespace:ng-template` and the check will fail.

These changes resolve the issue by looking at the tag name without the namespace.

Fixes #41308.

PR Close #41669
2021-04-20 09:44:44 -07:00
Ajit Singh 251bec159a docs: documentation of descendants property of @ContentChildren (#35927)
documentation of decendants property of @ContentChildren was not clear when decendants was set to false it did not pick up direct children when any directive was used on the elements. With Ivy the functionality follows the following pattern only query direct children (in the sense of elements in a template) when descendants: false is specified.

Fixes #20074

PR Close #35927
2021-04-19 15:57:17 -07:00
jeripeierSBB a99aa29040 fix(animations): allow animations on elements in the shadow DOM (#40134)
When determining whether to run an animation, the `TransitionAnimationPlayer`
checks to see if a DOM element is attached to the document. This is done by
checking to see if the element is "contained" by the document body node.

Previously, if the element was inside a shadow DOM, the engine would
determine that the element was not attached, even if the shadow DOM's
host was attached to the document. This commit updates the `containsElement()`
method on `AnimationDriver` implementations to also include shadow DOM
elements as being contained if their shadow host element is contained.

Further, when using CSS keyframes to trigger animations, the styling
was always added to the `head` element of the document, even for
animations on elements within a shadow DOM. This meant that those
elements never receive those styles and the animation would not run.
This commit updates the insertion of these styles so that they are added,
to the element's "root node", which is the nearest shadow DOM host, or the
`head` of the document if the element is not in a shadow DOM.

Closes #25672

PR Close #40134
2021-04-15 12:45:52 -07:00
Joey Perrott e66a5fbca6 feat(core): update supported range of node versions (#41544)
Update the supported range of node versions for Angular.  Angular now
supports node >=12.14.1 to <16.0.0, dropping support for Node v10.

BREAKING CHANGE: Angular no longer maintains support for node v10

PR Close #41544
2021-04-14 09:40:17 -07:00
mgechev f7e391a912 perf(core): optimize getDirectives (#41525)
This commit introduces the following optimizations:

1. We return an empty array for text nodes in `getDirectives` because
Angular does not support attaching logic to them. This optimization
improves performance of `getDirectives` significantly because text nodes
often result in expensive calls to `loadLContext` since we can't resolve
it from a parent node.
1. `getDirectives` now calls `loadLContext` with second argument `false`
so it doesn't throw an error. This brings another significant
improvement because prevents the VM from deoptimizing calls.

BREAKING CHANGE:

Previously the `ng.getDirectives` function threw an error in case a
given DOM node had no Angular context associated with it (for example
if a function was called for a DOM element outside of an Angular app).
This behavior was inconsistent with other debugging utilities under `ng`
namespace, which handled this situation without raising an exception.
Now calling the `ng.getDirectives` function for such DOM nodes would
result in an empty array returned from that function.

PR Close #41525
2021-04-13 16:06:32 -07:00
mgechev a07f303708 feat(core): introduce getDirectiveMetadata global debugging utility (#41525)
This commit introduces a global debugging method
`ng.getDirectiveMetadata` which returns the metadata for a directive or
component instance.

PR Close #41525
2021-04-13 16:06:32 -07:00
Alan Agius ed7d288364 build: update several dependencies (#41434)
With this change we update several dependencies to avoid Renovate creating a lot of PRs during onboarding. We also remove yarn workspaces as after further analysis these are not needed.

Certain dependencies such as `@octokit/rest`, `remark` and `@babel/*` have not been updated as they require a decent amount of work to update, and it's best to leave them for a seperate PR.

PR Close #41434
2021-04-12 16:46:29 -07:00
JoostK c20db69f9f refactor(compiler-cli): introduce declaration function to declare class metadata (#41200)
This commit refactors the generated code for class metadata in partial
compilation mode. Instead of emitting class metadata into a top-level
`ɵsetClassMetadata` call guarded by `ngDevMode` flags, the class
metadata is now declared using a top-level `ɵɵngDeclareClassMetadata`
call.

PR Close #41200
2021-04-12 10:41:17 -07:00
Kristiyan Kostadinov aa0e54fe97 fix(core): error if DebugRenderer2.destroyNode is called twice in a row (#41565)
Fixes an error that will be thrown if  `DebugRenderer2.destroyNode` is called with a node that has already been destroyed. The error happened, because we had a non-null assertion, even though the value can be null.

Note that this fix applies only to ViewEngine, because Ivy doesn't provide the `DebugRenderer2`. I decided to resolve it, because it fix is straightforward and this error has been showing up in our logs for a long time now, making actual errors harder to find.

PR Close #41565
2021-04-12 10:30:11 -07:00
Andrew Kushnir 51bb922a08 refactor(forms): add base class for all built-in ControlValueAccessors (#41225)
This commit adds a base class that contains common logic for all ControlValueAccessors defined in Forms package. This allows to remove duplicated logic from all built-in ControlValueAccessor classes.

PR Close #41225
2021-04-08 10:24:10 -07:00
Pete Bacon Darwin 10a7c87692 refactor(compiler): implement `ngDeclareInjectable()` (#41316)
This commit changes the partial compilation so that it outputs declarations
rather than definitions for injectables.

The JIT compiler and the linker are updated to be able to handle these
new declarations.

PR Close #41316
2021-04-07 13:57:13 -07:00
Pete Bacon Darwin c83fe1698b refactor(core): rename `ɵɵInjectableDef` interface to `ɵɵInjectableDeclaration` (#41316)
The other similar interfaces were renamed in https://github.com/angular/angular/pull/41119,
but this one was left since it had existed before Ivy. It looks like the interface was
never actually exposed on npm so it is safe to rename this one too.

PR Close #41316
2021-04-07 13:57:12 -07:00
Kristiyan Kostadinov ec27bd4ed1 feat(compiler): support nullish coalescing in templates (#41437)
Adds support for nullish coalescing expressions inside of Angular templates (e.g. `{{ a ?? b ?? c}}`).

Fixes #36528.

PR Close #41437
2021-04-07 12:04:28 -07:00
Kristiyan Kostadinov d641542587 refactor(core): remove deprecated rxjs signature usage in event emitter and make more minifier-friendly (#41450)
* We had a usage of `Observable.subscribe` that uses the deprecated signature with 3 arguments. These changes switch to the non-deprecated version that passes in an `Observer`.
* Avoids always creating a `complete` callback since it isn't required.
* We were repeating all of the internal callbacks twice: once for sync and once for async. These changes move them out into variables so that they're more minifier-friendly. The savings aren't huge (~100 bytes minified), but it doesn't add any maintenance effort on our end so I decided to add it.

PR Close #41450
2021-04-07 11:53:09 -07:00
Kristiyan Kostadinov f7c294ee0f feat(core): support `forwardRef` in `providedIn` of `Injectable` declaration (#41426)
Adds support for using a `forwardRef` inside of the `providedIn` of an `Injectable` declaration.

Fixes #41205.

PR Close #41426
2021-04-06 10:03:38 -07:00
mgechev 520ff69854 perf(core): add private hooks around user code executed by the runtime (#41255)
Introduces an **internal**, **experimental** `profiler` function, which
the runtime invokes around user code, including before and after:
- Running the template function of a component
- Executing a lifecycle hook
- Evaluating an output handler

The `profiler` function invokes a callback set with the global
`ng.ɵsetProfiler`. This API is **private** and **experimental** and
could be removed or changed at any time.

This implementation is cheap and available in production. It's cheap
because the `profiler` function is simple, which allows the JiT compiler
to inline it in the callsites. It also doesn't add up much to the
production bundle.

To listen for profiler events:

```ts
ng.ɵsetProfiler((event, ...args) => {
  // monitor user code execution
});
```

PR Close #41255
2021-04-02 10:34:23 -07:00
Pete Bacon Darwin ed77bfea26 test(core): fix JIT factory declaration test for IE11 (#41416)
This commit removes a check for the name of the generated factory
function, which is unimportant to test the behaviour of the code.

The name of these functions is generated from the name of the class
being instantiated. In IE11, there is no `function.name` property available
and so there is a shim for it in `third_party/shims_for_IE.js`, which patches
the `Function.property.name` property.

For performance reasons this shim writes the result of the computation
to the prototype of the function. Unfortunately, this means that any class
that extends the patched class will have the same value for `name`.

PR Close #41416
2021-04-01 12:21:00 -07:00
JoostK ff9470b0a0 fix(compiler): include used components during JIT compilation of partial component declaration (#41353)
In #41104 the list of used directives was split into two arrays of used
directives and components, but the JIT side was not updated. This commit
fixes the JIT integration by including the list of used components.

Fixes #41318

PR Close #41353
2021-04-01 11:39:41 -07:00
Kristiyan Kostadinov e112e320bf fix(compiler): handle case-sensitive CSS custom properties (#41380)
Currently we normalize all CSS property names in the `StylingBuilder` which breaks custom properties, because they're case-sensitive. These changes add a check so that custom properties aren't normalized.

Fixes #41364.

PR Close #41380
2021-03-30 16:57:44 -07:00
Pete Bacon Darwin 2d3cd2b969 refactor(compiler): rename `R3FactoryTarget` to `FactoryTarget` (#41231)
This enumeration will now start to appear in publicly facing code,
as part of declarations, so we remove the R3 to make it less specific
to the internal name for the Ivy renderer/compiler.

PR Close #41231
2021-03-30 16:46:37 -07:00
Pete Bacon Darwin 72b65f995d refactor(compiler): remove `R3ResolvedDependencyType` altogether (#41231)
Now that other values were removed from `R3ResolvedDependencyType`,
its meaning can now be inferred from the other properties in the
`R3DeclareDependencyMetadata` type. This commit removes this enum
and updates the code to work without it.

PR Close #41231
2021-03-30 16:46:37 -07:00
Pete Bacon Darwin 857dfaa1e7 refactor(core): remove the need for `ɵɵinjectPipeChangeDetectorRef()` (#41231)
This instruction was created to work around a problem with injecting a
`ChangeDetectorRef` into a pipe. See #31438. This fix required special
metadata for when the thing being injected was a `ChangeDetectorRef`.

Now this is handled by adding a flag `InjectorFlags.ForPipe` to the
`ɵɵdirectiveInject()` call, which avoids the need to special test_cases
`ChangeDetectorRef` in the generated code.

PR Close #41231
2021-03-30 16:46:37 -07:00
Pete Bacon Darwin cf4f74aad0 refactor(compiler-cli): implement `ɵɵngDeclareFactory` (#41231)
This commit changes the partial compilation so that it outputs declaration
calls rather than compiled factory functions.

The JIT compiler and the linker are updated to be able to handle these
new declarations.

PR Close #41231
2021-03-30 16:46:37 -07:00
Pete Bacon Darwin 9c9fd2d074 refactor(compiler): remove `injectFn` option from factory metadata (#41231)
The `injectFn` reference can be inferred unamiguously from the `target`
property so it is not needed.

PR Close #41231
2021-03-30 16:46:37 -07:00
Alan Agius 95ff5ecb23 feat(core): add migration for `XhrFactory` import (#41313)
Automatically migrates `XhrFactory` from `@angular/common/http` to `@angular/common`.

PR Close #41313
2021-03-29 15:14:16 -07:00
Alan Agius e0028e5741 fix(platform-browser): configure `XhrFactory` to use `BrowserXhr` (#41313)
With this change we move `XhrFactory` to the root entrypoint of `@angular/commmon`, this is needed so that we can configure `XhrFactory` DI token at a platform level, and not add a dependency  between `@angular/platform-browser` and `@angular/common/http`.

Currently, when using `HttpClientModule` in a child module on the server, `ReferenceError: XMLHttpRequest is not defined` is being thrown because the child module has its own Injector and causes `XhrFactory` provider to be configured to use `BrowserXhr`.
Therefore, we should configure the `XhrFactory` at a platform level similar to other Browser specific providers.

BREAKING CHANGE:

`XhrFactory` has been moved from `@angular/common/http` to `@angular/common`.

**Before**
```ts
import {XhrFactory} from '@angular/common/http';
```

**After**
```ts
import {XhrFactory} from '@angular/common';
```

Closes #41311

PR Close #41313
2021-03-29 15:14:16 -07:00
JoostK 274dc15452 fix(core): detect synthesized constructors that have been downleveled using TS 4.2 (#41305)
TypeScript 4.2 has changed its emitted syntax for synthetic constructors
when using `downlevelIteration`, which affects ES5 bundles that have
been downleveled from ES2015 bundles. This is typically the case for UMD
bundles in the APF spec, as they are generated by downleveling the
ESM2015 bundle into ES5. The reflection capabilities in the runtime need
to recognize this new form to correctly deal with synthesized
constructors, as otherwise JIT compilation could generate invalid
factory functions.

Fixes #41298

PR Close #41305
2021-03-23 11:23:04 -07:00
Kristiyan Kostadinov 190fa07b9a feat(router): add migration for ActivatedRouteSnapshot.fragment (#41092)
Adds a migration that casts the value of `ActivatedRouteSnapshot.fragment` to be non-nullable.

Also moves some code from the `AbstractControl.parent` migration so that it can be reused.

Relates to #37336.

PR Close #41092
2021-03-23 11:18:00 -07:00
Pete Bacon Darwin e7b1d434c8 refactor(compiler): use `ɵɵInjectorDeclaration` rather than `ɵɵInjectorDef` in compiled output (#41119)
The `ɵɵInjectorDef` interface is internal and should not be published publicly
as part of libraries. This commit updates the compiler to render an opaque
type, `ɵɵInjectorDeclaration`, for this instead, which appears in the typings
for compiled libraries.

PR Close #41119
2021-03-22 08:57:18 -07:00
Pete Bacon Darwin 4dc27a7eaa refactor(core): rename `ɵɵFactoryDef` to `ɵɵFactoryDeclaration` (#41119)
Th `ɵɵFactoryDef` type will appear in published libraries, via their typings
files, to describe what type dependencies a DI factory has. The parameters
on this type are used by tooling such as the Language Service to understand
the DI dependencies of the class being created by the factory.

This commit moves the type to the `public_definitions.ts` file alongside
the other types that have a similar role, and it renames it to `ɵɵFactoryDeclaration`
to align it with the other declaration types such as `ɵɵDirectiveDeclaration`
and so on.

PR Close #41119
2021-03-22 08:57:18 -07:00
Pete Bacon Darwin 88683702e5 refactor(core): rename `...WithMeta` types to `...Declaration` and alias to `unknown` (#41119)
These types are only used in the generated typings files to provide
information to the Angular compiler in order that it can compile code
in downstream libraries and applications.

This commit aliases these types to `unknown` to avoid exposing the
previous alias types such as `ɵɵDirectiveDef`, which are internal to
the compiler.

PR Close #41119
2021-03-22 08:57:18 -07:00
Pete Bacon Darwin f2f0eaf37c docs(core): fix typos in interface docs (#41119)
The terminology use in the comments did not match the actual
types being referred to.

PR Close #41119
2021-03-22 08:57:18 -07:00
Andrew Kushnir 3a55698402 fix(core): remove obsolete check for [class] and [className] presence (#41254)
Previously presence of both [class] and [className] bindings on an element was treated as compiler error (implemented in 6f203c9575). Later, the situation was improved to actually allow both bindings to co-exist (see a153b61098), however the compiler check was not removed completely. The only situation where the error is thrown at this moment is when static (but with interpolation) and bound `class` attributes are present on an element, for ex.:

```
<div class="{{ one }}" [class]="'two'"></div>
```

In the current situation the error is acually misleading (as it refers to `[className]`).

This commit removes the mentioned compiler check as obsolete and makes the `class` and `style` attribute processing logically the same (the last occurrence is used to compute the value).

PR Close #41254
2021-03-19 12:37:45 -07:00
Kristiyan Kostadinov 59ef40988e feat(core): support TypeScript 4.2 (#41158)
Updates the repo to TypeScript 4.2 and tslib 2.1.0.

PR Close #41158
2021-03-17 09:10:25 -07:00
Andrew Kushnir e88a9c6350 perf(forms): make `RadioControlRegistry` class tree-shakable (#41126)
This commit makes the `RadioControlRegistry` class tree-shakable by adding the `providedIn` property to its
`@Injectable` decorator. Now if the radio buttons are not used in the app (thus no `RadioControlValueAccessor`
directive is initialized), the `RadioControlRegistry` should not be included into application's prod bundle.

PR Close #41126
2021-03-16 09:35:14 -07:00
Pete Bacon Darwin 1a9f526315 docs(core): fix typo in developer docs (#41080)
PR Close #41080
2021-03-15 13:26:51 -07:00
Pete Bacon Darwin 5565810bd6 refactor(compiler-cli): implement `ɵɵngDeclareNgModule` and `ɵɵngDeclareInjector` (#41080)
This commit changes the partial compilation so that it outputs declaration
calls rather than definition calls for NgModules and Injectors.

The JIT compiler and the linker are updated to be able to handle these
new declarations.

PR Close #41080
2021-03-15 13:26:51 -07:00
Andrew Kushnir 3bd1992218 perf(forms): avoid direct references to the `Validators` class (#41189)
Currently the `Validators` class contains a number of static methods that represent different validators as well as some helper methods. Since class methods are not tree-shakable, any reference to the `Validator` class retains all of its methods (even if you've used just one).

This commit refactors the code to extract the logic into standalone functions and use these functions in the code instead of referencing them via `Validators` class. That should make the code more tree-shakable. The `Validators` class still retains its structure and calls these standalone methods internally to keep this change backwards-compatible.

PR Close #41189
2021-03-15 11:12:55 -07:00
Andrew Kushnir 937e90cd16 perf(forms): make built-in ControlValueAccessors more tree-shakable (#41146)
This commit updates Forms code to avoid direct references to all built-in ControlValueAccessor classes, which
prevents their tree-shaking from production builds. Instead, a new static property is added to all built-in
ControlValueAccessors, which is checked when we need to identify whether a given ControlValueAccessors is a
built-in one.

PR Close #41146
2021-03-12 15:54:59 -08:00
Misko Hevery 70962465b5 fix(core): Switch `emitDistinctChangesOnlyDefaultValue` to true (#41121)
BREAKING CHANGE:

Switching default of `emitDistinctChangesOnlyDefaultValue`
which changes the default behavior and may cause some applications which
rely on the incorrect behavior to fail.

`emitDistinctChangesOnly` flag has also been deprecated and will be
removed in a future major release.

The previous implementation would fire changes `QueryList.changes.subscribe`
whenever the `QueryList` was recomputed. This resulted in an artificially
high number of change notifications, as it is possible that recomputing
`QueryList` results in the same list. When the `QueryList` gets recomputed
is an implementation detail, and it should not be the thing that determines
how often change event should fire.

Unfortunately, fixing the behavior outright caused too many existing
applications to fail. For this reason, Angular considers this fix a
breaking fix and has introduced a flag in `@ContentChildren` and
`@ViewChildren`, that controls the behavior.

```
export class QueryCompWithStrictChangeEmitParent {
  @ContentChildren('foo', {
    // This option is the new default with this change.
    emitDistinctChangesOnly: true,
  })
  foos!: QueryList<any>;
}
```
For backward compatibility before v12
`emitDistinctChangesOnlyDefaultValue` was set to `false. This change
changes the default to `true`.

PR Close #41121
2021-03-12 10:47:56 -08:00
Kristiyan Kostadinov 3c66b100dd perf(common): remove unused methods from DomAdapter (#41102)
The `DomAdapter` is present in all Angular apps and its methods aren't tree shakeable.
These changes remove the methods that either aren't being used anymore or were only
used by our own tests. Note that these changes aren't breaking, because the adapter
is an internal API.

The following methods were removed:
* `getProperty` - only used within our own tests.
* `log` - Guaranteed to be defined on `console`.
* `logGroup` and `logGroupEnd` - Only used in one place. It was in the DomAdapter for built-in null checking.
* `logGroupEnd` - Only used in one place. It was placed in the DomAdapter for built in null checking.
* `performanceNow` - Only used in one place that has to be invoked through the browser console.
* `supportsCookies` - Unused.
* `getCookie` - Unused.
* `getLocation` and `getHistory` - Only used in one place which appears to have access to the DOM
already, because it had direct accesses to `window`. Furthermore, even if this was being used
in a non-browser context already, the `DominoAdapter` was set up to throw an error.

The following APIs were changed to be more compact:
* `supportsDOMEvents` - Changed to a readonly property.
* `remove` - No longer returns the removed node.

PR Close #41102
2021-03-10 11:48:24 -08:00
Andrew Kushnir fa3689f432 test(forms): split Forms example app into Reactive and Template-driven ones (#41108)
One of the main goals of the bundling tests is to verify that unused symbols are tree-shaken away in prod bundles.
Currently both Reactive and Template-driven test apps are merged into one. In order to make these tree-shaking
tests even more useful, this commit splits exiting test app into two, so that we can further optimize sets of
symbols that should be retained in both scenarios.

PR Close #41108
2021-03-08 16:05:11 -08:00
Pete Bacon Darwin 2ebe2bcb2f refactor(compiler): move factory out of injector definition (#41022)
Previously, injector definitions contained a `factory` property that
was used to create a new instance of the associated NgModule class.

Now this factory has been moved to its own `ɵfac` static property on the
NgModule class itself. This is inline with how directives, components and
pipes are created.

There is a small size increase to bundle sizes for each NgModule class,
because the `ɵfac` takes up a bit more space:

Before:

```js
let a = (() => {
  class n {}
  return n.\u0275mod = c.Cb({type: n}),
  n.\u0275inj = c.Bb({factory: function(t) { return new (t || n) }, imports: [[e.a.forChild(s)], e.a]}),
  n
})(),
```

After:

```js
let a = (() => {
  class n {}
  return n.\u0275fac = function(t) { return new (t || n) },
  n.\u0275mod = c.Cb({type: n}),
  n.\u0275inj = c.Bb({imports: [[r.a.forChild(s)], r.a]}),
  n
})(),
```

In other words `n.\u0275fac = ` is longer than `factory: ` (by 5 characters)
and only because the tooling insists on encoding `ɵ` as `\u0275`.

This can be mitigated in a future PR by only generating the `ɵfac` property
if it is actually needed.

PR Close #41022
2021-03-08 15:31:30 -08:00
Igor Minar 03d47d5701 feat(core): manually annotate de-sugarred core tree-shakable providers with @pureOrBreakMyCode (#41096)
This is necessary for closure compiler in order to support cross chunk code motion.

I'm intentionally not annotating these call sites with @__PURE__ at the moment because
build-optimizer does it within the Angular CLI build. In the future we might want to consider
having both annotations here in case we change how build-optimizer works.

PR Close #41096
2021-03-08 10:30:08 -08:00
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