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(vue): support SSR #468

Merged
merged 15 commits into from
Oct 19, 2024
Merged

feat(vue): support SSR #468

merged 15 commits into from
Oct 19, 2024

Conversation

christian-bromann
Copy link
Member

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally for affected output targets
  • Tests (npm test) were run locally and passed
  • Prettier (npm run prettier) was run locally and passed

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Currently the Vue Output Target would not support SSR.

What is the new behavior?

This patch adds support for it. Furthermore:

  • it adds a Nuxt.js example application for testing purposes
  • it requires users to have @stencil/vue-output-target as dependency to access runtime files (similar to React)
  • it adds a hydrateModule property to the output target that allows users to enable SSR

Does this introduce a breaking change?

  • Yes
  • No

Other information

Copy link
Member

@tanner-reits tanner-reits left a comment

Choose a reason for hiding this comment

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

There's a lot here, but looks like it works as expected. I tested out the Nuxt app and everything was rendering (some of the components are goofy, but that's just the components, not the SSR implementation). I didn't double-check a client-side Vue app.

@@ -66,8 +66,12 @@ export const config: Config = {
hydrateModule: 'component-library/hydrate'
}),
vueOutputTarget({
Copy link
Member

Choose a reason for hiding this comment

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

Should we have two Vue output target configs like we do for React?

Copy link
Member Author

Choose a reason for hiding this comment

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

React and Vue projects are setup differently here. We have two output targets for React because we directly compile the components into their represented projects. With Vue we have setup an example project that just re-exports the components, and potentially more Vue related modules. That example project is imported by Nuxt and the Vite project. A bit different setup but it is actually how we see projects being organised.

@christian-bromann
Copy link
Member Author

I didn't double-check a client-side Vue app.

FWIW I raised PR adding an example app using Vite + Vue, see #499. For that I've added an e2e test for this. For all these environments we now run a WebdriverIO tests that verifies that Stencil is properly able to hydrate the component, e.g. interacting with an input component with SSR support or without. While these tests are very rudimental, they are a start a least 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it was part of the basic Nuxt setup. I can remove it.

Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

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

LGTM, added some comments but they're not blockers

packages/vue-output-target/src/generate-vue-component.ts Outdated Show resolved Hide resolved
packages/example-project/nuxt-app/README.md Outdated Show resolved Hide resolved
packages/example-project/nuxt-app/README.md Outdated Show resolved Hide resolved
* chore: re-org package structure

* update deps in next project

* lerna change

* add back missing components dir

* fix tests

* fix react tests

* fix types

* run headless

* ignore React type mismatch

* build nextjs project alongside other projects

* update unit test

* fix(react): don't populate non-primitive objects (#498)

* chore: re-org package structure

* fix(react): don't populate non-primitive objects

* test(vue): add playground for Vite+Vue (#499)

* test(vue): add playground for Vite+Vue

* ignore type issue
@christian-bromann christian-bromann merged commit c860023 into main Oct 19, 2024
3 checks passed
@christian-bromann christian-bromann deleted the cb/vue-ssr-support branch October 19, 2024 16:56
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