0.2.1 • Published 2 years ago

unplugin-auto-re-export v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

// vite.config.ts
import autoReExportPlugin from "unplugin-auto-re-export/vite";

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

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

// rollup.config.js
import autoReExportPlugin from "unplugin-auto-re-export/rollup";

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

Options

KeyTypeDefaultDescription
dirstring \| string[] \| DirConfig[][]An array of watched directory path
ignorestring[][]An array of file path to exclude watched file
outputFilestringindex.jsDefine the outputfile name and extension name
exportAllbooleanfalseIs spread all exports with export * from "mod"
deepnumberInfinitySpecifies the maximum depth of a read directory relative to the start directory
baseNameMatchstring*The pattern to match basename. See pattern-syntax
DirConfig
type DirConfig = {
  path: string;
  exportAll?: boolean;
  deep?: number;
  baseNameMatch?: string;
};
0.2.1

2 years ago

0.2.0

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.3-beta.1

2 years ago

0.1.3-beta.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago