0.4.1 • Published 2 months ago

vite-plugin-circular-dependency v0.4.1

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

vite-plugin-circular-dependency

English | 中文

A framework-agnostic build-time Vite plugin designed to detect circular imports and self-references, compatible with dynamic and static imports.

DEMO

// Configure the output path, 
// a scan report will be generated to the specified path
export default defineConfig({
  plugins: [
    circleDependency({
        outputFilePath: './circleDep'
    })
  ],
})

image

// Without any configuration, it will be printed on the console
export default defineConfig({
  plugins: [
    circleDependency()
  ],
})

image

Installation

npm i -D vite-plugin-circular-dependency
// yarn add --dev vite-plugin-circular-dependency
// pnpm i --dev vite-plugin-circular-dependency

Usage

Please use this plugin when building

In your vite.config.(js|ts) import the plugin and register it.

import { defineConfig } from 'vite'
import circleDependency from 'vite-plugin-circular-dependency'

export default defineConfig({
  plugins: [
    circleDependency()
  ],
})

Options

export interface Options {
    /**
     * Rules to include transforming target.
     *
     * @default [/\.[jt]sx?$/, /\.vue\??/]
     */
    include?: FilterPattern

    /**
     * Rules to exclude scan target.
     *
     * @default [/node_modules/, /\.git/]
     */
    exclude?: FilterPattern

    /**
     * The file address of the scan result output, the default console print
     */
    outputFilePath?: string

    /**
     * Whether to throw an error when a circular import exists
     *
     * @default true
     */
    circleImportThrowErr?: boolean

    /**
     * Format the path of the output node. 
     * By default, vite.config will be used as the root path to generate a relative path
     *
     * @default function
     */
    formatOutModulePath?: (path: string) => string

    /**
     * The result of formatted output 
     * will also affect the data format in the console print or output file
     *
     * @default (data: CircleData) => data
     */
    formatOut?: (data: CircleData) => any
}
0.4.1

2 months ago

0.4.0

2 months ago

0.3.1

3 months ago

0.3.0

4 months ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago