Skip to main content

deleteJsxNodes()v4.0.527

Deletes one or more JSX elements identified by source node references. It works with any JSX layer, including <Sequence> and <Solid>.

warning

Draft API: This API is not yet stable. We are in the experimental phase of this package and reserve to change it at any time.

delete-jsx-nodes.ts
import {deleteJsxNodes, type CodemodProject} from '@remotion/codemods'; import type {SequenceNodePath} from 'remotion'; declare const project: CodemodProject; declare const nodePath: SequenceNodePath; const result = await deleteJsxNodes({ project, nodes: [{filePath: 'src/Video.tsx', nodePath}], }); console.log(result.project.files); console.log(result.changes);

The input project is not mutated.

Options

Pass an object with the following properties.

project

An in-memory Remotion project containing rootDir and a files record.

nodes

The JSX elements to delete. Nodes may belong to different project files.

filePath

The source file containing the JSX element. Absolute paths emitted by a mounted layer and project-relative paths are both accepted.

nodePath

The SequenceNodePath identifying the JSX element to delete. Obtain it from getJsxNodes(), an insertion result, or a mounted layer. Canvas layers expose it as nodePathInfo.sequenceSubscriptionKey.nodePath.

Return value

A promise resolving to an object with the following properties.

project

A new project containing the transformed source. Unchanged project fields are preserved.

changes

An array describing each changed file with its filePath, previousContents, and nextContents.

nodePathRemappingsv4.0.528

File-qualified {filePath, oldNodePath, newNodePath} mappings for keeping node references after the edit. A null old path indicates an insertion; a null new path indicates removal. See node references.

Compatibility

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

See also