-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Hot Module Replacement (HMR) Integration #1265
Conversation
solving issue responsively-org#1255 This project implements Hot Module Replacement (HMR) for a React-based Chrome extension, allowing developers to see real-time changes in their popup component without needing to refresh the entire extension. The following outlines the configuration and structure necessary for achieving this setup. #### Key Components 1. **Webpack Configuration (`webpack.config.js`)**: - Configures Webpack for development and production modes, specifying the entry point and output settings. - Enables HMR in the development server for instant updates. 2. **Entry Point (`src/popup.js`)**: - Contains the main logic for the popup component, integrating the HMR logic to allow for module updates without a full reload. 3. **Index File (`src/index.js`)**: - Updated to support HMR with checks for `module.hot`, ensuring that the component re-renders on updates without refreshing the entire popup. 4. **Package Configuration (`package.json`)**: - Includes scripts for building and serving the application, specifying configurations needed for both development and production. 5. **Development Server**: - The command `npm start` launches a development server with HMR enabled, providing a smooth development experience. #### Summary of Changes - **HMR Logic**: - Added in `popup.js` using `if (module.hot) { ... }` to ensure updates are reflected in real-time. - Implemented in `index.js` to facilitate automatic re-rendering of the popup component on code changes. - **Webpack Dev Server**: Configured with `hot: true` to support HMR functionality. - **File Structure**: Organized files into a clear structure, facilitating maintainability and ease of access. ### Benefits Implementing HMR improves the development workflow by reducing the time spent on refreshing and waiting for the extension to reload. This results in a more productive environment, allowing for faster iteration and debugging of features.
@manojVivek I hope this would solve your doubts.And you can check my code as well.I hope u star it |
import React, {useMemo, useState, useEffect, useRef} from 'react'; | ||
import {Rnd} from 'react-rnd'; | ||
import {useSelector, useDispatch} from 'react-redux'; | ||
import React, { useMemo, useState, useEffect, useRef } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the purpose of these changes in the legacy app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would give an simplified version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better understanding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@minowau We don't actively do any development on the legacy app. So, for the sake of clean git history, can you please revert these changes so that we can merge the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I am reverting those
I tested it and the reloading is faster when you change any css :) |
Can U merge the pull request |
it is not possible to revert from my side as there is only one commit can u merge the pull request as there will be no visible change but just a shortening of code. Or u can change it after merging. |
@minowau in your branch you can do: |
oh thanks for the help I forgot |
I tried it but It
I tried but I was not able to do it. If U can help U can have my credentials and U can try or U CAN JUST MERGE IT and change it afterwards with an other pull it is just a one line code |
don't give your credentials to anyone please. Can you do from the root of the project |
It is giving a fatal error once review the changes it was just adding a place in the brackets so there would be no problem |
it just gives the code a better look but no changes were done withe the change in the location of words in the brackets.Sorry but I tried but it didn't work on my side |
can u add me as a contibutor |
@all-contributors Please add @minowau for code. |
I've put up a pull request to add @minowau! 🎉 |
solving issue #1255
This project implements Hot Module Replacement (HMR) for a React-based Chrome extension, allowing developers to see real-time changes in their popup component without needing to refresh the entire extension. The following outlines the configuration and structure necessary for achieving this setup.
Key Components
Webpack Configuration (
webpack.config.js
):Entry Point (
src/popup.js
):Index File (
src/index.js
):module.hot
, ensuring that the component re-renders on updates without refreshing the entire popup.Package Configuration (
package.json
):Development Server:
npm start
launches a development server with HMR enabled, providing a smooth development experience.Summary of Changes
HMR Logic:
popup.js
usingif (module.hot) { ... }
to ensure updates are reflected in real-time.index.js
to facilitate automatic re-rendering of the popup component on code changes.Webpack Dev Server: Configured with
hot: true
to support HMR functionality.File Structure: Organized files into a clear structure, facilitating maintainability and ease of access.
Benefits
Implementing HMR improves the development workflow by reducing the time spent on refreshing and waiting for the extension to reload. This results in a more productive environment, allowing for faster iteration and debugging of features.
✨ Pull Request
📓 Referenced Issue
ℹ️ About the PR
🖼️ Testing Scenarios / Screenshots