moveComposition()v4.0.528
Moves a composition into a folder, to the root, or beside another registration.
Draft API: This API is experimental and may change.
move-composition.tsimport {moveComposition , typeCodemodProject } from '@remotion/codemods'; declare constproject :CodemodProject ; constresult =moveComposition ({project ,compositionFile : 'src/Root.tsx',compositionId : 'MyComposition',destination : {type : 'folder',folder : {name : 'Social',parentName : null}}, });console .log (result );
The composition and destination must be in the same registration file. Their source must allow a direct child move. The component implementation and composition ID stay unchanged.
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 static IDs or folder names. Aliased and namespace imports from remotion are supported.
compositionId
The static ID of the composition to edit.
destination
Where to move the item within the same file. Use {type: 'root'}, {type: 'folder', folder: {name, parentName}}, or {type: 'before' | 'after', target}. A target is {type: 'composition', compositionId} or {type: 'folder', name, parentName}. Moving an item into its current parent is a no-op.
Return value
Returns an object with the following properties.
changes
An array of {filePath, previousContents, nextContents} file changes. A null content value indicates a created or deleted file.
nodePathRemappings
An array of {filePath, oldNodePath, newNodePath} mappings. A null old path indicates an insertion; a null new path indicates removal. Apply these mappings to references from the input project. See node references.
updatedNodev4.0.530
The moved registration's node reference in the new project.
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 | ||||