Skip to content

Commit

Permalink
fix(@schematics/angular): update private Components utilities to work…
Browse files Browse the repository at this point in the history
… with standalone project structure

When the utilities for adding providers to the `bootstrapApplication` call were written, the structure for a standalone project handn't been finalized yet which meant that the code made some assumptions around how the app config is being passed in. This code breaks with the final project structure, because there the app config is in a separate file instead of an object literal.

These changes update the utilities to account for the new structure. Note the updates are meant to cover the majority of apps and there are likely some edge cases that aren't covered. Covering all cases is tricky with the current setup, because to do so correctly would require knowledge of the entire app whereas the utilities operate on a file-by-file basis. For example, now the code is able to update a config in a separate file, but it wouldn't be able to handle a config that is re-exported. For such a case to be supported, we would need access to the type checker. These edge cases will be addressed later on with a larger refactor of the schematics utilities.

I've added a couple of extra utilities for inserting function calls into the `providers` array and checking if a function is called in the `providers` array. We'll need them for the `ng generate` schematics on Components.
  • Loading branch information
crisbeto authored and angular-robot[bot] committed Apr 3, 2023
1 parent f76466f commit bff634f
Show file tree
Hide file tree
Showing 3 changed files with 798 additions and 123 deletions.
2 changes: 2 additions & 0 deletions packages/schematics/angular/private/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

export {
addModuleImportToStandaloneBootstrap,
addFunctionalProvidersToStandaloneBootstrap,
callsProvidersFunction,
findBootstrapApplicationCall,
importsProvidersFrom,
} from './standalone';
Loading

0 comments on commit bff634f

Please sign in to comment.