Skip to content

Commit 9c35417

Browse files
authored
Revert "fix(unplugin-vue-i18n): Support for transform.handler in vite:json pl…" (#487)
This reverts commit b8900e3.
1 parent adc8dca commit 9c35417

File tree

2 files changed

+2
-52
lines changed

2 files changed

+2
-52
lines changed

packages/unplugin-vue-i18n/src/core/resource.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import {
2121
checkVuePlugin,
2222
error,
2323
getVitePlugin,
24-
getVitePluginTransform,
25-
overrideVitePluginTransform,
2624
raiseError,
2725
resolveNamespace,
2826
warn
@@ -138,24 +136,11 @@ export function resourcePlugin(
138136
`configResolved: isProduction = ${isProduction}, sourceMap = ${sourceMap}`
139137
)
140138

141-
/**
142-
* NOTE:
143-
* For the native rolldown plugin, we need to change to another solution from the current workaround.
144-
* Currently, the rolldown team and vite team are discussing this issue.
145-
* https://github.com/vitejs/rolldown-vite/issues/120
146-
*/
147-
148139
// json transform handling
149140
const jsonPlugin = getVitePlugin(config, 'vite:json')
150141
if (jsonPlugin) {
151-
// saving `vite:json` plugin instance
152-
const [orgTransform, transformWay] =
153-
getVitePluginTransform(jsonPlugin)
154-
if (!orgTransform) {
155-
throw new Error('vite:json plugin not found!')
156-
}
157-
158-
async function overrideViteJsonPlugin(code: string, id: string) {
142+
const orgTransform = jsonPlugin.transform // backup @rollup/plugin-json
143+
jsonPlugin.transform = async function (code: string, id: string) {
159144
if (!/\.json$/.test(id) || filter(id)) {
160145
return
161146
}
@@ -177,13 +162,6 @@ export function resourcePlugin(
177162
// @ts-expect-error
178163
return orgTransform!.apply(this, [code, id])
179164
}
180-
181-
// override `vite:json` plugin transform function
182-
overrideVitePluginTransform(
183-
jsonPlugin,
184-
overrideViteJsonPlugin,
185-
transformWay!
186-
)
187165
}
188166

189167
/**

packages/unplugin-vue-i18n/src/utils/plugin.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,6 @@ export function getVitePlugin(
1919
return config.plugins.find(p => p.name === name) as RollupPlugin
2020
}
2121

22-
export function getVitePluginTransform(
23-
plugin: RollupPlugin
24-
): [RollupPlugin['transform'], 'handler' | 'transform' | undefined] {
25-
if (plugin.transform) {
26-
return 'handler' in plugin.transform
27-
? [plugin.transform.handler, 'handler']
28-
: [plugin.transform, 'transform']
29-
} else {
30-
return [undefined, undefined]
31-
}
32-
}
33-
34-
// TODO: `override` type, we need more strict type
35-
export function overrideVitePluginTransform(
36-
plugin: RollupPlugin,
37-
override: Function,
38-
to: 'handler' | 'transform'
39-
): void {
40-
if (plugin.transform == undefined) {
41-
throw new Error('plugin.transform is undefined')
42-
}
43-
if (to === 'handler' && 'handler' in plugin.transform) {
44-
plugin.transform.handler = override as typeof plugin.transform.handler
45-
} else {
46-
plugin.transform = override as typeof plugin.transform
47-
}
48-
}
49-
5022
export function checkVuePlugin(vuePlugin: RollupPlugin | null): boolean {
5123
if (vuePlugin == null || !vuePlugin.api) {
5224
error(

0 commit comments

Comments
 (0)