https://github.com/aquaveo/mfe-ol

Micro Front End for an open Layers Map

https://github.com/aquaveo/mfe-ol

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.2%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Micro Front End for an open Layers Map

Basic Info
  • Host: GitHub
  • Owner: Aquaveo
  • Language: JavaScript
  • Default Branch: main
  • Size: 231 KB
Statistics
  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 1 year ago · Last pushed over 1 year ago
Metadata Files
Readme

README.md

version min size mingzip size license

dependancies downloads

code of conduct

stargazers number of forks

:heart: to auto badger for making badging simple

MFE-OL (MicroFrontEnd Module for Open Layers)

The following is a react component that serves as the UI for the map plugin from the nwms-plugins for the tethysDash application.

Getting Started

The following npm package exports a remote entry point using the ModuleFederationPlugin feature on webpack. This can be use as an example for an npm package that accompanies a python plugin for the tethysdash app

Configuration

The following is the structure of this project:

``` ├── package.json ├── package-lock.json ├── public │   ├── index.html │   └── robots.txt ├── README.md ├── src │   ├── App.js │   ├── App.test.js │   ├── index.css │   └── index.js ├── structure.txt └── webpack.config.js

3 directories, 11 files ```

The following is added to the webpack.config.js file:

js .... new ModuleFederationPlugin({ name: 'mfe_ol', filename: 'remoteEntry.js', exposes: { './MapComponent': './src/App', // Adjusted path to exposed module }, shared: { 'react': { singleton: true, requiredVersion: '^18.3.1', eager: true, }, 'react-dom': { singleton: true, requiredVersion: '^18.3.1', eager: true, }, }, }), new HtmlWebpackPlugin({ template: './public/index.html' }) ....

Similarly, please note that the filename can be any name. It refers to the name of the entrypoint file.

Please note that the exposes section will be the component that you will like to expose through the entrypoint. The expose section exposes the MapComponent that is imported in the App.js file.

Finally, you need to edit the package.json to expose the entrypoint as well

json "exports": { ".": "./dist/bundle.js", "./remoteEntry": "./dist/remoteEntry.js" },

the "." is the main bundle, while the "./remoteEntry" refers to the entrypoint that will be used by the Tethysdash app.

Use

When the package is ready to use, you need to build it and publish it.

bash $ npm run build $ npm publish

Once published you can access the remoteEntry.js file on your TethysDash intake driver plugin in the following way:

```python def init(self, basemaplayer, zoom, services, hucid, metadata=None): # self.mfeunpkgurl = "http://localhost:3000/remoteEntry.js" # if you are developing self.mfeunpkgurl = "https://unpkg.com/mfe-ol@latest/dist/remoteEntry.js" self.mfescope = "mfeol" self.mfemodule = "./Map" self.zoom = zoom self.hucid = hucid parts = services.split("/") self.service = parts[-3] self.layerid = int(parts[-1]) self.BASEURL = "/".join(parts[:-3]) self.basemaplayer = self.getesribaselayerdict(basemaplayer) self.servicelayer = self.getservicelayerdict() self.center = self.getcenter() self.view = self.getviewconfig(center=self.center, zoom=self.zoom) self.mapconfig = self.getmapconfig() self.legend = self.makelegend() self.HUCLAYER = self.getwbdlayer()

    super(MapVisualization, self).__init__(metadata=metadata)

def read(self):
    logger.info("Reading map data configuration")
    layers = [self.base_map_layer, self.HUC_LAYER, self.service_layer]
    return {
        "url": self.mfe_unpkg_url,
        "scope": self.mfe_scope,
        "module": self.mfe_module,
        "props": {
            "layers": layers,
            "viewConfig": self.view,
            "mapConfig": self.map_config,
            "legend": self.legend,
        },
    }

```

TroubleShooting

Common Errors

Webpack not loading the shared module on the ModuleFederation plugin

bash _Uncaught Error: Shared module is not available for eager consumption: webpack/sharing/consume/default/react/react_

Links

Some Useful Examples

Owner

  • Name: Aquaveo
  • Login: Aquaveo
  • Kind: organization
  • Email: it@aquaveo.com
  • Location: Provo

GitHub Events

Total
  • Member event: 1
  • Push event: 17
  • Create event: 3
Last Year
  • Member event: 1
  • Push event: 17
  • Create event: 3

Dependencies

package-lock.json npm
  • 1366 dependencies
package.json npm
  • @babel/core ^7.25.9 development
  • @babel/preset-env ^7.25.9 development
  • @babel/preset-react ^7.25.9 development
  • babel-loader ^9.2.1 development
  • css-loader ^7.1.2 development
  • dotenv-webpack ^8.1.0 development
  • html-webpack-plugin ^5.6.3 development
  • sass-loader ^16.0.2 development
  • style-loader ^4.0.0 development
  • webpack ^5.95.0 development
  • webpack-cli ^5.1.4 development
  • webpack-dev-server ^5.1.0 development
  • - ^0.0.1
  • @testing-library/jest-dom ^5.17.0
  • @testing-library/react ^13.4.0
  • @testing-library/user-event ^13.5.0
  • ol ^10.2.1
  • react ^18.3.1
  • react-dom ^18.3.1
  • react-icons ^5.3.0
  • react-scripts 5.0.1
  • save-dev ^0.0.1-security
  • styled-components ^6.1.13
  • web-vitals ^2.1.4
  • workbox-background-sync ^6.6.0
  • workbox-broadcast-update ^6.6.0
  • workbox-cacheable-response ^6.6.0
  • workbox-core ^6.6.0
  • workbox-expiration ^6.6.0
  • workbox-google-analytics ^6.6.1
  • workbox-navigation-preload ^6.6.0
  • workbox-precaching ^6.6.0
  • workbox-range-requests ^6.6.0
  • workbox-routing ^6.6.0
  • workbox-strategies ^6.6.0
  • workbox-streams ^6.6.0