MCPcopy
hub / github.com/shadcn-ui/ui / transform

Function transform

packages/shadcn/src/utils/transformers/index.ts:43–72  ·  view source on GitHub ↗
(
  opts: TransformOpts,
  transformers: Transformer[] = [
    transformImport,
    transformRsc,
    transformCssVars,
    transformTwPrefixes,
    transformRtl,
    transformIcons,
    transformCleanup,
  ]
)

Source from the content-addressed store, hash-verified

41}
42
43export 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}

Calls 2

transformJsxFunction · 0.90
createTempSourceFileFunction · 0.70

Tested by

no test coverage detected