Skip to content

Commit

Permalink
add poly-decamp require shim
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Dec 2, 2016
1 parent 793d1ee commit c72a9d0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ gulp.task('watch', function() {
var b = browserify({
entries: ['src/module/main.js'],
standalone: 'Matter',
plugin: [watchify]
plugin: [watchify],
transform: ['browserify-shim']
});

var bundle = function() {
Expand Down Expand Up @@ -249,7 +250,7 @@ var build = function(options) {

var compiled = gulp.src(['src/module/main.js'])
.pipe(through2.obj(function(file, enc, next){
browserify(file.path, { standalone: 'Matter' })
browserify(file.path, { standalone: 'Matter', transform: ['browserify-shim'] })
.bundle(function(err, res){
file.contents = res;
next(null, file);
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
],
"devDependencies": {
"browserify": "^12.0.1",
"browserify-shim": "^3.8.12",
"cheerio": "^0.19.0",
"connect-livereload": "^0.5.4",
"event-stream": "^3.3.2",
Expand Down Expand Up @@ -58,5 +59,8 @@
"src",
"build",
"CHANGELOG.md"
]
],
"browserify-shim": {
"poly-decomp": "global:decomp"
}
}
3 changes: 1 addition & 2 deletions src/factory/Bodies.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var Common = require('../core/Common');
var Body = require('../body/Body');
var Bounds = require('../geometry/Bounds');
var Vector = require('../geometry/Vector');
var decomp = require('poly-decomp');

(function() {

Expand Down Expand Up @@ -213,8 +214,6 @@ var Vector = require('../geometry/Vector');
removeCollinear = typeof removeCollinear !== 'undefined' ? removeCollinear : 0.01;
minimumArea = typeof minimumArea !== 'undefined' ? minimumArea : 10;

var decomp = window.decomp;

if (!decomp) {
Common.warn('Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.');
}
Expand Down

0 comments on commit c72a9d0

Please sign in to comment.