Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
El módulo inyectado no se cargó correctamente al habilitar Webpack HMR

Estoy trabajando en una biblioteca y luego la inyecto en un documento html usando Webpack. Necesito habilitar HMR en el proyecto. Sin embargo, cuando lo habilito, la biblioteca no se cargará correctamente. Esto es lo que obtengo de la consola:

Library.init() no es una función.

y la biblioteca se carga como un object vacío, mientras que al desactivar HMR, se carga correctamente.

Aquí está mi configuración de Webpack:

 { ...baseConfigs, entry: './src/index.ts', output: { path: __dirname + '/dist', filename: `lib.js`, library: { name: 'Library', type: 'window', }, }, devServer: { contentBase: path.resolve(__dirname, 'dist'), publicPath: '/', port: 8000, open: true, hot: true, }, plugins: [ ...baseConfig.plugins, new HtmlWebpackPlugin({ template: path.resolve(__dirname, 'demo', 'index.html'), inject: 'head', }), new webpack.HotModuleReplacementPlugin(), ], }

y el punto de entrada - index.ts - es así:

 import {main, subscribe} from './main' // Library's main functionality imported export { init, subscribe, } if(module.hot){ module.hot.accept('./index.ts') }

¿Me estoy perdiendo una pieza del rompecabezas?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!