website/docs/en/plugins/webpack/deterministic-module-ids-plugin.mdx
import WebpackLicense from '@components/WebpackLicense';
<WebpackLicense from="https://webpack.js.org/configuration/optimization/#optimizationmoduleids" />DeterministicModuleIdsPlugin assigns short numeric ids to modules based on their module identifiers. The ids are stable between compilations, which makes the plugin useful for long-term caching.
optimization.moduleIds: 'deterministic' uses this plugin internally. Use the plugin directly when you need to customize the deterministic id generation behavior.
import rspack from '@rspack/core';
export default {
optimization: {
moduleIds: false,
},
plugins: [
new rspack.ids.DeterministicModuleIdsPlugin({
maxLength: 4,
}),
],
};
stringcompiler.contextThe context used to create relative module identifiers before ids are generated.
(module: Module) => booleanundefinedSelects which modules should receive deterministic ids from this plugin. When omitted, all modules that need ids are included.
import rspack from '@rspack/core';
export default {
optimization: {
moduleIds: false,
},
plugins: [
new rspack.ids.DeterministicModuleIdsPlugin({
test: (module) => module.type.startsWith('css'),
}),
],
};
number3The maximum id length in digits used as the starting id space. The generated numeric id space starts at 10 ** maxLength.
number0The hash salt used when generating ids. Change this value to try a different hash starting value in the same id space.
booleanfalseWhen enabled, Rspack does not increase the id length to find a larger id space.
booleanfalseWhen enabled, Rspack reports an error if deterministic id assignment produces conflicts. By default, Rspack resolves conflicts by retrying with a larger id space.
For the common long-term caching setup, prefer the built-in optimization option:
export default {
optimization: {
moduleIds: 'deterministic',
},
};
Use DeterministicModuleIdsPlugin directly only when you need the options above.