Built aura project reloading modules twice with requirejs

247 views Asked by At

I have an aura.js project which as part of the documentation, to load extensions you specify the path with require js. Here is an example of an extension:

define ["pace"], ($) ->
  (app) ->
    require:
      paths:
        morris: 'bower_components/morris.js/morris'
        raphael: 'bower_components/raphael/raphael'
      shim:
        morris:
          deps: ['jquery','raphael']
    initialize: (app) ->
      Morris = require "morris"
      Pace = require "pace"
      Pace.start()

My issue is that after I build the project and include all the dependencies into app.js which is the entry point for require, I can see the network requests and the app.js file is loaded but then require continues to pull down all the unoptimized modules (i.e. bower_components/morris.js/morris).

This results in a double request for each module which of course is unnecessary. Ideas?

1

There are 1 answers

0
imrane On BEST ANSWER

The build file had an error in it as the moment-range library couldn't find moment to attach itself to.

As a result, it was blowing out of the loading of the app.js file and forcing require to use the unoptimized versions of the libraries.