fix: types for rollup
This commit is contained in:
parent
08cac3965e
commit
8bf28c8aed
|
|
@ -1,4 +1,3 @@
|
||||||
import type { Plugin } from 'rollup';
|
|
||||||
import type { CsvLoaderOptions } from './loader.js';
|
import type { CsvLoaderOptions } from './loader.js';
|
||||||
import { csvToModule } from './loader.js';
|
import { csvToModule } from './loader.js';
|
||||||
import * as path from 'path';
|
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.
|
* Rollup plugin for loading CSV files with inline-schema validation.
|
||||||
* Works with both Vite and Tsup (esbuild).
|
* Works with both Vite and Tsup (esbuild).
|
||||||
*/
|
*/
|
||||||
export function csvLoader(options: CsvRollupOptions = {}): Plugin {
|
export function csvLoader(options: CsvRollupOptions = {}): RollupPlugin {
|
||||||
const {
|
const {
|
||||||
include = /\.csv$/,
|
include = /\.csv$/,
|
||||||
exclude,
|
exclude,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue