Skip to content

Commit ed4fe91

Browse files
committed
standalone: AMD shim
1 parent 4bb335c commit ed4fe91

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

standalone/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
]
88
},
99
"browserify-shim": {
10-
"react": "global:React",
11-
"react/lib/cloneWithProps": "global:React.addons.cloneWithProps",
10+
"react": "global:__ReactShim.React",
11+
"react/lib/cloneWithProps": "global:__ReactShim.cloneWithProps",
1212
"react/lib/invariant": "global:__ReactShim.invariant",
1313
"react/lib/merge": "global:__ReactShim.merge",
1414
"react/lib/mergeInto": "global:__ReactShim.mergeInto",

standalone/prelude.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
1-
;(function() {
1+
;(function (root, factory) {
2+
if (typeof define === 'function' && define.amd) {
3+
define(['react'], factory);
4+
} else {
5+
root.ReactRouter = factory(root.React);
6+
}
7+
})(this, function(React) {
8+
9+
var Shim = window.__ReactShim = window.__ReactShim || {};
10+
11+
Shim.React = React;
212

3-
window.__ReactShim = window.__ReactShim || {};
13+
Shim.cloneWithProps = React.addons.cloneWithProps;
414

5-
window.__ReactShim.invariant = function(check, msg) {
15+
Shim.invariant = function(check, msg) {
616
if (!check) {
717
throw new Error(msg);
818
}
919
}
1020

11-
var mergeInto = window.__ReactShim.mergeInto = function(dst, src) {
21+
var mergeInto = Shim.mergeInto = function(dst, src) {
1222
for (var k in src) {
1323
if (src.hasOwnProperty(k)) {
1424
dst[k] = src[k];
1525
}
1626
}
1727
}
1828

19-
window.__ReactShim.merge = function(a, b) {
29+
Shim.merge = function(a, b) {
2030
var c = {};
2131
mergeInto(c, a);
2232
mergeInto(c, b);
2333
return c;
2434
}
2535

26-
window.__ReactShim.emptyFunction = function() {
36+
Shim.emptyFunction = function() {
2737
}
2838

29-
window.__ReactShim.ExecutionEnvironment = {
39+
Shim.ExecutionEnvironment = {
3040
canUseDOM: true
3141
};
3242

33-
window.__ReactShim.ReactUpdates = {
43+
Shim.ReactUpdates = {
3444
batchedUpdates: function(cb) { cb(); }
3545
};
3646

37-
})();
47+
});

0 commit comments

Comments
 (0)