Feature request: hot modules
- Dominant language
- TypeScript
- Stars
- 44k
- Forks
- 6k
- Avg merge
- 5d 15h
- Merged PRs (30d)
- 23
Description
## Feature Request
**Is your feature request related to a problem? Please describe.**
The problem is reloading code. Sometimes it is cumbersome to reload an app (f.e. an Electron app) and click your way back to the state you were at. It could involve login steps, and a slew of navigation and interactions.
There's tools like Webpack, but using Webpack negates the benefits of the native runtime `require` and simplicity that `@babel/register` affords.
**Describe the solution you'd like**
It'd be neat if there were some sort of hot-module feature for `@babel/register`. Is it possible?
**Describe alternatives you've considered**
The alternative is Webpack, with convoluted configuration compared to `@babel/register`, and the downside that import paths are fake because app code is bundled.
The upside of `@babel/register` is that import paths are real, they use native `require`, and we can therefore take advantage of require hooks and/or monkey patching `Module.prototype.require` to achieve certain things like dynamic passing of references based on import strings (f.e., between main process and renderer process of an Electron app).
Using native require gives us some superpowers we don't otherwise get very easily with Webpack. But, we lose the Webpack hot-module super power.
**Teachability, Documentation, Adoption, Migration Strategy**
I would be glad to help document this. Not sure what the API would be like yet though.
Contributor guide
Research direction
The issue names @babel/register, native require, Module.prototype.require, and Webpack but no repository files or tests. Start by reviewing the @babel/register entry point and its require-hook behavior, then define the hot-module API and lifecycle needed to preserve application state. Done means an agreed design, implementation scope, and documented behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, javascript, node.js, webpack
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100