Skip to content

Commit

Permalink
fix(unplugin-vue-i18n): plugin option made be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Aug 30, 2024
1 parent 19b223a commit bb8ed1e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
15 changes: 11 additions & 4 deletions packages/unplugin-vue-i18n/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import createDebug from 'debug'
import { raiseError, checkInstallPackage, resolveNamespace } from './utils'
import { resolveOptions, resourcePlugin, directivePlugin } from './core'

import type { UnpluginFactory, UnpluginInstance } from 'unplugin'
import type { PluginOptions } from './types'

const debug = createDebug(resolveNamespace('root'))
const installedPkgInfo = checkInstallPackage(debug)

export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
export * from './types'

export const unpluginFactory: UnpluginFactory<PluginOptions | undefined> = (
options = {},
meta
) => {
debug('meta framework', meta.framework)
// check bundler type
if (!['vite', 'webpack'].includes(meta.framework)) {
Expand All @@ -31,8 +37,9 @@ export const unplugin = createUnplugin<PluginOptions>((options = {}, meta) => {
}

return plugins
})
}

export default unplugin
export const unplugin: UnpluginInstance<PluginOptions | undefined, boolean> =
/* #__PURE__ */ createUnplugin(unpluginFactory)

export * from './types'
export default unplugin
11 changes: 9 additions & 2 deletions packages/unplugin-vue-i18n/src/vite.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import unplugin from '.'
import { createVitePlugin } from 'unplugin'
import { unpluginFactory } from '.'

export default unplugin.vite
import type { UnpluginInstance } from 'unplugin'
import type { PluginOptions } from './types'

const vite: UnpluginInstance<PluginOptions | undefined, boolean>['vite'] =
createVitePlugin(unpluginFactory)

export default vite
10 changes: 8 additions & 2 deletions packages/unplugin-vue-i18n/src/webpack.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import unplugin from '.'
import { createWebpackPlugin } from 'unplugin'
import { unpluginFactory } from '.'

export default unplugin.webpack
import type { UnpluginInstance } from 'unplugin'
import type { PluginOptions } from './types'

const webpack: UnpluginInstance<PluginOptions | undefined, boolean>['webpack'] =
createWebpackPlugin(unpluginFactory)
export default webpack

0 comments on commit bb8ed1e

Please sign in to comment.