0.11.6 • Published 1 year ago

@chengdx/default-export-resolver v0.11.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

defaultExportResolver

Help to generate default export for unplugin-vue-components and unplugin-auto-import

unplugin-vue-components

// in vite.config.ts
import AutoImportComponents from 'unplugin-vue-components/vite'
import { defaultExportResolver } from '@chengdx/default-export-resolver'

export default defineConfig({
  plugins: [
    AutoImportComponents({
      dts: true,
      resolvers: [
        defaultExportResolver([
          { name: 'VChart', from: 'vue-echarts' },
        ]),
      ],
    }),
  ],
})

Then in the components.d.ts, a global component VChart will be generated.

// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'
export {}
declare module '@vue/runtime-core' {
  export interface GlobalComponents {
    VChart: typeof import('vue-echarts')['default']
  }
}

Now you can use VChart in your template without import it.

<template>
  <v-chart />
</template>

unplugin-auto-import

// in vite.config.ts
import AutoImport from 'unplugin-auto-import'
import { defaultExportResolver } from '@chengdx/default-export-resolver'

export default defineConfig({
  plugins: [
    AutoImportComponents({
      dts: true,
      resolvers: [
        defaultExportResolver([
          { name: 'defu', from: 'defu' },
        ]),
      ],
    }),
  ],
})

Then in the auto-import.d.ts, a global const defu will be generated.

// Generated by 'unplugin-auto-import'
export {}
declare global {
  const defu: typeof import('defu')['default']
}

Now you can use defu without import it.

const a = {
  b: 1
}

defu(a, { b: 0, c: -1 }) // { b: 1, c: -1 }

License

MIT License © 2022 Cheng-DX

0.11.6

1 year ago

0.11.1

1 year ago

0.11.4

1 year ago

0.11.0

1 year ago

0.10.1

1 year ago

0.10.2

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.7.2

1 year ago

0.6.3

2 years ago

0.8.0

1 year ago

0.7.1

2 years ago

0.6.2

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago