Nest: HMR docs should be changed as webpack-node-externals version update

Created on 10 Jul 2020  路  2Comments  路  Source: nestjs/nest

Regression

I updated whole my project's dependencies today, and i got a few collisions.
Other things got issues open already but i cannot find this one.

As webpack-node-externals version is updated 1.7.2 to 2.3.0 in two years, it has breaking change in options.
As it is only for who had updated it, I cannot rashly make PR from it

key context

We should change our option property whitelist to allowlist

Ref:

v1 : https://www.npmjs.com/package/webpack-node-externals/v/1.7.2
v2 : https://www.npmjs.com/package/webpack-node-externals

Input Code

As is

externals: [
  nodeExternals({
     whitelist: ['webpack/hot/poll?100'],
  }),
],

To be

externals: [
  nodeExternals({
    allowlist: ['webpack/hot/poll?100'],
  }),
],

Expected behavior/code

if you do not change above part, you will got error as follows

Error: [HMR] Hot Module Replacement is disabled.
    at Object../node_modules/webpack/hot/poll.js?100 (C:\Users\82106\Desktop\vhract\dist\webpack:\(webpack)\hot\poll.js:36:1)
    at __webpack_require__ (C:\Users\82106\Desktop\vhract\dist\webpack:\webpack\bootstrap:19:1)
    at Object.0 (C:\Users\82106\Desktop\vhract\dist\main.js:13006:1)
    at __webpack_require__ (C:\Users\82106\Desktop\vhract\dist\webpack:\webpack\bootstrap:19:1)
    at C:\Users\82106\Desktop\vhract\dist\webpack:\webpack\bootstrap:83:1
    at Object.<anonymous> (C:\Users\82106\Desktop\vhract\dist\main.js:88:10)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)

additional

I do not know it is relevant but I experienced another issue
follows is my build nest app command webpack --config webpack.config.js
it does not have any problems before, but it cause as follows

Error: [HMR] Hot Module Replacement is disabled.
    at Object../node_modules/webpack/hot/poll.js?100 (C:\Users\82106\Desktop\vhract\dist\webpack:\(webpack)\hot\poll.js:36:1)
    at __webpack_require__ (C:\Users\82106\Desktop\vhract\dist\webpack:\webpack\bootstrap:19:1)
    at Object.0 (C:\Users\82106\Desktop\vhract\dist\main.js:13006:1)
    at __webpack_require__ (C:\Users\82106\Desktop\vhract\dist\webpack:\webpack\bootstrap:19:1)
    at C:\Users\82106\Desktop\vhract\dist\webpack:\webpack\bootstrap:83:1
    at Object.<anonymous> (C:\Users\82106\Desktop\vhract\dist\main.js:88:10)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)

And I solved by adding --hot arg to my build command
webpack --config webpack.config.js --hot
and removed
new webpack.HotModuleReplacementPlugin() from webpack.config.js

For Tooling issues:

  • Node version: 12.18.2
  • Platform: windows
needs triage type

Most helpful comment

Can you update this file https://github.com/nestjs/nest/blob/master/sample/08-webpack/webpack-hmr.config.js as well? :)

All 2 comments

Would you like to create a PR for this issue?

Can you update this file https://github.com/nestjs/nest/blob/master/sample/08-webpack/webpack-hmr.config.js as well? :)

Was this page helpful?
0 / 5 - 0 ratings