Skip to content

Commit 0c6bbf2

Browse files
committed
Ship CJS modules instead of browserified build
It turns out that if you try to browserify a file requiring react-tools, it doesn't work. This is because browserify just visits the require statements in the file and looks for files in that path. ./ReactCompositeComponent doesn't exist and that's the point that fails. So the fix is to actually ship each of our CJS modules as individual files like browserify expects. This should have no negative side effects - we still only export React (though the rest of our modules are now actually accessible, which might make it easier to do more with the module). The other change here is to move source-map to dependencies since it's required in the transform code. Test Plan: ``` $ npm pack . $ cd /tmp $ npm install path/to/react-tools-0.3.1.tgz $ echo "require('react-tools')" > test.js $ browserify test.js ```
1 parent b20a7c2 commit 0c6bbf2

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var React = require('./build/react');
3+
var React = require('./build/modules/React');
44
var visitors = require('./vendor/fbtransform/visitors').transformVisitors;
55
var transform = require('./vendor/fbtransform/lib/transform').transform;
66

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"README.md",
1717
"main.js",
1818
"bin/jsx",
19-
"build/react.js",
19+
"build/modules/",
2020
"vendor/fbtransform/",
2121
"vendor/woodchipper.js"
2222
],
@@ -35,7 +35,8 @@
3535
"base62": "~0.1.1",
3636
"commoner": "~0.6.8",
3737
"esprima": "git://github.com/facebook/esprima#fb-harmony",
38-
"recast": "~0.3.3"
38+
"recast": "~0.3.3",
39+
"source-map": "~0.1.22"
3940
},
4041
"devDependencies": {
4142
"browserify": "~2.14.2",
@@ -47,7 +48,6 @@
4748
"optimist": "~0.4.0",
4849
"phantomjs": ">= 1.9.0",
4950
"semver": ">= 1.1.4",
50-
"source-map": "~0.1.22",
5151
"uglify-js": "~2.3.6",
5252
"grunt-contrib-clean": "~0.4.1",
5353
"grunt-compare-size": "~0.4.0",

0 commit comments

Comments
 (0)