{
"$type": "site.standard.document",
"canonicalUrl": "https://mhartington.io/post/a-moduleless-future-for-angular",
"path": "/post/a-moduleless-future-for-angular",
"publishedAt": "2024-01-10T13:51:49.275Z",
"site": "at://did:plc:7kwylbxx56yro6aqz3oh5d2s/site.standard.publication/3mpgyj6haew2g",
"textContent": "Recently a Pull Request from Matthieu Riegler came to the Angular repo that wanted to mark the HTTPClientModule and similar modules as deprecated. Overall it seems the idea has received positive traction, though in Matthieu's tweet about the PR, there was a comment in there that did stand out to me.\n\n> I think I need an example before I decide whether I need pitchforks or not.\n\nSo let's make a quick example to show this person what this PR does and how it can impact non-standalone apps.\n\nIn an Angular app that uses NgModules, if you want to add HttpClientModule to the app, you need to go to the module that requires HTTP, and then add that to the imports array of the NgModule:\n\nWith Standalone apps, this has moved to the simpler method of just providing the provideHttpClient in the main bootstrapping function\n\nWhy does this change matter? Well under the hood, HttpClientModule was doing the same exact thing as provideHttpClient. If we reference a very old version of HTTPClientModule, you can see how this works.\n\nSo when you add the HttpClientModule in your app, you're just having the module setup and provide the rest of your providers. What does provideHttpClient do? \n\nThe exact same thing! It's very nice to see how the two map back to one another. \n\nSo this begs the question, what do you do if you still are using NgModules and need to use HttpClient? Well first off, don't panic. The PR isn't merged yet and it's only a deprecation notice. There's still time.\n\nBut since provideHttpClient and HttpClientModule fundamentally did the same thing, migration could be as simple as replacing the module with the provideHttpClient code.\n\nThen in your components, you'd be good to go!\n\nTo me, this feels like the best of both worlds, and helps people as they continue their migration to a standalone app setup.",
"title": "A Moduleless Future for Angular"
}