This repository was archived by the owner on Apr 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 984
feat(nuxt): server-only components #9972
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
15151a0
feat(nuxt): server-only components
danielroe 2e9ebd4
docs: add documentation for server-only components
danielroe 39de11c
chore: revert non-essential changes
danielroe 2b79ad0
chore: ts-expect-error on virtual import
danielroe 473b2d5
docs: temporarily add stabilityedge component back pending upstream
danielroe ac8562e
feat: warn if user is using without islands support
danielroe e6b722a
docs: add comment
danielroe 811f8e8
Merge remote-tracking branch 'origin/main' into feat/server-components-2
danielroe cff39ed
fix: remove duplicate component
danielroe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
examples/auto-imports/components/components/ServerOnlyComponent.server.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <script setup lang="ts"> | ||
| const props = defineProps({ foo: Number }) | ||
| const colors = [ | ||
| 'red', | ||
| 'blue', | ||
| 'yellow' | ||
| ] | ||
| const color = colors[(props.foo ?? 1) % colors.length] | ||
| </script> | ||
|
|
||
| <template> | ||
| <section class="flex flex-col gap-1 p-4"> | ||
| I'm a server component with some reactive state: {{ foo }} | ||
| </section> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| .flex { | ||
| color: v-bind(color) | ||
| } | ||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { defineComponent, h } from 'vue' | ||
| // @ts-expect-error virtual import | ||
| import { NuxtIsland } from '#components' | ||
|
|
||
| export const createServerComponent = (name: string) => { | ||
| return defineComponent({ | ||
| name, | ||
| inheritAttrs: false, | ||
| setup (_props, { attrs }) { | ||
| return () => h(NuxtIsland, { | ||
| name, | ||
| props: attrs | ||
| }) | ||
| } | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
test/fixtures/basic/components/ServerOnlyComponent.server.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <template> | ||
| <div> | ||
| server-only component | ||
| </div> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.