Skip to content

Commit c72a9d0

Browse files
committed
add poly-decamp require shim
1 parent 793d1ee commit c72a9d0

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

Gulpfile.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ gulp.task('watch', function() {
105105
var b = browserify({
106106
entries: ['src/module/main.js'],
107107
standalone: 'Matter',
108-
plugin: [watchify]
108+
plugin: [watchify],
109+
transform: ['browserify-shim']
109110
});
110111

111112
var bundle = function() {
@@ -249,7 +250,7 @@ var build = function(options) {
249250

250251
var compiled = gulp.src(['src/module/main.js'])
251252
.pipe(through2.obj(function(file, enc, next){
252-
browserify(file.path, { standalone: 'Matter' })
253+
browserify(file.path, { standalone: 'Matter', transform: ['browserify-shim'] })
253254
.bundle(function(err, res){
254255
file.contents = res;
255256
next(null, file);

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
],
2222
"devDependencies": {
2323
"browserify": "^12.0.1",
24+
"browserify-shim": "^3.8.12",
2425
"cheerio": "^0.19.0",
2526
"connect-livereload": "^0.5.4",
2627
"event-stream": "^3.3.2",
@@ -58,5 +59,8 @@
5859
"src",
5960
"build",
6061
"CHANGELOG.md"
61-
]
62+
],
63+
"browserify-shim": {
64+
"poly-decomp": "global:decomp"
65+
}
6266
}

src/factory/Bodies.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var Common = require('../core/Common');
1818
var Body = require('../body/Body');
1919
var Bounds = require('../geometry/Bounds');
2020
var Vector = require('../geometry/Vector');
21+
var decomp = require('poly-decomp');
2122

2223
(function() {
2324

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

216-
var decomp = window.decomp;
217-
218217
if (!decomp) {
219218
Common.warn('Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.');
220219
}

0 commit comments

Comments
 (0)