unplugin-jsx-source
Version:
[](https://www.npmjs.com/package/unplugin-jsx-source)
58 lines (55 loc) • 1.82 kB
TypeScript
import { ParserOptions } from '@babel/parser';
import { FilterPattern } from 'unplugin-utils';
import * as t from '@babel/types';
interface Options {
/**
* The include pattern to match files
* @default ['.[jt]sx?$']
*/
include?: FilterPattern;
exclude?: FilterPattern | undefined;
enforce?: "post" | "pre" | undefined;
parserOptions?: ParserOptions;
/**
* The transform function to modify the file name used in the `attributes.at` option
*/
transformFileName?: (fileName: string, location: t.SourceLocation) => string;
/**
* The attributes to add to the JSX element
* @default { at: 'data-at', in: 'data-in', kind: 'data-kind' }
*/
attributes?: {
/**
* The attribute name to add for the `fileName:lineStart-lineEnd` location
* @default 'data-at'
* data-source="file.tsx:4-4"
*/
at?: string | false;
/**
* The attribute name to add for the file location (only)
* @default false
*
* @example
* data-source="4-4"
*/
loc?: string | false;
/**
* The attribute name to add for the wrapping component name
* @default 'data-in'
*/
in?: string | false;
/**
* The attribute name to add for the component kind
* @default 'data-kind'
*/
kind?: string | false;
};
}
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
type OptionsResolved = Overwrite<Required<Options>, {
exclude: Options["exclude"];
enforce: Options["enforce"];
attributes: Required<Required<Options>["attributes"]>;
}>;
declare function resolveOption(options: Options): OptionsResolved;
export { type Options, type OptionsResolved, resolveOption };