SubAppOptions: {
    __filename?: string;
    bundleName?: string;
    getModule: Promise<any> | (() => Promise<any>);
    name: string;
    resolveName?: string | false;
    wantFeatures?: SubAppFeatureFactory[];
}

Options for calling the declareSubApp API.

To see example of implement and declare a subapp, see a framework specific SubApp implementation type, such as ReactSubApp.

Type declaration

  • Optional __filename?: string

    File name of the module that declares the subapp.

    • Only required for server side rendering (SSR).
    • Typically just set it to __filename, which webpack set to "/<file>" for client side bundle.
    • If not set, then xarc will figure it out through webpack compiling.
    • But webpack compiling is not 100%, so setting it yourself guarantees it.
  • Optional bundleName?: string

    optional webpack bundle name for the subapp

    • By default, xarc will create one like "subapp-<name>"
    • Use this if you want to override it, such as to combine multiple subapps a single bundle.
  • getModule: Promise<any> | (() => Promise<any>)

    The dynamic import promise for the subapp's module, or a function that returns it

  • name: string

    Name of the subapp

    • This will be used to name the JS bundle
    • It must follow valid filename format, avoid space and special characters
  • Optional resolveName?: string | false

    The name of the export for the subapp from the module.

    • default to subapp
    • then default
    • If it's false, then this subapp is treated as having no UI logic.
  • Optional wantFeatures?: SubAppFeatureFactory[]

    Extra features that the subapp wants. Should be initialized with the feature provider function

    • The intent is to allow a module to provide one or more features for a subapp.

    • Typically the feature needs to have implementation for server and client side, and exposed through the main/browser fields in package.json.

    • The feature is access through an API function. The API should return another function to be called by the subapp system later, and the subapp's info will be passed.