{"id":20719,"library":"webpack-chunk-rename-plugin","title":"Webpack Chunk Rename Plugin","description":"A webpack plugin to rename chunks, supporting initial chunks with entry, async chunks, and specific chunk naming. Current stable version is 1.0.3 (last release: unknown, possibly unmaintained). Requires webpack 4.1+ and Node >=6.11.7. Differentiates from similar plugins by offering per-chunk renaming with placeholders like [name], [hash], [chunkhash]. Note: webpack 5 compatibility is not documented; may break.","status":"maintenance","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/MhMadHamster/webpack-chunk-rename-plugin","tags":["javascript","webpack","plugin","chunk","rename"],"install":[{"cmd":"npm install webpack-chunk-rename-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-chunk-rename-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-chunk-rename-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin requires webpack 4.1+ to hook into compilation process.","package":"webpack","optional":false}],"imports":[{"note":"Package does not export ES modules; use CommonJS require. No default export for ESM.","wrong":"import ChunkRenamePlugin from 'webpack-chunk-rename-plugin';","symbol":"ChunkRenamePlugin","correct":"const ChunkRenamePlugin = require('webpack-chunk-rename-plugin');"},{"note":"Some similar webpack plugins use .default; this plugin directly exports the constructor, so .default is undefined and will cause 'ChunkRenamePlugin is not a constructor' error if used.","wrong":"","symbol":"ChunkRenamePlugin","correct":"const ChunkRenamePlugin = require('webpack-chunk-rename-plugin').default;"},{"note":"Constructor expects an object; calling with no arguments passes undefined, leading to runtime error when options are accessed. Always pass at least an empty object.","wrong":"new ChunkRenamePlugin()","symbol":"ChunkRenamePlugin","correct":"new ChunkRenamePlugin({ initialChunksWithEntry: true })"}],"quickstart":{"code":"const ChunkRenamePlugin = require('webpack-chunk-rename-plugin');\n\nmodule.exports = {\n  output: {\n    filename: '[name].js',\n    chunkFilename: '[name].[chunkhash].js',\n  },\n  entry: {\n    main: './src/index.js',\n  },\n  plugins: [\n    new ChunkRenamePlugin({\n      initialChunksWithEntry: true,\n      asyncChunks: 'async/[name].[chunkhash].js',\n      main: 'custom/[name].js',\n    }),\n  ],\n};","lang":"javascript","description":"Shows basic usage: rename initial chunks using output.filename, async chunks with a template, and a specific chunk by name."},"warnings":[{"fix":"Consider webpack 5 alternatives such as webpack's built-in chunk naming or community plugins explicitly supporting webpack 5.","message":"Plugin is only compatible with webpack 4. Use with webpack 5 may cause build failures or incorrect chunk naming.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade Node to at least 6.11.7 or use a transpiler/polyfill.","message":"Requires Node >=6.11.7. Older Node versions cause runtime errors due to unsupported JS features.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always provide an options object: new ChunkRenamePlugin({}) or with proper keys.","message":"If no options object is passed to constructor, plugin errors with 'Cannot read property 'initialChunksWithEntry' of undefined'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure output.filename is defined in webpack config.","message":"Setting 'initialChunksWithEntry: true' uses output.filename pattern for initial chunks; if output.filename is undefined or not set, chunks may be named 'undefined.js'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use the entry point key (e.g., 'main') as the chunk name property for per-chunk renaming.","message":"Placeholders like [name] in chunk names refer to the original chunk name (the entry key or split chunk name), not a custom alias. Misuse leads to unexpected filenames.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use const ChunkRenamePlugin = require('webpack-chunk-rename-plugin');","cause":"Importing with ES module syntax (import) or using .default when the package exports via module.exports directly.","error":"ChunkRenamePlugin is not a constructor"},{"fix":"Pass an options object: new ChunkRenamePlugin({ initialChunksWithEntry: true })","cause":"Calling new ChunkRenamePlugin() without an options object.","error":"Cannot read property 'initialChunksWithEntry' of undefined"},{"fix":"Ensure asyncChunks is a string with valid placeholders; avoid using in webpack 5.","cause":"If 'asyncChunks' option is not a string, or if webpack emits chunks without the expected structure (e.g., webpack 5 changes).","error":"TypeError: Cannot destructure property 'async' of 'undefined' or 'null'"},{"fix":"Chunk name properties must be strings containing placeholders like '[name].js'.","cause":"Passing a non-string value (e.g., an object) as a chunk name property in options.","error":"Error: [object Object] is not a valid chunk name"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}