Subscribe on changes!

`defineComponent` is no longer tree-shakeable without `/* @__PURE__ */` with rollup since 3.0.0-rc.3

avatar
May 5th 2023

Vue version

3.3.0-beta.4

Link to minimal reproduction

Rollup REPL

Steps to reproduce

  1. Open the rollup REPL I linking above.
  2. See the output includes defineComponent code.
  3. Toggle codes in the defineComponent function in utils.js.
  4. "re 3.0.0-rc.3 version" and "my suggestion version" works fine but "pre 3.3.0-alpha.6 version" and "current main branch version" doesn't

What is expected?

The defineComponent function is detected as side-effect free by Rollup as described in the document.

What is actually happening?

The defineComponent function is not detected as side-effect free by Rollup.

It seems the extend call and the property access (options.name) is treated as side-effectful.

related commits: https://github.com/vuejs/core/commit/304830a764cd9f28098cfb0ac0e520e1bb2f57c7, https://github.com/vuejs/core/commit/d77557c4038f88a676903b379505b280a88cc774

System Info

No response

Any additional comments?

Original issue: https://github.com/vitejs/vite/issues/13087

avatar
May 5th 2023

For a temporary workaround, you might consider this rollup plugin.