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: support setup script #18

Merged
merged 4 commits into from
May 28, 2021
Merged

feat: support setup script #18

merged 4 commits into from
May 28, 2021

Conversation

peter50216
Copy link
Contributor

The <script setup> tag is parsed by compiler-sfc as a scriptSetup in the
returned descriptor.

=========

Reference: <script setup> is an RFC that is available in vue 3.1.0-beta now.

The <script setup> tag is parsed by compiler-sfc as a scriptSetup in the
returned descriptor.
const endingTag = `</${type}>\n`;
const tagName = type === 'scriptSetup' ? 'script setup' : type;
const startingTag = `<${tagName}${lang ? ` lang="${lang}"` : ''}>`;
const endingTag = `</${tagName}>\n`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the ending tag would be </script setup>

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add an extra condition like this:

const startingTag = `<${type}${type === 'scriptSetup' ? 'setup' : ''}${lang ? ` lang="${lang}"` : ''}>`;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@meteorlxy
Copy link
Owner

The type of setupScript is script, too. So in fact we do not need those changes about the tagName.

@meteorlxy meteorlxy changed the title feat: support <script setup> feat: support setup script May 28, 2021
@meteorlxy meteorlxy merged commit 49e71f4 into meteorlxy:main May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants