resolveCompositionComponent()v4.0.528
Locates the component used by a composition, following supported project imports and re-exports.
Draft API: This API is experimental and may change.
resolve-composition-component.tsimport {resolveCompositionComponent , typeCodemodProject } from '@remotion/codemods'; declare constproject :CodemodProject ; constresult =resolveCompositionComponent ({project ,compositionFile : 'src/Root.tsx',compositionId : 'MyComposition', });console .log (result );
The component must return supported JSX. Dynamic component expressions and unresolved imports throw an error. This function does not load or execute components.
Options
project
An in-memory CodemodProject. The input project is not mutated.
environment?v4.0.544
A file-backed source environment, used instead of project. It follows imports by reading files synchronously on demand.
compositionFile
The file registering the composition.
compositionId
The static ID of the composition to resolve.
Return value
Returns an object with the following properties for both source modes.
filePath
The component source file, using its key in project.files.
exportName
The resolved export name, or default.
location
The declaration's {line, column} location. Lines are one-based; columns are zero-based.
canAddContent
Whether the component's return value supports content insertion. Pass filePath and exportName as a {type: 'component'} target to addElement() to insert into the resolved component.
Errors
Throws when the composition cannot be found or its component cannot be resolved.
Compatibility
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||