Skip to content

Code comments are confusing on correct way to setup zoneless. #577

Description

@bh3605

Question

The comment on the provideSingleSpaPlatform() method is

/**
 * The `PlatformLocation` class is injected into `PathLocationStrategy`,
 * which creates a `Subject` internally for listening to `popstate` events. We provide
 * this custom class in the root injector used during application bootstrapping.
 *
 * THIS IS REQUIRED FOR ALL APPLICATIONS (BOTH ZONE AND ZONELESS). Pass the result of
 * this function to `platformBrowser()` when bootstrapping your application:
 *
 * @example
 * const lifecycles = singleSpaAngular({
 *   bootstrapFunction: async () => {
 *     const platformRef = platformBrowser(provideSingleSpaPlatform());
 *     return bootstrapApplication(AppComponent, appConfig, { platformRef });
 *   },
 *   template: '<app-root />',
 *   NgZone: 'noop',
 *   Router,
 *   NavigationStart,
 * });
 */

But in the mount method there's this comment.

  // However, if the app is running in zoneless mode (`NgZone: 'noop'`), change detection is
  // managed manually and the platform location override is not needed, so we skip this check.

This means I should be able to get away with this setup right?

const lifecycles = singleSpaAngular({
  bootstrapFunction: (singleSpaProps: SingleSpaProps) => {
    singleSpaPropsSubject.next(singleSpaProps);
    return bootstrapApplication(AppComponent, appConfig);
  },
  template: '<my-mfe-root />',
  NavigationStart,
  NgZone: 'noop',
});

Environment


Libs:
- @angular/core version: 22.1.0
- single-spa-angular version: 21.0.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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