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(plugin-vue): add option inlineTemplate #10505

Closed
wants to merge 1 commit into from
Closed

feat(plugin-vue): add option inlineTemplate #10505

wants to merge 1 commit into from

Conversation

sxzz
Copy link
Member

@sxzz sxzz commented Oct 17, 2022

Description

Provide inlineTemplate option to control whether to make template inline or not.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sodatea
Copy link
Member

sodatea commented Oct 18, 2022

Per my previous discussion with Evan, we want it to always be on in production #4984 (comment)
What's your use case?

@sxzz
Copy link
Member Author

sxzz commented Oct 18, 2022

🤔 It's about my vue macros project actually. It doesn't support the inline mode of template, so I want to disable it.

@sodatea
Copy link
Member

sodatea commented Oct 21, 2022

Which specific feature?
We can try to find out a better way to work around the limitations. But disabling inlineTemplate in production should not be encouraged.

@sxzz
Copy link
Member Author

sxzz commented Oct 21, 2022

@sodatea namedTemplate. It's pretty hard to transform the inline template currently because of the shared setup context.

@sxzz
Copy link
Member Author

sxzz commented Oct 21, 2022

The core of namedTemplate uses custom blocks to implement. And then custom blocks will be transformed to template with src (aka .vue?vue&type=template). It's hard to transform separate modules into inline functions.

@sapphi-red
Copy link
Member

@sxzz How about transforming

<script setup>
const pager = 'top'
</script>

<template name="pager">
  <span>This is pager</span>
</template>

<template>
  <template v-if="pager === 'top'">
    <template is="pager" />
  </template>

  <span>Here is data table</span>

  <template v-if="pager === 'bottom'">
    <template is="pager" />
  </template>
</template>

into

<script setup>
const pager = 'top'
</script>

<template>
  <template v-if="pager === 'top'">
    <span>This is pager</span>
  </template>

  <span>Here is data table</span>

  <template v-if="pager === 'bottom'">
    <span>This is pager</span>
  </template>
</template>

before it's passed to vue plugin?

@sxzz
Copy link
Member Author

sxzz commented Oct 23, 2022

@sapphi-red I think yes, but it will generate more duplicated code.

Also, I plan to improve this feature, and here is the example code https://github.com/vuejs/core/discussions/6898#discussioncomment-3905380

For this proposal, it is a bit difficult to do by replacing the template.

@patak-dev
Copy link
Member

@sxzz would you move this PR to the new repository for plugin-vue?

@patak-dev patak-dev closed this Dec 3, 2022
@sxzz sxzz deleted the feat/inline-template-option branch December 4, 2022 06:24
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

4 participants