Skip to main content
This release is 5 versions behind 0.16.0 — the latest version of @unplugin/macros. Jump to latest

Built and signed on GitHub Actions

Macros plugin for bundlers.

This package works with Node.js, BunIt is unknown whether this package works with Cloudflare Workers, Deno
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
JSR Score
100%
Published
a month ago (0.14.0)
Package root>src>core>options.ts
import type { FilterPattern } from 'npm:@rollup/pluginutils@^5.1.4' import type { InlineConfig, ViteDevServer } from 'npm:vite@^6.0.7' /** * Represents the options for the plugin. */ export interface Options { /** * The patterns of files to include. * @default [/\.[cm]?[jt]sx?$/] */ include?: FilterPattern /** * The patterns of files to exclude. * @default [/node_modules/] */ exclude?: FilterPattern /** * The Vite dev server instance. * * If not provided and the bundler is Vite, it will reuse the current dev server. * If not provided, it will try to use `viteConfig` to create one. */ viteServer?: ViteDevServer | false /** * The Vite configuration. * Available when `viteServer` is not provided. * @see https://vitejs.dev/config/ */ viteConfig?: InlineConfig /** * Adjusts the plugin order (only works for Vite and Webpack). * @default 'pre' */ enforce?: 'pre' | 'post' | undefined /** * The mapping of import attributes. * @default { "type": "macro" } */ attrs?: Record<string, string> } /** * Represents the resolved options for the plugin. */ export type OptionsResolved = Omit< Required<Options>, 'enforce' | 'viteServer' > & { enforce?: Options['enforce'] viteServer?: Options['viteServer'] } /** * Resolves the options for the plugin. * * @param options - The options to resolve. * @returns The resolved options. */ export function resolveOptions(options: Options): OptionsResolved { return { include: options.include || [/\.[cm]?[jt]sx?$/], exclude: options.exclude || [/node_modules/], viteServer: options.viteServer, viteConfig: options.viteConfig || {}, enforce: 'enforce' in options ? options.enforce : 'pre', attrs: options.attrs || { type: 'macro' }, } }