Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add unwrap to babysitter and wreqr to remove UMDs
  • Loading branch information
jamiebuilds committed May 7, 2014
1 parent 85ace68 commit 2a938da
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 15 deletions.
56 changes: 42 additions & 14 deletions Gruntfile.js
@@ -1,3 +1,6 @@
var path = require('path');
var unwrap = require('unwrap');

module.exports = function(grunt) {

require('load-grunt-tasks')(grunt, {
Expand Down Expand Up @@ -41,7 +44,7 @@ module.exports = function(grunt) {

clean: {
lib: 'lib',
tmp: 'tmp'
tmp: 'tmp'
},

preprocess: {
Expand All @@ -53,8 +56,8 @@ module.exports = function(grunt) {
src: 'src/build/amd.core.js',
dest: 'tmp/backbone.marionette.amd.js'
},
tmp: {
src: '<%= preprocess.core_build.src %>',
bundle: {
src: 'src/build/marionette.bundle.js',
dest: 'tmp/backbone.marionette.js'
}
},
Expand All @@ -64,18 +67,14 @@ module.exports = function(grunt) {
banner: "<%= meta.core_banner %>"
},
core: {
src: '<%= preprocess.tmp.dest %>',
src: '<%= preprocess.bundle.dest %>',
dest: 'lib/core/backbone.marionette.js'
},
bundle: {
options: {
banner: "<%= meta.banner %>"
},
src: [
'<%= assets.babysitter %>',
'<%= assets.wreqr %>',
'<%= preprocess.tmp.dest %>',
],
src: '<%= preprocess.bundle.dest %>',
dest: 'lib/backbone.marionette.js'
},
amd: {
Expand Down Expand Up @@ -133,7 +132,7 @@ module.exports = function(grunt) {
},
marionette : {
src : [
'<%= preprocess.tmp.dest %>',
'<%= preprocess.bundle.dest %>',
'spec/javascripts/support/marionette.support.js'
],
}
Expand Down Expand Up @@ -174,7 +173,7 @@ module.exports = function(grunt) {
}
}
},

lintspaces: {
all: {
src: [
Expand All @@ -185,17 +184,46 @@ module.exports = function(grunt) {
editorconfig: '.editorconfig'
}
}
},

unwrap: {
babysitter: {
src: './bower_components/backbone.babysitter/lib/backbone.babysitter.js',
dest: './tmp/backbone.babysitter.bare.js'
},
wreqr: {
src: './bower_components/backbone.wreqr/lib/backbone.wreqr.js',
dest: './tmp/backbone.wreqr.bare.js'
}
}
});

grunt.registerMultiTask('unwrap', 'Unwrap UMD', function () {
var done = this.async();
var timesLeft = 0;

this.files.forEach(function (file) {
file.src.forEach(function (src) {
timesLeft++;
unwrap(path.resolve(__dirname, src), function (err, content) {
if (err) return grunt.log.error(err);
grunt.file.write(path.resolve(__dirname, file.dest), content);
grunt.log.ok(file.dest + ' created.');
timesLeft--;
if (timesLeft <= 0) done();
});
});
});
});

grunt.registerTask('default', 'An alias task for running tests.', ['test']);

grunt.registerTask('lint', 'Lints our sources', ['lintspaces', 'jshint']);

grunt.registerTask('test', 'Run the unit tests.', ['lint', 'preprocess:tmp', 'jasmine:marionette', 'clean:tmp']);
grunt.registerTask('test', 'Run the unit tests.', ['lint', 'unwrap', 'preprocess:bundle', 'jasmine:marionette', 'clean:tmp']);

grunt.registerTask('dev', 'Auto-lints while writing code.', ['lint', 'preprocess:tmp', 'jasmine:marionette', 'watch:marionette']);
grunt.registerTask('dev', 'Auto-lints while writing code.', ['lint', 'unwrap', 'preprocess:bundle', 'jasmine:marionette', 'watch:marionette']);

grunt.registerTask('build', 'Build all three versions of the library.', ['clean:lib', 'lint', 'preprocess', 'jasmine:marionette', 'concat', 'uglify', 'clean:tmp']);
grunt.registerTask('build', 'Build all three versions of the library.', ['clean:lib', 'lint', 'unwrap', 'preprocess', 'jasmine:marionette', 'concat', 'uglify', 'clean:tmp']);

};
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -60,6 +60,7 @@
"bower": "1.2.8",
"grunt-cli": "0.1.13",
"grunt-contrib-clean": "~0.5.0",
"grunt-preprocess": "~4.0.0"
"grunt-preprocess": "~4.0.0",
"unwrap": "^0.1.0"
}
}
42 changes: 42 additions & 0 deletions src/build/marionette.bundle.js
@@ -0,0 +1,42 @@
var Marionette = (function(global, Backbone, _){
"use strict";

// @include ../../tmp/backbone.babysitter.bare.js
// @include ../../tmp/backbone.wreqr.bare.js

// Define and export the Marionette namespace
var Marionette = {};
Backbone.Marionette = Marionette;

// Get the DOM manipulator for later use
Marionette.$ = Backbone.$;

// @include ../marionette.helpers.js
// @include ../marionette.triggermethod.js
// @include ../marionette.domRefresh.js

// @include ../marionette.bindEntityEvents.js

// @include ../marionette.callbacks.js
// @include ../marionette.controller.js
// @include ../marionette.region.js
// @include ../marionette.regionManager.js

// @include ../marionette.templatecache.js
// @include ../marionette.renderer.js

// @include ../marionette.view.js
// @include ../marionette.itemview.js
// @include ../marionette.collectionview.js
// @include ../marionette.compositeview.js
// @include ../marionette.layout.js

// @include ../marionette.behavior.js
// @include ../marionette.behaviors.js

// @include ../marionette.approuter.js
// @include ../marionette.application.js
// @include ../marionette.module.js

return Marionette;
})(this, Backbone, _);

0 comments on commit 2a938da

Please sign in to comment.