This repo contains a bare-bones example of how to create an application using Rollup, with code-splitting and dynamic imports.
Clone this repository and install its dependencies:
git clone https://github.com/rollup/rollup-starter-code-splitting cd rollup-starter-code-splitting npm install
npm run build to create two versions of the app, as defined in rollup.config.js:
public/nomodulecontains SystemJS modules, for legacy browsers
public/index.html file contains two sets of
<script> tags, one for each version.
Notice that the seven modules in our
src folder have been optimised into four modules — two for the 'entry points', and two more for code that is shared by multiple entry points or is loaded dynamically. Rollup will automatically create chunks in such a way that no code is duplicated between them.
npm run build builds the application, along with sourcemap files for debugging.