aaronfrost / ama

Ask me anything!
https://github.com/aaronfrost/ama/issues?utf8=%E2%9C%93&q=is%3Aissue
4 stars 1 forks source link

Dynamically load JS modules #5

Open dannymk opened 7 years ago

dannymk commented 7 years ago

Hi Aaaron, I took your "The Ins & Outs of the Newest JavaScript: ES6" @ Udemy. It was great, you are a very good presenter and explained the material very well.

I've had this lingering question quite a while. How do I support dynamic module upload. I think it is best to give you a scenario:

  1. ES6 SPA "application-a" running on page. Application state is maintained using Redux.
  2. User "A" uploads "dyn_module.js" to website running in step 1
  3. applicaiton-a "polls/receives message/etc..." server for new modules in "well known" directory
  4. application-a loads module(s) and may dynamically establish a route that immediately becomes available in step 1.

For a moment, lets take security out of the picture as I understand the risks from that perspective. The point is that we never know when "dyn_module.js" will be available. We don't know the module name or functionality. All we know is the well known directory on the server where the modules will be available and that we may get these uploaded/updated at any point in time while the application is running.

Solutions I have thought about:

My current development environment: React/Aurelia Redux WebPack

Thank you for your time. I know you are a busy guy.

Dan.