Skip to content

Commit

Permalink
Improve non require shim approach
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed Feb 10, 2015
1 parent 2a7dad4 commit b122018
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#### TODO

* investigate a better solution for the browserify web shim
* release to npm

------------
Expand Down
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/usr/bin/env bash

rm dist/build.js

./node_modules/.bin/browserify src/index.js \
--standalone Module \
--external backbone \
--external backbone.marionette \
--external underscore \
-o dist/build.js
| ./node_modules/.bin/global-lookup-shim \
--global-shim underscore:_ \
--global-shim backbone:Backbone \
--global-shim backbone.marionette:Marionette \
> dist/build.js
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dependencies": {
"backbone": "^1.1.2",
"backbone.marionette": "^2.3.2",
"underscore": "^1.7.0"
"underscore": "^1.7.0",
"global-lookup-shim": "~0.1.0"
}
}
4 changes: 2 additions & 2 deletions src/callbacks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var _ = (window && window._) || require('underscore'),
Backbone = (window && window.Backbone) || require('backbone');
var _ = require('underscore'),
Backbone = require('backbone');

// Callbacks
// ---------
Expand Down
7 changes: 3 additions & 4 deletions src/module.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
var _ = (window && window._) || require('underscore'),
Backbone = (window && window.Backbone) || require('backbone'),
var _ = require('underscore'),
Backbone = require('backbone'),
Callbacks = require('./callbacks'),
Marionette = (window && window.Backbone && window.Backbone.Marionette) || require('backbone.marionette');

Marionette = require('backbone.marionette');
/* jshint maxparams: 9 */

// Module
Expand Down
2 changes: 1 addition & 1 deletion src/shim.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Module = require('./module'),
_ = (window && window._) || require('underscore');
_ = require('underscore');

module.exports = function(Mn) {
Mn.Application.prototype.module = function(moduleNames, moduleDefinition) {
Expand Down
2 changes: 0 additions & 2 deletions test/module.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
global.window = null;

var sinon = require('sinon');
var sinonChai = require('sinon-chai');
var chaiJq = require('chai-jq');
Expand Down
2 changes: 0 additions & 2 deletions test/module.stop.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
global.window = null;

var sinon = require('sinon');
var sinonChai = require('sinon-chai');
var chaiJq = require('chai-jq');
Expand Down
2 changes: 0 additions & 2 deletions test/shim.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
global.window = null;

var shim = require('../src');
var chai = require('chai');
expect = chai.expect;
Expand Down

0 comments on commit b122018

Please sign in to comment.