aurajs / aura

A scalable, event-driven JavaScript architecture for developing component-based applications.
MIT License
2.94k stars 255 forks source link

Generate source maps on build #324

Open VirtueMe opened 11 years ago

VirtueMe commented 11 years ago

Source maps are the new big thing. Requirejs has support for source maps and Aurajs should maybe utilize this. The documentation shows how simple it is to add the feature. I don't know if it has any implications on the build, but it seemed to generated the source maps just fine when I added the needed configuration element.

To utilize this we only need to add the following highlighted line to the requirejs section in the grunt file.

options: { baseUrl: '.', optimize: 'uglify2', preserveLicenseComments: false, generateSourceMaps: true,

It might need some testing in a browser to see if it works as intended.

mprinc commented 11 years ago

I surely support that as default! :) +1

VirtueMe commented 11 years ago

I have now tested this, and it seems to work well. I was able to add breakpoints in the code and look at the inner workings of Aurajs even when I was using the minified version.

Howto: I installed first Aurajs with the command bower install aura. Afterwards I executed the commands npm install && bower install --save && grunt build in the bower_components/aura folder. In my require config I added paths: { aura: 'bower_components/aura/dist' } before I ran my example.

This is how chrome sees the minified file after I added source maps to it.

Image showing the result when using minified aurajs

I ran this example with grunt-contrib-jasmine and grunt-template-jasmine-requirejs using the following configuration.

    jasmine: {
      lpapi: {
        options: {
          specs: 'spec/lpapi/**/*_spec.js',
          helpers: ['spec/libs/sinon-1.5.2.js', 'spec/libs/jasmine-sinon.js'],
          keepRunner: true,
          template: require('grunt-template-jasmine-requirejs'),
          templateOptions: {
            mainConfigFile: 'lib/config.js',
            requireConfig: {
              baseUrl: 'lib/',
              paths: {
                'jquerylib': '../bower_components/jquery/jquery',
                'underscorelib': '../bower_components/underscore/underscore',
                'textlib': '../bower_components/requirejs-text/text',
                'aura': '../bower_components/aura/dist/'
              },
              shim: {
                'jquerylib': {
                  exports: '$'
                },
                'underscorelib': {
                  exports: '_',
                }
              },
              map: {
                '*': {
                  'underscore': 'underscorelib',
                  'jquery': 'jquerylib',
                  'text': 'textlib'
                }
              }
            }
          }
        }
      }
    },