single-spa.js.org | repo contains the source code | Single Page Application library
kandi X-RAY | single-spa.js.org Summary
kandi X-RAY | single-spa.js.org Summary
This repo contains the source code and documentation powering single-spa.js.org.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of single-spa.js.org
single-spa.js.org Key Features
single-spa.js.org Examples and Code Snippets
Community Discussions
Trending Discussions on single-spa.js.org
QUESTION
I work with microfrontend single-spa (https://single-spa.js.org/) I create a store
...ANSWER
Answered 2022-Feb-07 at 12:12According to the docs, store
should be a subproperty of appOptions
:
QUESTION
The question:
How (is it possible) to configure webpack (with single-spa), to take make some packages (projects) under a scope (@orginazation) externals and other internals (not external) ?
Project information:
We are building a single-spa application using webpack an uses Github npm registrer (and github actions). All the micro front-ends are projects in Github, and some of them are util/helper/provider projects, that is compiled as externals with webpack.
But some of them are meant to be compiled with the micro-frontend (must not be external)
It seems that when webpack sees one of the project under the organization scope as external, it set all package under that scope to external!
As we can see from the log the "CompilingTool" will also be compiled as external, event thought it should not.
The packages are set in the files as:
...ANSWER
Answered 2021-Aug-05 at 15:14This is possible by passing in orgPackagesAsExternal: false
to the single-spa webpack config, in your case named singleSpaDefaults
. Per the create-single-spa documentation,
This changes whether package names that start with @your-org-name are treated as webpack externals or not. Defaults to true.
You will then need to either:
- Enumerate which packages to mark as external
- Provide a function that does this (which you've noted in your question)
and then merge that with single-spa's config as usual. Because this can become verbose and annoying to do for every microfrontend, consider doing this in a base config that you publish that is specific for your company and which each mfe will then need to consume.
QUESTION
I have 3 TypeScript projects below:
- root-config
- parcel, let us call it
my-app
- in-browser utility module, let us call it
api
All the projects above were generated using the create-single-spa
command.
In the api/src/lomse-api.ts
file, I'm exporting the fetchPeople
module as shown below:
ANSWER
Answered 2021-Feb-28 at 00:03That error is a TypeScript error, not a JavaScript or single-spa error. Here are options for what you need to do:
- Publish your utility module to a registry (types are optional since TS can infer from the source, though types are better). Then install it into each other microfrontend's node_modules. Since it's a webpack external, the version in node_modules will only be used for typescript compilation but not for execution in the browser.
- You could publish only the types, whether as an individual package or together with other microfrontend's typings.
- Mock the utility module's types, as described here.
Source:
QUESTION
I've created a few apps that follow the same pattern as the react-microfrontend projects listed on the Single-spa examples page. However, these examples are not using TypeScript.
I am receiving a TS error when App2 tries to import a function that exists in App1, because App2 is unable to find the typings for the App1 object. And this makes sense to me, since the importmap.json
that is referenced in the index.html
file of the root-config project only has a URL listed for the .js file of each microfrontend. I really don't want to add @ts-ignore statements everywhere, and I also don't want to do cross-app communication without being type safe.
An example of what I'm referring to:
This file in the Planets app references the Button component from the Styleguide app. I am unable to build this unless I place a @ts-ignore on the line before the import statement, because my Planets app cannot find the type declarations for Styleguide.
I am very new to import maps and SystemJS in general, so if anyone could point me in the right direction, I'd appreciate it. I've actually gone through the trouble of building my Styleguide as a regular npm library and just including it as a dependency in the Planets package.json file... which kind of defeats the whole purpose of using Single-spa in the first place.
importmap.json
...ANSWER
Answered 2020-Oct-30 at 17:45Unfortunately no, they cannot be shared via the import map because that operates in the browser, and browsers do not understand TypeScript syntax.
Your alternatives are:
- Publish your module's types to an npm registry and
npm install
it into each dependent microfrontend- One caveat here: you will need to update this with every new publish of the shared module, but that can be automated with various tools such as renovate
- Mock the utility module's types
More info can be found at this Github issue: https://github.com/single-spa/single-spa/issues/609#issuecomment-665132965
QUESTION
I am creating micro frontend angular application using single spa.How can i load i18n files from assets folder.
I have followed the instructions from : https://single-spa.js.org/docs/ecosystem-angular/
Angular Version : 9.1.12
Single spa : 4
single spa angular: 4.4.2
Do we need to add some additional configuration in webpack so that it loads the i18n files from assets folder ?
...ANSWER
Answered 2020-Sep-28 at 04:58When you install single-spa library to your application, single-spa/assets-url.ts is generated. You need to import asset-url.ts in your component and pass the path of i18n file in assetUrl method so that it will be available when you run the application.
QUESTION
I need a help to communicate from my container single-spa to loaded angular app ( child ). when user click on parent app ( spa-container ) option, that should communicated to child application to change the mode.
it will not happen very frequently. But not able to find a way to communicate from container to loaded angular application.
there is a detail given by spa itself : spa-communication detail but not clear and there is no detailed steps. any one help me?
...ANSWER
Answered 2020-Apr-07 at 15:59I'm one of the maintainers of single-spa.
We tend to be light on our opinions in the documentation about how to implement communication between modules because there are a lot of ways to implement it and each comes with pros/cons. In the situation you described it sounds like you might want to explore option #3 from the link you posted.
Custom Browser eventsIn the parent you're fire custom events on the window. API on MDN.
Quick exampleCommunity Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install single-spa.js.org
cd single-spa.js.org/website to go into the website root
yarn to install the website's npm dependencies
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page