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

async-bundle

v0.0.8

Published

Asynchronous code splitting for React, Redux and Redux-Saga

Downloads

3

Readme

async-bundle

npm version npm

Code splitting for React, Redux and Redux-Saga. Based on React Router 4 and React Boilerplate.

async-bundle helps you scale your application and improve load time by providing an easy way to split your code into various bundles, which can then be loaded in on demand. Giving you complete flexibility in the way that you load in your async modules. Not just with regards to the import tools you can use, but also how you structure your code within your application.

Features

Code Splitting - Easily split your application into dynamically loaded chunks, using either ES6 Imports or Webpack's Bundle Loader

Inject asynchronously loaded reducers - Split your store's state into easily maintainable chunks, loading only what you need for each route.

Inject asynchronously loaded redux-sagas - Dynamically load your saga's as and when you need them

Getting started

Install

$ npm install async-bundle --save

or

$ yarn add async-bundle

Parameters

async-bundle load prop accepts:

  • comp - view component import using specified async imports
  • reducer - redux reducer
  • sagas - array of generators

Array:

/**
 * load property as array (order must be as specified)
 */
<Bundle load={[
    yourImportedComponent,
    reducer,
    sagas
]}

Object:

/**
 * load property as object passing in correctly names keys
 */
<Bundle load={{
    comp,
    reducer,
    sagas
}}

Usage Example

async-bundle provides several ways to split up your code and asynchronously load in your modules. The easiest way is by passing your imports to the load prop of the bundle.

Once the Bundle resolves your imported component it updates the state internally and renders the component.

You can use either the component or render props of React's Route component. Please refer to the React Router docs for further information.

import React from 'react';
import Home from 'bundle-loader?lazy!./Home';
import { AsyncRoute, AsyncBundle } from 'async-bundle';
import { Route } from 'react-router-dom';

// Initialise your Bundle
const Bundle = AsyncBundle();
// Initialise your Bundle using AsyncRoute, a higher order component for AsyncBundle
const RouteBundle = AsyncRoute();

class App extends React.Component {
    // Component code
    render() {
        return (
            <div>
                <h1>Welcome!</h1>
                // load component using bundle-loader
                <Route path="/" component={() => <Bundle load={[Home]} />} />
                // load component using babel-import
                <Route path="/dashboard" component={() => <Bundle load={[import('./Dashboard')]} />} />
                // load component using bundle-loader
                // pass in RouteBundle directly without having to define a function
                <Route path="/about" component={RouteBundle({comp: import('./about')})} />
            </div>
        )
    }
}

Documentation

Issues

If you find a bug, please file an issue on the issue tracker on GitHub.

Contribution

Please feel free to contribute or provide improvements.