Skip to content

Commit a152b7c

Browse files
authored
fix: backward compat for internal plugin transform calls (#19878)
1 parent 7c26d09 commit a152b7c

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

packages/vite/src/node/plugins/css.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
512512
return cssBundleName
513513
}
514514

515-
return {
515+
const plugin = {
516516
name: 'vite:css-post',
517517

518518
renderStart() {
@@ -1080,7 +1080,14 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
10801080
}
10811081
}
10821082
},
1083-
}
1083+
} satisfies Plugin
1084+
1085+
// backward compat
1086+
const handler = plugin.transform.handler
1087+
;(plugin as any).transform = handler
1088+
;(plugin as any).transform.handler = handler
1089+
1090+
return plugin
10841091
}
10851092

10861093
export function cssAnalysisPlugin(config: ResolvedConfig): Plugin {

packages/vite/src/node/plugins/json.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function jsonPlugin(
4141
options: Required<JsonOptions>,
4242
isBuild: boolean,
4343
): Plugin {
44-
return {
44+
const plugin = {
4545
name: 'vite:json',
4646

4747
transform: {
@@ -119,7 +119,14 @@ export function jsonPlugin(
119119
}
120120
},
121121
},
122-
}
122+
} satisfies Plugin
123+
124+
// backward compat
125+
const handler = plugin.transform.handler
126+
;(plugin as any).transform = handler
127+
;(plugin as any).transform.handler = handler
128+
129+
return plugin
123130
}
124131

125132
function serializeValue(value: unknown): string {

0 commit comments

Comments
 (0)