vite-plugin-custom-functions-metadata

raw JSON →
1.0.1 verified Mon Apr 27 auth: no javascript

Vite plugin (v1.0.1) that generates JSON metadata for custom Excel functions from TypeScript source files, intended for Office Add-ins development. It scans a given input file for JSDoc-annotated functions and outputs a metadata JSON file referencing function names, descriptions, and parameters. The plugin is designed to integrate into the Vite build pipeline, automating metadata generation that would otherwise require manual maintenance. Differentiators: dedicated to Excel custom functions, leverages TypeScript type definitions, and provides a simple plugin interface for modern Vite projects. Release cadence is currently low; no breaking changes known.

error Error: Cannot find module 'vite-plugin-custom-functions-metadata'
cause Package not installed or using require() in an ESM-only package.
fix
Install with 'npm install vite-plugin-custom-functions-metadata --save-dev' and use import syntax.
error TypeError: customFunctionsMetadataPlugin is not a function
cause Default import expected but named import used incorrectly.
fix
Use 'import customFunctionsMetadataPlugin from ...' instead of destructured import.
gotcha The plugin only processes a single input file; if your functions are split across multiple files, you must manually aggregate them into one input file or use a workaround.
fix Create a barrel file that re-exports all custom functions from separate modules.
gotcha The output JSON file is overwritten on every build; ensure no manual edits are lost.
fix Do not manually edit the output file; treat it as a build artifact.
gotcha JSDoc annotations are required for function metadata to be generated; plain TypeScript without JSDoc will not produce entries.
fix Add JSDoc tags like @customfunction, @param, @returns to your functions.
breaking No breaking changes known yet; however, the plugin is at v1.0.x and may introduce breaking changes in future major versions.
fix Pin to version 1.x and test upgrades.
npm install vite-plugin-custom-functions-metadata
yarn add vite-plugin-custom-functions-metadata
pnpm add vite-plugin-custom-functions-metadata

Configures the Vite plugin to generate Excel custom functions metadata from a TypeScript input file.

import { defineConfig } from 'vite';
import customFunctionsMetadataPlugin from 'vite-plugin-custom-functions-metadata';
import { resolve } from 'path';

export default defineConfig({
  plugins: [
    customFunctionsMetadataPlugin({
      inputFile: resolve(__dirname, 'src/functions/functions.ts'),
      outputFile: resolve(__dirname, 'src/functions/functions.json'),
    }),
  ],
});