npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unplugin-auto-export

v1.0.2

Published

Automates the maintenance of export statements in the index.ts file.

Downloads

311

Readme

unplugin-auto-export

unplugin-auto-export is a plugin designed specifically for Vite and Webpack build tools, that automates the maintenance of export statements in index.ts files, reducing the manual effort of writing export statements. It's especially useful in large projects where managing export statements can become cumbersome.

中文文档

Features

  • Automatically watches specified directories for file changes.
  • Updates the index.ts file within those directories with the appropriate export statements.
  • Configurable to ignore specific files or directories.
  • Supports ts | js file extensions (default is ts).
  • Custom export format.

Installation

You can install the unplugin-auto-export plugin using npm or yarn:

npm install unplugin-auto-export --save-dev
# or
yarn add unplugin-auto-export --dev

Usage

To use the unplugin-auto-export plugin in your Vite project, follow these steps:

  1. Configure the plugin

vite: In your vite.config.js file, import the plugin and specify configuration options:

import { defineConfig } from 'vite';
import AutoExport from 'unplugin-auto-export/vite';

export default defineConfig({
  // ... other Vite configuration options

  plugins: [
    AutoExport({
      // Directories to watch, paths can use aliases; It just needs to end with /*
      path: ['~/views/**/{components,hooks}/*', '~/hooks/*'],
      // Directories or files to ignore (optional)
      ignore: ['**/node_modules/*'],
      // File extension (default is 'ts') `ts` | `js`
      extname: 'ts',
      // Custom export format
      formatter: (filename, extname) => `export * from './${filename}'`
    }),
  ],
});

webpack: In your webpack.config.js file, import the plugin and specify configuration options:

module.exports = {
  /* ... */
  plugins: [
    require('unplugin-auto-export/webpack').default({ /* options */ }),
  ],
}
  1. Run your project, and the unplugin-auto-export plugin will automatically maintain the index.ts files in the specified directories.

Configuration Options

  • path (string or string[]): Directories to watch for changes. Can be a single string or an array of strings.
    • You can use your own configured path aliases.
    • To use a wildcard pattern, such as ~/views/**/{components,hooks}/* or src/hooks/*.ts
  • ignore (string[]): Directories or files to ignore during watching. (optional)
    • Follows the same path rule as path.
  • extname (string): The file extension to use for the index files (default is ts).
    • support ts | js.
  • formatter((filename: string, extname: string) => string): Custom export format

Error Handling

  • The unplugin-auto-export plugin enforces a specific path rule: /\/\*(\.[\w\d]+)?$/.
    • When using a wildcard pattern, it only requires ending with /* or /*.ts. Typically, ending with /* is sufficient.
    • Because this is the only way to indicate monitoring files within a specific folder.
  • If the path does not match this rule, the plugin will throw an error with the message: Path rule does not match. Please check the path format.
  • Correct examples: ~/views/**/{components,hooks}/* or src/hooks/*.ts
    • "~" is a configured path alias.

Example

Vite

Webpack

Contributing

If you encounter any issues or have suggestions for improvements, feel free to open an issue or contribute to the project.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

GitHub: coderhyh

Additional Information

For more information and updates, visit the unplugin-auto-export GitHub repository.