UNPKG

@plugjs/plug

Version:
30 lines (29 loc) 854 B
import type { Plugin } from 'esbuild'; /** * A simple ESBuild plugin fixing extensions for `require` and `import` calls. * * This can be useful when compiling dual-module packages (`esm` and `cjs`), * where the file module type is determined by the `.mjs` or `.cjs` extension. * * For example this will make sure all `import` statements use the `.mjs` * extensions, while all `require` use `.cjs`. * * ``` * await find('*.ts', { directory: 'src' }) * .esbuild({ * outdir: 'dist', * format: 'cjs', * plugins: [ fixExtensions ], * outExtension: { '.js': '.mjs' }, * }) * * await find('*.ts', { directory: 'src' }) * .esbuild({ * outdir: 'dist', * format: 'esm', * plugins: [ fixExtensions ], * outExtension: { '.js': '.mjs' }, * }) * ``` */ export declare function fixExtensions(): Plugin;