Skip to content

Use of single-spa-layout causes twice loaded warning. #204

@barryspearce

Description

@barryspearce

I have two copies of my shell application. The first uses an MFE List and registers the apps:

const mfeList: any = [
    {
        name: 'widget1',
        app: () => import('widget1'),
        activeWhen: '/',
    },
        {
        name: 'widget2',
        app: () => import('widget2'),
        activeWhen: '/'
    },
    {
        name: 'nav',
        app: () => import('nav'),
        activeWhen: '/',
    },
    {
        name: 'app1',
        app: () => import('app1'),
        activeWhen: '/app1',
    },
    {
        name: 'app2',
        app: () => import('app2'),
        activeWhen: '/app2',
    },
    {
        name: 'app3',
        app: () => import('app3'),
        activeWhen: '/app3',
    },
    {
        name: 'footer',
        app: () => import('footer'),
        activeWhen: '/',
    }
]
mfeList.map((mfe: any) => registerApplication({
    ...mfe,
    customProps: {
        publish,
        subscribe,
        comms,
        config
    }
}));

start();

This works without warning. However, moving this over into spa-single-layout causes the warning that single-spa has been loaded twice on the page, and this causes single-spa-inspector to stop working:

export const mfeLayout = `
<single-spa-router mode="history" base="/" containerEl="#main-router">
    <nav class="topnav">
        <application name="nav" props="publish,subscribe,comms,config"></application>
    </nav>
    <div class="main-content">
        <route path="/app1">
            <application name="app1" props="publish,subscribe,comms,config"></application>
        </route>
        <route path="/app2">
            <application name="app2" props="publish,subscribe,comms,config"></application>
        </route>
        <route path="/app3">
            <application name="app3" props="publish,subscribe,comms,config"></application>
        </route>
        <route default>
            <h1>404 Not Found</h1>
        </route>
    </div>
    <footer>
        <application name="footer" props="publish,subscribe,comms,config"></application>
    </footer>
</single-spa-router>
`;
// Layout MFEs.
const routes = constructRoutes(mfeLayout, { props: appInfrastructure });
const applications = constructApplications({
    routes,
    loadApp({ name }) {
        return import(name)
    },
});
const layoutEngine = constructLayoutEngine({ routes, applications });
applications.forEach(registerApplication);

start();

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