This release is 2 versions behind 0.13.1 — the latest version of @unplugin/ast. Jump to latest
Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
Manipulate the AST to transform your code.
This package works with Node.js, BunIt is unknown whether this package works with Cloudflare Workers, Deno, Browsers
JSR Score
88%
Published
2 months ago (0.12.0)
import { toArray, type Arrayable } from 'npm:@antfu/utils@^0.7.10' import type { Transformer } from './types.ts' import type { ParserOptions } from 'npm:@babel/parser@^7.26.2' import type { FilterPattern } from 'npm:@rollup/pluginutils@^5.1.3' export interface Options { include?: FilterPattern exclude?: FilterPattern | undefined enforce?: 'post' | 'pre' | undefined parserOptions?: ParserOptions transformer?: Arrayable<Transformer<any>> } type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U export type OptionsResolved = Overwrite< Required<Options>, { exclude: Options['exclude'] enforce: Options['enforce'] transformer: Transformer<any>[] } > export function resolveOption(options: Options): OptionsResolved { return { include: options.include || [/\.[jt]sx?$/], exclude: options.exclude || undefined, enforce: options.enforce || undefined, parserOptions: options.parserOptions || {}, transformer: options.transformer ? toArray(options.transformer) : [], } }