Single-spa - Registering application

I'm fairly new with Javascript/Typescript and was developing a Single-Spa with Single SPA RouterSearching for info about registering applications I found different ways of doing that, one way is using the LayoutEngine that "automatically" register my applications this way:

const routes = constructRoutes(microfrontendLayout);
const applications = constructApplications({routes, loadApp({name}) { return System.import(name);
}});
const layoutEngine = constructLayoutEngine({ routes, applications });
applications.forEach(registerApplication);
layoutEngine.activate();

From what I understood is, in microfrontend-layout.html we have to put something like an HTML tag in this way

<application name="@prueba-organizacion/micro-prueba-app1"></application>

with that and having an importmap in index.ejs the app was loading fine.

But then I found another way, the manually way:

A)

import { registerApplication, start } from "single-spa";
registerApplication({ name: '@prueba-organizacion/micro-prueba-app1', app: () => System.import('@prueba-organizacion/micro-prueba-app1'), activeWhen: (location) => location.pathname.startsWith('/app1')
});
start();

But that says: Promise\<System.Module\> is not assignable to type Application\<{}\>

Then I found ANOTHER WAY of doing the same as above:

B)

System.import('single-spa').then(({ registerApplication, start }) => { registerApplication({ name: '@prueba-organizacion/micro-prueba-app1', app: () => System.import('@prueba-organizacion/micro-prueba-app1'), activeWhen: (location) => location.pathname.startsWith('/app1'), }); start();
});

The thing here is, what's the difference between point A) and point B)? I mean, they're importing the modules and registerApplication, start functions but one of them is throwing me an error.

I'm using "single-spa": "^5.9.3" from package.json

Thanks!

I've tried both ways, one of them is not working, the other one is working (B) as expected

Related questions 0 How to query this in Activerecord 3 ActiveRecord subquery in select clause 1 ActiveRecord Subquery Comparison as a Scope Related questions 0 How to query this in Activerecord 3 ActiveRecord subquery in select clause 1 ActiveRecord Subquery Comparison as a Scope 0 using a subquery in rails 16 Rails Activerecord Relation: using subquery as a table for a SQL select statement 0 Query to compare values across different tables? 0 ActiveRecord - Compare two values in same row 3 Rails, ActiveRecord and SubQueries 0 How to create Rails query that (I think) requires PostgreSQL subquery? 0 How to use ActiveRecord for a sql query with subquery in FROM clause Load 7 more related questions Show fewer related questions Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like