Skip to content

fix: backward compat for internal plugin transform calls #19878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
return cssBundleName
}

return {
const plugin = {
name: 'vite:css-post',

renderStart() {
Expand Down Expand Up @@ -1080,7 +1080,14 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
}
}
},
}
} satisfies Plugin

// backward compat
const handler = plugin.transform.handler
;(plugin as any).transform = handler
;(plugin as any).transform.handler = handler

return plugin
}

export function cssAnalysisPlugin(config: ResolvedConfig): Plugin {
Expand Down
11 changes: 9 additions & 2 deletions packages/vite/src/node/plugins/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function jsonPlugin(
options: Required<JsonOptions>,
isBuild: boolean,
): Plugin {
return {
const plugin = {
name: 'vite:json',

transform: {
Expand Down Expand Up @@ -119,7 +119,14 @@ export function jsonPlugin(
}
},
},
}
} satisfies Plugin

// backward compat
const handler = plugin.transform.handler
;(plugin as any).transform = handler
;(plugin as any).transform.handler = handler

return plugin
}

function serializeValue(value: unknown): string {
Expand Down