We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
./package.json:
{ "name": "chat-contests", "version": "1.0.0", "main": "index.js", "scripts": { "dev": "npx webpack serve", "build": "npx webpack" }, "author": "", "license": "ISC", "description": "", "devDependencies": { "@babel/core": "^7.26.0", "@babel/preset-env": "^7.26.0", "@babel/preset-react": "^7.26.3", "babel-loader": "^9.2.1", "css-loader": "^7.1.2", "html-webpack-plugin": "^5.6.3", "style-loader": "^4.0.0", "webpack": "^5.97.1", "webpack-cli": "^6.0.1", "webpack-dev-server": "^5.2.0" }, "dependencies": { "@reduxjs/toolkit": "^2.5.0", "axios": "^1.7.9", "react": "^19.0.0", "react-dom": "^19.0.0", "react-redux": "^9.2.0" } }
./src/index.js:
In the logs there's only the "HOT AVAILABLE" message. For some reason HMR doesn't accept my module.
import React from 'react'; import { createRoot } from 'react-dom/client'; import App from './App'; const app = createRoot( document.getElementById('app') ); const render = () => app.render(<App />); if (module.hot) { console.error('HOT AVAILABLE'); module.hot.accept('./App', () => { console.error('HOT ACCEPTED'); const NextApp = require('./App').default; console.error('HOT APP LOADED'); app.render(<NextApp />); }); } else { console.error('NOT HOT'); render(); }
./src/App.js:
import React from 'react'; const App = () => { return ( <div>Hello World!!10!</div> ); }; export default App;
./webpack.config.js:
const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { mode: 'development', entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.[contenthash].js', clean: true }, devServer: { static: { directory: './dist', publicPath: '/apps/chat-contests/dev' }, port: 1010, hot: true, allowedHosts: 'all', client: { webSocketURL: { protocol: 'wss', port: 443, hostname: 'my-hostname.com', pathname: '/chat-contests-ws' } } }, module: { rules: [{ test: /\.jsx?$/, exclude: /node_modules/, use: 'babel-loader' }, { test: /\.css$/, use: [ 'style-loader', 'css-loader' ] }] }, resolve: { extensions: [ '.js', '.jsx' ] }, plugins: [ new HtmlWebpackPlugin({ template: './public/index.html' }) ] };
The text was updated successfully, but these errors were encountered:
import React from 'react'; import { createRoot } from 'react-dom/client'; import App from './App'; const app = createRoot( document.getElementById('app') ); const render = () => app.render(<App />); render(); if (module.hot) { module.hot.accept(); }
Sorry, something went wrong.
Any help?
No branches or pull requests
1st issue: The error gets shown right before the HMR reloads (not updates) the page after changes are made.
2nd issue: HMR reloads the page instead of updating trivial components (App).
./package.json:
./src/index.js:
In the logs there's only the "HOT AVAILABLE" message. For some reason HMR doesn't accept my module.
./src/App.js:
./webpack.config.js:
The text was updated successfully, but these errors were encountered: