File: index.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 (42 lines) | stat: -rw-r--r-- 1,591 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
39
40
41
42
'use strict';

if (process.env.NODE_ENV === 'production') {
  module.exports = require('./dist/react-hot-loader.production.min.js');
} else if (process.env.NODE_ENV === 'test') {
  module.exports = require('./dist/react-hot-loader.production.min.js');
} else if (typeof window === 'undefined') {
  // this is just server environment
  module.exports = require('./dist/react-hot-loader.production.min.js');
} else if (!module.hot) {
  module.exports = require('./dist/react-hot-loader.production.min.js');
  module.exports.AppContainer.warnAboutHMRDisabled = true;
  module.exports.hot.shouldWrapWithAppContainer = true;
} else {
  var evalAllowed = false;
  var evalError = null;
  try {
    eval('evalAllowed = true');
  } catch (e) {
    // eval not allowed due to CSP
    evalError = e && e.message ? e.message : 'unknown reason';
  }

  // TODO: dont use eval to update methods. see #1273
  // RHL needs setPrototypeOf to operate Component inheritance, and eval to patch methods
  var jsFeaturesPresent = !!Object.setPrototypeOf;

  if (!jsFeaturesPresent || !evalAllowed) {
    // we are not in prod mode, but RHL could not be activated
    console.warn(
      'React-Hot-Loader is not supported in this environment:',
      [
        !jsFeaturesPresent && "some JS features are missing",
        !evalAllowed && "`eval` is not allowed(" + evalError + ")"
      ].join(','),
      '.'
    );
    module.exports = require('./dist/react-hot-loader.production.min.js');
  } else {
    module.exports = window.reactHotLoaderGlobal = require('./dist/react-hot-loader.development.js');
  }
}