/MimosaDynamicRequire

Example code for using dynamic requires and using mimosa to create dynamic builds.

Primary LanguageCoffeeScript

MimosaDynamicRequire

This example Mimosa app shows how to configure Mimosa to build dynamic module require.js applications.

The app has 4 modules.

  1. A common module containing common code
  2. A main1 module that waits 5 seconds before dynamically requiring main2
  3. A main2 module that waits 5 seconds before dynamically requiring main3
  4. A main3 module.

How to Install

  1. npm install -g mimosa, version 1.0.0-rc.6 or higher is needed.
  2. git clone https://github.com/dbashford/MimosaDynamicRequire
  3. cd MimosaDynamicRequire
  4. mimosa watch -s
  5. Navigate to https://localhost:3000

Keep an eye on your browsers "Net" panel and watch require.js dynamically pull in each module as time passes.

Now, shut down the server.

  1. mimosa watch -som
  2. Navigate to https://localhost:3000 when the build finishes.

Nothing changes from a UI perspective, but now the application has been r.js optimized into the 4 dynamic modules with no code duplication between those modules.