(
opts: TransformOpts,
transformers: Transformer[] = [
transformImport,
transformRsc,
transformCssVars,
transformTwPrefixes,
transformRtl,
transformIcons,
transformCleanup,
]
)
| 41 | } |
| 42 | |
| 43 | export async function transform( |
| 44 | opts: TransformOpts, |
| 45 | transformers: Transformer[] = [ |
| 46 | transformImport, |
| 47 | transformRsc, |
| 48 | transformCssVars, |
| 49 | transformTwPrefixes, |
| 50 | transformRtl, |
| 51 | transformIcons, |
| 52 | transformCleanup, |
| 53 | ] |
| 54 | ) { |
| 55 | const tempFile = await createTempSourceFile(opts.filename) |
| 56 | const sourceFile = project.createSourceFile(tempFile, opts.raw, { |
| 57 | scriptKind: ScriptKind.TSX, |
| 58 | }) |
| 59 | |
| 60 | for (const transformer of transformers) { |
| 61 | await transformer({ sourceFile, ...opts }) |
| 62 | } |
| 63 | |
| 64 | if (opts.transformJsx) { |
| 65 | return await transformJsx({ |
| 66 | sourceFile, |
| 67 | ...opts, |
| 68 | }) |
| 69 | } |
| 70 | |
| 71 | return sourceFile.getText() |
| 72 | } |
no test coverage detected