@bondi-js/utils
TypeScript icon, indicating that this package has built-in type declarations

0.0.30 • Public • Published
  • @bondi-js/utils

    A set of utilities that makes loading libs and React components as federated modules easier!

    Installation

    npm i @bondi-js/utils

    or

    yarn add @bondi-js/utils

    Usage

    createDynamicComponent

    This function provides a way to load a React Component as a federated module.

    import React from "react";
    import { Spinner } from "@chakra-ui/react"
    import { createDynamicComponent } from "@bondi-js/utils";
    
    const Layout = createDynamicComponent({
      url: "https://dreamy-wescoff-2993eb.netlify.app/crypto-layout.js",
      module: "crypto_app_layout",
      scope: "default_namespace",
      placeholder: <Spinner />
    });
    
    const App = () => {
      return (
        <Layout>
          {/* your content here*/}
        </Layout>
      );
    };
    
    export default App;

    importModule

    This function is very similar to the dynamic import (import("./foo.js")), makes a dynamic import for the federated module and returns a promise

    import { importModule } from '@bondi-js/utils';
    
    async function main() {
      const module = await importModule({
        url: "https://test/module.js",
      	module: "module_name",
        scope: "default_namespace",
      })
      
      module.method()
    }

    Contact

    If you need help or have any question, feel free to contact us or open an issue!

Readme

Keywords

none

Package Sidebar

Install

npm i @bondi-js/utils

Weekly Downloads

150

Version

0.0.30

License

MIT

Unpacked Size

71.4 kB

Total Files

58

Last publish

Collaborators

  • leonelv