Skip to content

Commit b97a51f

Browse files
committed
Merge branch 'dev'
2 parents 562f032 + 4e508df commit b97a51f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-lazy-hydration",
3-
"version": "2.0.0-beta.2",
3+
"version": "2.0.0-beta.3",
44
"description": "Lazy hydration of server-side rendered Vue.js components",
55
"keywords": [
66
"gridsome",

src/utils/nonce.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
const isServer = typeof window === `undefined`;
22

3+
function isAsyncComponentFactory(componentOrFactory) {
4+
return typeof componentOrFactory === `function`;
5+
}
6+
7+
function resolveComponent(componentOrFactory) {
8+
if (isAsyncComponentFactory(componentOrFactory)) {
9+
return componentOrFactory().then(componentModule => componentModule.default);
10+
}
11+
return componentOrFactory;
12+
}
13+
314
export function makeNonce({ component, hydrationPromise }) {
415
if (isServer) return component;
516

6-
return () => hydrationPromise.then(() => component);
17+
return () => hydrationPromise.then(() => resolveComponent(component));
718
}

0 commit comments

Comments
 (0)