Starter project with code-splitting and dynamic imports, for modern and legacy browsers
Clone or download
keqingrong and lukastaegert Remove `experimentalCodeSplitting` option (#14)
`experimentalCodeSplitting` has been removed in rollup v1.
Latest commit 2097d2d Jan 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
public upgrade to SystemJS 2.0.0 stable Oct 1, 2018
src initial commit Feb 8, 2018
.gitignore Add module/nomodule folders to gitignore Aug 24, 2018
LICENSE initial commit Feb 8, 2018
README.md initial commit Feb 8, 2018
package.json chore: update dependencies Jan 1, 2019
rollup.config.js Remove `experimentalCodeSplitting` option (#14) Jan 4, 2019
yarn.lock Update dependencies Aug 24, 2018

README.md

rollup-starter-code-splitting

This repo contains a bare-bones example of how to create an application using Rollup, with code-splitting and dynamic imports.

Getting started

Clone this repository and install its dependencies:

git clone https://github.com/rollup/rollup-starter-code-splitting
cd rollup-starter-code-splitting
npm install

Run npm run build to create two versions of the app, as defined in rollup.config.js:

  • public/module contains native JavaScript modules, for browsers that support them
  • public/nomodule contains SystemJS modules, for legacy browsers

The 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.

Because it outputs native JavaScript modules, there is zero bundler overhead when targeting modern browsers.

Building and serving

npm run build builds the application, along with sourcemap files for debugging.

npm start launches a server, using serve. Navigate to localhost:5000.

License

MIT.