Skip to content

"#37 Invalid application - no unmount function" when importing Angular 18 standalone app #551

@ShawnM1

Description

@ShawnM1

Describe the bug or question
I'm using single-spa (v6.0.3) as a root config to import a simple Angular 18 microfrontend that uses standalone components (no NgModule). After running the Angular schematic (ng add single-spa-angular) and adjusting for standalone components, I can build and serve the Angular app, and the root-config serves the import map. However when I visit the root-config (http://localhost:9000) I get:

$37: Invalid application - no unmount function

To Reproduce
Repo: https://github.com/ShawnM1/single-spa-playground

Start the Angular MFE dev server

cd angular-mfe
npm run serve:single-spa:angular-mfe
(serves at http://localhost:4200)
Start the root-config dev server

cd root-config
npm start
(serves at http://localhost:9000)
Open http://localhost:9000 in the browser.

Files / snippets used in my setup:

  • root-config import map (index.ejs, local section)
{
  "imports": {
    "@app/root-config": "//localhost:9000/app-root-config.js",
    "@angular-demo": "//localhost:4200/main.js"
  }
}
  • Angular single-spa entry
const lifecycles = singleSpaAngular({
  bootstrapFunction: singleSpaProps => {
    singleSpaPropsSubject.next(singleSpaProps);
    return bootstrapApplication(AppComponent, appConfig);
  },
  template: '<app-root />',
  NgZone,
});

export const bootstrap = lifecycles.bootstrap;
export const mount = lifecycles.mount;
export const unmount = lifecycles.unmount;

Expected behavior
single-spa should import the microfrontend, find the exported lifecycle functions (bootstrap, mount, unmount), and mount the Angular app successfully. No #37: Invalid application - no unmount function error.

Screenshots and/or console output
If applicable, add screenshots or console output to help explain your problem.

Additional context

  • single-spa root-config: v6.0.3
  • angular: 18.2.0, using standalone components (no NgModule)
  • single-spa-angular: ^9.2.0
  • zone.js: ~0.14.10
  • Repo: Repo: https://github.com/ShawnM1/single-spa-playground — root-config and angular-mfe are included there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions