Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop hot calls for prod mode #1081

Merged
merged 2 commits into from
Nov 1, 2018
Merged

Conversation

smelukov
Copy link
Contributor

closes #1080

@codecov-io
Copy link

codecov-io commented Oct 23, 2018

Codecov Report

Merging #1081 into master will increase coverage by 0.28%.
The diff coverage is 94.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1081      +/-   ##
==========================================
+ Coverage    86.9%   87.18%   +0.28%     
==========================================
  Files          31       32       +1     
  Lines         840      874      +34     
  Branches      194      206      +12     
==========================================
+ Hits          730      762      +32     
- Misses         91       93       +2     
  Partials       19       19
Impacted Files Coverage Δ
src/babel.prod.js 94.11% <94.11%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 696da9b...f7b922c. Read the comment docs.

@smelukov
Copy link
Contributor Author

Now supports all import cases:

import { hot } from 'react-hot-loader'
import { hot as namedHot } from 'react-hot-loader'
import * as RHL from 'react-hot-loader'

@theKashey
Copy link
Collaborator

Amazing! Just amazing!

@smelukov
Copy link
Contributor Author

Are there any comments for this? )

@theKashey
Copy link
Collaborator

Gonna handle this and another pending PRs on weekends.

@theKashey theKashey merged commit a6e97c8 into gaearon:master Nov 1, 2018
@smelukov smelukov deleted the drop-hot-for-prod branch November 1, 2018 10:27
@theKashey
Copy link
Collaborator

Released in 4.3.12

@smelukov
Copy link
Contributor Author

smelukov commented Nov 1, 2018

Thanks :)

@edmorley
Copy link
Contributor

edmorley commented Nov 1, 2018

Hi!

I don't see any change in the babel output when using default exports. Is this expected?

eg:

import React from 'react'
import { hot } from 'react-hot-loader'

const App = () => <div>Hello World!</div>

export default hot(module)(App)

@smelukov
Copy link
Contributor Author

smelukov commented Nov 1, 2018

@edmorley Hi!
The output will change only in the production build (when NODE_ENV is production)

@edmorley
Copy link
Contributor

edmorley commented Nov 1, 2018

Yup, this is with NODE_ENV=production, and webpack mode production.

@smelukov
Copy link
Contributor Author

smelukov commented Nov 1, 2018

@edmorley thank you! I've investigated this and find out that hot-dropping may not work with babel 7 (no matter which kind of export do you use).
Fix in #1093

hyldmo pushed a commit to hyldmo/typescript-react-starter-kit that referenced this pull request Nov 12, 2018
## The devDependency [react-hot-loader](https://github.com/gaearon/react-hot-loader) was updated from `4.3.11` to `4.3.12`.
This version is **not covered** by your **current version range**.

If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update.

---

<details>
<summary>Release Notes for v4.3.12</summary>

<h3>Bug fixes</h3>
<ul>
<li>babel plugin will remove calls to <code>hot</code> in production mode to remove side-effect on webpack <a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/pull/1081" data-hovercard-type="pull_request" data-hovercard-url="/gaearon/react-hot-loader/pull/1081/hovercard">#1081</a></li>
<li>class methods, deleted on update, will be deleted from proxy <a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/pull/1091" data-hovercard-type="pull_request" data-hovercard-url="/gaearon/react-hot-loader/pull/1091/hovercard">#1091</a></li>
</ul>
</details>

<details>
<summary>Commits</summary>
<p>The new version differs by 14 commits.</p>
<ul>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/8d8763d5d6e2fd477a04d36144744bd8ac19a8b5"><code>8d8763d</code></a> <code>chore(release): 4.3.12</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/a6e97c8f07e173d80e554148dacf84e733de13bd"><code>a6e97c8</code></a> <code>Merge pull request #1081 from smelukov/drop-hot-for-prod</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/847b5cd8d68dd46088d709d4b85a58d08b8bcde9"><code>847b5cd</code></a> <code>Merge pull request #1091 from bradennapier/remove-generational-methods</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/08f7457435af7df46b114a629031b9529025ccae"><code>08f7457</code></a> <code>remove all removed methods from proxy prototype</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/2a6a8bbc21887fb02d8405b532dee957e4ab901b"><code>2a6a8bb</code></a> <code>change to use property check in jest</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/5b5ef8ae4ab1d3d05ce9f1880e65a2fee74e3e49"><code>5b5ef8a</code></a> <code>add test case</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/db489955759bc10eaf80a1efe5a2f0d0e752f83d"><code>db48995</code></a> <code>remove certain members if removed from prototype</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/21cfe37f58e436d0c795d5be7926040d879f7f04"><code>21cfe37</code></a> <code>Merge pull request #1086 from andfelzapata/Fix_Grammar_Mistake_OpenedModules_Console_Warning_Comment</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/00e5aed30567bdea05c21938dd28b1a534ab3c36"><code>00e5aed</code></a> <code>Fix grammar mistake in commment</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/f7b922c2c9136c8c7ab29f373c97f3d9d1e32d67"><code>f7b922c</code></a> <code>support all import cases</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/308f35ea709b5871c073873fa27570059fbe127a"><code>308f35e</code></a> <code>drop <code>hot</code> calls for prod mode</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/696da9baa258d841715a77737b896f2c5d643460"><code>696da9b</code></a> <code>Merge pull request #1065 from PavelGavlik/patch-1</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/972d1eb688b2ecb739453ff9d35c26aae4aaa399"><code>972d1eb</code></a> <code>chore(examples): add example with uglifyjs, #1074</code></li>
<li><a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/commit/e08f95b331f6b227cdc97b4db980990906593075"><code>e08f95b</code></a> <code>Remove link that leads to 404</code></li>
</ul>
<p>See the <a href="https://urls.greenkeeper.io/gaearon/react-hot-loader/compare/28bab4cc92ebf897681e197bec00125314eed86b...8d8763d5d6e2fd477a04d36144744bd8ac19a8b5">full diff</a></p>
</details>

<details>
  <summary>FAQ and help</summary>

  There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new).
</details>

---


Your [Greenkeeper](https://greenkeeper.io) bot 🌴
edmorley added a commit to neutrinojs/neutrino that referenced this pull request Nov 20, 2018
`react-hot-loader` internally uses `process.env.NODE_ENV` conditionals
to make most of its functionality a no-op when in production.

Previously the production Babel plugin was a no-op too, however after
gaearon/react-hot-loader#1081 and gaearon/react-hot-loader#1093 it
now replaces instances of `hot(module)(App)` with `App`.

In addition to removing a few lines of RHL code, this allows webpack
to now perform its module concatenation optimization, and avoids
Content-Security-Policy script-src `unsafe-eval` false positives.

This change is compatible with all versions of RHL 4, however to
see the benefit, users will need to upgrade to >=4.4.0 (in beta).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using module for hot cancels some webpack optimizations in prod
4 participants