Supported Export Types
The extension recognizes and processes multiple export patterns through its Babel-based parser implementation.Function Declarations
Standard function declarations that return JSX elements containing SVG components:Function declarations are parsed at
src/utilities/svg/extracts.ts:122 and analyzed to extract the returned JSX element.Arrow Function Expressions
Arrow functions assigned to variables, supporting both implicit and explicit returns:Named vs Default Exports
The extension supports both named and default export patterns:Named Exports
Default Exports
JSX/TSX Component Formats
The extension uses the Babel parser withjsx and typescript plugins to support modern JavaScript and TypeScript syntax.
Required Attributes
For a component to be recognized as a valid SVG:Component Props Support
The extension analyzes component parameters and extracts prop types:Component parameters are analyzed at
src/utilities/svg/analyze.ts:17 using the getNodeParams function to extract prop information.Parser Configuration
The Babel parser is configured with specific plugins to ensure broad syntax support:- JSX syntax - React-style JSX elements and fragments
- TypeScript syntax - Type annotations, interfaces, and TypeScript-specific features
- ES Modules - Import/export statements and module-level code
File Type Support
Based on thepackage.json configuration, the extension activates for files matching:
.js- JavaScript files.jsx- JavaScript with JSX.ts- TypeScript files (excluding.d.tsdefinition files).tsx- TypeScript with JSX
Non-Exported Components
By default, the extension focuses on exported components, but you can configure it to show non-exported SVG components:Component Validation
The extension performs several validation checks:- Valid SVG Tag - Ensures the root element is a recognized SVG tag (not Fragment)
- xmlns Attribute - Validates the presence and value of the SVG namespace
- Component Structure - Analyzes the JSX tree to extract properties and children
- Error Handling - Captures and reports parsing errors with file location context
Validation occurs at
src/utilities/svg/SVGComponent.ts:23 in the validateOpeningElement function.