core icon indicating copy to clipboard operation
core copied to clipboard

feat(complier-sfc): add `hoistStatic` for `<script setup>`

Open sxzz opened this issue 2 years ago • 7 comments

closes #5750

Introduce a option hoistStatic in script. Only enables when there's only one <script setup> (enabled by default)

Fix these cases

_useCssVars should be put inside of setup

Before | After

enum shouldn't be hoisted

Before | After


Demo

sxzz avatar Apr 19 '22 06:04 sxzz

Deploy Preview for vuejs-coverage failed.

Name Link
Latest commit 02081e08004a02c758526862e6ab3794e9707f42
Latest deploy log https://app.netlify.com/sites/vuejs-coverage/deploys/63d2b44c6f5a0c000832157d

netlify[bot] avatar Apr 19 '22 06:04 netlify[bot]

Deploy Preview for vue-next-template-explorer ready!

Name Link
Latest commit ef61ebe326e91400407afc8bf3da53312e437f4d
Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/625fc7ead944db000863edf3
Deploy Preview https://deploy-preview-5752--vue-next-template-explorer.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Apr 19 '22 06:04 netlify[bot]

Deploy Preview for vue-sfc-playground ready!

Name Link
Latest commit ef61ebe326e91400407afc8bf3da53312e437f4d
Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/625fc7ea8b6c1f00081d3521
Deploy Preview https://deploy-preview-5752--vue-sfc-playground.netlify.app/
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Apr 19 '22 06:04 netlify[bot]

If this feature is acceptable, I will add a Unit Test for it later.

sxzz avatar Apr 19 '22 08:04 sxzz

This is great. Let's add some tests for it

yyx990803 avatar Apr 19 '22 12:04 yyx990803

I'm considering whether this feature is enabled by default, or is it an experimental feature and not enabled by default?

sxzz avatar Apr 19 '22 13:04 sxzz

@yyx990803 Added.

sxzz avatar Apr 20 '22 07:04 sxzz

/ecosystem-ci run

haoqunjiang avatar Feb 10 '23 11:02 haoqunjiang

📝 Ran ecosystem CI: Open

suite result
nuxt :x: failure
pinia :white_check_mark: success
router :white_check_mark: success
test-utils :x: failure
vite-plugin-vue :x: failure
vitepress :white_check_mark: success

vue-bot avatar Feb 10 '23 11:02 vue-bot

I think this may have introduced a regression: #7973. I'm not sure of the cause, but testing locally it seems to work fine prior to this being merged.

skirtles-code avatar Mar 28 '23 19:03 skirtles-code