renameComposition()v4.0.528
Changes a composition registration's ID.
Draft API: This API is experimental and may change.
rename-composition.tsimport {renameComposition , typeCodemodProject } from '@remotion/codemods'; declare constproject :CodemodProject ; constresult =renameComposition ({project ,compositionFile : 'src/Root.tsx',compositionId : 'MyComposition',newId : 'RenamedComposition', });console .log (result );
Changes the ID in source. It does not rename component exports, files, or references elsewhere. Passing the existing ID returns an unchanged project.
Options
project
An in-memory CodemodProject. The input project is not mutated.
compositionFile
The project file containing the composition registrations. Registration edits support <Composition>, <Still>, and <Folder> with their original import names and static IDs or folder names.
compositionId
The static ID of the composition to edit.
newId
The new ID, containing only letters, numbers, or hyphens. It must be unused in this file.
Return value
Returns an object with the following properties.
project
The updated project. Unchanged files and extra project fields are preserved.
changes
An array of {filePath, previousContents, nextContents} file changes. A null content value indicates a created or deleted file.
Errors
Throws when the target cannot be resolved, the requested edit is unsupported, or an option is invalid. Failed edits leave the input project unchanged.
Compatibility
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||