{"id":"e3bcf6145f83889d","repo":"webpack/webpack","slug":"plugin-name-unexpected-value-of-order","errorCode":null,"errorMessage":"${PLUGIN_NAME}: unexpected value of order","messagePattern":"(.+?): unexpected value of order","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/ids/ChunkModuleIdRangePlugin.js","lineNumber":74,"sourceCode":"\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t/** @type {Module[]} */\n\t\t\t\tlet chunkModules;\n\t\t\t\tif (this.options.order) {\n\t\t\t\t\t/** @type {ModuleComparator} */\n\t\t\t\t\tlet cmpFn;\n\t\t\t\t\tswitch (this.options.order) {\n\t\t\t\t\t\tcase \"index\":\n\t\t\t\t\t\tcase \"preOrderIndex\":\n\t\t\t\t\t\t\tcmpFn = compareModulesByPreOrderIndexOrIdentifier(moduleGraph);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"index2\":\n\t\t\t\t\t\tcase \"postOrderIndex\":\n\t\t\t\t\t\t\tcmpFn = compareModulesByPostOrderIndexOrIdentifier(moduleGraph);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow new Error(`${PLUGIN_NAME}: unexpected value of order`);\n\t\t\t\t\t}\n\t\t\t\t\tchunkModules = chunkGraph.getOrderedChunkModules(chunk, cmpFn);\n\t\t\t\t} else {\n\t\t\t\t\tchunkModules = [...modules]\n\t\t\t\t\t\t.filter((m) => chunkGraph.isModuleInChunk(m, chunk))\n\t\t\t\t\t\t.sort(compareModulesByPreOrderIndexOrIdentifier(moduleGraph));\n\t\t\t\t}\n\n\t\t\t\tlet currentId = this.options.start || 0;\n\t\t\t\tfor (let i = 0; i < chunkModules.length; i++) {\n\t\t\t\t\tconst m = chunkModules[i];\n\t\t\t\t\tif (m.needId && chunkGraph.getModuleId(m) === null) {\n\t\t\t\t\t\tchunkGraph.setModuleId(m, currentId++);\n\t\t\t\t\t}\n\t\t\t\t\tif (this.options.end && currentId > this.options.end) break;\n\t\t\t\t}\n\t\t\t});\n\t\t});","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/webpack/webpack/blob/318421ea8ac81371f5171236a6efb63675576528/lib/ids/ChunkModuleIdRangePlugin.js#L56-L92","documentation":"ChunkModuleIdRangePlugin switches on options.order to pick a module comparator: 'index'/'preOrderIndex' use pre-order, 'index2'/'postOrderIndex' use post-order. Any other value falls through to default and throws. The allowed set is fixed and case-sensitive; the error is a config-time validation surfaced during the moduleIds compilation hook.","triggerScenarios":"Setting new webpack.ids.ChunkModuleIdRangePlugin({ order: 'post-order' }) or any typo/case variant not in the allowed set. Triggered at build time when module ids are assigned.","commonSituations":"Guessing an order value from intuition; copy-pasting a value from outdated docs; case mismatch like 'Index' or 'INDEX'; using a synonym like 'natural' or 'size'.","solutions":["Set order to one of 'index', 'index2', 'preOrderIndex', or 'postOrderIndex'.","Omit order entirely to fall back to the default pre-order-by-identifier sort.","Double-check the spelling and case against the current webpack docs for the installed version."],"exampleFix":"// before\nnew webpack.ids.ChunkModuleIdRangePlugin({ name: 'app', order: 'post-order', start: 0 })\n// after\nnew webpack.ids.ChunkModuleIdRangePlugin({ name: 'app', order: 'postOrderIndex', start: 0 })","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set(['index', 'index2', 'preOrderIndex', 'postOrderIndex']);\nif (pluginOptions.order !== undefined && !ALLOWED.has(pluginOptions.order)) {\n  throw new Error(`ChunkModuleIdRangePlugin.order must be one of ${[...ALLOWED].join(', ')}`);\n}","typeGuard":"/** @param {unknown} o */\nfunction isValidOrder(o) {\n  return o === undefined || o === 'index' || o === 'index2' || o === 'preOrderIndex' || o === 'postOrderIndex';\n}","tryCatchPattern":null,"preventionTips":["Keep a shared constant of allowed order values and validate against it.","Omit order to use the safe default sort.","Copy the exact spelling from current webpack docs for your version."],"tags":["config","chunk-ids","plugin","build"],"analyzedSha":"318421ea8ac81371f5171236a6efb63675576528","analyzedAt":"2026-08-03T19:39:56.731Z","schemaVersion":2}