fix(build): retain defineComponent() treeshakability in Rollup

close #8236
This commit is contained in:
Evan You 2023-05-08 12:12:15 +08:00
parent b2be75bad4
commit c2172f3a0e
1 changed files with 4 additions and 1 deletions

View File

@ -279,6 +279,9 @@ export function defineComponent(
extraOptions?: ComponentOptions
) {
return isFunction(options)
? extend({ name: options.name }, extraOptions, { setup: options })
? // #8326: extend call and options.name access are considered side-effects
// by Rollup, so we have to wrap it in a pure-annotated IIFE.
/*#__PURE__*/ (() =>
extend({ name: options.name }, extraOptions, { setup: options }))()
: options
}