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,