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

UW-32342 Sprint 0: Can we swap the footer store from VueX to Pinia? #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-ssr-build",
"version": "8.0.2",
"version": "8.0.4",
"description": "Vue.js SSR Build Helper",
"author": "[email protected]",
"license": "MIT",
6 changes: 3 additions & 3 deletions src/entry-server.js
Original file line number Diff line number Diff line change
@@ -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) {
1 change: 1 addition & 0 deletions src/renderer.js
Original file line number Diff line number Diff line change
@@ -119,6 +119,7 @@ function render(config, clientManifest, req, res) {
url: req.url,
clientManifest,
initialState: null,
initialPiniaState: null,
};

res.setHeader('Content-Type', 'text/html');
190 changes: 84 additions & 106 deletions test/entry-server.spec.js
Original file line number Diff line number Diff line change
@@ -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: {} };