Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

unplugin-auto-re-export

Rongger68MIT0.2.1TypeScript support: included

Unified utils for auto generate re-export file.

auto-export-plugin, auto-export, re-export

readme

unplugin-auto-re-export

NPM version

Auto generate re-export file for Vite, Webpack, Rollup and more. Powered by unplugin.

If you have some files like

// utils/func.js
export function foo() {
  /* ... */
}

// utils/types.js
export const bar = 1;

the plugin can generate a file to re-export

// utils/index.js
export { foo } from "./func";
export { bar } from "./types";

by options

autoReExportPlugin({
  dir: ["utils"],
});

and modify when watched files change.

Install

npm i -D unplugin-auto-re-export

Usage

<summary>Vite</summary>
// vite.config.ts
import autoReExportPlugin from "unplugin-auto-re-export/vite";

export default defineConfig({
  plugins: [
    autoReExportPlugin({
      /* options */
    }),
  ],
});


<summary>Webpack</summary>
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require("unplugin-auto-re-export/webpack")({
      /* options */
    }),
  ],
};


<summary>Rollup</summary>
// rollup.config.js
import autoReExportPlugin from "unplugin-auto-re-export/rollup";

export default {
  plugins: [
    autoReExportPlugin({
      /* options */
    }),
  ],
};


Options

Key Type Default Description
dir string | string[] | DirConfig[] [] An array of watched directory path
ignore string[] [] An array of file path to exclude watched file
outputFile string index.js Define the outputfile name and extension name
exportAll boolean false Is spread all exports with export * from "mod"
deep number Infinity Specifies the maximum depth of a read directory relative to the start directory
baseNameMatch string * The pattern to match basename. See pattern-syntax
DirConfig
type DirConfig = {
  path: string;
  exportAll?: boolean;
  deep?: number;
  baseNameMatch?: string;
};