Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
barryspearce opened this issue Nov 7, 2023 · 0 comments
Open

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

barryspearce opened this issue Nov 7, 2023 · 0 comments

Comments

@barryspearce
Copy link

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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant