unplugin-vue-named-export
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

unplugin-vue-named-export npm

Unit Test

Named export for Vue SFC.

Installation

npm i -D unplugin-vue-named-export
Vite
// vite.config.ts
import VueNamedExport from 'unplugin-vue-named-export/vite'

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


Rollup
// rollup.config.js
import VueNamedExport from 'unplugin-vue-named-export/rollup'

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


esbuild
// esbuild.config.js
import { build } from 'esbuild'

build({
  plugins: [
    require('unplugin-vue-named-export/esbuild')({
      /* options */
    }),
  ],
})


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-vue-named-export/webpack')({
      /* options */
    }),
  ],
}


Usage

Use pascal case named exports in Vue SFC.

import { MyComponent } from './MyComponent.vue'
import { MyCard } from './my-card.vue'
import { MyFooter } from './my_footer.vue'

Options

type Options = {
  include?: string | RegExp | (string | RegExp)[]
  exclude?: string | RegExp | (string | RegExp)[]

  /**
   * Convert filename to export name
   * @default pascalCaseFn
   */
  resolveName?: (id: string) => string | Promise<string>
  /**
   * Whether to keep default export
   * @default false
   */
  removeDefault?: boolean
}

Vue Language Tools (Volar)

For Vue Language Tools (Volar) < 2.0, please use unplugin-vue-named-export@0.3.0

Support only pascal case named export for Volar.

// tsconfig.json
{
  // ...
  "vueCompilerOptions": {
    "plugins": ["unplugin-vue-named-export/volar"],

    "namedExport": {
      // defaults to false
      "removeDefault": false,
    },
  },
}

Sponsors

License

MIT License © 2023-PRESENT 三咲智子

Package Sidebar

Install

npm i unplugin-vue-named-export

Weekly Downloads

1

Version

0.4.0

License

MIT

Unpacked Size

3.77 MB

Total Files

33

Last publish

Collaborators

  • userquin
  • hannoeru
  • sxzz
  • antfu