webpack/webpack · error · Error

${PLUGIN_NAME}: unexpected value of order

Error message

${PLUGIN_NAME}: unexpected value of order

What it means

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.

Source

Thrown at lib/ids/ChunkModuleIdRangePlugin.js:74

					);
				}

				/** @type {Module[]} */
				let chunkModules;
				if (this.options.order) {
					/** @type {ModuleComparator} */
					let cmpFn;
					switch (this.options.order) {
						case "index":
						case "preOrderIndex":
							cmpFn = compareModulesByPreOrderIndexOrIdentifier(moduleGraph);
							break;
						case "index2":
						case "postOrderIndex":
							cmpFn = compareModulesByPostOrderIndexOrIdentifier(moduleGraph);
							break;
						default:
							throw new Error(`${PLUGIN_NAME}: unexpected value of order`);
					}
					chunkModules = chunkGraph.getOrderedChunkModules(chunk, cmpFn);
				} else {
					chunkModules = [...modules]
						.filter((m) => chunkGraph.isModuleInChunk(m, chunk))
						.sort(compareModulesByPreOrderIndexOrIdentifier(moduleGraph));
				}

				let currentId = this.options.start || 0;
				for (let i = 0; i < chunkModules.length; i++) {
					const m = chunkModules[i];
					if (m.needId && chunkGraph.getModuleId(m) === null) {
						chunkGraph.setModuleId(m, currentId++);
					}
					if (this.options.end && currentId > this.options.end) break;
				}
			});
		});

View on GitHub (pinned to 318421ea8a)

Solutions

  1. Set order to one of 'index', 'index2', 'preOrderIndex', or 'postOrderIndex'.
  2. Omit order entirely to fall back to the default pre-order-by-identifier sort.
  3. Double-check the spelling and case against the current webpack docs for the installed version.

Example fix

// before
new webpack.ids.ChunkModuleIdRangePlugin({ name: 'app', order: 'post-order', start: 0 })
// after
new webpack.ids.ChunkModuleIdRangePlugin({ name: 'app', order: 'postOrderIndex', start: 0 })
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = new Set(['index', 'index2', 'preOrderIndex', 'postOrderIndex']);
if (pluginOptions.order !== undefined && !ALLOWED.has(pluginOptions.order)) {
  throw new Error(`ChunkModuleIdRangePlugin.order must be one of ${[...ALLOWED].join(', ')}`);
}

Type guard

/** @param {unknown} o */
function isValidOrder(o) {
  return o === undefined || o === 'index' || o === 'index2' || o === 'preOrderIndex' || o === 'postOrderIndex';
}

Prevention

When it happens

Trigger: 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.

Common situations: 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'.

Related errors


AI-assisted analysis of webpack/webpack@318421ea8a (2026-08-03). Data as JSON: /data/errors/e3bcf6145f83889d.json. Report an issue: GitHub.