Appearance
Programmatic API
The package exports two functions from src/convert.ts (re-exported by src/index.ts):
convert— read a file from disk, write a.vuefile.convertCode— convert an in-memory string (used by the playground and tests).
Only from: "react" and to: "vue" are valid. Anything else throws.
convert(options)
ts
export type ConvertOptions = {
from: "react"
to: "vue"
inputPath: string
outputDir?: string
}
export function convert(options: ConvertOptions): voidinputPath: path to a.tsx/.jsx/.ts/.jssource file (resolved withpath.resolve).outputDir: optional; if omitted, the.vueis written beside the input file.
Errors
Throws if from / to are not exactly react / vue:
txt
Only --from react --to vue is supported in this version.convertCode(options)
ts
export type ConvertCodeOptions = {
from: "react"
to: "vue"
sourceCode: string
filename?: string
}
export function convertCode(options: ConvertCodeOptions): stringsourceCode: full source of a single React component file.filename: optional; defaults to"component.tsx". Used for parse error context and as the virtual path passed to the parser.
Returns the full Vue SFC as a string (including <script setup> and <template>).
Errors
Throws if from / to are not supported:
txt
Only React to Vue conversion is supported in this version.Parsing or codegen failures surface as standard Error messages from the implementation.
ESM import
The published bundle is ESM ("type": "module").
ts
import { convert, convertCode } from "cross-framework"TypeScript types
The repo currently builds with tsup and dts is not emitted in tsup.config.ts. Consumers can still use TypeScript and may add their own ambient types or enable allowJs / skipLibCheck as needed; adding .d.ts generation is a possible future improvement.