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: expose ssrTransform to server #5983

Merged
merged 4 commits into from
Dec 7, 2021
Merged

feat: expose ssrTransform to server #5983

merged 4 commits into from
Dec 7, 2021

Conversation

antfu
Copy link
Member

@antfu antfu commented Dec 6, 2021

Description

I need this in vitest 👀

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.

patak-dev
patak-dev previously approved these changes Dec 6, 2021
@antfu
Copy link
Member Author

antfu commented Dec 6, 2021

For the context, Vitest is a WIP test running powered by Vite (which you probably already know). It uses server.transformRequest(id, { ssr: true }) to transpile modules and execute the result. It works prefectly fine for vanilla js, but when it comes to Vue (and probably other frameworks too), the ssr: true has also been passed to the plugins which generate SSR version of Vue component. In Vitest, we want to separate those two behaviors into two steps to run the client version of component transform while being able to execute them in SSR.

    // for components like Vue, we want to use the client side
    // plugins but then covert the code to be consumed by the server
    const result = await server.transformRequest(id)
    if (!result)
      return
    return await server.ssrTransform(result.code, result.map, id)

patak-dev
patak-dev previously approved these changes Dec 6, 2021
aleclarson
aleclarson previously approved these changes Dec 7, 2021
@patak-dev patak-dev dismissed stale reviews from aleclarson and themself via 2fe08b9 December 7, 2021 06:10
@patak-dev
Copy link
Member

Marked the feature as experimental so we can merge it in 2.7, hopefully to be released today 🙌🏼

@antfu antfu merged commit 8184feb into main Dec 7, 2021
@antfu antfu deleted the feat/expose-ssr-transform branch December 7, 2021 06:34
@bluwy bluwy mentioned this pull request Apr 8, 2022
4 tasks
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.

3 participants