Skip to content

Commit ad2c968

Browse files
committed
Merge pull request allenhwkim#496 from nkovacic/umd
Added UMD support
2 parents 1146559 + b7adc2a commit ad2c968

File tree

4 files changed

+63
-15
lines changed

4 files changed

+63
-15
lines changed

build/scripts/ng-map.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
/**
1+
(function(root, factory) {
2+
if (typeof exports === "object") {
3+
module.exports = factory(require('angular'));
4+
} else if (typeof define === "function" && define.amd) {
5+
define(['angular'], factory);
6+
} else{
7+
factory(root.angular);
8+
}
9+
}(this, function(angular) {
10+
/**
211
* AngularJS Google Maps Ver. 1.16.8
312
*
413
* The MIT License (MIT)
@@ -3201,3 +3210,7 @@ angular.module('ngMap', []);
32013210

32023211
angular.module('ngMap').service('StreetView', StreetView);
32033212
})();
3213+
3214+
3215+
return 'ngMap';
3216+
}));

build/scripts/ng-map.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
/* jshint node: true */
12
'use strict';
3+
24
var pjson = require('./package.json');
35
var gulp = require('gulp');
46
var concat = require('gulp-concat');
@@ -21,6 +23,7 @@ var path = require('path');
2123
var cheerio = require('cheerio');
2224
var argv = require('yargs').argv;
2325
var replace = require('gulp-replace');
26+
var umd = require('gulp-umd');
2427

2528
var bumpVersion = function(type) {
2629
type = type || 'patch';
@@ -67,22 +70,49 @@ gulp.task('build-js', function() {
6770
.pipe(gulp.dest('build/scripts'))
6871
.pipe(stripDebug())
6972
.pipe(concat('ng-map.js'))
73+
.pipe(umd({
74+
dependencies: function (file) {
75+
return [{
76+
name: 'angular',
77+
amd: 'angular',
78+
cjs: 'angular',
79+
global: 'angular',
80+
param: 'angular'
81+
}];
82+
},
83+
exports: function (file) {
84+
return "'ngMap'";
85+
},
86+
//template: umdTemplates.returnExportsNoNamespace.path,
87+
templateSource: '(function(root, factory) {\r\n' +
88+
'if (typeof exports === "object") {\r\n' +
89+
'module.exports = factory(<%= cjs %>);\r\n' +
90+
'} else if (typeof define === "function" && define.amd) {\r\n' +
91+
'define(<%= amd %>, factory);\r\n' +
92+
'} else{\r\n' +
93+
'factory(<%= global %>);\r\n' +
94+
'}\r\n' +
95+
'}(this, function(<%= param %>) {\r\n' +
96+
'<%= contents %>\r\n' +
97+
'return <%= exports %>;\r\n' +
98+
'}));'
99+
}))
70100
.pipe(gulp.dest('build/scripts'))
71101
.pipe(uglify({preserveComments: license}))
72102
.pipe(rename('ng-map.min.js'))
73103
.pipe(gulp.dest('build/scripts'))
74104
.on('error', gutil.log);
75105
});
76106

77-
gulp.task('docs', function() {
78-
gulp.task('docs', shell.task([
79-
'node_modules/jsdoc/jsdoc.js '+
80-
'-c node_modules/angular-jsdoc/common/conf.json '+ // config file
81-
'-t node_modules/angular-jsdoc/angular-template '+ // template file
82-
'-d build/docs '+ // output directory
83-
'./README.md ' + // to include README.md as index contents
84-
'-r directives services' // source code directory
85-
]));
107+
gulp.task('docs', function() {
108+
shell.task([
109+
path.join('node_module', 'jsdoc', 'jsdoc.js')+
110+
' -c ' + path.join('node_modules','angular-jsdoc', 'common', 'conf.json ') + // config file
111+
' -t ' + path.join('node_modules', 'angular-jsdoc', 'angular-template') + // template file
112+
' -d ' + path.join('build', 'docs') + // output directory
113+
' ' + path.join('./README.md') + // to include README.md as index contents
114+
' -r directives services' // source code directory
115+
]);
86116
});
87117

88118
gulp.task('bump', function() { bumpVersion('patch'); });
@@ -156,5 +186,4 @@ gulp.task('examples:json', function() {
156186
}
157187
))
158188
.pipe(gulp.dest('testapp'));
159-
});
160-
189+
});

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
"name": "ngmap",
33
"version": "1.16.8",
44
"main": "build/scripts/ng-map.js",
5+
"description": "The Simplest AngularJS Google Maps V3 Directive",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/allenhwkim/angularjs-google-maps.git"
9+
},
510
"dependencies": {},
611
"engines": {
712
"node": ">=0.8.0"
@@ -30,10 +35,11 @@
3035
"gulp-strip-debug": "~0.3.0",
3136
"gulp-tap": "~0.1.1",
3237
"gulp-uglify": "~0.3.0",
38+
"gulp-umd": "~0.2",
3339
"gulp-usemin": "^0.3.15",
3440
"gulp-util": "~2.2.16",
3541
"jsdoc": "^3.3.0-beta3",
36-
"karma": "0.13.15",
42+
"karma": "~0.13",
3743
"karma-chrome-launcher": "0.2.1",
3844
"karma-jasmine": "0.2.2",
3945
"karma-ng-html2js-preprocessor": "0.2.0",

0 commit comments

Comments
 (0)