esbuild-plugin-file-path-extensions
Version:
An esbuild plugin to automatically insert file extensions in your built JavaScript files based on the specified target
53 lines (50 loc) • 1.87 kB
TypeScript
import { OnLoadOptions, BuildOptions, Plugin } from 'esbuild';
interface PluginOptions {
/**
* The [esbuild filter](https://esbuild.github.io/plugins/#filters) to
* apply for the filtering of files to parse with this plugin
*
* @default /.*/
*/
filter?: OnLoadOptions['filter'];
/**
* The [esbuild namespace](https://esbuild.github.io/plugins/#namespaces) to
* which the plugin should apply
*
* @default undefined
*/
namespace?: OnLoadOptions['namespace'];
/**
* Whether the current build is for ESM or not.
*
* Accepts either a boolean value or a function that returns a boolean value.
* The function may also return a Promise which will be resolved first.
*
* In order to account for the cross-target capabilities of `tsup` the default is:
* @default build.initialOptions?.define?.TSUP_FORMAT === '"esm"'
*
*/
esm?: boolean | ((initialOptions: BuildOptions) => Awaitable<boolean>);
/**
* The extension to apply for CJS code.
* @remark Make sure to **NOT** start with a leading `.`.
*
* @default 'cjs'
*/
cjsExtension?: string | ((initialOptions: BuildOptions) => Awaitable<string>);
/**
* The extension to apply for ESM code.
* @remark Make sure to **NOT** start with a leading `.`.
*
* @default 'mjs'
*/
esmExtension?: string | ((initialOptions: BuildOptions) => Awaitable<string>);
}
declare const esbuildPluginFilePathExtensions: (options?: PluginOptions) => Plugin;
/**
* The [esbuild-plugin-file-path-extensions](https://github.com/favware/esbuild-plugin-file-path-extensions/#readme) version
* that you are currently using.
*/
declare const version: string;
type Awaitable<T> = PromiseLike<T> | T;
export { type PluginOptions, esbuildPluginFilePathExtensions, version };