MadeInHaus / react-starter

A client-side SPA starter bundled with React, Redux, CSS Modules, React Router 4, and Webpack 4
MIT License
9 stars 2 forks source link

Issue #6 - Code Splitting #8

Closed chrisjcodes closed 7 years ago

chrisjcodes commented 7 years ago

This branch addresses 2 things: code splitting and caching bundles.

The Bundle component can be used to wrap any component or component tree and dynamically requires its dependacy at runtime. You can use either () => import() or require('bundle!./myDep.js') as the loadfunction. Once its completed Bundle will render the component tree with the dependency injected.

This branch also implements webpack's recommended caching for bundles. In dev hashes are updated every bundle. In production only the chunks that have changed will have their chunkhash updated which will cache bust the old bundle and keep the cache for unchanged modules