diff --git a/package-lock.json b/package-lock.json index d2e84c7..73feb4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vue-ssr-build", - "version": "8.0.2", + "version": "8.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7aa7eed..c326cf3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-ssr-build", - "version": "8.0.2", + "version": "8.0.4", "description": "Vue.js SSR Build Helper", "author": "skennedy@urbn.com", "license": "MIT", diff --git a/src/entry-server.js b/src/entry-server.js index 30901b4..706df8f 100644 --- a/src/entry-server.js +++ b/src/entry-server.js @@ -20,11 +20,11 @@ import { * @returns {undefined} No return value */ export function useRouteVuexModulesServer(router, store, logger) { - getMatchedComponents(router.currentRoute.value) + getMatchedComponents(router.currentRoute) .filter(c => 'vuex' in c) .flatMap(c => c.vuex) .forEach((vuexModuleDef) => { - const name = getModuleName(vuexModuleDef, router.currentRoute.value); + const name = getModuleName(vuexModuleDef, router.currentRoute); safelyRegisterModule(store, name, vuexModuleDef.module, logger); }); } @@ -42,7 +42,7 @@ export function useRouteVuexModulesServer(router, store, logger) { * @returns {undefined} No return value */ export async function useFetchDataServer(ssrContext, app, router, store, opts) { - const route = router.currentRoute.value; + const route = router.currentRoute; const fetchDataArgs = getFetchDataArgs(ssrContext, app, router, store, route); const components = getMatchedComponents(route); if (opts && opts.middleware) { diff --git a/src/renderer.js b/src/renderer.js index 8568da8..0f7d946 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -119,6 +119,7 @@ function render(config, clientManifest, req, res) { url: req.url, clientManifest, initialState: null, + initialPiniaState: null, }; res.setHeader('Content-Type', 'text/html'); diff --git a/test/entry-server.spec.js b/test/entry-server.spec.js index 05582ea..64b878a 100644 --- a/test/entry-server.spec.js +++ b/test/entry-server.spec.js @@ -16,16 +16,14 @@ describe('entry-server utils', () => { }; const router = { currentRoute: { - value: { - matched: [{ - components: [{ - vuex: { - moduleName: 'test', - module: testModule, - }, - }], + matched: [{ + components: [{ + vuex: { + moduleName: 'test', + module: testModule, + }, }], - }, + }], }, }; const store = { @@ -41,15 +39,13 @@ describe('entry-server utils', () => { it('should ignore modules which do not specify a vuex key', () => { const router = { currentRoute: { - value: { - matched: [{ - components: [{ - name: '1', - }, { - name: '1', - }], + matched: [{ + components: [{ + name: '1', + }, { + name: '1', }], - }, + }], }, }; const store = { @@ -76,23 +72,21 @@ describe('entry-server utils', () => { }; const router = { currentRoute: { - value: { - matched: [{ - components: [{ - vuex: { - moduleName: 'test1', - module: testModule1, - }, - }, { - // No vuex module on this component - }, { - vuex: { - moduleName: 'test2', - module: testModule2, - }, - }], + matched: [{ + components: [{ + vuex: { + moduleName: 'test1', + module: testModule1, + }, + }, { + // No vuex module on this component + }, { + vuex: { + moduleName: 'test2', + module: testModule2, + }, }], - }, + }], }, }; const store = { @@ -117,16 +111,14 @@ describe('entry-server utils', () => { }; const router = { currentRoute: { - value: { - matched: [{ - components: [{ - vuex: { - moduleName: 'test', - module: testModule, - }, - }], + matched: [{ + components: [{ + vuex: { + moduleName: 'test', + module: testModule, + }, }], - }, + }], }, }; const store = { @@ -153,16 +145,14 @@ describe('entry-server utils', () => { }; const router = { currentRoute: { - value: { - matched: [{ - components: [{ - vuex: { - moduleName: 'test', - module: testModule, - }, - }], + matched: [{ + components: [{ + vuex: { + moduleName: 'test', + module: testModule, + }, }], - }, + }], }, }; const store = { @@ -187,19 +177,17 @@ describe('entry-server utils', () => { }; const router = { currentRoute: { - value: { - params: { - slug: 'foo', - }, - matched: [{ - components: [{ - vuex: { - moduleName: ({ $route }) => `test-${$route.params.slug}`, - module: testModule, - }, - }], - }], + params: { + slug: 'foo', }, + matched: [{ + components: [{ + vuex: { + moduleName: ({ $route }) => `test-${$route.params.slug}`, + module: testModule, + }, + }], + }], }, }; const store = { @@ -221,19 +209,17 @@ describe('entry-server utils', () => { }; const router = { currentRoute: { - value: { - params: { - slug: 'foo', - }, - matched: [{ - components: [{ - vuex: { - moduleName: 'foo/bar/baz', - module: testModule, - }, - }], - }], + params: { + slug: 'foo', }, + matched: [{ + components: [{ + vuex: { + moduleName: 'foo/bar/baz', + module: testModule, + }, + }], + }], }, }; const store = { @@ -258,12 +244,10 @@ describe('entry-server utils', () => { }; const router = { currentRoute: { - value: { - path: '/', - matched: [{ - components: [component], - }], - }, + path: '/', + matched: [{ + components: [component], + }], }, }; const store = { state: {} }; @@ -273,7 +257,7 @@ describe('entry-server utils', () => { app, router, store, - route: router.currentRoute.value, + route: router.currentRoute, }); }); @@ -291,16 +275,14 @@ describe('entry-server utils', () => { }; const router = { currentRoute: { - value: { - path: '/', - matched: [{ - components: [component1], - }, { - components: [component2], - }, { - components: [component3], - }], - }, + path: '/', + matched: [{ + components: [component1], + }, { + components: [component2], + }, { + components: [component3], + }], }, }; const store = { state: {} }; @@ -310,7 +292,7 @@ describe('entry-server utils', () => { app, router, store, - route: router.currentRoute.value, + route: router.currentRoute, }; expect(component1.fetchData).toHaveBeenCalledWith(expectedArg); expect(component3.fetchData).toHaveBeenCalledWith(expectedArg); @@ -324,12 +306,10 @@ describe('entry-server utils', () => { }; const router = { currentRoute: { - value: { - path: '/', - matched: [{ - components: [component], - }], - }, + path: '/', + matched: [{ + components: [component], + }], }, }; const store = { state: {} }; @@ -346,7 +326,7 @@ describe('entry-server utils', () => { app, router, store, - route: router.currentRoute.value, + route: router.currentRoute, }; expect(middleware).toHaveBeenCalledWith(expectedArg); expect(globalFetchData).toHaveBeenCalledWith(expectedArg); @@ -362,12 +342,10 @@ describe('entry-server utils', () => { }; const router = { currentRoute: { - value: { - path: '/', - matched: [{ - components: [component], - }], - }, + path: '/', + matched: [{ + components: [component], + }], }, }; const store = { state: {} };