Skip to content

Commit fc8cee7

Browse files
committed
feat: upgrading react-ssr-with-vite project dependencies
1 parent 90022e9 commit fc8cee7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1914
-1554
lines changed
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
11
{
2-
"extends": "@eleven-labs/eslint-config-react",
3-
"rules": {
4-
"@typescript-eslint/strict-boolean-expressions": "off",
5-
"@typescript-eslint/no-floating-promises": "off"
6-
},
7-
"overrides": [
8-
{
9-
"files": ["*.stories.tsx", "*.test.ts"],
10-
"rules": {
11-
"@typescript-eslint/consistent-type-assertions": "off"
12-
}
13-
}
14-
]
2+
"extends": "@eleven-labs/eslint-config-react"
153
}

templates/react-ssr-with-vite/bin/build.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { build as buildVite } from 'vite';
1+
import { build as buildVite } from "vite";
22

33
const build = async (): Promise<void> => {
44
// 1. Build Server
55
buildVite({
66
build: {
77
emptyOutDir: false,
8-
ssr: true,
9-
outDir: 'dist',
8+
outDir: "dist",
109
rollupOptions: {
11-
input: 'src/server.ts',
10+
input: "src/server.ts",
1211
},
12+
ssr: true,
1313
},
1414
});
1515

@@ -18,7 +18,7 @@ const build = async (): Promise<void> => {
1818
build: {
1919
emptyOutDir: false,
2020
manifest: true,
21-
outDir: 'dist/public',
21+
outDir: "dist/public",
2222
},
2323
});
2424
};

templates/react-ssr-with-vite/bin/dev.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { createServer as createViteServer } from "vite";
2+
3+
const development = async (): Promise<void> => {
4+
const vite = await createViteServer({
5+
appType: "custom",
6+
});
7+
await vite.ssrLoadModule("/src/server.ts");
8+
};
9+
10+
development();

templates/react-ssr-with-vite/bin/prerender.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
import { createServer as createViteServer } from 'vite';
1+
import { createServer as createViteServer } from "vite";
22

33
const prerender = async (): Promise<void> => {
44
const vite = await createViteServer({
5+
appType: "custom",
56
server: { middlewareMode: true },
6-
appType: 'custom',
77
});
88

99
try {
10-
const { generateHtmlFiles } = await vite.ssrLoadModule('/src/helpers/prerenderHelper.ts');
10+
const { generateHtmlFiles } = await vite.ssrLoadModule(
11+
"/src/helpers/prerenderHelper.ts",
12+
);
1113
generateHtmlFiles(process.cwd());
12-
} catch (e) {
13-
console.error(e);
14+
} catch (error) {
15+
console.error(error);
1416
} finally {
1517
vite.close();
1618
}

templates/react-ssr-with-vite/package.json

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"build": "ts-node bin/build",
77
"prerender": "ts-node bin/prerender",
8-
"start:dev": "ts-node bin/dev",
8+
"start:dev": "ts-node bin/development",
99
"start:prod": "NODE_ENV=production node dist/server",
1010
"start:static": "npx serv --path dist/public",
1111
"lint:es": "eslint --ext .ts,.tsx src bin"
@@ -21,51 +21,39 @@
2121
"node": ">= 16.0"
2222
},
2323
"dependencies": {
24-
"@eleven-labs/design-system": "^0.5.4",
25-
"@remix-run/router": "^1.4.0",
26-
"cross-fetch": "^3.1.5",
24+
"@eleven-labs/design-system": "^0.6.2",
25+
"@remix-run/router": "^1.9.0",
26+
"cross-fetch": "^4.0.0",
2727
"express": "^4.18.2",
28-
"hoofd": "^1.5.2",
29-
"i18next": "^22.4.13",
30-
"i18next-browser-languagedetector": "^7.0.1",
31-
"i18next-http-middleware": "^3.3.0",
28+
"hoofd": "^1.7.1",
29+
"i18next": "^23.5.1",
30+
"i18next-browser-languagedetector": "^7.1.0",
31+
"i18next-http-middleware": "^3.4.1",
3232
"react": "^18.2.0",
3333
"react-dom": "^18.2.0",
34-
"react-i18next": "^12.2.0",
35-
"react-router-dom": "^6.9.0",
34+
"react-i18next": "^13.2.2",
35+
"react-router-dom": "^6.16.0",
3636
"serve-static": "^1.15.0"
3737
},
3838
"devDependencies": {
39-
"@eleven-labs/eslint-config-react": "0.1.1",
40-
"@types/express": "^4.17.17",
39+
"@eleven-labs/eslint-config-react": "^1.0.1",
40+
"@types/express": "^4.17.19",
4141
"@types/i18next": "^13.0.0",
42-
"@types/node": "^18.15.9",
43-
"@types/react": "^18.0.29",
44-
"@types/react-dom": "^18.0.11",
42+
"@types/node": "^20.8.4",
43+
"@types/react": "^18.2.28",
44+
"@types/react-dom": "^18.2.13",
4545
"@types/react-i18next": "^8.1.0",
4646
"@types/react-router-dom": "^5.3.3",
47-
"@typescript-eslint/eslint-plugin": "^5.43.0",
48-
"@vitejs/plugin-react": "^3.1.0",
49-
"dotenv": "^16.0.3",
50-
"eslint": "^8.0.1",
51-
"eslint-config-prettier": "8.x",
52-
"eslint-config-standard-with-typescript": "34.0.1",
53-
"eslint-import-resolver-typescript": "3.*",
54-
"eslint-plugin-autofix": "1.x",
55-
"eslint-plugin-import": "^2.25.2",
56-
"eslint-plugin-jsx-a11y": "6.x",
57-
"eslint-plugin-n": "^15.0.0",
58-
"eslint-plugin-prettier": "4.x",
59-
"eslint-plugin-promise": "^6.0.0",
60-
"eslint-plugin-react": "7.x",
61-
"eslint-plugin-react-hooks": "4.x",
62-
"husky": "^8.0.3",
63-
"lint-staged": "^13.2.0",
64-
"prettier": "2.x",
65-
"sass": "^1.60.0",
47+
"@typescript-eslint/eslint-plugin": "^6.7.5",
48+
"@vitejs/plugin-react-swc": "^3.4.0",
49+
"dotenv": "^16.3.1",
50+
"eslint": "^8.51.0",
51+
"lint-staged": "^14.0.1",
52+
"prettier": "3.0.3",
53+
"sass": "^1.69.3",
6654
"ts-node": "^10.9.1",
67-
"typescript": "^4.9.5",
68-
"vite": "^4.2.1",
69-
"vite-tsconfig-paths": "^4.0.7"
55+
"typescript": "^5.2.2",
56+
"vite": "^4.4.11",
57+
"vite-tsconfig-paths": "^4.2.1"
7058
}
7159
}
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import { type InitOptions } from 'i18next';
1+
import { type InitOptions } from "i18next";
22

3-
import { AUTHORIZED_LANGUAGES, DEFAULT_LANGUAGE } from '@/constants';
4-
import translationsEn from '@/translations/messages.en.json';
5-
import translationsFr from '@/translations/messages.fr.json';
3+
import { AUTHORIZED_LANGUAGES, DEFAULT_LANGUAGE } from "@/constants";
4+
import translationsEn from "@/translations/messages.en.json";
5+
import translationsFr from "@/translations/messages.fr.json";
66

77
export const i18nConfig: InitOptions = {
8-
load: 'languageOnly',
9-
preload: AUTHORIZED_LANGUAGES,
10-
fallbackLng: DEFAULT_LANGUAGE,
11-
resources: {
12-
fr: { messages: translationsFr },
13-
en: { messages: translationsEn },
8+
defaultNS: "messages",
9+
detection: {
10+
lookupFromPathIndex: 0,
11+
order: ["path"],
1412
},
15-
returnEmptyString: false,
16-
defaultNS: 'messages',
17-
ns: 'messages',
13+
fallbackLng: DEFAULT_LANGUAGE,
14+
load: "languageOnly",
15+
ns: "messages",
16+
preload: AUTHORIZED_LANGUAGES,
1817
react: {
19-
bindI18n: 'languageChanged',
18+
bindI18n: "languageChanged",
2019
bindI18nStore: false,
2120
useSuspense: false,
2221
},
23-
detection: {
24-
order: ['path'],
25-
lookupFromPathIndex: 0,
22+
resources: {
23+
en: { messages: translationsEn },
24+
fr: { messages: translationsFr },
2625
},
26+
returnEmptyString: false,
2727
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './i18n.config';
1+
export * from "./i18n.config";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './routes';
1+
export * from "./routes";
Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,66 @@
1-
import fetch from 'cross-fetch';
2-
import * as React from 'react';
3-
import { type RouteObject } from 'react-router';
4-
import { Outlet } from 'react-router-dom';
1+
import fetch from "cross-fetch";
2+
import * as React from "react";
3+
import { type RouteObject } from "react-router";
4+
import { Outlet } from "react-router-dom";
55

6-
import { AUTHORIZED_LANGUAGES, PATHS } from '@/constants';
6+
import { AUTHORIZED_LANGUAGES, PATHS } from "@/constants";
77
import {
88
HomePageContainer,
99
LayoutTemplateContainer,
1010
NotFoundPageContainer,
1111
PokemonListPageContainer,
12-
} from '@/containers';
12+
} from "@/containers";
1313

1414
export const routes: RouteObject[] = [
1515
{
16-
element: (
17-
<LayoutTemplateContainer>
18-
<Outlet />
19-
</LayoutTemplateContainer>
20-
),
21-
errorElement: (
22-
<LayoutTemplateContainer>
23-
<NotFoundPageContainer />
24-
</LayoutTemplateContainer>
25-
),
2616
children: [
2717
{
28-
path: PATHS.ROOT,
2918
element: <HomePageContainer />,
19+
path: PATHS.ROOT,
3020
},
3121
{
32-
path: '/:lang',
33-
loader: ({ params }): Record<string, unknown> => {
34-
if (!AUTHORIZED_LANGUAGES.includes(params.lang as string)) {
35-
throw new Error('Lang not Found');
36-
}
37-
return {};
38-
},
3922
children: [
4023
{
41-
path: PATHS.HOME,
4224
element: <HomePageContainer />,
25+
path: PATHS.HOME,
4326
},
4427
{
45-
path: PATHS.POKEMON_LIST,
4628
element: <PokemonListPageContainer />,
47-
loader: async (): Promise<{ pokemons: Array<{ name: string }> }> => {
48-
const response = await fetch(`https://pokeapi.co/api/v2/pokemon?limit=3&offset=0`).then(
49-
async (res) => await res.json()
50-
);
29+
loader: async (): Promise<{
30+
pokemons: Array<{ name: string }>;
31+
}> => {
32+
const { results } = await fetch(
33+
`https://pokeapi.co/api/v2/pokemon?limit=3&offset=0`,
34+
).then((response) => response.json());
5135
return {
52-
pokemons: response.results,
36+
pokemons: results,
5337
};
5438
},
39+
path: PATHS.POKEMON_LIST,
5540
},
5641
],
42+
loader: ({ params }): Record<string, unknown> => {
43+
if (!AUTHORIZED_LANGUAGES.includes(params.lang as string)) {
44+
throw new Error("Lang not Found");
45+
}
46+
return {};
47+
},
48+
path: "/:lang",
5749
},
5850
{
59-
path: '*',
6051
element: <NotFoundPageContainer />,
52+
path: "*",
6153
},
6254
],
55+
element: (
56+
<LayoutTemplateContainer>
57+
<Outlet />
58+
</LayoutTemplateContainer>
59+
),
60+
errorElement: (
61+
<LayoutTemplateContainer>
62+
<NotFoundPageContainer />
63+
</LayoutTemplateContainer>
64+
),
6365
},
6466
];

0 commit comments

Comments
 (0)