fix: types for rollup
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user