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

fix(plugin): avoid duplicate import (#2640) #2897

Merged
merged 3 commits into from
Apr 22, 2021
Merged

Conversation

ygj6
Copy link
Member

@ygj6 ygj6 commented Apr 7, 2021

Description

Fixes #2640
The plugin-vue added a line:
import { useSSRContext } from 'vue'
which may duplicate with user's code

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.

`const _sfc_setup = _sfc_main.setup`,
`_sfc_main.setup = (props, ctx) => {`,
` const ssrContext = useSSRContext()`,
` const ssrContext = _useSSRContext()`,
Copy link
Member

Choose a reason for hiding this comment

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

We should name it __vite_useSSRContext, it is the convention for Vite internal helpers used in other places.

Note: I think we could detect the presence of useSSRContext and only inserted when needed, but this PR fixes the issue at this point and we could improve things later.

@Shinigami92 Shinigami92 added the p2-edge-case Bug, but has workaround or limited in scope (priority) label Apr 19, 2021
patak-dev
patak-dev previously approved these changes Apr 21, 2021
Shinigami92
Shinigami92 previously approved these changes Apr 22, 2021
@patak-dev patak-dev dismissed stale reviews from Shinigami92 and themself via 9433dcd April 22, 2021 15:38
@patak-dev patak-dev merged commit 011438d into vitejs:main Apr 22, 2021
TobiasMelen pushed a commit to TobiasMelen/vite that referenced this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSR: Using useSSRContext causes SyntaxError
3 participants