Commit Graph

29565 Commits

Author SHA1 Message Date
Payam Valadkhan f6e9dbbe73 refactor(compiler-cli): run resolve phase fully for components in local mode when generateExtraImportsInLocalMode is set (#53543)
In this commit the resolve method for components is run fully when the option `generateExtraImportsInLocalMode` is set. This is because we need local component depedencies in order to generate extra imports causing by them. This requires cutting some resolve phase logics that are unnecessary in local mode, such as diagnostics.

PR Close #53543
2024-01-30 15:05:43 +00:00
Payam Valadkhan 6a136d1ab3 refactor(compiler-cli): run register phase in local compilation mode (#53543)
When option `generateExtraImportsInLocalMode` is set, we need to compute component local depednecies in order to generate extra imports related to them. At the same time running the register phase in general is harmless in local compilation. So we run it anyway.

PR Close #53543
2024-01-30 15:05:43 +00:00
Payam Valadkhan 3263df23f2 feat(compiler-cli): generate global imports in local compilation mode (#53543)
With option `generateExtraImportsInLocalMode` set in local compilation mode, the compiler generates extra side effect imports using this rule: any external module from which an identifier is imported into an NgModule will be added as side effect import to every file in the compilation unit. To illustrate this better assume the compilation unit has source files `a.ts` and `b.ts`, and:

```
// a.ts
import {SomeExternalStuff} from 'path/to/some_where';
import {SomeExternalStuff2} from 'path/to/some_where2';

...

@NgModule({imports: [SomeExternalStuff]})

```

then the extra import `import "path/to/some_where"` will be added to both `a.js` and `b.js`. Note that this is not the case for `import "path/to/some_where2"` though, since the symbol `SomeExternalStuff2` is not imported into any NgModule.

The math behind this mechanism is, in local compilation mode we cannot resolve component external dependencies fully. For example if a component in `a.ts` uses an external component defined in an external file `some_external_comp.ts` then we can generate the import to this file in `a.js`. Instead, we want to generate an import to a file that "gurantees" that `a.js` is placed after `some_external_comp.js` in the bundle. Now since the component in  `some_external_comp.ts` is used in `a.ts`, then there must be a chain of imports starting from the NgModule that declares the component in `a.ts` to the component in `some_external_comp.ts`. This chain means some file in the same compilation unit as `a.ts` should import some external NgModule which includes `some_external_comp.ts` in its transitive closure and import it to some NgModule. So by adding this import to `a.js` we ensure that the bundling will have the right order.

PR Close #53543
2024-01-30 15:05:43 +00:00
Payam Valadkhan 5feed80523 refactor(bazel): make option generateExtraImportsInLocalMode configurable (#53543)
This is to allow testing this option using bazel

PR Close #53543
2024-01-30 15:05:42 +00:00
Payam Valadkhan 8c36f2d6f1 refactor(compiler-cli): ability to generate side effect imports (#53543)
As the first step,  the import manager's `generateSideEffectImport` method is implemented to enable it to store info for side effect imports. Next, the helper `addImports` is modified to be able to generate correct statement for side effect imports.

These changes will be tested in the subsequent commits when these tools are used to generate an actual extra import for the generated file.

PR Close #53543
2024-01-30 15:05:42 +00:00
Payam Valadkhan fc55de1416 refactor(compiler-cli): incorporate LocalCompilationExtraImportsTracker in the compilation workflow (#53543)
This commit includes a skeleton of how the tool `LocalCompilationExtraImportsTracker` is used in the overall compilation workflow end-to-end.

First of all, a new option `generateExtraImportsInLocalMode` is added, whose presence will make `LocalCompilationExtraImportsTracker` part of the compilation process. When this option is set an instance of `LocalCompilationExtraImportsTracker` is created within the NgCompiler. Then it is passed to the Ivy transformer and plumbed all the way down and the extra imports registered in it are added to the `ImportManager` instances before the imports are added from `ImportManager` to the generated file. This required adding a new method `generateSideEffectImport` to the `ImportManager`, which is an empty method and will be implemented in the subsequent commits.

This commit expected to make no change in the compilation behavior as the methods are not implemented yet.

PR Close #53543
2024-01-30 15:05:42 +00:00
Payam Valadkhan ac3c484bb1 refactor(compiler-cli): add API for extra import tracker (#53543)
The tracker is responsible for registering the extra imports during the analysis and resolve compiler phases, and later to be used by the transformer to get a list of extra imports to be generated for each source file.

This commit only contains the API, and the actual implementation for each method will be done in subsequent commits where an application of that method is available and so tests can be written for the implementation.

PR Close #53543
2024-01-30 15:05:42 +00:00
Andrew Scott 15c48113c2 refactor(router): Update integration tests to cover navigation and history API (#53799)
This commit updates the router integration tests to cover both the
classic History and the new Navigation API. There is more work to be
done here, but this commit works to prove the efficacy of the
`FakeNavigation` implementation.

PR Close #53799
2024-01-30 15:04:02 +00:00
Dylan Hunn 7b4d275f49 fix(compiler): Fix the template pipeline option (#54148)
The `useTemplatePipeline` option was not properly threaded through the component handler.

PR Close #54148
2024-01-29 21:12:32 +00:00
Andrew Scott 3ca34e606d refactor(core): Update ComponentFixture behavior when using zoneless scheduler (#54024)
When the zoneless scheduler is provided, we want to update the behavior
of `ComponentFixture` to address common issues and painpoints in testing.
Developers should never have to call `detectChanges` on a fixture
manually. Instead of calling `detectChanges` after performing an
action that updates state and requies a template refresh, developers
should wait for change detection to run because the update needs to also have
notified the scheduler. If this was not the case, the component would
not work correctly in the application. Calling `detectChanges` to force
an update could hide real bugs.

This commit also updates the zoneless tests to uses `ComponentFixture`
instead of manually attaching to the `ApplicationRef` and rewriting a
lot of the helpers (`getDebugNode`, `isStable` as a value, `whenStable` as a
Promise).

PR Close #54024
2024-01-29 20:21:47 +00:00
Mark Thompson 098543f1d8 docs: Update component-overview.md (#52282)
Refined the text a bit
PR Close #52282
2024-01-29 19:30:59 +00:00
Renan Ferro e86a13674f docs: add new component imports documentation structure (#52282)
PR Close #52282
2024-01-29 19:30:59 +00:00
Jesse Zomer c55018724a docs: fix shareReplay refcount default (#54145)
according to the official rxjs docs the refcount default is false. See https://rxjs.dev/api/operators/shareReplay

Co-authored-by: Andrew Scott <atscott01@gmail.com>

PR Close #54145
2024-01-29 19:30:33 +00:00
therealdennis08 9571287299 docs: correct grammar error on start page (#53993)
Fixed grammatical error

PR Close #53993
2024-01-29 16:41:29 +00:00
Alex Castle f5c520b836 feat(common): add placeholder to NgOptimizedImage (#53783)
Add a automatic placeholder implementation supporting loader-based and data URL placeholders

PR Close #53783
2024-01-29 16:00:38 +00:00
Ido Strauss f3a2b49f82 docs: update TypeScript version support details for Angular v15 and v16 (#54131)
Clarify the range of TypeScript versions supported in Angular v15 and v16 upgrade guides. The previous documentation's phrasing led to potential misunderstandings, as it suggested broader compatibility than actually supported. This change prevents errors by explicitly stating the maximum TypeScript version for each Angular version, ensuring developers have clear guidance during upgrades.

PR Close #54131
2024-01-29 15:57:01 +00:00
Swami 45288f7815 docs: update input/output guide links (#54135)
PR Close #54135
2024-01-29 15:43:05 +00:00
Kristiyan Kostadinov 28ad6fc4ad fix(migrations): error in standalone migration when non-array value is used as declarations in TestBed (#54122)
Adds some logic to skip over `TestBed.configureTestingModule` calls where the `declarations` aren't initialized to an array. We can't migrate these cases, because test migrations don't have access to the Angular compiler. Previously the migration would throw a runtime error.

PR Close #54122
2024-01-29 15:40:05 +00:00
Santosh Yadav d9a84705c9 docs: add link for control flow migration (#53375)
PR Close #53375
2024-01-29 15:39:05 +00:00
Dwouglas Mhagnum c213a4e15a InMemoryBackendConfigArgs.passThruUnknownUrl: fix tsdoc (#52273)
PR Close #52273
2024-01-26 20:39:38 +00:00
Matt Ezell aef7b2c74e docs: Corrected link for defer related blocks (#52704)
PR Close #52704
2024-01-26 20:38:36 +00:00
Muhammad Ahsan Ayaz 52e8f364ed docs(changelog): release notes, fix the typos etc (#52628)
fixed the typos in a few places
added a missing backtick
removed an unnecessary bullet point

PR Close #52628
2024-01-26 20:38:05 +00:00
Wojciech b0632bd703 docs: Update update-to-version-16.md (#51857)
Fix example for required inputs that leads to TS2564 error - property has no initializer

PR Close #51857
2024-01-26 19:13:24 +00:00
Matthieu Riegler 7800a3c9f5 refactor(core): remove InjectionToken descriptions in optimized builds. (#53747)
We started guarding the `InjectionToken` descriptions with `ngDevMode`. Let's generalize that accross the FW.

PR Close #53747
2024-01-26 19:12:41 +00:00
Payam Valadkhan 0970129e20 fix(compiler-cli): show proper error for custom decorators in local compilation mode (#53983)
At the moment local compilation mode does not support custom decorators, and it leads to unhandled errors. In this change a compile time diagnostic is produced in local mode for custom decorators. This is a temporary solution since there are few custom decorators are in use in g3. Custom decorators will be eventually supported in local mode.

PR Close #53983
2024-01-26 19:11:34 +00:00
Paul Gschwendtner 23eeea5bd7 ci: adding devversion to reviewers for compiler/core (#54053)
I've been working on framework parts and compiler since pre-Ivy, and
helped with Ivy, runtime and compiler. Adding myself as a reviewer to
ease future work and to help with review load.

PR Close #54053
2024-01-26 19:10:56 +00:00
Paul Gschwendtner fcea8c1c5d feat(docs-infra): show overloads of methods in API overview (#54053)
This enables us to show overloads of methods in the API overview. This
is useful for e.g. showing the various signatures of the signal input
function, or for signal-based queris.

There seems to be some issues with the length of the `InputFunction`
overloads. There is some line wrapping that doesn't make it _super_
readable but this is an unrelated problem to this change, but rather
a question of UI / API representation in the angular.io site.

PR Close #54053
2024-01-26 19:10:56 +00:00
Paul Gschwendtner 8ba4db2627 refactor(core): avoid clang-format obfuscating InputFunction.required (#54053)
clang-format seems to have problems with the call signature for
`input.required`. This commit works around the formatting issues that
obfuscate the signature. Users will actually see similar output when
they are looking for the `input` function definition of `@angular/core`.

PR Close #54053
2024-01-26 19:10:56 +00:00
Paul Gschwendtner fe4343cf13 refactor(compiler): extract call and construct signatures of interfaces (#54053)
This adds initial support for extracting and rendering call and construct
signatures of classes, like within the new `InputFunction` for signal
inputs.

For now, signatures are a rare occasion and represented as class member
entries. In the future we might consider exposing this via its own entry
type, and field on the class/interface entry.

PR Close #54053
2024-01-26 19:10:56 +00:00
Paul Gschwendtner 58b8a232d6 fix(compiler-cli): support jumping to definitions of signal-based inputs (#54053)
This fixes the definitions for signal-based inputs in the language
service and type checking symbol builder.

Signal inputs emit a slightly different output. The output works well
for comppletion and was designed to affect language service minimally.
Turns out there is a small adjustment needed for the definition symbols.

PR Close #54053
2024-01-26 19:10:56 +00:00
Paul Gschwendtner b78042f3a5 refactor(core): separate InputSignal and InputSignalWithTransform (#54053)
This commit separates `InputSignal` for input signals with transforms.
The reason being that most of the time, signal inputs are not using
transforms and the generics are rather confusing.

Especially for users with inferred types displayed in their IDEs, the
input signal types are seemingly complex, even if no transform is used.

For this reason, we are introducing a new type called
`InputSignalWithTransform`. This type will be used for inputs with
transforms, while non-transform inputs just use `InputSignal`.

A notable fact is that `InputSignal` extends `InputSignalWithTransform`,
with the "identity transform". i.e. there is no transform. This allows
us to share the code for input signals. In practice, we don't expect
users to pass around `InputSignal`'s anyway.

PR Close #54053
2024-01-26 19:10:56 +00:00
Matthieu Riegler d38238e478 docs: remove mention of providedIn module. This feature has been deprecated. (#54072)
PR Close #54072
2024-01-26 19:09:28 +00:00
fhoekstra 16fbe85702 docs(router): fix variable reference in text (#54099)
PR Close #54099
2024-01-26 19:02:42 +00:00
iliasaddab 4105ab51a5 docs: update i18n-common-merge.md (#52400)
correct spelling

PR Close #52400
2024-01-26 17:38:09 +00:00
Matthieu Riegler 1a2b5691e1 docs: add 2 new diagnostics created recently. (#52329)
PR Close #52329
2024-01-26 17:28:01 +00:00
Matthieu Riegler 8a1f1c075a refactor(platform-browser): remove non necessary factories (#52439)
Let's keep the code a simple as necessary

PR Close #52439
2024-01-26 17:26:51 +00:00
Matthieu Riegler 983968dc68 refactor(platform-browser): remove the depency on window for the AngularProfiler. (#52440)
`performance` and `console` are both available on NodeJS, we can replace `window` with `globalThis`.

PR Close #52440
2024-01-26 17:24:40 +00:00
Matthieu Riegler 89ab1c18a1 refactor(common): Use Nullish coalescing assignment when possible. (#53931)
Inspired by #53923, lets simplify code when possible.

PR Close #53931
2024-01-26 16:58:36 +00:00
Angular Robot 6946316350 docs: update events (#53654)
Generated `events.json` with the latest events retrieved from the Firebase DB.

Closes #53229

PR Close #53654
2024-01-26 16:58:07 +00:00
Shuaib hasan akib 271755d0e4 docs(docs-infra): cleanup repeated scss from typography (#51579)
PR Close #51579
2024-01-26 16:03:43 +00:00
Sylvain DEDIEU 1c49160129 docs(docs-infra): add if cases in templates to avoid internal marked parameters or methods to appear in the documentation (#52020)
Fix case of not wanted internal properties displayed in the documentation by adding if blocks in the concerned templates. So if the option is marked as internal the template won't create an entry in the documentation table for the concerned property of method

Fixes #52018

PR Close #52020
2024-01-26 15:47:15 +00:00
Chellappan 989394db90 refactor(forms): Specify Provider type for DEFAULT_VALUE_ACCESSOR (#54029)
Change from `any` to `Provider` type for enhanced type safety and clarity

PR Close #54029
2024-01-26 15:46:31 +00:00
Ezéchiel Amen AGBLA 768b927f9a docs: remove link (#54090)
PR Close #54090
2024-01-26 15:46:00 +00:00
cexbrayat 037b79b72e fix(core): change defer block fixture default behavior to playthrough (#54088)
This is a followup to #53956

The default behavior needs to be changed in `TestBedCompiler` as well to have an effect.

PR Close #54088
2024-01-26 15:44:40 +00:00
Magda98 c3b0095965 docs(docs-infra): move comma in Angular Language Service section (#53759)
PR Close #53759
2024-01-25 23:48:56 +00:00
jivanf b9547a98f6 docs: Use correct service name in hierarchical dependency injection guide (#53723)
This commit replaces `TitleService` with `TiresService` in the specialized providers scenario described in the guide.
PR Close #53723
2024-01-25 23:47:01 +00:00
Antoine PARIZE 863c12aa89 docs: testing-components-basics.md and components-basics.md links to css selector documentation are dead (#53586)
docs: testing-components-basics.md and components-basics.md links to css selector documentation are dead

As MDN's documentation link to the "css selector" topic is dead, this commit makes the angular documentation use the new valid link.

PR Close #53586
2024-01-25 23:34:03 +00:00
oliv37 c634405a52 docs: fix add builder from package (#53154)
PR Close #53154
2024-01-25 23:31:01 +00:00
pBouillon 89abbaac7f docs: fix reference to forwardRef in ForwardRefFn JSdoc (#53556)
PR Close #53556
2024-01-25 23:16:46 +00:00
lsst25 fa0f44da7e docs(docs-infra): close tag in the example of Composing Components tutorial (#52923)
PR Close #52923
2024-01-25 23:04:47 +00:00