Member-only story

How to migrate Angular CoreModule to standalone APIs

Tomas Trajan
9 min readSep 5, 2023

Standalone APIs are beautiful! (📸 by Kuno Schweizer)

In this article we’re going to learn how to migrate commonly used Angular CoreModule (or any other Angular module) to standalone APIs!

Angular standalone components and APIs are the future! Angular CLI now allows us to generate new Angular applications with standalone setup out of the box, simply by using the new --standalone flag when running ng new command!

This works really great for new greenfield projects, but we might encounter some issues in more complex enterprise environments which often tend to abstract base setup into NgModules in reusable libraries which are then consumed by multiple Angular apps.

Such module might prevent us from using of the standalone setup in consumer apps because we can’t import such module directly in the new app.config.ts and the provider workaround in form of importProvidersFrom handles only providers which is often just not enough!

// app.config.ts
import { MyOrgCoreModule } from '@my-org/core'

// standalone app setup generated by Angular CLI with --standalone
export const appConfig: ApplicationConfig = {
providers: [
// providers ...

MyOrgCoreModule, // ⚠️ doesn't work ...

importProvidersFrom(MyOrgCoreModule), // ⚠️ often not enough, doesn't work
],
};

First, let’s talk about the…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Tomas Trajan
Tomas Trajan

Written by Tomas Trajan

👋 I build, teach, write & speak about #Angular & #NgRx for enterprises 👨‍💻 Google Developer Expert #GDE 👨‍🏫 @AngularZurich meetup co-organizer

Responses (1)

Write a response

Thanks for sharing, Tomas!🙏