<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bit</title>
    <description>The latest articles on DEV Community by Bit (@bitdev_).</description>
    <link>https://dev.to/bitdev_</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F7970%2F08983fbd-24dc-4e12-89d1-ef3a385c6d3c.png</url>
      <title>DEV Community: Bit</title>
      <link>https://dev.to/bitdev_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bitdev_"/>
    <language>en</language>
    <item>
      <title>Sharing UI Components: Copy VS Install</title>
      <dc:creator>Eden Ella</dc:creator>
      <pubDate>Tue, 29 Oct 2024 19:27:28 +0000</pubDate>
      <link>https://dev.to/bitdev_/sharing-ui-components-copy-vs-install-4mii</link>
      <guid>https://dev.to/bitdev_/sharing-ui-components-copy-vs-install-4mii</guid>
      <description>&lt;p&gt;In recent years, there's been a noticeable shift in how developers approach UI libraries, moving away from installing entire component libraries via npm packages and toward directly copy-pasting the code into their codebase.&lt;/p&gt;

&lt;p&gt;This trend has been largely popularized by Shadcn/UI, a library that provides developers with ready-made, customizable components that can be copied directly into a project for maximum flexibility. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A4800%2Fformat%3Awebp%2F1%2AAmUFnKUOlivBX77K2fF-uQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A4800%2Fformat%3Awebp%2F1%2AAmUFnKUOlivBX77K2fF-uQ.png" width="800" height="549"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;shadcn/ui voted as the most popular design system accroding to The &lt;a href="https://tsh.io/state-of-frontend/" rel="noopener noreferrer"&gt;Software House&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Copying Wins for Complex Components
&lt;/h2&gt;

&lt;p&gt;The copy-paste approach shines, particularly for complex UI elements such as authentication pages, detailed dashboards, or intricate data visualizations. These components require fine-tuned customization that’s difficult to achieve through immutable npm packages.&lt;/p&gt;

&lt;p&gt;Instead of overwhelming the library’s API with endless configuration options, this approach allows developers to leverage the &lt;strong&gt;composable and declarative&lt;/strong&gt; nature of modern frontend frameworks, enabling greater control over every part of the component.&lt;/p&gt;

&lt;p&gt;Instead of long and complex CSS selectors, you can directly apply styles to elements in a component. Instead of injecting components using a complex dependency injection logic, you simply place or rearrange components however you choose.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A4800%2Fformat%3Awebp%2F1%2Aj8m7avYNH0Xnpi7IVsdQdg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A4800%2Fformat%3Awebp%2F1%2Aj8m7avYNH0Xnpi7IVsdQdg.png" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;An interactive shadcnui chart on &lt;a href="https://bit.cloud" rel="noopener noreferrer"&gt;Bit Platform&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This approach has gained even greater significance with the introduction of AI coding assistants. Instead of generating components from scratch through AI with long, complex prompts — or engaging in a lengthy conversation with the assistant — you can begin with a pre-built composition close to what you need.&lt;/p&gt;

&lt;p&gt;By embedding the code into your project, you give the AI assistant a specific, tangible context. From there, you can ask it to make incremental adjustments, such as tweaking styles, adding accessibility features, or changing the layout.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bit Components: Packages that you can directly edit
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://bit.dev" rel="noopener noreferrer"&gt;Bit&lt;/a&gt; has introduced a new entity to the world of web development: The &lt;a href="https://bit.cloud/products/components" rel="noopener noreferrer"&gt;Bit Component&lt;/a&gt;. In short, a Bit component can be thought of as a super-package. You can share it, install it, copy it, and even collaborate on it independently of any particular project setup.&lt;/p&gt;

&lt;p&gt;For simplicity, we can divide UI components into two groups: design system components and block components. In the design system, basic components like &lt;code&gt;Card&lt;/code&gt; are fundamental building blocks. Meanwhile, block components, such as a &lt;code&gt;MediaCard&lt;/code&gt;, are composed of design system elements but offer more advanced functionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Choice 1: Composing with Design System Components
&lt;/h3&gt;

&lt;p&gt;When creating a new component, the first option is to compose from your design system. For instance, to build a custom card, you may need to combine components like Card, Button, and Typography.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AB_mLWCtU0Xk7dTK7G5dm0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AB_mLWCtU0Xk7dTK7G5dm0g.png" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://bit.cloud/bitdesign/material-ui" rel="noopener noreferrer"&gt;MUI-based components shared on the Bit Platform&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These components can be installed in your project through npm, pnpm, yarn, or &lt;a href="https://bit.dev/reference/dependencies/dependency-installation/" rel="noopener noreferrer"&gt;Bit’s installation&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i @bitdesign/material-ui.surfaces.card bitdesign.material-ui/inputs/button @bitdesign/material-ui.data-display.typography
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Choice 2: Utilizing Block Components
&lt;/h2&gt;

&lt;p&gt;When opting for a pre-built block component, you have several flexible choices beyond simple installation.&lt;/p&gt;

&lt;p&gt;The easiest route is to install the component package directly and use its API. This approach works well if the component fits your needs out of the box or requires only minor tweaks.&lt;/p&gt;

&lt;p&gt;For scenarios where you need to make extensive changes, Bit’s fork command allows you to copy the component’s full code into your project. This includes source files, dependencies, and configurations (including the component’s dev tools).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A2000%2Fformat%3Awebp%2F1%2AsDryXyXB0ewvY7WalDzsWg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A2000%2Fformat%3Awebp%2F1%2AsDryXyXB0ewvY7WalDzsWg.png" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://bit.cloud/learnbit-react/material-ui-blocks/content/media-card" rel="noopener noreferrer"&gt;https://bit.cloud/learnbit-react/material-ui-blocks/content/media-card&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For example, to copy the &lt;code&gt;MediaCard&lt;/code&gt; component and its configuration, we’ll run bit fork and pass its component ID (not package name) as an argument:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bit fork learnbit-react.material-ui-blocks/content/media-card
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A2000%2Fformat%3Awebp%2F1%2AdXdTZsnou1o21iLUjbKcsg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A2000%2Fformat%3Awebp%2F1%2AdXdTZsnou1o21iLUjbKcsg.png" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s worth noting that Bit also provides the &lt;code&gt;bit import&lt;/code&gt; command, which allows you to create changes to the component and release a new version. This option requires that you have the proper permissions to modify the component (unlike the &lt;code&gt;bit fork&lt;/code&gt; command, which does not affect the original component).&lt;/p&gt;
&lt;h4&gt;
  
  
  Ejecting dependencies’ source files
&lt;/h4&gt;

&lt;p&gt;When forking components with dependencies, Bit auto-installs them for convenience. However, if you need direct access to the source code of a dependency, you can also fork those dependencies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2ACyWqHIGUPsfOnxqsOjFrhA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2ACyWqHIGUPsfOnxqsOjFrhA.png" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For instance, if you want to copy the Button component, you can fork it as well from your team’s collection on Bit Platform:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bit fork bitdesign.material-ui/inputs/button
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2A3d39bRMv1MOqG4K3Oy_mrg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2A3d39bRMv1MOqG4K3Oy_mrg.png" width="800" height="513"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Related Articles
&lt;/h2&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://blog.bitsrc.io/top-9-react-component-libraries-for-2025-a11139b3ed2e" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1200%2F1%2APah_qw69716aB1fbMZvnFg.jpeg" height="480" class="m-0" width="800"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://blog.bitsrc.io/top-9-react-component-libraries-for-2025-a11139b3ed2e" rel="noopener noreferrer" class="c-link"&gt;
          Top 9 React Component Libraries for 2025 | by Eden Ella | Nov, 2024 | Bits and Pieces
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Jumpstart your next React project with developer-friendly and user-friendly UI libraries: aesthetic, performance-optimized, and…
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afill%3A256%3A256%2F1%2A72WvVp4NqCU_4bfE6wCBEQ.png" width="128" height="128"&gt;
        blog.bitsrc.io
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Monorepo VS Polyrepo</title>
      <dc:creator>Eden Ella</dc:creator>
      <pubDate>Wed, 31 Jul 2024 10:25:48 +0000</pubDate>
      <link>https://dev.to/bitdev_/monorepo-vs-polyrepo-j9</link>
      <guid>https://dev.to/bitdev_/monorepo-vs-polyrepo-j9</guid>
      <description>&lt;p&gt;The question of whether to maintain your codebase as monorepo or polyrepo has become even more puzzling with the rise in popularity of micro-architecture patterns like microservices, micro frontends, and micro apps.&lt;/p&gt;

&lt;p&gt;On the one hand, monorepos are great for cross-project code sharing, dependency management, and consistency across the codebase. On the other hand, polyrepos offer more flexibility in managing projects, dependencies, and releases, and give teams the autonomy they need to work independently.&lt;/p&gt;

&lt;p&gt;In a way, polyrepos are the more "natural" approach for micro-architecture designs as they allow us to enjoy the benefits of small, simple and autonomous projects without the complexity of a monorepo. Unfortunately, polyrepos come with their own set of challenges, especially when it comes to managing dependencies and ensuring consistency across the codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  A solution that combines the best of both worlds
&lt;/h2&gt;

&lt;p&gt;There's a clear need for a solution that combines the best of both worlds: the simplicity and autonomy of polyrepos with the code sharing and consistency of monorepos. This is where &lt;a href="https://bit.cloud" rel="noopener noreferrer"&gt;Bit&lt;/a&gt; comes in. Bit allows you to manage each component of your codebase as a standalone entity, called a "Bit component."&lt;/p&gt;

&lt;p&gt;Bit can be integrated into existing monorepos or polyrepos, or it can be used to manage your codebase in a completely decentralized way, without the need for a repository.&lt;/p&gt;

&lt;p&gt;The first approach transforms your repository into a fine-grained monorepo, or a composable repository/codebase. The second approach no longer requires a repository at all, as Bit components can be modified, built, versioned, and shared, independently, not coupled to any repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ia5u3q0guna1vsysea2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ia5u3q0guna1vsysea2.png" alt="From monorepo to composable and finally to completely decentralized"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://static.bit.dev/Community/blogs/polyrepo-vs-monorepo/js%20monorepos.jpg" rel="noopener noreferrer"&gt;&lt;strong&gt;Click here for a high-resolution diagram&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Composable codebase: maximizing code reuse and simplifying project maintenance
&lt;/h2&gt;

&lt;p&gt;To understand how a composable codebase works, let's first look at how projects are structured in a monorepo. Monorepos typically host two types of projects: libraries and apps (with 'services' included). Libraries are reusable pieces of code that are shared across multiple apps, while apps are standalone projects that use these libraries (and other dependencies).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F934dhatv1dpg4cez45vn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F934dhatv1dpg4cez45vn.png" alt="No distinction between libs and apps in composable design"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A composable codebase, on the other hand, consists only of Bit components. A Bit component is both a library and, possibly, an app (i.e, a deployable component). Unlike the common structure of a monorepo, a repository consisting of Bit components will have a simple, "flat" structure that is similar to any other composable design.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Standard Applications/Services&lt;/th&gt;
&lt;th&gt;NodeJS Libraries&lt;/th&gt;
&lt;th&gt;Bit Components&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Published to NodeJS Registries&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;No.&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Yes.&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Yes.&lt;/strong&gt; Bit components are published to Bit Platform and possibly other registries like the NPM registry. This includes deployable components or “app components”. Bit components can be installed as standard NodeJS packages.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deployable&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Yes.&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;No.&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Yes.&lt;/strong&gt; While all Bit components are published to NodeJS registries, some can also be configured to be deployed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Source-of-Truth&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Project-level VCS and VCS platforms&lt;/strong&gt; like Git and Github.&lt;/td&gt;
&lt;td&gt;Project-level VCS and VCS platforms.&lt;/td&gt;
&lt;td&gt;Either &lt;strong&gt;“Bit scopes” and platforms&lt;/strong&gt; like Bit Platform or &lt;strong&gt;project-level VCS and VCS platforms.&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Component-Specific Development Setup and Dependencies&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;No.&lt;/strong&gt; Development tools and config, as well as dependencies, are configured on the entire repository or a sub-directory of it.&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;No.&lt;/strong&gt; Development tools and config, as well as dependencies, are configured on the entire repository or a sub-directory of it.&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Yes.&lt;/strong&gt; Each Bit component can have its own development setup and dependencies, completely independent of its current repository or its location inside the repository. Development environments/setups are maintained as Bit components and reused by other Bit components, across projects.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each Bit component has its source files in its own directory and a single file to serve as its entry point or "main" file. Each Bit component consumes other Bit components via their symlink/installed instance in the &lt;code&gt;node_modules&lt;/code&gt; directory. For example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

# An example of a composable repo

button/
    index.ts
    button.ts
my-app/
    my-app.ts
    my-app.bit-app.ts (defines 'my-app' as a deployable app component)
    index.ts
node_modules/
    @my-scope/button/
      index.js -&amp;gt; (symlink for type support and IntelliSense)
      button.js -&amp;gt; (symlink) ../../button/button.ts
      dist/
        index.js (compiled)
        button.js (compiled)
    @my-scope/my-app/
      index.js -&amp;gt; (symlink) ../../my-app/dist/index.ts
      my-app.js -&amp;gt; (symlink) ../../my-app/my-app.ts
      dist/
        index.js (compiled)
        my-app.js (compiled)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;There is no structural distinction between libraries and apps in a composable codebase. Each Bit component can be consumed by other Bit components and can consume other Bit components, regardless of their type.&lt;/p&gt;

&lt;p&gt;This greatly simplifies your project maintenance and management. You can easily understand the relationship between components, manage dependencies, and ensure consistency across the codebase.&lt;/p&gt;

&lt;p&gt;Furthermore, every piece of functionality in your codebase (not just utility functions and basic UI elements) is a standalone entity that can be shared, versioned, and updated independently. And the best thing is that it doesn't require additional overhead or complexity. Your code is just "naturally" shareable, reusable, and even portable.&lt;/p&gt;

&lt;p&gt;Common issues and challenges for code sharing and reusing are no longer a concern, as Bit takes care of it all, including: dependencies, documentation, build, test, versioning, and even CI/CD.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decentralized codebase: improving team autonomy and codebase flexibility
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8dlofz9qbclrimfcig17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8dlofz9qbclrimfcig17.png" alt="Collaboration when Bit scopes serve as the source-of-truth for components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A decentralized codebase is one that is not managed in a single repository but is distributed across multiple repositories or even none at all. As mentioned in the table above, when working with Bit components, you decide their source of truth. It can be a project-level repository hosted on a platform like GitHub, GitLab, or Bitbucket, or individual components hosted on the Bit platform.&lt;/p&gt;

&lt;p&gt;Depending on your team’s workflow structure, you can choose the source of truth: either the Bit scopes where components are hosted or the project repositories where they are maintained. Choosing the Bit scopes as the source of truth allows you to manage your codebase with fine-grained access-control and build setup, over each component and unparalleled flexibility in managing your codebase.&lt;/p&gt;

&lt;p&gt;Repositories can be created and destroyed, components can be moved around, and you can decide where they should be maintained based on your team's or ogranization's workflow and the project's requirements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6cc1b8cy3cwr0d5rxs8b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6cc1b8cy3cwr0d5rxs8b.png" alt="In a completely decentralized codebase, repositories are used as a disposable tool"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>monorepo</category>
    </item>
    <item>
      <title>Designing Your Codebase for Optimized AI-Driven Development</title>
      <dc:creator>Eden Ella</dc:creator>
      <pubDate>Tue, 23 Jul 2024 12:46:17 +0000</pubDate>
      <link>https://dev.to/bitdev_/designing-your-codebase-for-optimized-ai-driven-development-43l5</link>
      <guid>https://dev.to/bitdev_/designing-your-codebase-for-optimized-ai-driven-development-43l5</guid>
      <description>&lt;p&gt;AI-driven software development leverages artificial intelligence to automate various stages of the software development lifecycle, such as automating code reviews and generating code. This enables developers to deliver software more quickly and efficiently.&lt;/p&gt;

&lt;p&gt;While AI-driven software development offers many benefits, including faster code writing and improved code quality, it also has its drawbacks. It can introduce inconsistencies in development standards and practices, leading to code that is difficult to read, maintain, and debug.&lt;/p&gt;

&lt;p&gt;If left unchecked, these inconsistencies can degrade software quality and negatively impact the user experience. To address these risks, developers limit the use of AI and ensure it operates under human supervision.&lt;/p&gt;

&lt;p&gt;To further ensure quality, developers use additional tools and practices like fine-tuning large language models (LLMs) to a specific codebase and employing utility-based AI agents. These measures help ensure that AI-generated code aligns with the existing codebase and meets quality standards.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1200%2Fformat%3Awebp%2F1%2ATUkhmCiWq9iwIjG4xtn6Mg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1200%2Fformat%3Awebp%2F1%2ATUkhmCiWq9iwIjG4xtn6Mg.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recently, &lt;a href="https://bit.cloud" rel="noopener noreferrer"&gt;Bit Platform&lt;/a&gt; launched an AI assistant named “&lt;a href="https://bit.cloud" rel="noopener noreferrer"&gt;Hope AI&lt;/a&gt;.” This assistant helps developers generate new Bit components, edit existing ones, test and document components, and create change requests (similar to pull requests in Bit). This facilitates more effective collaboration among developers and helps them understand the impacts of their changes on the overall codebase.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/zJdhc4RqUMA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Hope AI enhances your codebase's organization, efficiency, and consistency by reusing existing components. This reduces the risk of inconsistencies and prevents the code from becoming bloated and difficult to manage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AEfAU4hBCb9lFkCDdcAtJvA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AEfAU4hBCb9lFkCDdcAtJvA.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A decentralized codebase consisting of small, reusable components with clear interfaces, dependencies, and responsibilities provides an ideal platform for effective collaboration among humans and between humans and AI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2Ao6G3eU_sb3pYsRp5-3NnKg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2Ao6G3eU_sb3pYsRp5-3NnKg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Like human developers, AI agents perform better when working with smaller, more focused components. Breaking tasks into smaller, manageable parts makes them easier to formulate and understand. The results are more accurate and reliable when tasks are executed modularly and incrementally, using existing components as building blocks whenever possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn More
&lt;/h2&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://bit.cloud/" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fstatic.bit.dev%2Fdesign-graphics%2Fsocial-assets%2Fbit-marketing-og-img-facebook-min.jpg" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://bit.cloud/" rel="noopener noreferrer" class="c-link"&gt;
          Bit. Composable software platform.
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          A complete development platform for innovative teams, building composable software products.
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbit.cloud%2Ffavicon.ico"&gt;
        bit.cloud
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://blog.bitsrc.io/building-composable-javascript-software-with-bit-components-2f75f991edc6" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1200%2F1%2A29Utd3MjXjb1SvxPPS3XFA.jpeg" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://blog.bitsrc.io/building-composable-javascript-software-with-bit-components-2f75f991edc6" rel="noopener noreferrer" class="c-link"&gt;
          Building Composable JavaScript Software: Tips and Tricks | by Eden Ella | Bits and Pieces
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          How to create composable systems using standardized, independent, and well-documented components of different granularity levels
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afill%3A256%3A256%2F1%2A72WvVp4NqCU_4bfE6wCBEQ.png"&gt;
        blog.bitsrc.io
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://blog.bitsrc.io/3-principles-for-component-driven-development-705706165208" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1200%2F1%2AVtqoMUDx2-byoJ5NXBYKWA.jpeg" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://blog.bitsrc.io/3-principles-for-component-driven-development-705706165208" rel="noopener noreferrer" class="c-link"&gt;
          3 Principles for Component-Driven Development, Modular Design and Modular Architecture | by Eden Ella | Medium | Bits and Pieces
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Principles and methodologies of software composition using independent Bit components.
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afill%3A256%3A256%2F1%2A72WvVp4NqCU_4bfE6wCBEQ.png"&gt;
        blog.bitsrc.io
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>ai</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Module Federation: Building a Micro Frontends Solution in 2024</title>
      <dc:creator>Eden Ella</dc:creator>
      <pubDate>Wed, 03 Jul 2024 19:01:10 +0000</pubDate>
      <link>https://dev.to/bitdev_/module-federation-building-a-micro-frontends-solution-in-2024-1jm0</link>
      <guid>https://dev.to/bitdev_/module-federation-building-a-micro-frontends-solution-in-2024-1jm0</guid>
      <description>&lt;p&gt;In this blog, we’ll use &lt;a href="https://module-federation.io/" rel="noopener noreferrer"&gt;Module Federation&lt;/a&gt; and &lt;a href="https://bit.cloud" rel="noopener noreferrer"&gt;Bit&lt;/a&gt; to implement a runtime integration of Micro Frontends. &lt;/p&gt;

&lt;p&gt;We'll cover the following topics:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using Bit’s templates to generate host applications and remote modules&lt;/li&gt;
&lt;li&gt;Managing ModFed shared dependencies as a Bit component&lt;/li&gt;
&lt;li&gt;Creating a “plugin system” via &lt;a href="https://bit.cloud/bit-bazaar/shell-app/types/navigation/~api-reference" rel="noopener noreferrer"&gt;shared types&lt;/a&gt; that allows remote modules to integrate into the host application in various ways&lt;/li&gt;
&lt;li&gt;Running remote modules in development within the context of their host application&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AIhWUeHzGmF-peQNZccFn_A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AIhWUeHzGmF-peQNZccFn_A.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://bit-bazaar.netlify.app/" rel="noopener noreferrer"&gt;The deployed solution&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AYcwnsOHOAQ6aufcGQWEnCw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AYcwnsOHOAQ6aufcGQWEnCw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://bit.cloud/bit-bazaar/~scopes" rel="noopener noreferrer"&gt;The Bit org that maintains the MFEs solution&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2A6nlxFEHjxyt3He3DICxWJQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2A6nlxFEHjxyt3He3DICxWJQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://github.com/orgs/bit-bazaar/repositories" rel="noopener noreferrer"&gt;The repos maintaining the Bit workspaces for the shared components, host app, and remote modules&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h2&gt;
  
  
  Host Apps and Remote Modules
&lt;/h2&gt;

&lt;p&gt;The host app and remote modules were generated using pre-configured templates (made available by Bit):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx @teambit/bvm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="c"&gt;# install Bit&lt;/span&gt;
bit init my-modfed-solution &lt;span class="c"&gt;# create a new Bit workspace&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;my-modfed-solution
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following to your &lt;code&gt;workspace.jsonc&lt;/code&gt; to make the ModFed templates available in your workspace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"teambit.generator/generator"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"envs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"frontend.module-federation/envs/mf-react-env"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bit &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="c"&gt;# install the workspace dependnecies&lt;/span&gt;
bit create modfed-remote-mfe storefront &lt;span class="c"&gt;# generate a remote module&lt;/span&gt;
bit create modfded-remote-mfe blog
bit create modfed-host-app shell-app &lt;span class="c"&gt;# generate a host app&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Run &lt;code&gt;bit templates&lt;/code&gt; to list the available ModFed templates&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To list the available apps (and remote modules), run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bit app list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output lists the component IDs and their corresponding app names:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────┬─────────────────────┐
│ id                                              │ name                │
├─────────────────────────────────────────────────┼─────────────────────┤
│ bit-bazaar.storefront/storefront                │ storefront          │
├─────────────────────────────────────────────────┼─────────────────────┤
│ bit-bazaar.blog/blog                            │ blog                │
├─────────────────────────────────────────────────┼─────────────────────┤
│ bit-bazaar.shell-app/shell-app                  │ shell-app           │
└─────────────────────────────────────────────────┴─────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run the apps locally by using their app name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bit run storefront
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Shared Dependencies
&lt;/h2&gt;

&lt;p&gt;Our solution consists of many shared dependencies configured to be excluded from the app bundles and loaded as separate chunks. This is one of ModFed’s strengths. It allows us to optimize our bundle size, maintain consistency, and avoid conflicts between versions of the same module.&lt;/p&gt;

&lt;p&gt;Our shared dependencies are maintained as a Bit component shared across projects (the host app and the remote modules). This allows teams to maintain consistency while working independently.&lt;/p&gt;

&lt;p&gt;The list of shared dependencies consists primarily of runtime libs and a design system:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2ASDBgYqyMyiTVR3MmXrCVtw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2ASDBgYqyMyiTVR3MmXrCVtw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://bit.cloud/bit-bazaar/shell-app/shared-dependencies/~code/shared-dependencies.ts" rel="noopener noreferrer"&gt;The ‘shared dependencies’ component&lt;/a&gt; (which lists the shred deps) is used by the host app config and remote modules config&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AowibIMnKJ0s749r8DEwWvw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AowibIMnKJ0s749r8DEwWvw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://bit.cloud/bit-bazaar/shell-app/shared-dependencies/~code/shared-dependencies.ts" rel="noopener noreferrer"&gt;https://bit.cloud/bit-bazaar/shell-app/shared-dependencies/~code/shared-dependencies.ts&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * @filename: storefront.bit-app.ts
 * @component-id: bit-bazaar.storefront/storefront
*/&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;MfReact&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@frontend/module-federation.react.apps-types.mf-rspack&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cm"&gt;/* import the 'shared dependnecies' components */&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;shellAppSharedDependencies&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@bit-bazaar/shell-app.shared-dependencies&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;MfReact&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;storefront&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;clientRoot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./storefront.app-root.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;moduleFederation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;exposes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;shared&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;shellAppSharedDependencies&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  A Shared Design System
&lt;/h2&gt;

&lt;p&gt;Our component library and theme are based on Material UI. They are maintained in the “design” scope and shared across Micro Frontends.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AVNkzhuxM7aQiLslASgYs9A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AVNkzhuxM7aQiLslASgYs9A.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://bit.cloud/bit-bazaar/design" rel="noopener noreferrer"&gt;The “design” scope which contains the shared UI components and themes&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Shared Context
&lt;/h2&gt;

&lt;p&gt;The ‘Theme Provider,’ ‘Auth Provider,’ and other context components are part of the “host app” or “shell app.” As such, they are maintained by the “shell app” team.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AgzRW_UPh8FVNg6AdunoDOg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AgzRW_UPh8FVNg6AdunoDOg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The context for all MFEs (provided by the &lt;a href="https://bit.cloud/bit-bazaar/shell-app/shell-app/~code/shell-app.tsx" rel="noopener noreferrer"&gt;shell app&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Teams working on MFEs do not need to bother with authentication, authorization, or any other shared functionality. The “host” or “shell” team provides it all to them.&lt;/p&gt;

&lt;p&gt;For example, if team Storefront needs to implement functionality based on the user auth, they would explore the ‘shell app’ scope and look for the proper “SDK”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AnygdqeWAhwyCEkAhZSH8Ww.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AnygdqeWAhwyCEkAhZSH8Ww.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://bit.cloud/bit-bazaar/shell-app/auth/auth-provider/~code" rel="noopener noreferrer"&gt;The “auth” context and hook&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Routing and Navigation
&lt;/h2&gt;

&lt;p&gt;The shell app provides a sort of “plugin system” where Micro Frontends (remote modules) can integrate into it in ways that go beyond a simple link. It does so by providing the types for each “plugin”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2ALNIly_jIcZHgyl67TluvKg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2ALNIly_jIcZHgyl67TluvKg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://bit.cloud/bit-bazaar/shell-app/types/navigation" rel="noopener noreferrer"&gt;The shared “navigation item” type&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example, a remote module can implement a “navigation item” interface that includes its navigation options.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AO5Z7c-movW0_IlQZ-W4kMw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AO5Z7c-movW0_IlQZ-W4kMw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This can then be exposed for the shell app (which will load it at runtime):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * @filename: blog.bit-app.ts
 * @component-id: bit-bazaar.blog/blog
*/&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;MfReact&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;blog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;clientRoot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./blog.app-root.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;moduleFederation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;exposes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="cm"&gt;/** 
       * the MFE navigation exposed to be loaded 
       * by the shell app at runtime
       **/&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./blognav&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./navitem.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="cm"&gt;/**
        * the main chunk of the 'blog' MFE
        **/&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./blog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./blog.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;shared&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;shellAppSharedDependencies&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Netlify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;netlifyConfig&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The routing is handled at the level that suits the module. For example, the shell app only handles routing to &lt;code&gt;/blog/*&lt;/code&gt; and &lt;code&gt;/storefront/*&lt;/code&gt;. It does not determine the routing “inside” each MFE (such as &lt;code&gt;storefront/products&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * @filename: shell-app.tsx
 * @component-id: bit-bazaar.shell-app/shell-app
*/&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ShellApp&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;BrowserRouter&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Routes&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Layout&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Homepage&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;store/*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Store&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blog/*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Blog&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;*&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Not&lt;/span&gt; &lt;span class="nx"&gt;Found&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;} /&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Route&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Routes&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/BrowserRouter&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Accordingly, remote modules, such as the &lt;code&gt;blog&lt;/code&gt;, are not responsible for the &lt;code&gt;/blog/*&lt;/code&gt; routing (the routing to the blog MFE)—only for nested routes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * @filename: blog.tsx
 * @component-id: bit-bazaar.blog/blog
*/&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Blog&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Routes&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;articles&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ArticlesPage&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;categories&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;CategoriesPage&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Routes&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  DevX
&lt;/h2&gt;

&lt;p&gt;For the ultimate dev experience, each team uses a “Platform” component to consume an immutable version of the shell app and possibly other remote modules.&lt;/p&gt;

&lt;p&gt;This provides the MFEs with the proper context to run in development. It ensures a consistent and seamless dev experience while properly enforcing permissions and access control (e.g., the 'blog' team cannot modify the 'storefront' MFE or the shell app).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2ANU2_MVKTnTMHAEfUr_5QBw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2ANU2_MVKTnTMHAEfUr_5QBw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://bit.cloud/bit-bazaar/storefront/storefront-platform/~code/shell-platform.bit-app.ts" rel="noopener noreferrer"&gt;https://bit.cloud/bit-bazaar/storefront/storefront-platform/~code/shell-platform.bit-app.ts&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AkxmzE2RnzgLq70WKtnKPSw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AkxmzE2RnzgLq70WKtnKPSw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The 'shell-app' as an immutable dependency of the ‘storefront-platform’ used by the ‘storefront’ team for ‘storefront’ development in full context&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example, the ‘storefront’ team are able to run the ‘storefront’ MFE in its full context (shell app and even other MFEs) by running the 'platform' app maintained by them (for development only):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bit run storefront-platform
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2A990s5cPwdR9-tYjigxgNbw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2A990s5cPwdR9-tYjigxgNbw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can generate a 'Platform' component using the template provided by the ModFed env (the one configured as a generator at the beginning of this blog):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bit create modfed-platform my-platform
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Composable Backend-for-Frontend</title>
      <dc:creator>Eden Ella</dc:creator>
      <pubDate>Wed, 15 May 2024 18:12:14 +0000</pubDate>
      <link>https://dev.to/bitdev_/composable-backend-for-frontend-1ba8</link>
      <guid>https://dev.to/bitdev_/composable-backend-for-frontend-1ba8</guid>
      <description>&lt;p&gt;The Backend-for-Frontend (BFF) pattern is an architectural approach where a dedicated backend service is created for each frontend application or client type. &lt;/p&gt;

&lt;p&gt;Utilizing the BFF pattern allows developers to tailor the APIs and backend services to the specific requirements of each client. This can result in improved performance, better security controls, and a more cohesive user experience.&lt;/p&gt;

&lt;p&gt;For the BFF architecture to be effective and sustainable, it has to be composable. BFFs should be assembled using loosely coupled, interoperable components that can be easily combined, reused, or replaced. &lt;/p&gt;




&lt;p&gt;A "BFF component" in a composable system is a standardized abstract layer for specific technical tasks or services built in-house or bought from different vendors. &lt;/p&gt;

&lt;p&gt;Components in this system should adhere to "rules of communication" agreed upon across teams to make them easily pluggable into the wider system architecture. &lt;/p&gt;

&lt;p&gt;A well-designed system of "BFF components" facilitates innovation and allows businesses to quickly respond to new opportunities or threats.&lt;/p&gt;




&lt;p&gt;In this article, we’ll explore &lt;a href="https://bit.dev/docs/harmony-platform/harmony-platform" rel="noopener noreferrer"&gt;Bit Harmony&lt;/a&gt;, an innovative framework for the composition of full-stack components using smart dependency injection. The platform uses &lt;a href="https://bit.dev" rel="noopener noreferrer"&gt;Bit components&lt;/a&gt; as its building blocks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flmu9udv2oq9jxe9ahzf0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flmu9udv2oq9jxe9ahzf0.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwweekjusy3rr42zcfnlw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwweekjusy3rr42zcfnlw.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Visit the &lt;a href="https://bit.cloud/lazyworks" rel="noopener noreferrer"&gt;"LazyWorks Inc."&lt;/a&gt; Bit organization to see a demo of this approach.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ecdr4h0yhm0gufgr2wy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7ecdr4h0yhm0gufgr2wy.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Aspects
&lt;/h2&gt;

&lt;p&gt;An aspect is the building block of a Harmony solution. It is a full-stack Bit component that provides UI and backend “services” for other aspects.&lt;/p&gt;

&lt;p&gt;An aspect represents a single feature that can be plugged into a larger system to form a full solution, a new application. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyc03tknj937sib2d2zr4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyc03tknj937sib2d2zr4.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Aspects extend other aspects by registering to their ‘slot’ API. This inversion of control allows teams to compose features with minimal overhead since the aspect is responsible for the integration, not the system that composes it.&lt;/p&gt;

&lt;p&gt;For example, &lt;a href="https://bit.cloud/lazyworks/no-sweat-shop/no-sweat-shop" rel="noopener noreferrer"&gt;the following Harmony app&lt;/a&gt; is an online shop for lazy living. The team responsible for that online store decided to add a blog to their site. After searching for a suitable aspect on the &lt;a href="https://bit.cloud/" rel="noopener noreferrer"&gt;Bit platform&lt;/a&gt;, they came across &lt;a href="https://bit.cloud/lazyworks/blog" rel="noopener noreferrer"&gt;this Contentful-based Blog aspect&lt;/a&gt;. Deciding they wanted to use it, they added it to their Hamrony application:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="cm"&gt;/**
 * @coponentId: lazyworks.no-sweat-shop/no-sweat-shop
 * @filename: no-sweat-shop.bit-app.ts
 */&lt;/span&gt; 

&lt;span class="c1"&gt;// imports...&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * The "LazyWorks Platform" defines how an 
 * aspect can integrate into the system 
 * (i,e, register new routes, 
 * extend the GraphQL schema, etc) 
 */&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;LazyworksPlatformAspect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@lazyworks/platform.lazyworks-platform&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NoSweatShopPlatformAspect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@lazyworks/no-sweat-shop.no-sweat-shop-platform&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;BlogAspect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@lazyworks/blog.blog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;NoSweatShop&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;HarmonyPlatform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;no-sweat-shop&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
   &lt;span class="cm"&gt;/**
    * aspects register themselves to the 'platform' aspect which
    * is the entry point for this application
    */&lt;/span&gt;
    &lt;span class="nx"&gt;LazyworksPlatformAspect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;No Sweat Shop&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;slogan&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Effortless Living, Delivered.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;no-sweat-shop.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;logo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://static.bit.dev/extensions-icons/my-project.svg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="cm"&gt;/**
    * aspects can run in multiple runtime environments. here, aspects 
    * provide functionalities to the NodeJS services and the web frontend apps
   */&lt;/span&gt;
  &lt;span class="na"&gt;runtimes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BrowserRuntime&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NodeJSRuntime&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt;

  &lt;span class="na"&gt;aspects&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="cm"&gt;/* 'no sweat shop' aspect extends the system with its 
     * own unique functionalities. this aspect is maintained by 
     * a team that composes the aspects for their own solution.
     */&lt;/span&gt;
    &lt;span class="nx"&gt;NoSweatShopPlatformAspect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="cm"&gt;/**
     * the blog aspect extends the system with content 
     * management capabilities.
     */&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="nx"&gt;BlogAspect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="cm"&gt;/**
         * the blog aspect also provides a config API for this app to use
         * in this case, since the blog uses the Contentful platform,
         * the team needs to provide it with their own Contentful space ID
         */&lt;/span&gt;        
        &lt;span class="na"&gt;spaceId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;contentful-spaceId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;NoSweatShop&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjphdsq4843xopt2fwmwh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjphdsq4843xopt2fwmwh.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Blog aspect registers itself to the platform in several ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It extends the system’s GraphQL schema with a node for content retrieval. This is done in the NodeJS Runtime.&lt;/li&gt;
&lt;li&gt;It extends the system’s routing with the /blog route. This is done in the Browser Runtime.&lt;/li&gt;
&lt;li&gt;It extends the header with an additional item a ‘Blog’ link to /blog . This is done in the Browser Runtime.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note that the UI provided by the aspects is optional. In some cases, depending on the type of application the BFF is serving, the browser-runtime features might not be used&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  NodeJS Runtime
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="cm"&gt;/**
 * @coponentId: lazyworks.blog/blog
 * @filename: blog.node.runtime.ts
 */&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BlogNode&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BlogConfig&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;getBlogPosts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blogData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BlogData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;blogData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBlogPosts&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;dependencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;LazyworksPlatformAspect&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;lazyworksPlatform&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;LazyworksPlatformAspect&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BlogConfig&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BlogNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;gqlSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;blogGqlSchema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blog&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;lazyworksPlatform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;registerBackendServer&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;gql&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;gqlSchema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;]);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;blog&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;BlogNode&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Browser Runtime
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;

&lt;span class="cm"&gt;/**
 * @coponentId: lazyworks.blog/blog
 * @filename: blog.browser.runtime.ts
 */&lt;/span&gt;


&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BlogBrowser&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BlogConfig&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;dependencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;LazyworksPlatformAspect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HeaderAspect&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;lazyworksPlatform&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;header&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;LazyworksPlatformBrowser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HeaderBrowser&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BlogConfig&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BlogBrowser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;lazyworksPlatform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;registerRoute&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/blog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;component&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ApolloBlogProvider&lt;/span&gt; &lt;span class="na"&gt;spaceId&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;spaceId&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;BlogLobby&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ApolloBlogProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;]);&lt;/span&gt;

    &lt;span class="nx"&gt;header&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;registerLink&lt;/span&gt;&lt;span class="p"&gt;([{&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Blog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/blog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}]);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;blog&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;BlogBrowser&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h4&gt;
  
  
  To learn more, visit &lt;a href="https://bit.dev" rel="noopener noreferrer"&gt;Bit's documentation&lt;/a&gt; site or the &lt;a href="https://bit.cloud" rel="noopener noreferrer"&gt;Bit Platform&lt;/a&gt;.
&lt;/h4&gt;

</description>
      <category>node</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>react</category>
    </item>
    <item>
      <title>Composable Software Architectures are Trending: Here’s Why</title>
      <dc:creator>Ashan Fernando</dc:creator>
      <pubDate>Tue, 19 Mar 2024 11:11:18 +0000</pubDate>
      <link>https://dev.to/bitdev_/composable-software-architectures-are-trending-heres-why-17ka</link>
      <guid>https://dev.to/bitdev_/composable-software-architectures-are-trending-heres-why-17ka</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgujyhrjo8a06at6nap0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgujyhrjo8a06at6nap0h.png" alt="Monolith to Composable" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The progression from monolithic applications to composable architecture marks a significant leap in building highly scalable and maintainable software applications. This evolution crossed different milestones in its path.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Era of Monolithic Applications
&lt;/h2&gt;

&lt;p&gt;Historically, software systems were predominantly monolithic. In these systems, various components, including the user interface, business logic, and data access layers, are tightly integrated within a single codebase. While this approach was straightforward and productive initially, it inevitably led to challenges as applications grew in complexity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F647dqnacaxabp8l4vhe4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F647dqnacaxabp8l4vhe4.png" alt="Monolith" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even a minor modification to the application could necessitate rebuilding, testing, and redeploying the entire application, introducing inefficiency. Additionally, developer efficiency decreases as many developers have to collaborate and handle a broader cognitive load to identify the areas of change and their impact.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Modular Monolith
&lt;/h2&gt;

&lt;p&gt;Before the widespread adoption of microservices and micro frontends, the modular monolith architectural style emerged as a middle ground between the traditional monolith and the fully distributed microservices.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F657mag29qemkgq7zxr9g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F657mag29qemkgq7zxr9g.png" alt="Modular Monolith" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This approach aims to retain the operational simplicity of the monolith while introducing a level of modularity and separation of concerns typically associated with Microservices. It draws clear boundaries around modules, making development and testing more granular, reducing the cognitive load for development, and thus improving overall productivity.&lt;/p&gt;

&lt;p&gt;Yet, the fundamental challenges of a large code base still exist, impacting developer collaboration and efficient use of resources to run the application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shift Toward Microservices and Micro Frontends
&lt;/h2&gt;

&lt;p&gt;The advent of Microservices marked a paradigm shift to address many challenges of monolithic architectures at scale. Microservices architecture enabled independent development, testing, and deployment by breaking down applications into smaller, loosely coupled services, each responsible for a specific function and communicating through well-defined interfaces.&lt;/p&gt;

&lt;p&gt;Building on the principles of Microservices, the concept of Micro frontends emerged to address similar challenges in the frontend landscape. Microfrontends extend the Microservices paradigm to the frontend, breaking down monolithic frontend codebases into smaller, more manageable pieces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flm1yjj0b3brz6qjs4bcb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flm1yjj0b3brz6qjs4bcb.png" alt="Microservies and Microfrontends" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, there is a fundamental difference between Microservices and Microfrontends. Microservices are distributed systems where each service has an end-to-end lifecycle and complete autonomy in development and operations. Therefore, it is recommended that each Microservice run on its own process (runtime isolation) and databases (data isolation) and has its own codebase (code isolation), minimizing dependencies across development teams, resulting in less reuse and collaboration.&lt;/p&gt;

&lt;p&gt;On the other hand, Micro frontends need a significant level of component reuse to keep UI consistent. It requires either run-time or build-time (preferred) integration before running in the browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgf5fixjjugg99cad981j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgf5fixjjugg99cad981j.png" alt="Development Cost vs Application Size" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Microservices and Micro frontends are not suitable for everyone. A startup or a small development team may find it difficult and counter-productive to adapt these architectural styles as they come with overheads in setting up projects and managing operations. Therefore, the cost of adapting these architectures makes sense beyond a certain scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing Purely Composable Architecture
&lt;/h2&gt;

&lt;p&gt;Composability involves creating software applications from independent, reusable components, each encapsulating its dependencies and distinct functionality. Then, these components (building blocks) can be combined to build complex applications. It’s a fundamental difference to the way we used to develop software applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqv5059i5f9va2osveh4d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqv5059i5f9va2osveh4d.png" alt="Purely Composable" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since components are smaller, reusable building blocks, the context of change becomes the scope of the components that can be modified and tested independently. The main gap in implementing composable architecture in the past is not having robust tooling to support it. And since some changes may cut across multiple components, robust tooling that aids in modifying components in bulk and testing the dependency chain is required.&lt;/p&gt;

&lt;p&gt;The following diagram showcases how &lt;a href="https://bit.dev"&gt;bit&lt;/a&gt; shows the dependency graph of modified components and their dependents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvh3nrkws8sc8l14t7bsg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvh3nrkws8sc8l14t7bsg.png" alt="Bit Dependency Graph" width="700" height="509"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the beauty of this approach is that since it’s so fundamental, you can use it with other architectural styles to address some of their weaknesses. Following are some examples.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can use components to build your Microservices so that you can start collaborating between teams and share components.&lt;/li&gt;
&lt;li&gt;Use app as the shell component to build your Micro frontends, using a &lt;a href="https://bit.dev/reference/reference/scope/scope-overview/"&gt;remote scope&lt;/a&gt; for each team.&lt;/li&gt;
&lt;li&gt;Create an &lt;a href="https://bit.dev/reference/envs/create-env/"&gt;Env&lt;/a&gt; for each Microservice so that the technology used in each Microservice is independent of one another.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxakbopi0f0ltvku19001.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxakbopi0f0ltvku19001.png" alt="Bit UI" width="720" height="666"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And, since each component has its documentation, clear interfaces, tests, and previews and share these in &lt;a href="https://bit.cloud"&gt;bit.cloud&lt;/a&gt;, collaboration increases at scale across codebases and teams.&lt;/p&gt;

&lt;p&gt;And there are many other benefits of implementing a composable architecture;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Flexibility:&lt;/strong&gt; Architecture becomes flexible when adopting different styles and patterns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability of the development team:&lt;/strong&gt; Individual components can be scaled as needed, allowing for more efficient resource utilization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintainability:&lt;/strong&gt; The modular nature of composable architectures simplifies maintenance and updates, as changes are localized to specific components.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Innovation and Speed:&lt;/strong&gt; Reusable components accelerate development cycles and foster innovation by enabling teams to leverage existing functionalities for new applications and collaborate better.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Better dependency management:&lt;/strong&gt; Consider a scenario where a UI component library is used across multiple projects within an organization. Bit can manage these components’ dependencies, ensuring that updates do not break functionality in any projects relying on the library.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The evolution from monolithic applications to composable architectures is redefining the standards for software development. With the support of advanced tools like Bit, the future of software development is set to be more flexible, efficient, and aligned with the dynamic needs of businesses.&lt;/p&gt;

&lt;p&gt;As we move forward, composable architectures will undoubtedly continue to shape the future of software development, marking a significant shift towards more adaptable and resilient software systems.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Micro Frontends with Vite and Bit</title>
      <dc:creator>Eden Ella</dc:creator>
      <pubDate>Wed, 13 Mar 2024 11:35:17 +0000</pubDate>
      <link>https://dev.to/bitdev_/micro-frontends-with-vite-and-bit-22a5</link>
      <guid>https://dev.to/bitdev_/micro-frontends-with-vite-and-bit-22a5</guid>
      <description>&lt;p&gt;In this tutorial, you'll learn the steps to create a micro frontend application leveraging the capabilities of &lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt;, &lt;a href="https://bit.dev" rel="noopener noreferrer"&gt;Bit&lt;/a&gt;,  and the modern browser.&lt;/p&gt;

&lt;p&gt;Our Micro Frontend applications (MFEs) and their shared dependencies will be bundled into ES Modules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In development&lt;/strong&gt;, our MFEs and shared dependencies will be loaded from our local workspace. This allows us to develop and test the MFEs locally without having to deploy them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In production&lt;/strong&gt;, our MFEs will be loaded (in runtime) from their remote entry point according to the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap" rel="noopener noreferrer"&gt;import map&lt;/a&gt; in the host app's &lt;code&gt;index.html&lt;/code&gt;. For example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"importmap"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;imports&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://esm.sh/react@18.2.0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@learnbit/react-es-mfe.my-mfe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://bit-react-esm-mfe.netlify.app/v0.0.1.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Our micro frontend solution will consist of three &lt;a href="https://bit.dev/reference/components/the-bit-component" rel="noopener noreferrer"&gt;Bit components&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A micro frontend&lt;/strong&gt;: An app bundled as an ESM library that can be imported and rendered by the host app (at runtime).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A remote module list&lt;/strong&gt;: A list of shared modules and micro frontends consumed at runtime by our host app and micro frontend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A host app&lt;/strong&gt;: A container application that imports and renders the micro frontends.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8gjjnwpfg3y5yes36pp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8gjjnwpfg3y5yes36pp.png" alt="The dependency graph of our micro frontends solution"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://bit.cloud/learnbit/react-es-mfe/my-host-app/~graph" rel="noopener noreferrer"&gt;The dependency graph of our solution&lt;/a&gt;. The host application and the micro frontend both share the list of remote modules (to be excluded from their bundles and imported dynamically).&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this project, we'll use Bit to manage different parts of our solution as Bit components. We'll &lt;a href="https://bit.dev/docs/getting-started/collaborate/exporting-components" rel="noopener noreferrer"&gt;share the components&lt;/a&gt; on &lt;a href="https://bit.cloud" rel="noopener noreferrer"&gt;bit.cloud&lt;/a&gt; and deploy the apps (also Bit components) to their respective hosting services.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4kyq8blvdwhm1z9cevap.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4kyq8blvdwhm1z9cevap.png" alt="A component-based solution for Micro Frontends with Vite"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Explore this project by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Reviewing the Bit components &lt;a href="https://bit.cloud/learnbit/react-es-mfe" rel="noopener noreferrer"&gt;in their remote scope on bit.cloud&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Forking (copying) the entire solution to your &lt;a href="https://bit.dev/docs/getting-started/installing-bit/start-bit-workspace" rel="noopener noreferrer"&gt;Bit workspace&lt;/a&gt; by running &lt;code&gt;bit scope fork learnbit.react-es-mfe YOUR_ACCOUNT_AND_SCOPE_NAME&lt;/code&gt; (use your &lt;a href="https://bit.cloud" rel="noopener noreferrer"&gt;bit.cloud&lt;/a&gt; account and scope name)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visiting the &lt;a href="https://bit-react-esm-host-app.netlify.app/" rel="noopener noreferrer"&gt;deployed application&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Creating the micro frontend
&lt;/h2&gt;

&lt;p&gt;To get started with our project, we'll create a new &lt;a href="https://bit.dev/docs/getting-started/installing-bit/start-bit-workspace" rel="noopener noreferrer"&gt;Bit workspace&lt;/a&gt; (replace &lt;code&gt;my-account.my-scope&lt;/code&gt; with your own &lt;a href="https://bit.cloud" rel="noopener noreferrer"&gt;bit.cloud&lt;/a&gt; account and scope name):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

bit new basic my-workspace &lt;span class="nt"&gt;--default-scope&lt;/span&gt; my-account.my-scope
&lt;span class="nb"&gt;cd &lt;/span&gt;my-workspace


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Since our solution is entirely component-based, our host app and micro frontend will also be maintained as independent Bit components.&lt;/p&gt;

&lt;p&gt;To create a new React Vite app, we'll use Bit's out-of-the-box component template for &lt;a href="https://bit.dev/docs/apps/create-react-apps" rel="noopener noreferrer"&gt;React Vite apps&lt;/a&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

bit create react-app my-mfe


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://bit.cloud/learnbit/react-es-mfe/my-mfe/~code/vite.config.js" rel="noopener noreferrer"&gt;See the micro frontend component in its scope&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To make our MFE dynamically loadable as an ES Module, we'll configure Vite to build it as a library with the &lt;code&gt;'es'&lt;/code&gt; format.&lt;/p&gt;

&lt;p&gt;We'll do this by adding the necessary configuration to the &lt;code&gt;vite.config.js&lt;/code&gt; file at the root of our component's directory:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;reactPlugin&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@vitejs/plugin-react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;cssInjectedByJsPlugin&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vite-plugin-css-injected-by-js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;myRemoteModules&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@learnbit/react-es-mfe.remote-modules&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nf"&gt;reactPlugin&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;jsxRuntime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;classic&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// it's easier to exclude react from the bundle when not using the new jsx runtime&lt;/span&gt;
    &lt;span class="p"&gt;}),&lt;/span&gt;
    &lt;span class="nf"&gt;cssInjectedByJsPlugin&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="c1"&gt;// this is to inject this MFE's CSS, when it is loaded&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;define&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;process.env&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;{}&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// this is to avoid 'process is undefined' error in the browser&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;lib&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;formats&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;es&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./my-mfe.tsx&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;v0.0.1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// it's recommended to use a version for each MFE deployment&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;rollupOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;external&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;myRemoteModules&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listModules&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="c1"&gt;// the remote modules to exclude from the bundle&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The remote modules component, used by this config, contains a list of modules to be loaded dynamically at runtime, and to be excluded from the MFE and host app bundles. This list contains shared dependencies like &lt;code&gt;react&lt;/code&gt;, as well as micro frontends.&lt;/p&gt;

&lt;p&gt;We'll also exclude shared dependencies from our MFE's bundle to keep our bundles small and avoid duplications.&lt;/p&gt;

&lt;p&gt;Bit components are configured as "app components" when they include a &lt;a href="https://bit.cloud/learnbit/react-es-mfe/my-mfe/~code/my-mfe.bit-app.ts" rel="noopener noreferrer"&gt;&lt;code&gt;*.bit-app.ts&lt;/code&gt; file in their component directory&lt;/a&gt;. This file configures the app's build and deployment. In this example, we'll deploy our app components (the MFE and host app) to Netlify.&lt;/p&gt;

&lt;p&gt;Since this is an app, we can run it locally using the &lt;code&gt;bit run&lt;/code&gt; command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

bit run my-mfe


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5t16f02dzhnsmmypw8b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5t16f02dzhnsmmypw8b.png" alt="The micro frontend running locally"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Run &lt;code&gt;bit app list&lt;/code&gt; to list the apps available in your workspace&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Creating the remote modules mapping
&lt;/h2&gt;

&lt;p&gt;As mentioned earlier, our MFEs and host app will use a (shared) Bit component to manage the list of modules to be loaded dynamically at runtime.&lt;/p&gt;

&lt;p&gt;We'll create a new Bit component to manage this list. This time, we'll use Bit's out-of-the-box component template for a simple Node.js module:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

bit create node my-remote-modules


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://bit.cloud/learnbit/react-es-mfe/remote-modules/~code/remote-modules-example.ts" rel="noopener noreferrer"&gt;See the remote module component in its scope&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Our list of modules will include the shared dependencies and the MFEs. In this example, we'll include &lt;code&gt;react&lt;/code&gt; and the previously created MFE.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;RemoteModules&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./remote-modules.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myRemoteModules&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RemoteModules&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://esm.sh/react@18.2.0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@learnbit/react-es-mfe.my-mfe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://bit-react-esm-mfe.netlify.app/v0.0.1.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// the MFE's URL as defined by its bit-app.ts file.&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Creating the host app
&lt;/h2&gt;

&lt;p&gt;To create our host application, we'll, again, use Bit's out-of-the-box component template for a &lt;a href="https://bit.dev/docs/apps/create-react-apps" rel="noopener noreferrer"&gt;React Vite app&lt;/a&gt;:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

bit create react-app my-host-app


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://bit.cloud/learnbit/react-es-mfe/my-host-app/~code/vite.config.js" rel="noopener noreferrer"&gt;See the host application component in its remote scope&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Our host app will be built as a regular Vite app. However, since it should dynamically load the MFEs, we'll need to configure it to exclude shared dependencies and MFEs from its bundle.&lt;br&gt;
We'll, also inject an import map to the HTML file, to instruct the browser on how to resolve imports at runtime.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;reactPlugin&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@vitejs/plugin-react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;myRemoteModules&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@learnbit/react-es-mfe.remote-modules&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// the remote modules list&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;importMapPlugin&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@learnbit/react-es-mfe.vite-import-map-plugin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// a custom Vite plugin to inject the import map&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;reactPlugin&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; 
&lt;span class="c1"&gt;// inject the import map (from the remote-modules component)&lt;/span&gt;
&lt;span class="nf"&gt;importMapPlugin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myRemoteModules&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createImportMap&lt;/span&gt;&lt;span class="p"&gt;())],&lt;/span&gt; 
  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;rollupOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// exclude remote modules from the app's bundle&lt;/span&gt;
      &lt;span class="na"&gt;external&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;myRemoteModules&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listModules&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;a href="https://bit.cloud/learnbit/react-es-mfe/vite-import-map-plugin/~code/vite-import-map-plugin.ts" rel="noopener noreferrer"&gt;The custom plugin&lt;/a&gt; used by the host app replaces the &lt;code&gt;&amp;lt;--importmaps--&amp;gt;&lt;/code&gt; placeholder in the HTML file with the import map generated by the remote modules list.&lt;/p&gt;

&lt;p&gt;To run the host app locally, we can use the &lt;code&gt;bit run&lt;/code&gt; command:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

bit run my-host-app


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpr1jsffif6n5x40484qx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpr1jsffif6n5x40484qx.png" alt="The host application running locally"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In development, our host app will consume the MFEs from the local &lt;code&gt;node_modules&lt;/code&gt; directory in the workspace, and will not load them from their deployed URLs (as it would in production).&lt;/p&gt;

&lt;p&gt;This allows us to develop and test the MFEs locally, without having to deploy them (when Bit components are maintained locally, they are symlinked from their source directory to the &lt;code&gt;node_modules&lt;/code&gt; directory. Otherwise, they are installed from the registry).&lt;/p&gt;
&lt;h2&gt;
  
  
  Sharing the components and deploying the apps
&lt;/h2&gt;

&lt;p&gt;Run the following to build your components, export (push) them to their remote scope on bit.cloud, and deploy the app components to their hosting (as configured in the &lt;code&gt;.bit-app.ts&lt;/code&gt; file of each app component):&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

bit tag -m "first version"
bit export


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;The components will be built on bit.cloud. Once the build is over, the components will be available in their remote scope (the remote scope was configured at the beginning of this tutorial when we initialized a new Bit workspace with the &lt;code&gt;--default-scope&lt;/code&gt; property).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://bit.cloud/learnbit/react-es-mfe" class="ltag_cta ltag_cta--branded" rel="noopener noreferrer"&gt;Explore the components in their scope on bit.cloud&lt;/a&gt;
&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>react</category>
    </item>
    <item>
      <title>Implementing a Service Oriented Architecture in 2024</title>
      <dc:creator>Eden Ella</dc:creator>
      <pubDate>Mon, 12 Feb 2024 10:36:58 +0000</pubDate>
      <link>https://dev.to/bitdev_/implementing-a-service-oriented-architecture-in-2024-56mn</link>
      <guid>https://dev.to/bitdev_/implementing-a-service-oriented-architecture-in-2024-56mn</guid>
      <description>&lt;p&gt;The advantages of microservices can generally be categorized into two groups: technological and human-centric. Within the human-centric category, the benefits relate to how we work and collaborate.&lt;/p&gt;

&lt;p&gt;Teams working on microservices have full ownership over parts of the system. They can work independently, choose their own stack, and deploy their services independently and in parallel to other teams.&lt;/p&gt;

&lt;p&gt;In addition to that, although microservices as a system can become more complex, individual services are simpler and easier to understand and maintain.&lt;/p&gt;

&lt;p&gt;This sort of “reverse Conway’s Law,” where the system’s architecture influences the organizational structure, is a key benefit of microservices that can also be found in other types of distributed systems.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h4&gt;
  
  
  How can we make our system more distributed and composable to get more of the same benefits?
&lt;/h4&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this article, we’ll look at &lt;a href="//https:/bit.dev"&gt;Bit&lt;/a&gt; as a tool that allows us to compose systems from independent components of all levels of granularity, from simple utility functions to microservices and, ultimately, to entire systems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bit.dev" class="ltag_cta ltag_cta--branded" rel="noopener noreferrer"&gt;Bit: A next-generation build system for composable software.&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;We’ll see how &lt;a href="https://bit.dev/reference/components/the-bit-component" rel="noopener noreferrer"&gt;Bit components&lt;/a&gt; can be shared and reused across microservices, how microservices can be maintained as Bit components, and how they can be composed in runtime using an API gateway component.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building a composable system
&lt;/h2&gt;

&lt;p&gt;To better understand how Bit can be used to compose microservices, let’s start by creating a new workspace with a few Bit components:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

bit new react my-project &lt;span class="nt"&gt;--env&lt;/span&gt; bitdev.react/react-env &lt;span class="nt"&gt;--default-scope&lt;/span&gt; my-org.my-project


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;cd &lt;/span&gt;my-project


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Your new workspace has seven components. Run &lt;code&gt;bit start&lt;/code&gt; to explore your components using Bit’s UI:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk1vuigmzxbfan6axbj1f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk1vuigmzxbfan6axbj1f.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To run the system, run:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

bit run my-project


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The output should list several different processes listening on different ports. Two microservices, &lt;a href="https://bit.cloud/bitdev/platforms/examples/discussion-server" rel="noopener noreferrer"&gt;&lt;code&gt;discussion-server&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;user-server&lt;/code&gt;, an &lt;a href="https://bit.cloud/bitdev/symphony/backends/gateway-server" rel="noopener noreferrer"&gt;API gateway&lt;/a&gt;, and a &lt;a href="https://bit.cloud/bitdev/platforms/examples/acme-web" rel="noopener noreferrer"&gt;frontend application&lt;/a&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="o"&gt;[&lt;/span&gt;discussions-server]: running on port 5003
&lt;span class="o"&gt;[&lt;/span&gt;user-server]: running on port 5002
&lt;span class="o"&gt;[&lt;/span&gt;HPM] Proxy created: /  -&amp;gt; http://localhost:5002/graphql
&lt;span class="o"&gt;[&lt;/span&gt;HPM] Proxy rewrite rule created: &lt;span class="s2"&gt;"/user-server/"&lt;/span&gt; ~&amp;gt; &lt;span class="s2"&gt;"/"&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;HPM] Proxy created: /  -&amp;gt; http://localhost:5003/graphql
&lt;span class="o"&gt;[&lt;/span&gt;HPM] Proxy rewrite rule created: &lt;span class="s2"&gt;"/discussions-server/"&lt;/span&gt; ~&amp;gt; &lt;span class="s2"&gt;"/"&lt;/span&gt;
backend server running on 5001
frontend server running on 3001 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This runtime composition of different services, both locally and remotely, is done using the &lt;a href="https://bit.dev/docs/apps/create-platforms/" rel="noopener noreferrer"&gt;&lt;code&gt;platform&lt;/code&gt;&lt;/a&gt; component. It is another Bit component whose role is to serve as the entry point for this system:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Platform&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@bitdev/platforms.platform&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserServer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@bitdev/node.examples.user-server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;DiscussionServer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@my-org/discussions.discussions-server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AcmeWeb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@my-org/my-project.my-platform-project-web&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PlatformGateway&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@bitdev/symphony.backends.gateway-server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyPlatformProjectPlatform&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Platform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-platform-project-platform&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

  &lt;span class="na"&gt;frontends&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/** main frontend application for the platform */&lt;/span&gt;
    &lt;span class="na"&gt;main&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AcmeWeb&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="na"&gt;backends&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/**
     * use an api gateway component.
     * supports proxy of graphql and restful requests.
     */&lt;/span&gt;
    &lt;span class="na"&gt;main&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PlatformGateway&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="cm"&gt;/** compose micro-service components. */&lt;/span&gt;
      &lt;span class="nx"&gt;UserServer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;DiscussionServer&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Note that not all Bit components need to be maintained locally. A composition of services can include remote services that are not available locally. This is tremendously helpful for local and remote testing of services in the context of the entire system.&lt;/p&gt;

&lt;p&gt;To learn more, see the &lt;a href="https://bit.dev/docs/apps/create-platforms" rel="noopener noreferrer"&gt;Platforms documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also, note that &lt;a href="https://bit.cloud/bitdev/symphony/backends/gateway-server" rel="noopener noreferrer"&gt;the API Gateway&lt;/a&gt; can be implemented in whatever way suits your needs. To explore the one used by this example, see:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frb0ntnii2p7h41qoz0p9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frb0ntnii2p7h41qoz0p9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Build-time or runtime integration? The choice is yours!
&lt;/h2&gt;

&lt;p&gt;One thing that is immediately apparent when reviewing the Bit components in your workspace is just how different they can be. UI and non-UI, Node and React, small and large.&lt;/p&gt;

&lt;p&gt;However, in the context of this article, the most important distinction is whether they are &lt;a href="https://bit.dev/reference/apps/create-apps" rel="noopener noreferrer"&gt;“app components”&lt;/a&gt; or not. App components are components that are available for consumption as Node packages, just like “regular” Bit components, but are also deployable and available for runtime compositions.&lt;/p&gt;

&lt;p&gt;For example, our &lt;a href="https://bit.cloud/bitdev/platforms/examples/discussion-server" rel="noopener noreferrer"&gt;&lt;code&gt;discussion-server&lt;/code&gt;&lt;/a&gt; Bit component runs as a separate process. Looking at its implementation, we can find one file that sets it apart from other components: the &lt;code&gt;.bit-app.ts&lt;/code&gt; file.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="cm"&gt;/** @filename: discussion-server.bit-app.ts */&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NodeApp&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@bitdev/node.node-app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;NodeApp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;discussions-server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;artifactName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;discussion-service&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;mainPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./discussions-server.app-root.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="cm"&gt;/** 
   * an optional deploy function for this app component -
   * to be executed when a new version of this compoennt is released
   */&lt;/span&gt;
  &lt;span class="c1"&gt;// deploy: () =&amp;gt; {}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With Bit components, you’re always building and delivering independently.&lt;/p&gt;

&lt;p&gt;You can enjoy the benefits of a composable and distributable system, regardless of how (and when) components are being integrated. This gives you the freedom to construct a system that perfectly balances your human or organizational needs with technological requirements.&lt;/p&gt;

&lt;p&gt;For example, you might want more than one team to maintain different aspects of a microservice. You can split the microservice into several microservices, but that’s not always the best solution when taking into consideration your system’s performance. It might be that build-time integration of independently delivered Bit componetns is a better choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  A symmetry between dependencies in dev and prod
&lt;/h2&gt;

&lt;p&gt;One benefit of this style of composition of Bit components is that it provides you with a clear dependency graph that includes components composed in runtime. This can be tremendously helpful in understanding complex systems and in maintaining them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnmzpokhw0uru9hkfd6rj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnmzpokhw0uru9hkfd6rj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned earlier, with Bit your system’s composition is a hybrid of services integrated in runtime and packages integrated in build time. Zooming out a bit further will reveal some of the Bit components used to compose this services:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1uvw3r4hg8wao0j9r77r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1uvw3r4hg8wao0j9r77r.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Reusing Bit components: faster development and better standardization
&lt;/h2&gt;

&lt;p&gt;Bit components can be maintained, &lt;a href="https://bit.dev/docs/getting-started/collaborate/exporting-components" rel="noopener noreferrer"&gt;released&lt;/a&gt;, and &lt;a href="https://bit.dev/docs/getting-started/composing/use-dependencies" rel="noopener noreferrer"&gt;installed&lt;/a&gt; from any project. That makes them an excellent tool for reusing code and standardizing the development process across separate projects.&lt;/p&gt;

&lt;h4&gt;
  
  
  The ‘discussion’ entity component as an example
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvbrlkopbuhbw5h9mj9zl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvbrlkopbuhbw5h9mj9zl.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, your workspace has an &lt;a href="https://bit.dev/docs/node-components/create-entities/" rel="noopener noreferrer"&gt;entity component&lt;/a&gt; called &lt;code&gt;discussion&lt;/code&gt;. The &lt;code&gt;discussion&lt;/code&gt; component provides the data modeling and a set of operations that can be utilized by any microservice or frontend application that handles discussion data within your system.&lt;/p&gt;

&lt;p&gt;It is a contract between services that outlines the structure and rules of engagement for discussions, ensuring consistency and reducing the duplication of effort when developing new features that interact with discussions.&lt;/p&gt;

&lt;p&gt;Furthermore, by using Bit’s versioning system, developers can easily upgrade to new versions of the discussion component as it evolves while maintaining compatibility across the services that depend on it.&lt;/p&gt;

</description>
      <category>node</category>
      <category>typescript</category>
      <category>react</category>
      <category>microservices</category>
    </item>
    <item>
      <title>3 Principles for Component-Driven Development</title>
      <dc:creator>Eden Ella</dc:creator>
      <pubDate>Tue, 23 Jan 2024 11:40:02 +0000</pubDate>
      <link>https://dev.to/bitdev_/3-principles-for-component-driven-development-13hc</link>
      <guid>https://dev.to/bitdev_/3-principles-for-component-driven-development-13hc</guid>
      <description>&lt;p&gt;&lt;a href="https://bit.dev" rel="noopener noreferrer"&gt;Bit&lt;/a&gt; drives a paradigm shift in the way we structure our software and collaborate on code. Its component-based approach produces more maintainable projects and more effective collaboration. However, the power of Bit is best harnessed when you adopt a certain mindset. This blog aims to guide you through the core principles and methodologies of building software with &lt;a href="https://bit.dev/reference/components/the-bit-component" rel="noopener noreferrer"&gt;independent Bit components&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AXTwOsNYvdYGdoBni4jqv0Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AXTwOsNYvdYGdoBni4jqv0Q.png" alt="A demo Bit organization working on a developer portfolio site, composed entirely of autonomous components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;An image of a &lt;a href="https://bit.cloud/showoff/~scopes" rel="noopener noreferrer"&gt;demo Bit organization&lt;/a&gt; working on a &lt;a href="https://bit.cloud/showoff/personal-portfolio/apps/portfolio" rel="noopener noreferrer"&gt;developer portfolio site&lt;/a&gt;, composed entirely of autonomous components&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Principle 1: Build for the present, not for vague future needs
&lt;/h2&gt;

&lt;p&gt;Bit components are easy-to-understand, reusable units of code with transparent dependency graphs. When you build software as a composition of Bit components, you inherently future-proof your codebase without any extra effort.&lt;/p&gt;

&lt;p&gt;Interestingly, the most effective way to leverage Bit’s future-proofing capabilities is to focus solely on present needs. This approach not only prevents the wasteful allocation of resources on speculative future requirements but also enforces “dogfooding” or “eating your own dog food”.&lt;/p&gt;

&lt;p&gt;By using the components you create, you validate the component’s functionality and reliability, thereby increasing overall confidence in the component’s utility for future projects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2ACymppvK0jC2AvhnkSLaBpw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2ACymppvK0jC2AvhnkSLaBpw.jpeg" alt="a man tasting his dog's food before letting him eat it"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The “building for the present” principle extends beyond just the number of components you build. It also entails limiting your components’ API and functionality to the current needs. Over-engineering a component’s API with features that are not currently needed can lead to a bloated, less maintainable component and, as mentioned above, even less reliable (since it's not fully tested by its maintainer).&lt;/p&gt;

&lt;h2&gt;
  
  
  Principle 2: Start from the most concrete component
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AEfAU4hBCb9lFkCDdcAtJvA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AEfAU4hBCb9lFkCDdcAtJvA.jpeg" alt="The order of component creation/composition corresponds to the feature’s dependency graph"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;The order of component creation/composition corresponds to the feature’s dependency graph&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When rolling out a new feature or app, it’s best to start your development with the most concrete component and then work your way to more generic components.&lt;/p&gt;

&lt;p&gt;For instance, if you’re constructing a new form, start by creating the ‘form’ component itself. From there, identify the components it requires. Search for existing ones on &lt;a href="https://bit.cloud" rel="noopener noreferrer"&gt;bit.cloud&lt;/a&gt; and use them in your form. If you can’t find what you need, extend existing components or create new ones.&lt;/p&gt;

&lt;p&gt;This process continues recursively until you have all the components you need to compose your feature. For instance, if you can’t find the date picker you need for that form, create it, identify the components it requires, search for existing components, and repeat the process. The “base case” for this recursive process is when you reach the most concrete component that answers your current needs. This approach ensures a focused and efficient development process and promotes the reuse of existing components.&lt;/p&gt;

&lt;p&gt;It’s worth noting that components are valuable even when they are not reusable. Concrete, specific components that serve a particular function within a feature or application are equally important. They contribute to the modularity and maintainability of your project, even when they are not reused in other places.&lt;/p&gt;

&lt;p&gt;Furthermore, component development is an iterative process. A component that starts as a concrete, specific solution can evolve into a more reusable asset as needs change and grow. Over time, you may find that what began as a highly specialized component has gained features or attributes that make it applicable in a broader context, thereby naturally transitioning from a concrete to a reusable component.&lt;/p&gt;

&lt;h2&gt;
  
  
  Principle 3: Align component names with business objectives
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AXTwOsNYvdYGdoBni4jqv0Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AXTwOsNYvdYGdoBni4jqv0Q.png" alt="A demo Bit organization working on a developer portfolio site, composed entirely of autonomous components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;An image of a &lt;a href="https://bit.cloud/showoff/~scopes" rel="noopener noreferrer"&gt;demo Bit organization&lt;/a&gt; working on a &lt;a href="https://bit.cloud/showoff/personal-portfolio/apps/portfolio" rel="noopener noreferrer"&gt;developer portfolio site&lt;/a&gt;, composed entirely of autonomous components&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Adopting a business-centric mindset is crucial when constructing, naming, and organizing Bit components. Component names should be descriptive and closely aligned with the specific business needs they address. Similarly, components should be organized into scopes in a manner that reflects their business structure and functionality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AHsyqJjAc_1NjppM-v5QeJA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AHsyqJjAc_1NjppM-v5QeJA.png" alt="The dos and dont's of component naming"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This business-oriented naming convention serves multiple purposes. First, it makes the codebase more accessible to all stakeholders, including non-developers such as designers and product managers. This fosters a more inclusive and efficient collaboration, with an increased feedback loop among all team members.&lt;/p&gt;

&lt;p&gt;Second, properly-named, business-centric components make component dependency graphs easier to understand, which, in turn, makes it easier to refactor code, identify, and resolve bugs.&lt;/p&gt;

&lt;p&gt;Lastly, a business-oriented naming convention makes it easier to find and discover components, which, in turn, promotes component reuse and saves time and resources.&lt;/p&gt;




</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>node</category>
    </item>
    <item>
      <title>Monorepo, Poly-repo, or No Repo at all?</title>
      <dc:creator>Eden Ella</dc:creator>
      <pubDate>Fri, 01 Dec 2023 17:57:05 +0000</pubDate>
      <link>https://dev.to/bitdev_/monorepo-poly-repo-or-no-repo-at-all-4nel</link>
      <guid>https://dev.to/bitdev_/monorepo-poly-repo-or-no-repo-at-all-4nel</guid>
      <description>&lt;p&gt;Should you go for a monorepo or a poly-repo? Should you use a monorepo solution better suited for managing integrated applications or one better suited for managing libraries and publishing packages?&lt;/p&gt;

&lt;p&gt;This blog will explain how &lt;a href="https://bit.dev" rel="noopener noreferrer"&gt;Bit&lt;/a&gt; can be used to implement any architecture and transform “fatal” decisions that seem too hard to change into decisions that are easy to make and change.&lt;/p&gt;

&lt;p&gt;We’ll use the "&lt;a href="https://blog.bitsrc.io/" rel="noopener noreferrer"&gt;Bits and Pieces&lt;/a&gt;" &lt;a href="https://article-submission.netlify.app/" rel="noopener noreferrer"&gt;article submission form&lt;/a&gt; as an example project to demonstrate the different approaches.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://article-submission.netlify.app/" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsymx3vju3cw6unyhl9k0.png" alt="The article submission form app for guest writers"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The article submission form app for guest writers&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The project is a simple React app that allows users to submit articles for publication.&lt;br&gt;
The app is composed of components from a curated design system. The form data is sent to a serverless Lambda function that saves the article to a database.&lt;br&gt;
In a poly-repo approach, we might have a repository for each application, the client and the API, and a repository for the design system. In a monorepo, a single repository will maintain all our libs and apps.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this article, we’ll go from &lt;a href="https://github.com/bitdev-community/bnp-article-submission" rel="noopener noreferrer"&gt;a monorepo handled by Bit&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpv4ib2mdbn8rcdgewznt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpv4ib2mdbn8rcdgewznt.png" alt="the article-submission project as a monorepo handled by Bit"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To a &lt;a href="https://bit.cloud/bits-and-pieces" rel="noopener noreferrer"&gt;fully distributed codebase that consists of independent Bit components&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7mawz0z0pyzcz7123vc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7mawz0z0pyzcz7123vc.png" alt="The “Bits and Pieces” Bit organization. The org’s scopes host the Bit components that compose the ‘article-submission’ project."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bit in repositories
&lt;/h2&gt;

&lt;p&gt;When using &lt;a href="https://bit.dev" rel="noopener noreferrer"&gt;Bit&lt;/a&gt; in a repository, we decide to treat the repository as the source of truth for all our Bit components.&lt;/p&gt;

&lt;p&gt;In this case, we enjoy many of the benefits Bit offers while minimizing the effect Bit has on our development workflow and existing tools.&lt;/p&gt;

&lt;p&gt;We can collaborate using our existing Git workflow and tools to build, test, and deploy our applications and services.&lt;/p&gt;

&lt;p&gt;When used as a monorepo solution, Bit provides intelligent and efficient dependency management, insight into our codebase, efficient incremental builds, and an easy way to publish packages.&lt;/p&gt;

&lt;p&gt;For instance, see &lt;a href="https://github.com/bitdev-community/bnp-article-submission" rel="noopener noreferrer"&gt;this repository that contains the components used in the article submission form&lt;/a&gt;. For simplicity's sake, this example uses only Bit, but remember that Bit can be integrated into any existing repository and used alongside any other monorepo tool.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxb0ftj30a29hxjw5nhqv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxb0ftj30a29hxjw5nhqv.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try out this monorepo example by cloning the repository:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

git clone https://github.com/bitdev-community/bnp-article-submission
cd bnp-article-submission
bit install


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run Bit’s workspace UI to get a visual overview of the components in the project:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

bit start


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5fzqpst6n0427lu7xpj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5fzqpst6n0427lu7xpj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Browse around the components and see how they are connected:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AcI-PYmlm5rq4iNOXPOHeMg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2Fformat%3Awebp%2F1%2AcI-PYmlm5rq4iNOXPOHeMg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Going from monorepo to multi-repo
&lt;/h2&gt;

&lt;p&gt;As you can see, unlike many traditional monorepo solutions, there is no distinction between “apps” and “libs” in this repository. All the components are managed by Bit and are treated as “packages” with the potential to run independently and be deployed as apps.&lt;/p&gt;

&lt;p&gt;The project is composed of components of all levels of complexity. Some components are used in multiple places, and others are only used in one place. All of them are published as packages.&lt;/p&gt;

&lt;p&gt;One of the things that enables this is that all components are consumed via an absolute package name rather than a relative path.&lt;/p&gt;

&lt;p&gt;For example, the &lt;code&gt;article-submission-form&lt;/code&gt; component consumes this schema validator using its package name and not using its relative path in the repo:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;

&lt;span class="cm"&gt;/**
* @filename: article-submission-form.tsx
**/&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ArticleSubmission&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;articleSubmissionScheme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@bits-and-pieces/article-submission.entities.article-submission-scheme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This allows you to move components around the repository without breaking the code that consumes them. More importantly, it allows you to move components between repositories without breaking the code that consumes them.&lt;/p&gt;

&lt;p&gt;For example, say that at a certain point, the publication decides to refactor the project and move some parts of it to separate repositories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;design team&lt;/strong&gt; will handle the 'design system’ components in a separate &lt;a href="https://github.com/bnp-article-submission/design-system" rel="noopener noreferrer"&gt;repository&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;frontend dev team&lt;/strong&gt; will handle the ‘article submission’ client side in a separate &lt;a href="https://github.com/bnp-article-submission/article-submission-client" rel="noopener noreferrer"&gt;repository&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The backend dev team will handle the API for the ‘article submission’ in a separate &lt;a href="https://github.com/bnp-article-submission/article-submission-api" rel="noopener noreferrer"&gt;repository&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffvo4yr7xfbixngwg3qqa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffvo4yr7xfbixngwg3qqa.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The process of moving components between repositories is very simple. All you need to do is export the components you want to move and then import them into the new repository.&lt;/p&gt;

&lt;p&gt;For example, the following commands create a new version of the article-submission-scheme component, export it to a remote hosting (“remote scope”), and stops maintaining it in the current repository (i.e., install it as a regular package instead of symlinking to its source files in the project):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

bit tag article-submission-scheme
bit &lt;span class="nb"&gt;export &lt;/span&gt;article-submission-scheme &lt;span class="nt"&gt;--eject&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8bh1o0jyi4ak59q1r6pu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8bh1o0jyi4ak59q1r6pu.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the new repository, you can import the component using the following command (here, we assume the component was exported to the ‘article-submission’ scope maintained by the ‘bits-and-pieces’ organization):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;cd &lt;/span&gt;article-submission-client 
bit import bits-and-pieces.article-submission/entities/article-submission-scheme


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The component can now be developed and updated in its new repository.&lt;/p&gt;

&lt;p&gt;What about the code that consumes the component in the previous repository?&lt;br&gt;
It will continue to work as before because it still consumes the component via its absolute package name.&lt;/p&gt;

&lt;p&gt;What about the component’s development environment? build setup? tests?&lt;br&gt;
They are all part of a &lt;a href="https://bit.dev/docs/getting-started/composing/dev-environments/" rel="noopener noreferrer"&gt;reusable development environment&lt;/a&gt; configured on the component itself (the env will also be exported to a remote hosting or “scope” if it’s not available there already).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1z5ouetnq3ae4frkf20h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1z5ouetnq3ae4frkf20h.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bit with no repository: entirely distributed
&lt;/h2&gt;

&lt;p&gt;Exporting components to a remote hosting (“scope”) and importing them into a new repository is not limited to just a number of permanent repositories.&lt;/p&gt;

&lt;p&gt;It can be used to collaborate on components without having to maintain a repository at all. In this case, the source of truth for the components is the remote hosting (the “scope”).&lt;/p&gt;

&lt;p&gt;Permissions to modify or use components are managed only in the remote hosting, the ‘remote scopes’.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeiuixckd9tp3hzelqs3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeiuixckd9tp3hzelqs3.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Importing only the components you need into “disposable” Bit workspaces, modifying them, and exporting them back keeps your workspace simple, clean, and understandable.&lt;/p&gt;

&lt;p&gt;This distributed form of collaboration significantly improves your dev experience and makes onboarding new teammates and scaling up, in any sense of the word, smoother and more manageable.&lt;/p&gt;

&lt;h3&gt;
  
  
  What about the CI?
&lt;/h3&gt;

&lt;p&gt;Bit uses Ripple CI as the default CI. Ripple CI is a CI system designed for Bit components.&lt;/p&gt;

&lt;p&gt;Ripple with Bit enables efficient builds that run only on modified components and their dependencies (the affected components). Ripple also builds sibling components in parallel for faster builds.&lt;/p&gt;

&lt;p&gt;Most importantly, since every Bit component is independent and autonomous, its build steps are determined by it (the component) rather than one central (external) place.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3h41b1ia8lp021el1bi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3h41b1ia8lp021el1bi.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned at the beginning of this article, “apps” are not much different than “libs.” Both are Bit components hosted on remote scopes and published as packages.&lt;/p&gt;

&lt;p&gt;That said, “apps” or app components will have additional build tasks responsible for generating deployable assets and then deploying them to the relevant platform.&lt;/p&gt;

&lt;p&gt;One such ‘app component’ is the &lt;code&gt;article-submission-app&lt;/code&gt;. It is a Bit component, much like other components. It can even be installed as a package (build-time micro frontends, anyone?).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnle8srly8sra82ecp2xp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnle8srly8sra82ecp2xp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>monorepo</category>
      <category>react</category>
    </item>
  </channel>
</rss>
