I have set up an Angular application with requireJS. Before deploying, I bundle everything into one and unique file. Usually, external libraries doesn't have a requireJS 'define' wrapper.
For example, the Angular Parallax library is written like this:
# https://github.com/durated/angular-parallax/blob/master/angular-parallax.min.js
angular.module("duParallax",["duScroll","duParallax.directive"...
Here is my main.js:
require.config({
baseUrl: '/angular-dev',
paths: {
angular: '//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min',
angularScroll: 'bower_components/angular-scroll/angular-scroll.min',
angularParallax: 'bower_components/ng-parallax/angular-parallax.min'
},
shim: {
'angular': { exports: 'angular' },
'angularScroll': { deps: ['angular'] },
'angularParallax': { deps: ['angular'] }
}
});
I'm using grunt-contrib-requirejs to then bundle all the libraries (not CDN ones) to one and unique file. This is what I get after bundling everything:
angular.module("duParallax",["duScroll","duParallax.directive"...
define("angularParallax", ["angular"], function(){});
But what I expect is the code to be wrapped within the define:
define("angularParallax", ["angular"], function(){
angular.module("duParallax",["duScroll","duParallax.directive"...
});
How can I achieve the latest without changing the library itself?
Edit: According to this other stackoverflow question, this is how it should work. But I'm also using grunt-contrib-requirejs to bundle my code and that might be the problem.