forked from formatjs/formatjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (32 loc) · 1.25 KB
/
Copy pathindex.js
File metadata and controls
37 lines (32 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* jshint node:true */
'use strict';
// Expose `React` as a global, because the ReactIntlMixin assumes it's global.
var oldReact = global.React;
global.React = require('react');
// Require the lib and add all locale data to `ReactIntl`. This module will be
// ignored when bundling for the browser with Browserify/Webpack.
var ReactIntl = require('./lib/react-intl');
require('./lib/locales');
// Export the Mixin as the default export for back-compat with v1.0.0. This will
// be changed to simply re-exporting `ReactIntl` as the default export in v2.0.
exports = module.exports = ReactIntl.IntlMixin;
// Define non-enumerable expandos for each named export on the default export --
// which is the Mixin for back-compat with v1.0.0.
Object.keys(ReactIntl).forEach(function (namedExport) {
Object.defineProperty(exports, namedExport, {
enumerable: true,
value : ReactIntl[namedExport]
});
});
// Put back `global.React` to how it was.
if (oldReact) {
global.React = oldReact;
} else {
// IE < 9 will throw when trying to delete something off the global object,
// `window`, so this does the next best thing as sets it to `undefined`.
try {
delete global.React;
} catch (e) {
global.React = undefined;
}
}