GithubHelp home page GithubHelp logo

native-federation-core-microfrontend's Introduction

Native Federation Core Example

Screenshot

This example demonstrate how to use Native Federation in a framework- and tooling-agnostic way. For this, Native Federation Core -- @softarc/native-federation -- is used.

Hint: There is also an Angular-based wrapper.

Try it out

npm i
npm run build
npm start

This simple example does not implement a watch-mode for development.

Inspect the Example

  • Have a look at the project structure: It contains a shell (host), a micro frontend mfe1 (remote), and a shared lib used for exchanging data between the shell and the shell and mfe1.

  • Have a look at the build process in the file build/build-common.ts. It's a simple esbuild-based process augmented by Native Federation.

  • The build process uses an adapter to bring in the build tool of your choice.

  • Have a look at the file federation.config.js in the shell. It configures Native Federation. The shareAll-helper shares all the libs found in your package.json in the node dependencies.

  • The Micro Frontend's federation.config.js also exposes a component. This component can be loaded into the shell.

  • The entry point into the shell is the file main.ts. It initializes Native Federation and passes key data about the remotes. Then, it loads the application via an dynamic import.

  • The entry point into mfe2 is called main.ts too. It's similar to the one used by the shell. However, it doesn't point to further Micro Frontends.

  • The shell's app.ts uses the function loadRemoteModule to load the separately compiled and deployed Micro Frontend at runtime.

  • Both applications use rxjs. However, it's only loaded once because of using shareAll in the federation config. To assure yourself of this, just have a look to your browser's network tab.

  • For the same reason, the shared-lib (libs/shared-lib) is only loaded once and can be used as a mediator for exchaning data between the shell and mfe1.

native-federation-core-microfrontend's People

Contributors

manfredsteyer avatar

Stargazers

Cavid Hacıyev avatar  avatar Walter Augustine avatar XO GILKO avatar Ted Lindholm avatar Sergei Koshel avatar Roy Ling avatar AlexStorm avatar  avatar Aaron Hardy avatar Constantin Câmpean avatar Austin Knight avatar Olavo Amorim Santos avatar HG avatar Alan Schio avatar Peter van Meijgaard avatar Brady Whitten avatar Nick Balestra-Foster avatar KyrieChen avatar Arun George avatar Ryan avatar Douglas Zaltron avatar  LAKSHMAN S avatar XIAO MING avatar Pedro Pereira avatar Michael Jeries avatar Alexey avatar Duc-Thien Bui avatar Alexander Khoroshikh avatar Igor Kamyşev avatar Jesse Nguyen avatar Isidro Moreno avatar  avatar Enrico Secondulfo avatar Brais Antela avatar Eduardo Gracez Dusik avatar danielsdesk avatar  avatar Oleg Lustenko avatar

Watchers

James Cloos avatar Michał Kotas avatar  avatar  avatar  LAKSHMAN S avatar Eduardo Gracez Dusik avatar Pavel Rotanov avatar

native-federation-core-microfrontend's Issues

Dynamic require of "@softarc/native-federation-runtime" is not supported

chunk-EFBCFLQ4.js:12 Uncaught Error: Dynamic require of "@softarc/native-federation-runtime" is not supported
    at chunk-EFBCFLQ4.js:12:9
    at node_modules/@softarc/native-federation/src/index.js (main.js:373:26)
    at __require2 (chunk-EFBCFLQ4.js:18:50)
    at mfe1/main.ts (main.js:380:44)
    at __require2 (chunk-EFBCFLQ4.js:18:50)
    at main.js:387:16

run demo with problem

node v16.14.0
npm 8.3.1


Shell:
Have a look into your JavaScript console ...

Microfrontend 1
Have a look into your JavaScript console ...


but there has not anything in the console

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.