-
Notifications
You must be signed in to change notification settings - Fork 41
/
universalImport.js
43 lines (36 loc) · 973 Bytes
/
universalImport.js
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
38
39
40
41
42
43
/* eslint-disable */
module.exports = function(config, makeThennable) {
if (makeThennable === false) return config
var load = config.load
config.then = function(cb) {
return load().then(function(res) {
return cb && cb(res)
})
}
config.catch = function(cb) {
return load().catch(function(e) {
return cb && cb(e)
})
}
return config
}
var isSet = false
function setHasPlugin() {
if (isSet) return
var universal
var isWebpack = typeof __webpack_require__ !== 'undefined'
try {
if (isWebpack) {
var weakId = require.resolveWeak('react-universal-component')
universal = __webpack_require__(weakId)
} else {
var nodeRequire = typeof __non_webpack_require__ === 'undefined' ? module.require : __non_webpack_require__
universal = nodeRequire('react-universal-component')
}
if (universal) {
universal.setHasBabelPlugin()
isSet = true
}
} catch (e) {}
}
setHasPlugin()