Introduction
conventional-changelog-preset-loader resolves a preset by name — turning a shorthand like angular into the conventional-changelog-angular package — and loads its config. It’s what powers .loadPreset() across the tooling; reach for it directly when building your own tools or when a bundler needs a custom module loader.
Quick start
Section titled “Quick start”-
Install
conventional-changelog-preset-loader:pnpm add conventional-changelog-preset-loadernpm i conventional-changelog-preset-loaderyarn add conventional-changelog-preset-loader -
Load a preset by name.
loadPresetis async and imports the matching package:import { loadPreset } from 'conventional-changelog-preset-loader'const preset = await loadPreset('conventionalcommits') -
Get its config — the object returned by the preset’s
createPresetfactory:console.log(Object.keys(preset))// → ['commits', 'parser', 'writer', 'whatBump']
Shorthand names
Section titled “Shorthand names”A bare name is expanded to the conventional-changelog- package, falling back to the name as-is:
| Input | Resolved (in order) |
|---|---|
angular | conventional-changelog-angular, then angular |
@scope/foo | @scope/conventional-changelog-foo, then @scope/foo |
@conventional-changelog/preset | used as-is |
/abs/path/to/preset.js | used as-is |
Passing preset options
Section titled “Passing preset options”Pass an object with a name and the preset’s options — everything is forwarded to createPreset:
const preset = await loadPreset({ name: 'conventionalcommits', preMajor: true})Custom module loader
Section titled “Custom module loader”The default loadPreset imports modules with import(name). When you need different resolution — for example inside a bundle — build a loader with createPresetLoader:
import { createPresetLoader } from 'conventional-changelog-preset-loader'
const loadPreset = createPresetLoader(name => import(name))
const preset = await loadPreset('conventionalcommits')This is also how conventional-changelog accepts a custom loader as the second argument to .loadPreset().