0

Id like to run HMR in production, using it for seamless application updates. I cannot seem to find any docs or tutorials regarding how to do this.

My setup is currently "serverless", and statics are served from AWS S3. My first thought is i would create an "Update" server of some sort, wherby the HMR clients would poll for updates, and the magic would work.

My questions:

  • a) How do I run this in production (optimally)
  • b) For this to work the "Update" server will have to know of module changes, how?
    • I know the json file with the updates is what HMR relies on to know of the changes, will i have to push some sort of this file to the server?
    • Or, Do I have the server watch S3 files somehow, and recompile, in turn triggering updates.

A complete solution would be awesome, but also just some sudo logic as to how this could work would be great.

donny5561
  • 21
  • 4

1 Answers1

-1

Read this two documents to understand how it works:

No idea to what you mean by "serverless"... How would you serve a website without a server? You will need at least webpack or a nodejs/express instance running somewhere

This will not be optimal. This feature is thought to be used for development. HMR will add listeners to the application for file changes and add code for replacing old modules with new ones. This adds overhead to your code. Optimal would be no hmr.

jperelli
  • 6,988
  • 5
  • 50
  • 85
  • 2
    You obviously dont have enough knowledge on this topic to answer for it, and you have not fully read the documentation. – donny5561 Apr 03 '17 at 04:25
  • 1
    "**You can also use it in production as an updating mechanism. Here you would need to write your own management code that integrates HMR with your app.**" - per the docs – donny5561 Apr 03 '17 at 04:32
  • Who said you **can't** do it? I read that, I just said it would not be **optimal** as you asked. If you have read the documentation, you should say that in your question. I quote you: "I cannot seem to find any docs or tutorials regarding how to do this". You said **any**, I provided you with links to at least **some** documentation. If you already read those, then state that in your question. I couldn't know that beforehand, by reading your quesiton. – jperelli Apr 03 '17 at 12:42
  • From the docs "HMR is not intended for use in production, meaning it should only be used in development". But: "You can also use it in production as update mechanisms. Here you need to write your own management code that integrates HMR with your app." Actually, [read this](https://stackoverflow.com/a/24587740/2581562) – Legends Mar 12 '18 at 22:30