Commit Graph

4258 Commits

Author SHA1 Message Date
Kristiyan Kostadinov 40c976c909 fix(migrations): use NgForOf instead of NgFor (#49022)
Adds a function that allows for the import resolution for files to be customized in the standalone migration. Externally it's only use is to change `NgForOf` to `NgFor`, but we'll need it internally to deduplicate some Material modules.

Fixes #49006.

PR Close #49022
2023-02-10 17:19:49 +01:00
cexbrayat c19486702a test: typos in standalone test names (#49014)
Fixes a recurring typo in test names containing `bootstrap`

PR Close #49014
2023-02-10 10:22:21 +01:00
Kristiyan Kostadinov 4ac25b2aff perf(migrations): avoid re-traversing nodes when resolving bootstrap call dependencies (#49010)
Fixes that the migration was unnecessarily traversing top-level nodes. This was a large performance bottle-neck, because it involves a lot of language service lookups.

PR Close #49010
2023-02-09 15:37:18 +01:00
Kristiyan Kostadinov 521ccfbe6c fix(migrations): avoid interrupting the migration if language service lookup fails (#49010)
In some internal migrations the language service was throwing for some file reads which was crashing the migration. These changes add a `try/catch` to avoid interrupting it.

PR Close #49010
2023-02-09 15:37:18 +01:00
Kristiyan Kostadinov 26cb7ab2e6 perf(migrations): speed up language service lookups (#49010)
For the module pruning and bootstrap API migration steps we depend heavily upon the TypeScript `LanguageService` which ends up being slow on a large project. E.g. in some large internal projects single-file lookups were taking around 30s.

These changes introduce a wrapper around the `LanguageService` that we can use to trick it into not traversing the entire project every time.

PR Close #49010
2023-02-09 15:37:18 +01:00
Kristiyan Kostadinov bdbf21d04b fix(migrations): avoid generating imports with forward slashes (#48993)
We're using Node's `path` utilities to remap existing imports and create new ones which can yield paths with forward slash separators.

These changes add some logic to ensure that we only generate forward slashes.

PR Close #48993
2023-02-08 15:19:59 +01:00
Kristiyan Kostadinov c7926b5773 fix(migrations): move standalone migrations into imports (#48987)
Normally having a standalone declaration in the `imports` array is an error and something we handle in the conversion to standalone, but tests can end up in this situation, because apps may have separate tsconfigs for the main app and for tests.

These changes make it so that we move any incorrectly-defined standalone declarations, even if they aren't part of the current migration.

PR Close #48987
2023-02-08 15:18:06 +01:00
Kristiyan Kostadinov ffad1b49d9 fix(migrations): reduce number of files that need to be checked (#48987)
Attempts to speed up the standalone migration by:
1. Not analyzing typechecker files.
2. Telling TS not to check libraries.

PR Close #48987
2023-02-08 15:18:05 +01:00
Kristiyan Kostadinov e9e4449a43 fix(migrations): preserve tsconfig in standalone migration (#48987)
For the standalone migration we need to pass a couple of compiler flags which accidentally also overwrote the project's compiler options. These changes extend the options instead.

PR Close #48987
2023-02-08 15:18:05 +01:00
Kristiyan Kostadinov 1afa6ed322 fix(migrations): don't add ModuleWithProviders to standalone test components (#48987)
Fixes that we were copying all expressions in the `imports` array of the test to the `imports` of the component, including any potential `ModuleWithProviders`.

Fixes #48971.

PR Close #48987
2023-02-08 15:18:05 +01:00
Kristiyan Kostadinov 770191cf1f fix(migrations): migrate tests when switching to standalone bootstrap API (#48987)
The first step of the migration updates the tests of the component being migrated, however it also skips any bootstraped declarations. We get back to the these declarations when converting to the standalone bootstrapping APIs, but we weren't updating their tests.

These changes rework some of the logic so that we migrate any remaining tests as a part of the final step.

Relates to #48944.

PR Close #48987
2023-02-08 15:18:05 +01:00
Kristiyan Kostadinov 6377487b1a fix(migrations): only exclude bootstrapped declarations from initial standalone migration (#48987)
Currently the standalone migration is set up to skip any modules that have a `bootstrap` array with at least one element. This ends up being misleading for small apps who have everything in the root module.

These changes add some logic to only skip the root component.

Fixes #48944.

PR Close #48987
2023-02-08 15:18:05 +01:00
Andrew Scott 5128ba036a refactor(router): Warn if a navigation will change in the upcoming v16 release (#48688)
v16 will have a breaking change to the way `UrlTree`s are constructed.
This change is actually a bug fix that makes `UrlTree` creation correct
in more scenarios (see #48508). However, this can affect applications that are
relying on the current incorrect behavior. This commit adds a dev mode
warning when the target of a navigation will change once #48508 is
submitted.

PR Close #48688
2023-02-07 12:25:59 -08:00
Kristiyan Kostadinov 0cf11167f1 fix(compiler-cli): incorrectly detecting forward refs when symbol already exists in file (#48988)
In #48898 the `isForwardRef` flag was added to indicate whether a reference should be wrapped in a `forwardRef`. This logic assumed that the node can't be referring to another node within the same file, however from testing it looks like that's not actually the case, because we hit the same code path when an external import to the same symbol exists already.

PR Close #48988
2023-02-07 09:00:46 -08:00
Walid Bouguima 73394126b6 docs(core): standalone-migration schematics typos fix and properties addition (#48961)
Fixed a typo and updated the hyphenation in a couple of words to keep consistency across schematics docs style. Assuming beginners reading docs, I also added the property called 

public showGreeting = true;

This is because it is available in the examples `.HTML` `*ngIf` directive snippets without being present in the `.ts` class properties declarations.  also this removes potential inference that this absence is a result of the standalone migration schematics work.
PR Close #48961
2023-02-06 12:32:57 -08:00
Kristiyan Kostadinov a47721c2f1 refactor(migrations): add API to remap generated import names (#48974)
Internally we'll need to remap some imports to generate better import statements. These changes add an API that we can use to do the remapping.

PR Close #48974
2023-02-06 12:28:38 -08:00
Kristiyan Kostadinov 4f6127aa34 refactor(migrations): account for internal module names in module reference check (#48974)
Fixes that the code which checks if something is a reference to a specific class didn't work internally.

PR Close #48974
2023-02-06 12:28:38 -08:00
Kristiyan Kostadinov 32cf4e5cb9 fix(migrations): avoid internal modules when generating imports (#48958)
Adds some logic to prefer non-Angular-internal modules when generating imports. This allows us to generate better code for some cases like the `ɵInternalFormsSharedModule` in Forms.

Also adds some logic to prefer symbols that are already in the same file.

Fixes #48942.

PR Close #48958
2023-02-06 12:27:52 -08:00
Kristiyan Kostadinov 49a7c9f94a fix(migrations): standalone migration incorrectly throwing path error for multi app projects (#48958)
Fixes that the standalone migration was throwing the "Could not find any paths to migrate..." error on a per-tsconfig-basis, preventing the migration from running on any configs that might occur further down in the project.

These changes move the error to after all the configs have been checked.

PR Close #48958
2023-02-06 12:27:52 -08:00
Kristiyan Kostadinov 759db12e0b fix(migrations): duplicated comments on migrated classes (#48966)
Fixes that the migration was duplicating the comments on class nodes that were being converted to standalone.

Fixes #48943.

PR Close #48966
2023-02-06 09:52:18 -08:00
Kristiyan Kostadinov 2de6dae16d fix(migrations): migrate RouterModule.forRoot with a config object to use features (#48935)
Previously if the standalone migration saw a `RouterModule.forRoot` with a config object, it wouldn't migrate it. These changes add some logic that convert the config object to a set of features from the new router API.

PR Close #48935
2023-02-03 11:40:45 -08:00
Matthieu Riegler 2ceff3f0c2 refactor(core): remove IE11 only sanitization code (#48438)
As IE11 support has been drop with v13, this specific code isn't needed anymore.

PR Close #48438
2023-02-03 09:45:03 -08:00
Kristiyan Kostadinov ba38178d19 fix(migrations): generate forwardRef for same file imports (#48898)
Adds some logic that will generate a `forwardRef` if necessary when adding imports.

PR Close #48898
2023-02-02 13:40:17 -08:00
Kristiyan Kostadinov 8389557848 fix(migrations): don't copy unmigrated declarations into imports array (#48882)
Currently the migration is set up to assume that any elements that exist in a `declarations` array will be converted to standalone and copied into the `imports` array, however that might be incorrect for some special cases like the root component.

These changes rework the declaration merging logic so that they take all the declarations being migrated into account.

PR Close #48882
2023-02-02 09:35:57 -08:00
Kristiyan Kostadinov 584976e6c8 fix(migrations): support --defaults in standalone migration (#48921)
Fixes that running the standalone migration with `--defaults` was throwing an error, because all the properties were specified as required. We don't need to set them as required, because they have default values.

Fixes #48845.

PR Close #48921
2023-02-02 09:31:09 -08:00
Kristiyan Kostadinov a40cd47aa7 fix(migrations): avoid modifying testing modules without declarations (#48921)
Fixes that we were changing the testing modules that have no `declarations` unnecessarily, resulting in more formatting changes that users would have to clean up.

PR Close #48921
2023-02-02 09:31:09 -08:00
Kristiyan Kostadinov 03f47ac901 fix(migrations): use consistent quotes in generated imports (#48876)
Adds some logic so that the imports generated by the `ImportManager` use the same styles as the other imports.

PR Close #48876
2023-01-30 16:52:23 -08:00
Kristiyan Kostadinov f82bdc4b01 fix(migrations): don't delete classes that may provide dependencies transitively (#48866)
Fixes that we would incorrectly remove a module that imports another module which has providers. This is a follow-up from the following discussion: https://github.com/angular/angular/pull/48832#discussion_r1086623514

PR Close #48866
2023-01-27 16:55:20 +00:00
Kristiyan Kostadinov c865b8b59c docs(migrations): follow-up readme fixes (#48866)
Addresses a couple of notes from #48848 that came in after the PR was merged.

PR Close #48866
2023-01-27 16:55:20 +00:00
Dario Piotrowicz b4187548ca fix(animations): fix non-animatable warnings for easing (#48583)
the easing "prop" used to specify the easing function to
apply to animations isn't a valid css property, it is thus
considered not animatable but different values for such
property shouldn't cause non-animatable warnings

resolves #48571

PR Close #48583
2023-01-26 22:03:07 +00:00
Kristiyan Kostadinov ed8f70125e docs(core): add readme for standalone migration (#48848)
Updates the readme for the standalone migration to describe the process and the different transformations that are happening.

PR Close #48848
2023-01-26 17:02:50 +00:00
Kristiyan Kostadinov 345e737daa feat(core): add ng generate schematic to convert to standalone bootstrapping APIs (#48848)
Adds a new mode to the `@angular/core:standalone` schematic that allows users to switch from `bootstrapModule` to `bootstrapApplication`, as well as `provideRouter`, `provideAnimations` and `provideNoopAnimations`.

PR Close #48848
2023-01-26 17:02:50 +00:00
Kristiyan Kostadinov 04e0ac3d7c fix(migrations): migration host incorrectly reading empty files (#48849)
Fixes that the migration host was doing a basic falsy check if the content was read correctly which meant that a component with an empty template would be considered as having a missing template file.

Fixes #48846.

PR Close #48849
2023-01-26 15:54:14 +00:00
Alan Agius 65c74ed93e fix(migrations): normalize paths to posix (#48850)
Both TypeScript and Angular Schematic rely on posix system paths which can cause issues on Windows if paths are not normalized correctly.

Such as `sourceFile.fileName.startsWith(pathToMigrate)` on Windows will always return falsey.

PR Close #48850
2023-01-26 15:53:48 +00:00
Alan Agius 2796230e95 fix(migrations): add enum in mode option in standalone schema (#48851)
Currently the `mode` is validated during schematic execution. While this cover a case of incorrect value this caused other parts were the correct values cannot be determined.

Options in schemas are used for a number of reasons during runtime.

- These are used to build auto complete
- Validation of inputs prior of the schematic is built with meaningful errors such as suggested inputs.
- Generation of help output.

Eventually these should also be used to generate DTS. This is already done in the CLI to avoid having to write Types manually.

PR Close #48851
2023-01-26 15:52:48 +00:00
Iván Navarro a055196c55 fix(common): warn if using ngSrcset without a configured image loader (#48804)
Warn the user in the console in case the `ngSrcset` is present and no
loader is configured. In this case, the default loader is used and
it ignores this attribute.

PR Close #48804
2023-01-25 19:27:00 +00:00
Kristiyan Kostadinov 06e161f2dd fix(compiler): incorrect code when non-null assertion is used after a safe access (#48801)
Fixes that the expression converter was producing code that throws a runtime error if a non-null assertion is used as a part of a safe read, write or call.

Fixes #48742.

PR Close #48801
2023-01-25 18:31:37 +00:00
Matthieu Riegler fd539a298e docs: fix the documentation for BootstrapOptions (#48834)
Inline code was being rendered on aio, this commit fixes this.

PR Close #48834
2023-01-25 18:31:08 +00:00
Kristiyan Kostadinov e7318fc758 feat(core): add ng generate schematic to remove unnecessary modules (#48832)
Adds a new mode to the `@angular/core:standalone` schematic that automatically deletes modules that may not be necessary after the previous step of converting them to standalone.

PR Close #48832
2023-01-25 16:20:27 +00:00
Kristiyan Kostadinov a154db8a81 feat(core): add ng generate schematic to convert declarations to standalone (#48790)
Implements a new `ng generate @angular/core:standalone` schematic that allows the user to convert all the declarations in a set of NgModules to standalone.

PR Close #48790
2023-01-24 16:48:19 +00:00
Kristiyan Kostadinov b37a624985 build: set up ng generate schematics for core (#48790)
Adds the necessary boilerplate to allow for `ng generate` schematics to be included with `@angular/core`.

PR Close #48790
2023-01-24 16:48:19 +00:00
Kristiyan Kostadinov 69c3d2849d refactor(migrations): minor improvements to existing schematic utilties (#48790)
Makes the following minor improvements to our current schematic utilities:
* `closestNode` now takes a TS predicate function instead of a `SyntaxKind`. This allows it automatically infer the type of the match.
* `getImportSpecifier` now accepts a regex for the module name. This will be useful for some upcoming migrations.
* Splits the logic for creating the migration program options into a separate function so that it's easier to reuse.
* `createMigrationProgram` now returns the program directly, instead of a literal with some other information.
* `FakeReadFileFn` and `createMigrationCompilerHost` aren't exported anymore since they aren't used anywhere.

PR Close #48790
2023-01-24 16:48:19 +00:00
Kristiyan Kostadinov e4b28456a9 refactor(migrations): allow for aliases to be specified in the import manager (#48790)
Adds the ability to set an alias when adding an import through the `ImportManager`. This will be required in some upcoming schematics.

PR Close #48790
2023-01-24 16:48:19 +00:00
Kristiyan Kostadinov 1e30baaaa7 test: remove usages of deprecated runSchematicAsync function (#48745)
Removes our usages of `runSchematicAsync` since it is deprecated.

PR Close #48745
2023-01-17 09:13:39 -08:00
Pawel Kozlowski 5f21c6d627 perf(common): avoid excessive DOM mutation in NgClass (#48433)
This commit represents rewrite of the NgClass directive to address
severe performance problem (excessive DOM mutation). The modified
algorithm removes all the known performance clifs and has number of
desirable properties:
- it is shorter and (arguably) easier to follow;
- drops usage of existing differs thus limiting dependencies on other
part of the code without increasing size of the directive;
- doesn't degrade any other performance metrics.

Fixes #25518

PR Close #48433
2023-01-13 10:38:54 -08:00
Alex Rickabaugh f00bf71411 fix(core): makeEnvironmentProviders should accept EnvironmentProviders (#48720)
`makeEnvironmentProviders` constructs the wrapped `EnvironmentProviders`
type, which can only be used in environment injectors (not element
injectors). It makes sense that `makeEnvironmentProviders` should be able
to accept existing `EnvironmentProviders`-wrapped providers, since it will
be providing the same guarantee, but the current types do not allow this.

This commit fixes the typings to allow nesting `EnvironmentProviders` and
adds a test to verify that it will work.

PR Close #48720
2023-01-12 13:47:59 -08:00
Matthieu Riegler c8310a842d refactor(core): cleanup type any (#48623)
Removing every type any in core with a reference to #9100

PR Close #48623
2023-01-04 12:15:16 -08:00
Pawel Kozlowski dacfe4372e refactor(core): move attachDebugGetter to i18n specifc code (#48549)
The attachDebugGetter function is only used in the i18n specific code
so could be moved closer to the sole usage site instead of being
exported to the entire framework code. It also lets us remove the
entire packages/core/src/render3/util/debug_utils.ts file.

PR Close #48549
2023-01-04 12:14:30 -08:00
Pawel Kozlowski 1085e5c2ce refactor(core): remove unused attachDebugObject function (#48549)
This commit removes the unused attachDebugObject function.

PR Close #48549
2023-01-04 12:14:30 -08:00
Kristiyan Kostadinov a532d71975 feat(compiler): allow self-closing tags on custom elements (#48535)
Allows for self-closing tags to be used for non-native tag names, e.g. `<foo [input]="bar"></foo>` can now be written as `<foo [input]="bar"/>`. Native tag names still have to have closing tags.

Fixes #39525.

PR Close #48535
2023-01-04 12:07:37 -08:00