Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
  dist
  src
  CHANGELOG.md
  README.md
  package.json
  tsconfig.json
Size: Mime:
  README.md

loadable

high level flow is:

  • we wrap each import('path') in a loadable function (because as soon as import() is called, the file starts loading)
  • the result of an import('path') is a promise
  • we pass each loadable into a () => class LoadableComponent
  • the LoadableComponent will be included in the main chunk, but only starts loading the loadable function during componentWillMount
  • a high level example for this flow is as follows:
const loadable = (loadComponent) => class extends React.PureComponent {
  state = { Component: undefined }
  async componentWillMount() {
    this.setState({ Component: await loadComponent() })
  }
  render() {
    return <scoped.Component {...this.props} />
  }
}

export const Eh = loadable(() =>
  import(/* webpackChunkName: "Eh.page" */ '../../views/pages/Eh')
)