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(hydrate): removed vue3-lazy-hydration, added vue hydration #1120

Merged
merged 20 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
33333f5
chore(deps): update nuxt to v3.13.1
renovate[bot] Sep 5, 2024
ffd02c9
fix(hydrate): removed `vue3-lazy-hydration`, added vue hydration
ThornWalli Sep 5, 2024
4d071f1
fix(components): removed unused props
ThornWalli Sep 5, 2024
765b835
fix(module): update compatibility for nuxt
ThornWalli Sep 5, 2024
f588ade
Merge branch 'next' into feature/update-hydrate
ThornWalli Sep 5, 2024
8fc0d7d
Merge branch 'next' into feature/update-hydrate
ThornWalli Sep 5, 2024
d7e84f6
fix(components): fix class
ThornWalli Sep 5, 2024
f64b550
fix(components): remove Test component
ThornWalli Sep 5, 2024
948619b
chore(deps): update all non-major dependencies
renovate[bot] Sep 7, 2024
8559a12
Merge pull request #1122 from basics/renovate/all-minor-patch
ThornWalli Sep 8, 2024
222c2c3
chore(deps): update devdependency postcss-preset-env to v10.0.3
renovate[bot] Sep 9, 2024
5e4977f
Merge pull request #1123 from basics/renovate/all-minor-patch
ThornWalli Sep 9, 2024
f43aee7
chore(deps): update devdependency serve-static to v1.16.0
renovate[bot] Sep 10, 2024
02c896d
Merge pull request #1124 from basics/renovate/all-minor-patch
ThornWalli Sep 10, 2024
24ccfc4
chore(deps): update nuxt
renovate[bot] Sep 10, 2024
e8f603e
fix(update): removed unused values
ThornWalli Sep 10, 2024
cc5ec5d
Merge branch 'renovate/nuxt' into feature/update-hydrate
ThornWalli Sep 10, 2024
894b422
test(browser): update booster hydrate test
ThornWalli Sep 10, 2024
be25a5e
docs(composables): update booster hydrate
ThornWalli Sep 10, 2024
b7af835
Merge branch 'next' into feature/update-hydrate
ThornWalli Sep 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default {
'change-case',
'hash-sum',
'probe-image-size',
'vue3-lazy-hydration',
'node-cache',

// package
Expand All @@ -20,7 +19,6 @@ export default {
'image-meta',
'pathe',
'sort-css-media-queries',
'vue3-lazy-hydration',
'mime-types',
'mime-db'
],
Expand Down
48 changes: 46 additions & 2 deletions docs/src/composables/useBoosterHydrate.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
---
title: useBoosterHydrate
title2: useBoosterHydrate(component, hydrateOverride)
---

# {{$frontmatter.title}}
# {{$frontmatter.title2}}

Compasable provides a function for wrapping components in order to control hydration.

[Learn more about component import](/guide/usage#import-components).

## Arguments

### `component`

- Type: `Function`
- Default: `true`

Component import function.

### `hydrateOverride`

- Type: `Function`
- Default: `hydrateOnVisible(…)`

Hydrate override function.

Learn more about [Lazy Hydration](https://vuejs.org/guide/components/async#lazy-hydration).

## Return

Returns import wrapper function.
Expand All @@ -17,5 +36,30 @@ Returns import wrapper function.
```js
const hydrate = useBoosterHydrate();

const component = hydrate(() => import('~/components/MyComponent.vue'));
const component = hydrate(
() => import('~/components/MyComponent.vue'),
hydrateOnVisibleSpezificRoute({ rootMargin: '100px' })
);
```

### Useful

With a custom hydrate function, you can control the hydration of components.

It is possible to create a custom hydrate function that will hydrate only on a specific route.

#### Example

```js

const $router = useRouter();

const hydrateOnVisibleSpezificRoute = options => (hydrate, forEach) => {
if ($router.currentRoute.value === 'specific-route') {
return hydrateOnVisible(options)(hydrate, forEach);
} else {
hydrate();
}
};

```
2 changes: 0 additions & 2 deletions docs/src/guide/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ Until now, components were imported either statically (`import component from '@
- 'Ensures that components are initialized only when needed in the visible viewport.'
- 'Optimizes initialization of critical components on initial page load (critical components are initially in the visible viewport).'

In the background, the module [`vue3-lazy-hydration`](https://github.com/freddy38510/vue3-lazy-hydration) inspired by `vue-lazy-hydration` from [Markus Oberlehner](https://github.com/maoberlehner/vue-lazy-hydration) is used in a standardised way.

[Learn more about `useBoosterHydrate`](/composables/useBoosterHydrate).

````js
Expand Down
Loading