From 542a66da21bf8b1144cb71dc783712837895a069 Mon Sep 17 00:00:00 2001 From: Will Binns-Smith Date: Sun, 20 Apr 2014 21:57:51 -0400 Subject: [PATCH] Add a umd wrapper for commonjs and amd support --- Gruntfile.js | 7 +++++++ package.json | 2 ++ src/echo.js | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9348e85..e83e1e8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -54,6 +54,12 @@ module.exports = function (grunt) { banner: '<%= tag.banner %>' } }, + umd: { + dist: { + src: 'dist/<%= project.name %>.js', + objectToExport: 'echo' + } + }, uglify: { files: { src: ['dist/<%= project.name %>.js'], @@ -88,6 +94,7 @@ module.exports = function (grunt) { grunt.registerTask('default' , [ 'jshint', 'concat:dist', + 'umd:dist', 'uglify', // 'connect:livereload', // 'open', diff --git a/package.json b/package.json index acd1c32..ac0e466 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "Echo", "version": "1.5.0", + "main": "dist/echo.js", "homepage": "https://github.com/toddmotto/echo", "author": "Todd Motto", "description": "Lazy-loading with data-* attributes, offset and throttle options", @@ -26,6 +27,7 @@ "grunt-contrib-watch": "~0.4.4", "connect-livereload": "~0.2.0", "grunt-open": "~0.2.0", + "grunt-umd": "^1.7.3", "matchdep": "~0.1.2" }, "peerDependencies": { diff --git a/src/echo.js b/src/echo.js index 3399e13..17dde3d 100644 --- a/src/echo.js +++ b/src/echo.js @@ -1,4 +1,5 @@ -window.Echo = (function (global, document, undefined) { +/* exported echo */ +var echo = (function (global, document, undefined) { 'use strict';