soundcloud / chunk-manifest-webpack-plugin

Allows exporting a manifest that maps entry chunk names to their output files, instead of keeping the mapping inside the webpack bootstrap.
MIT License
394 stars 73 forks source link

Add in manifest key by name or id chunk #60

Open Insidexa opened 6 years ago

Insidexa commented 6 years ago
Chunk {
  id: 1,
  ids: [ 1 ],
  debugId: 1002,
  name: 'profile', // by name
  _modules: 
   Set {

Config maybe

{
        filename: 'wmanifest.json',
        manifestVariable: 'webpackManifest',
        inlineManifest: true,
        keyChunk: 'name' // id default
    }

https://github.com/soundcloud/chunk-manifest-webpack-plugin/blob/master/lib/ChunkManifestPlugin.js#L29-L31 var keyChunk = this.keyChunk c.id replace by c[keyChunk] In constructor ChunkManifestPlugin add this.keyChunk = options.keyChunk || 'id';

Result of this operation window.webpackManifest={"restaurantProfile":"restaurantProfile-1a19c34fddd34bea5d68.chunk.js"]

this will help in lazy loading of modules using pure js without dynamic import when we can not specify /* webpackChunkName: "name" */ comments in imports () if dynamic file name or other situations

I think you understand me