From 65dff0b676dbe43ca7d7562a3c24ae051749018e Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Tue, 17 Jun 2014 17:43:28 +0200 Subject: [PATCH] Fix for AMD when using concatenated file; fixes #13812 --- Gruntfile.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 922daf5e4d91..bd8f5a1feaea 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -34,6 +34,10 @@ module.exports = function (grunt) { ' */\n', // NOTE: This jqueryCheck code is duplicated in customizer.js; if making changes here, be sure to update the other copy too. jqueryCheck: 'if (typeof define == \'undefined\' && typeof exports == \'undefined\' && typeof jQuery == \'undefined\') { throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\') }\n\n', + umdWrap: '(function (o_o) {\n' + + ' typeof define == \'function\' && define.amd ? define([\'jquery\'], o_o) :\n' + + ' typeof exports == \'object\' ? o_o(require(\'jquery\')) : o_o(jQuery)\n' + + '})(function ($) {\n\n', // Task configuration. clean: { @@ -87,8 +91,21 @@ module.exports = function (grunt) { concat: { options: { - banner: '<%= banner %>\n<%= jqueryCheck %>', - stripBanners: false + banner: '<%= banner %>\n<%= jqueryCheck %>\n<%= umdWrap %>', + footer: '});\n', + stripBanners: false, + process: function (src) { + var umd = '\n\n' + + ' (function (o_o) {\n' + + ' typeof define == \'function\' && define.amd ? define([\'jquery\'], o_o) :\n' + + ' typeof exports == \'object\' ? o_o(require(\'jquery\')) : o_o(jQuery)\n' + + ' })(function ($) {' + + var footer = ' })\n\n' + + '}();\n' + + return src.replace(umd, '').replace(footer, '}();\n') + } }, bootstrap: { src: [