From 8bf28c8aedd362524bc1d8dd05822267ae1b7519 Mon Sep 17 00:00:00 2001 From: hypercross Date: Sat, 4 Apr 2026 16:55:17 +0800 Subject: [PATCH] fix: types for rollup --- src/csv-loader/rollup.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/csv-loader/rollup.ts b/src/csv-loader/rollup.ts index b16c234..07a03e6 100644 --- a/src/csv-loader/rollup.ts +++ b/src/csv-loader/rollup.ts @@ -1,4 +1,3 @@ -import type { Plugin } from 'rollup'; import type { CsvLoaderOptions } from './loader.js'; import { csvToModule } from './loader.js'; import * as path from 'path'; @@ -25,11 +24,35 @@ function matchesPattern( }); } +interface TransformResult { + code: string; + map: null; +} + +interface EmitFileOptions { + type: 'asset'; + fileName: string; + source: string; +} + +interface PluginContext { + emitFile: (options: EmitFileOptions) => string; +} + +interface RollupPlugin { + name: string; + transform: ( + this: PluginContext, + code: string, + id: string + ) => TransformResult | null; +} + /** * Rollup plugin for loading CSV files with inline-schema validation. * Works with both Vite and Tsup (esbuild). */ -export function csvLoader(options: CsvRollupOptions = {}): Plugin { +export function csvLoader(options: CsvRollupOptions = {}): RollupPlugin { const { include = /\.csv$/, exclude,