diff --git a/Gulpfile.js b/Gulpfile.js index 6921d94..21d75cd 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -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() { @@ -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); diff --git a/package.json b/package.json index ab5cce4..62a0c65 100644 --- a/package.json +++ b/package.json @@ -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", @@ -58,5 +59,8 @@ "src", "build", "CHANGELOG.md" - ] + ], + "browserify-shim": { + "poly-decomp": "global:decomp" + } } diff --git a/src/factory/Bodies.js b/src/factory/Bodies.js index b7e89ae..d384722 100644 --- a/src/factory/Bodies.js +++ b/src/factory/Bodies.js @@ -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() { @@ -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.'); }