From b91c297a75d219879ba87f1f23d0dd40e18b6b52 Mon Sep 17 00:00:00 2001 From: Sarah Dayan <5370675+sarahdayan@users.noreply.github.com> Date: Thu, 5 Feb 2026 13:37:29 +0100 Subject: [PATCH 1/2] fix: spread parserOpts and writerOpts to avoid immutable object error The preset config objects may be frozen. Create shallow copies before passing to conventional-changelog-core to avoid "Cannot modify immutable object" error. Co-Authored-By: Claude Opus 4.5 --- packages/shipjs/src/step/prepare/updateChangelog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shipjs/src/step/prepare/updateChangelog.js b/packages/shipjs/src/step/prepare/updateChangelog.js index 5391c0cc..034ea4fb 100644 --- a/packages/shipjs/src/step/prepare/updateChangelog.js +++ b/packages/shipjs/src/step/prepare/updateChangelog.js @@ -169,8 +169,8 @@ function runConventionalChangelog({ args, templateContext, { ...gitRawCommitsOpts, path: dir }, - parserOpts, - writerOpts, + parserOpts ? { ...parserOpts } : undefined, + writerOpts ? { ...writerOpts } : undefined, { path: dir, cwd: dir } ).on('error', reject); From 4a65f39eac7d7d68f838dfeda82423fc48bb5fbe Mon Sep 17 00:00:00 2001 From: Sarah Dayan <5370675+sarahdayan@users.noreply.github.com> Date: Thu, 5 Feb 2026 13:42:44 +0100 Subject: [PATCH 2/2] fix(changelog): handle frozen commit objects from conventional-changelog-writer The conventional-changelog-writer library freezes commit objects, but presets like angular expect to mutate them. This causes a "Cannot modify immutable object" error when the transform function tries to change commit.type. Add a wrapTransform helper that deep clones commits before passing them to the original transform function, allowing mutation while preserving the original frozen objects. Co-Authored-By: Claude Opus 4.5 --- .../src/step/prepare/updateChangelog.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/shipjs/src/step/prepare/updateChangelog.js b/packages/shipjs/src/step/prepare/updateChangelog.js index 034ea4fb..09be9fbf 100644 --- a/packages/shipjs/src/step/prepare/updateChangelog.js +++ b/packages/shipjs/src/step/prepare/updateChangelog.js @@ -152,6 +152,21 @@ export async function prepareParams({ return { args, gitRawCommitsOpts, templateContext }; } +// Wraps a transform function to clone commits before modification. +// This is needed because conventional-changelog-writer freezes commit objects, +// but presets like angular expect to mutate them. +function wrapTransform(originalTransform) { + if (!originalTransform) { + return undefined; + } + + return (commit, context) => { + const mutableCommit = JSON.parse(JSON.stringify(commit)); + + return originalTransform(mutableCommit, context); + }; +} + function runConventionalChangelog({ args, templateContext, @@ -165,12 +180,15 @@ function runConventionalChangelog({ } const { parserOpts, writerOpts } = args.config || {}; + const wrappedWriterOpts = writerOpts + ? { ...writerOpts, transform: wrapTransform(writerOpts.transform) } + : undefined; const changelogStream = conventionalChangelogCore( args, templateContext, { ...gitRawCommitsOpts, path: dir }, parserOpts ? { ...parserOpts } : undefined, - writerOpts ? { ...writerOpts } : undefined, + wrappedWriterOpts, { path: dir, cwd: dir } ).on('error', reject);