Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 28, 2023
Merged

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

merged 1 commit into from
Mar 28, 2023

Conversation

sxzz
Copy link
Member

@sxzz sxzz commented Apr 19, 2022

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

@netlify
Copy link

netlify bot commented Apr 19, 2022

Deploy Preview for vuejs-coverage failed.

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

@netlify
Copy link

netlify bot commented Apr 19, 2022

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
Copy link

netlify bot commented Apr 19, 2022

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.

@sxzz sxzz changed the title feat(complier-sfc): add hoistStatic for script feat(complier-sfc): add hoistStatic for script setup Apr 19, 2022
@sxzz
Copy link
Member Author

sxzz commented Apr 19, 2022

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

@yyx990803
Copy link
Member

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

@sxzz
Copy link
Member Author

sxzz commented Apr 19, 2022

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

@sxzz
Copy link
Member Author

sxzz commented Apr 20, 2022

@yyx990803 Added.

@sxzz sxzz changed the title feat(complier-sfc): add hoistStatic for script setup feat(complier-sfc): add hoistStatic for <script setup> Jul 20, 2022
@sxzz sxzz changed the title feat(complier-sfc): add hoistStatic for <script setup> feat(complier-sfc): add hoistStatic for <script setup> Jul 20, 2022
@antfu antfu added the ready to merge The PR is ready to be merged. label Oct 3, 2022
@haoqunjiang

This comment was marked as outdated.

@vue-bot

This comment was marked as outdated.

@vuejs vuejs deleted a comment from vue-bot Mar 28, 2023
@yyx990803 yyx990803 merged commit 7def8b1 into vuejs:main Mar 28, 2023
@sxzz sxzz deleted the feat/script-hoistStatic branch March 28, 2023 03:36
@skirtles-code
Copy link
Contributor

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.

IAmSSH pushed a commit to IAmSSH/core that referenced this pull request May 14, 2023
- Support using literal constants in macros
- fix useCssVars insert position edge case
- fix non-literal-const enum hoisting

close vuejs#5750
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged. scope: sfc
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

literal constant references should be supported in macros
7 participants