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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
`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
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
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