Skip to content

Commit d0064c8

Browse files
authored
fix(unplugin-vue-i18n): plugin option made be optional (#390)
1 parent 19b223a commit d0064c8

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

packages/unplugin-vue-i18n/src/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import createDebug from 'debug'
33
import { raiseError, checkInstallPackage, resolveNamespace } from './utils'
44
import { resolveOptions, resourcePlugin, directivePlugin } from './core'
55

6+
import type { UnpluginFactory, UnpluginInstance } from 'unplugin'
67
import type { PluginOptions } from './types'
78

89
const debug = createDebug(resolveNamespace('root'))
910
const installedPkgInfo = checkInstallPackage(debug)
1011

11-
export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
12+
export * from './types'
13+
14+
export const unpluginFactory: UnpluginFactory<PluginOptions | undefined> = (
15+
options = {},
16+
meta
17+
) => {
1218
debug('meta framework', meta.framework)
1319
// check bundler type
1420
if (!['vite', 'webpack'].includes(meta.framework)) {
@@ -31,8 +37,9 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
3137
}
3238

3339
return plugins
34-
})
40+
}
3541

36-
export default unplugin
42+
export const unplugin: UnpluginInstance<PluginOptions | undefined, boolean> =
43+
/* #__PURE__ */ createUnplugin(unpluginFactory)
3744

38-
export * from './types'
45+
export default unplugin
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
import unplugin from '.'
1+
import { createVitePlugin } from 'unplugin'
2+
import { unpluginFactory } from '.'
23

3-
export default unplugin.vite
4+
import type { UnpluginInstance } from 'unplugin'
5+
import type { PluginOptions } from './types'
6+
7+
const vite: UnpluginInstance<PluginOptions | undefined, boolean>['vite'] =
8+
createVitePlugin(unpluginFactory)
9+
10+
export default vite
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
import unplugin from '.'
1+
import { createWebpackPlugin } from 'unplugin'
2+
import { unpluginFactory } from '.'
23

3-
export default unplugin.webpack
4+
import type { UnpluginInstance } from 'unplugin'
5+
import type { PluginOptions } from './types'
6+
7+
const webpack: UnpluginInstance<PluginOptions | undefined, boolean>['webpack'] =
8+
createWebpackPlugin(unpluginFactory)
9+
export default webpack

0 commit comments

Comments
 (0)