npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lumrianjs

v0.0.4

Published

A distributed/decentralized micro frontend engine

Downloads

5

Readme

MondrianJS

A distributed micro frontend engine which helps building application with remote elements (UI / business / logic / app. sub tree / ...etc.). MondrianJS is the microservices architecture but for frontend.

A good analogy would be this Mondrian painting (Discover Piet Mondrian)

Where the black outter frame is your main application that will act as a host and each colored square is a subpart of you app (UI+business) that can be either part of your main bundle or a remotely stored (not part of your core app).

MondrianJS has been designed for ReactJS application but you can also use it with other lib/frameworks.

What can be loaded thru MondrianJS ?

At the moment MondrianJS only supports amd modules format. (cjs and umd are in the roadmap)

Is this a Server Side Rendering approach ?

In a sense, yes. Remote element can be generated on the fly / when requested by your application.

It is like using Iframes in my UI and load remote content.

Not really. Using Iframes implies there is no shared resources between the loaded element. If 2 remotes content used lib. X, then the library will be loaded twice. With MonrianJS approach dependencies, communications, styles are shared and controlled by your main application.

So you are loaded distant code, what about security issues ?

Of course you have to control what your application is executing, but since MondrianJS will provide all the required dependencies you have quite a good control over what your application is doing.

Can I use MondrianJS to do module lazy loading ?

Yep, even if it has been created to distribute a ReactJS application, it also works for plain JS modules.

Does it helps to reduce my bundle size ?

Sure ! but that's not the real goal of MondrianJS. If you want to reduce your bundle and/or reduce your application loading time, you should have a look to code spliting.

What if I need to use several time the same remote element ?

MondrianJS provides a caching system so your remote dependency will be fetched only once.

Seems to be the same as RequireJS !

¯_(ツ)_/¯ Actually I never really used and look at RequireJS implementation.

Ecosystem

Usage

yarn add mondrianjs

real basic usage

import React from 'react';
import {Mondrian} from 'mondrianjs'; 

const mdr = new Mondrian({
    endpoints : [{name:'local', url:'http://127.0.0.1:2601'}],
    depsMap : {"react":React}
  });

mdr.load({identifier:'bundle.js', endpointName:'local'})
.then(comp => console.log('My remote module ', comps))
.catch(err => console.log(err));

API

new Mondrian(config)

Starts the engine and define some settings. config.endpoints : An array that defines a conveniente map of endpoints, and then only use aliases. Format [{name:'xxx', url:'https://aaaaa.zzz.ee'}];

config.depsMap : A map used to resolve remote loaded component depensencies. Format {'import name from the remote module': {The object to inject} }

consfig.verbose : A flag used to get console logs from the engine. Default false.

load(params)

Loads a remote module from an endpoint and returns it thru a Promise params.endpointURL : The base URL where MondrianJS will fetch the module from.

params.endpointName : If the engine is initialized with the endpoints paramater you can simply use an endpoint alias.

params.identifier : Name of the file to load from the endpoint.

params.selector : If the remote module has a multi export, this parameter specify what should be grabed from the module.

prefetch(target)

Preload some remote modules. The target can either be an object or an Array. Target format is the same as the load() params except for the selector. target.endpointURL : The base URL where MondrianJS will fetch the module from.

target.endpointName : If the engine is initialized with the endpoints paramater you can simply use an endpoint alias.

target.identifier : Name of the file to load from the endpoint.

Sample application

see (MondrianJS-React Wrapper) or MondrianJS-ReactAppExample