Skip to content

Commit 00251e5

Browse files
committed
use browserify
1 parent bc26469 commit 00251e5

34 files changed

Lines changed: 256 additions & 128 deletions

Gruntfile.js

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,11 @@ module.exports = function(grunt) {
44
buildName: 'matter',
55
buildVersion: 'edge-master',
66
docVersion: 'v<%= pkg.version %>',
7-
concat: {
8-
build: {
9-
options: {
10-
process: function(src, filepath) {
11-
return '// Begin ' + filepath + '\n\n' + src + '\n\n; // End ' + filepath + '\n\n';
12-
}
13-
},
14-
src: ['src/**/*.js', '!src/module/*'],
15-
dest: 'build/<%= buildName %>.js'
7+
browserify: {
8+
options: {
9+
banner: '/**\n* <%= buildName %>.js <%= buildVersion %> <%= grunt.template.today("yyyy-mm-dd") %>\n* <%= pkg.homepage %>\n* License: <%= pkg.license %>\n*/\n\n',
1610
},
17-
pack: {
18-
options: {
19-
banner: '/**\n* <%= buildName %>.js <%= buildVersion %> <%= grunt.template.today("yyyy-mm-dd") %>\n* <%= pkg.homepage %>\n* License: <%= pkg.license %>\n*/\n\n'
20-
},
21-
src: ['src/module/Intro.js', 'build/<%= buildName %>.js', 'src/module/Outro.js'],
22-
dest: 'build/<%= buildName %>.js'
23-
}
11+
'build/<%= buildName %>.js': ['src/module/main.js']
2412
},
2513
uglify: {
2614
min: {
@@ -49,9 +37,9 @@ module.exports = function(grunt) {
4937
},
5038
copy: {
5139
demo: {
52-
src: 'build/<%= buildName %>.js',
53-
dest: 'demo/js/lib/<%= buildName %>.js'
54-
}
40+
src: 'build/<%= buildName %>.js',
41+
dest: 'demo/js/lib/<%= buildName %>.js'
42+
}
5543
},
5644
jshint: {
5745
options: {
@@ -110,7 +98,7 @@ module.exports = function(grunt) {
11098
}
11199
});
112100

113-
grunt.loadNpmTasks('grunt-contrib-concat');
101+
grunt.loadNpmTasks('grunt-browserify');
114102
grunt.loadNpmTasks('grunt-contrib-uglify');
115103
grunt.loadNpmTasks('grunt-contrib-connect');
116104
grunt.loadNpmTasks('grunt-contrib-watch');
@@ -134,20 +122,20 @@ module.exports = function(grunt) {
134122
if (isDev) {
135123
grunt.config.set('buildName', 'matter-dev');
136124
grunt.config.set('buildVersion', pkg.version + '-dev');
137-
grunt.task.run('concat', 'uglify:dev', 'uglify:min', 'copy');
125+
grunt.task.run('browserify', 'uglify:dev', 'uglify:min', 'copy');
138126
}
139127

140128
// release build mode
141129
if (isRelease) {
142130
grunt.config.set('buildName', 'matter-' + pkg.version);
143131
grunt.config.set('buildVersion', pkg.version + '-alpha');
144-
grunt.task.run('concat', 'uglify:min', 'copy');
132+
grunt.task.run('browserify', 'uglify:min', 'copy');
145133
}
146134

147135
// edge build mode (default)
148136
if (isEdge || (!isDev && !isRelease)) {
149137
grunt.config.set('buildVersion', 'edge-master');
150-
grunt.task.run('concat', 'preprocess', 'uglify:min');
138+
grunt.task.run('browserify', 'preprocess', 'uglify:min');
151139
}
152140
});
153141

@@ -158,11 +146,11 @@ module.exports = function(grunt) {
158146

159147
if (isEdge)
160148
grunt.config.set('docVersion', 'edge version (master)');
161-
149+
162150
grunt.task.run('yuidoc');
163151
});
164152

165153
grunt.registerTask('set_config', 'Set a config property.', function(name, val) {
166154
grunt.config.set(name, val);
167155
});
168-
};
156+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
],
2222
"devDependencies": {
2323
"grunt": "~0.4.2",
24-
"grunt-contrib-concat": "~0.3.0",
24+
"grunt-browserify": "~3.7.0",
2525
"grunt-contrib-connect": "~0.6.0",
2626
"grunt-contrib-copy": "~0.5.0",
2727
"grunt-contrib-jshint": "~0.6.3",

src/body/Body.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
var Vertices = require('../geometry/Vertices');
2+
var Vector = require('../geometry/Vector');
3+
var Sleeping = require('../core/Sleeping');
4+
var Render = require('../render/Render');
5+
var Common = require('../core/Common');
6+
var Bounds = require('../geometry/Bounds');
7+
var Axes = require('../geometry/Axes');
8+
19
/**
210
* The `Matter.Body` module contains methods for creating and manipulating body models.
311
* A `Matter.Body` is a rigid body that can be simulated by a `Matter.Engine`.
@@ -11,6 +19,8 @@
1119

1220
var Body = {};
1321

22+
module.exports = Body;
23+
1424
(function() {
1525

1626
Body._inertiaScale = 4;

src/body/Composite.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
var Events = require('../core/Events');
2+
var Common = require('../core/Common');
3+
var Body = require('./Body');
4+
15
/**
26
* The `Matter.Composite` module contains methods for creating and manipulating composite bodies.
37
* A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure.
@@ -12,6 +16,8 @@
1216

1317
var Composite = {};
1418

19+
module.exports = Composite;
20+
1521
(function() {
1622

1723
/**

src/body/World.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
var Composite = require('./Composite');
2+
var Constraint = require('../constraint/Constraint');
3+
var Common = require('../core/Common');
4+
15
/**
26
* The `Matter.World` module contains methods for creating and manipulating the world composite.
37
* A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`.
@@ -14,6 +18,8 @@
1418

1519
var World = {};
1620

21+
module.exports = World;
22+
1723
(function() {
1824

1925
/**

src/collision/Contact.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
var Contact = {};
88

9+
module.exports = Contact;
10+
911
(function() {
1012

1113
/**

src/collision/Detector.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
var SAT = require('./SAT');
2+
var Pair = require('./Pair');
3+
var Bounds = require('../geometry/Bounds');
4+
15
/**
26
* _Internal Class_, not generally used outside of the engine's internals.
37
*
@@ -8,6 +12,8 @@
812

913
var Detector = {};
1014

15+
module.exports = Detector;
16+
1117
(function() {
1218

1319
/**

src/collision/Grid.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
var Pair = require('./Pair');
2+
var Detector = require('./Detector');
3+
var Common = require('../core/Common');
4+
15
/**
26
* See [Demo.js](https://github.com/liabru/matter-js/blob/master/demo/js/Demo.js)
37
* and [DemoMobile.js](https://github.com/liabru/matter-js/blob/master/demo/js/DemoMobile.js) for usage examples.
@@ -7,6 +11,8 @@
711

812
var Grid = {};
913

14+
module.exports = Grid;
15+
1016
(function() {
1117

1218
/**

src/collision/Pair.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var Contact = require('./Contact');
2+
13
/**
24
* _Internal Class_, not generally used outside of the engine's internals.
35
*
@@ -6,6 +8,8 @@
68

79
var Pair = {};
810

11+
module.exports = Pair;
12+
913
(function() {
1014

1115
/**

src/collision/Pairs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
var Pair = require('./Pair');
2+
var Common = require('../core/Common');
3+
14
/**
25
* _Internal Class_, not generally used outside of the engine's internals.
36
*
@@ -6,6 +9,8 @@
69

710
var Pairs = {};
811

12+
module.exports = Pairs;
13+
914
(function() {
1015

1116
var _pairMaxIdleLife = 1000;

0 commit comments

Comments
 (0)