Skip to content

Commit 37e28a3

Browse files
IWANABETHATGUYsapphi-red
authored andcommitted
feat: clone class plugins correctly
1 parent 899aa2d commit 37e28a3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/vite/src/node/build.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,11 @@ export function injectEnvironmentToHooks(
11371137
): Plugin {
11381138
const { resolveId, load, transform } = plugin
11391139

1140-
const clone = { ...plugin }
1140+
// the plugin can be a class instance (e.g. native plugins)
1141+
const clone: Plugin = Object.assign(
1142+
Object.create(Object.getPrototypeOf(plugin)),
1143+
plugin,
1144+
)
11411145

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

0 commit comments

Comments
 (0)