Skip to content

Commit

Permalink
perf: avoid hitting fs if we have no transformers (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jan 10, 2024
1 parent d440d97 commit 1a173aa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,20 @@ export function useComponentMetaParser (
// Component is missing required values
if (!component?.fullPath || !component?.pascalName) { return }

// Read component code
let code = await readFile(component.fullPath, 'utf-8')

// Support transformers
if (transformers && transformers.length > 0) {
// Read component code
let code = await readFile(component.fullPath, 'utf-8')

for (const transform of transformers) {
const transformResult = transform(component, code)
component = transformResult?.component || component
code = transformResult?.code || code
}
}

// Ensure file is updated
checker.updateFile(component.fullPath, code)
// Ensure file is updated
checker.updateFile(component.fullPath, code)
}

const { type, props, slots, events, exposed } = checker.getComponentMeta(component.fullPath)

Expand Down

0 comments on commit 1a173aa

Please sign in to comment.