diff --git a/src/babel.prod.js b/src/babel.prod.js index cdfa8587a..d0f92ce24 100644 --- a/src/babel.prod.js +++ b/src/babel.prod.js @@ -74,6 +74,7 @@ export default function plugin() { // ensure that this is `hot` from RHL isImportedFromRHL(path, specifier.local) && path.parent.type === 'CallExpression' && + path.parent.arguments.length === 1 && path.parent.arguments[0] && path.parent.arguments[0].type === 'Identifier' ) { diff --git a/test/__babel_fixtures__/drop-hot-half.prod.js b/test/__babel_fixtures__/drop-hot-half.prod.js new file mode 100644 index 000000000..44b231fb3 --- /dev/null +++ b/test/__babel_fixtures__/drop-hot-half.prod.js @@ -0,0 +1,23 @@ +import { hot } from 'react-hot-loader'; +import { hot as rootHot } from 'react-hot-loader/root'; + +const control = compose( + withDebug, + withDebug, +)(App); + +const targetCase1 = compose( + withDebug, + withDebug, + hot(module), +)(App); + +const targetCase2 = compose( + withDebug, + withDebug, + rootHot, +)(App); + +const removeHot1 = hot(control); +const removeHot2 = hot(module)(control); +const removeHot3 = rootHot(control); \ No newline at end of file diff --git a/test/__snapshots__/babel.test.js.snap b/test/__snapshots__/babel.test.js.snap index 1bfd1531d..a835fb508 100644 --- a/test/__snapshots__/babel.test.js.snap +++ b/test/__snapshots__/babel.test.js.snap @@ -1069,6 +1069,24 @@ exports.default = _default; })();" `; +exports[`babel Targetting "es2015" tags potential React components drop hot half.prod.js 1`] = ` +"'use strict'; + +var _reactHotLoader = require('react-hot-loader'); + +var _root = require('react-hot-loader/root'); + +var control = compose(withDebug, withDebug)(App); + +var targetCase1 = compose(withDebug, withDebug, (0, _reactHotLoader.hot)(module))(App); + +var targetCase2 = compose(withDebug, withDebug, _root.hot)(App); + +var removeHot1 = (0, _reactHotLoader.hot)(control); +var removeHot2 = control; +var removeHot3 = control;" +`; + exports[`babel Targetting "es2015" tags potential React components drop hot.prod.js 1`] = ` "'use strict'; @@ -2179,6 +2197,20 @@ exports.default = _default; })();" `; +exports[`babel Targetting "modern" tags potential React components drop hot half.prod.js 1`] = ` +"'use strict'; + +Object.defineProperty(exports, \\"__esModule\\", { + value: true +}); + +var _reactHotLoader = require('react-hot-loader'); + +var _root = require('react-hot-loader/root'); + +exports.default = withDebug(App);" +`; + exports[`babel Targetting "modern" tags potential React components drop hot.prod.js 1`] = ` "'use strict';