Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack plugin for module friendly names (path instead of a number)

During the hot update in webpack development server in console I see these messages:

[HMR] Updated modules: 
[HMR]  - 1009 
[HMR]  - 1007

I would rather see the path names in there and I remember there was a plugin for that, but could not find it in Google.

like image 941
Ilya Chernomordik Avatar asked Nov 29 '16 09:11

Ilya Chernomordik


People also ask

What is an entry point webpack?

The entry object is where webpack looks to start building the bundle. The context is an absolute string to the directory that contains the entry files.

What is ModuleFederationPlugin?

The ModuleFederationPlugin allows a build to provide or consume modules with other independent builds at runtime. const { ModuleFederationPlugin } = require('webpack').

What is Hotmodulereplacementplugin?

Enables Hot Module Replacement, otherwise known as HMR.

Can you have multiple entry points in a single webpack configuration file?

webpack.config.jsWe can also pass an array of file paths to the entry property which creates what is known as a "multi-main entry". This is useful when you would like to inject multiple dependent files together and graph their dependencies into one "chunk".


1 Answers

UPDATED ANSWER:

In webpack 4 it's just on by default when mode is set to development

module.exports = {
  mode: 'development',
}

and can be controlled directly as well:

module.exports = {
  //...
  optimization: {
    namedModules: true
  }
};

ORIGINAL ANSWER: (for older webpack versions)

I have found it myself, it's part of webpack itself it seems. here is how you add it:

plugins: [
    new webpack.NamedModulesPlugin(),
    ...
]

Now the module names in console and in the source will be like that:

[HMR] Updated modules:
[HMR]  - ./../MyModule1.jsx
[HMR]  - ./../MyModule2.jsx
like image 152
Ilya Chernomordik Avatar answered Oct 06 '22 00:10

Ilya Chernomordik