diff --git a/packages/unplugin-vue-i18n/src/core/resource.ts b/packages/unplugin-vue-i18n/src/core/resource.ts index 0bed0f07..94426d62 100644 --- a/packages/unplugin-vue-i18n/src/core/resource.ts +++ b/packages/unplugin-vue-i18n/src/core/resource.ts @@ -21,8 +21,6 @@ import { checkVuePlugin, error, getVitePlugin, - getVitePluginTransform, - overrideVitePluginTransform, raiseError, resolveNamespace, warn @@ -138,24 +136,11 @@ export function resourcePlugin( `configResolved: isProduction = ${isProduction}, sourceMap = ${sourceMap}` ) - /** - * NOTE: - * For the native rolldown plugin, we need to change to another solution from the current workaround. - * Currently, the rolldown team and vite team are discussing this issue. - * https://github.com/vitejs/rolldown-vite/issues/120 - */ - // json transform handling const jsonPlugin = getVitePlugin(config, 'vite:json') if (jsonPlugin) { - // saving `vite:json` plugin instance - const [orgTransform, transformWay] = - getVitePluginTransform(jsonPlugin) - if (!orgTransform) { - throw new Error('vite:json plugin not found!') - } - - async function overrideViteJsonPlugin(code: string, id: string) { + const orgTransform = jsonPlugin.transform // backup @rollup/plugin-json + jsonPlugin.transform = async function (code: string, id: string) { if (!/\.json$/.test(id) || filter(id)) { return } @@ -177,13 +162,6 @@ export function resourcePlugin( // @ts-expect-error return orgTransform!.apply(this, [code, id]) } - - // override `vite:json` plugin transform function - overrideVitePluginTransform( - jsonPlugin, - overrideViteJsonPlugin, - transformWay! - ) } /** diff --git a/packages/unplugin-vue-i18n/src/utils/plugin.ts b/packages/unplugin-vue-i18n/src/utils/plugin.ts index b5a83253..254f8d3f 100644 --- a/packages/unplugin-vue-i18n/src/utils/plugin.ts +++ b/packages/unplugin-vue-i18n/src/utils/plugin.ts @@ -19,34 +19,6 @@ export function getVitePlugin( return config.plugins.find(p => p.name === name) as RollupPlugin } -export function getVitePluginTransform( - plugin: RollupPlugin -): [RollupPlugin['transform'], 'handler' | 'transform' | undefined] { - if (plugin.transform) { - return 'handler' in plugin.transform - ? [plugin.transform.handler, 'handler'] - : [plugin.transform, 'transform'] - } else { - return [undefined, undefined] - } -} - -// TODO: `override` type, we need more strict type -export function overrideVitePluginTransform( - plugin: RollupPlugin, - override: Function, - to: 'handler' | 'transform' -): void { - if (plugin.transform == undefined) { - throw new Error('plugin.transform is undefined') - } - if (to === 'handler' && 'handler' in plugin.transform) { - plugin.transform.handler = override as typeof plugin.transform.handler - } else { - plugin.transform = override as typeof plugin.transform - } -} - export function checkVuePlugin(vuePlugin: RollupPlugin | null): boolean { if (vuePlugin == null || !vuePlugin.api) { error(