]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(build): retain defineComponent() treeshakability in Rollup
authorEvan You <yyx990803@gmail.com>
Mon, 8 May 2023 04:12:15 +0000 (12:12 +0800)
committerEvan You <yyx990803@gmail.com>
Mon, 8 May 2023 04:12:15 +0000 (12:12 +0800)
close #8236

packages/runtime-core/src/apiDefineComponent.ts

index 9edb9965e27c03846df3376772b36d5a45053708..76e9567fe2ff554185fc3ecb344873ea9daa4e8c 100644 (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
 }