Skip to main content
This release is 2 versions behind 0.13.1 — the latest version of @unplugin/ast. Jump to latest

@unplugin/ast@0.12.0
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
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
It is unknown whether this package works with Deno
This package works with Bun
It is unknown whether this package works with Browsers
JSR Score
88%
Published
2 months ago (0.12.0)
Package root>src>core>options.ts
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) : [], } }