0.1.1 • Published 10 months ago

unplugin-doctor v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

unplugin-doctor

NPM version

🩺 Inject lifecycle hooks in unplugin tools for better develop experience.

Features

  • Easy to analysis each step of unplugin
  • Provide before / after lifecycle hooks
  • Written in typescript
  • Support diff origin code with transform result

Installation

pnpm i unplugin-doctor -D

Usage

Wrap Unplugin

Use unplugin-vue-router as example:

// vite.config.ts
import Doctor from 'unplugin-doctor'
import VueRouter from 'unplugin-vue-router'

export default defineConfig({
  plugins: [
    Doctor(VueRouter, {
      /* vue router options */
    }).vite({})
  ],
})

Inject Lifecycle Hooks

Doctor(VueRouter, {}).vite({
  beforeLoad() {
    console.time('[vue router load module]')
  },
  afterLoad(id, code) {
    console.timeEnd('[vue router load module]')
    console.log(id, code)
  }
})

Props

props.buildStart

  • Type: (ctx: { options: Options }) => void | Promise<void>
  • Default: undefined

props.beforeLoad

  • Type: (id: string, ctx: { options: Options }) => void | Promise<void>
  • Default: undefined

props.afterLoad

  • Type: (id: string, code: TransformResult, ctx: { options: Options }) => void | Promise<void>
  • Default: undefined

props.beforeTransform

  • Type: (id: string, code: string, ctx: { options: Options }) => void | Promise<void>
  • Default: undefined

props.afterTransform

  • Type: (id: string, code: TransformResult, ctx: { options: Options }) => void | Promise<void>
  • Default: undefined

props.buildEnd

  • Type: (ctx: { options: Options }) => void | Promise<void>
  • Default: undefined

License

MIT License © 2024-PRESENT Tamago

0.1.1

10 months ago

0.1.0

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago