File: root.js

package info (click to toggle)
node-react-hot-loader 4.13.1%2B~cs12.12.4-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 6,260 kB
  • sloc: javascript: 12,320; sh: 58; makefile: 17
file content (38 lines) | stat: -rw-r--r-- 939 bytes parent folder | download
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
if (process.env.NODE_ENV !== 'production') {
  var hot = require('./index').hot;
  if (module.hot) {
    var cache = require.cache;

    if (!module.parents || module.parents.length === 0) {
      throw new Error(
        'React-Hot-Loader: `react-hot-loader/root` is not supported on your system. ' +
        'Please use `import {hot} from "react-hot-loader"` instead'
      );
    }
    // access parent
    var parent = cache[module.parents[0]];
    if (!parent) {
      throw new Error(
        'React-Hot-Loader: `react-hot-loader/root` is not supported on your system. ' +
        'Please use `import {hot} from "react-hot-loader"` instead'
      );
    }

    // remove self from a cache
    delete cache[module.id];

    // setup hot for caller
    exports.hot = hot(parent);
  } else {
    fallbackHot();
  }
} else {
  // prod mode
  fallbackHot();
}

function fallbackHot() {
  exports.hot = function (a) {
    return a;
  };
}