Skip to content

Commit

Permalink
feat: clone class plugins correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY authored and sapphi-red committed Sep 18, 2024
1 parent cb67fbc commit afa534d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,11 @@ export function injectEnvironmentToHooks(
): Plugin {
const { resolveId, load, transform } = plugin

const clone = { ...plugin }
// the plugin can be a class instance (e.g. native plugins)
const clone: Plugin = Object.assign(
Object.create(Object.getPrototypeOf(plugin)),
plugin,
)

for (const hook of Object.keys(clone) as RollupPluginHooks[]) {
switch (hook) {
Expand Down

0 comments on commit afa534d

Please sign in to comment.