Skip to content

Commit 6384e10

Browse files
committed
upgrading vite and to react 19
1 parent 1a59c7c commit 6384e10

20 files changed

+8099
-18891
lines changed

.prettierignore

-1
This file was deleted.

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

package-lock.json

+8,011-18,747
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+23-29
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "react-training-workshop",
3+
"private": true,
34
"version": "0.0.0",
5+
"type": "module",
46
"scripts": {
5-
"start": "node scripts/start.js",
7+
"start": "vite-node scripts/start.ts",
68
"kill-db-port": "node scripts/kill-db-port 3333",
7-
"template": "cd scripts && plop",
89
"install-remix": "cd remix && npm install",
910
"test": "jest"
1011
},
@@ -26,8 +27,8 @@
2627
"mobx-react": "^7.2.1",
2728
"mobx-react-lite": "^3.2.3",
2829
"prop-types": "^15.8.1",
29-
"react": "^18.2.0",
30-
"react-dom": "^18.2.0",
30+
"react": "^19.0.0-beta-1beb73de0f-20240503",
31+
"react-dom": "^19.0.0-beta-1beb73de0f-20240503",
3132
"react-hook-form": "^7.48.2",
3233
"react-icons": "^4.11.0",
3334
"react-popper": "^2.3.0",
@@ -37,23 +38,27 @@
3738
"redux-logger": "^3.0.6",
3839
"zod": "^3.22.2"
3940
},
41+
"overrides": {
42+
"@types/react": "npm:types-react@beta",
43+
"@types/react-dom": "npm:types-react-dom@beta"
44+
},
4045
"devDependencies": {
41-
"@babel/eslint-parser": "^7.16.5",
46+
"@types/concurrently": "^6.4.0",
47+
"@types/react": "npm:types-react@beta",
48+
"@types/react-dom": "npm:types-react-dom@beta",
49+
"@types/readline-sync": "^1.4.8",
50+
"@types/shelljs": "^0.8.15",
4251
"@testing-library/jest-dom": "^5.16.2",
4352
"@testing-library/react": "^13.1.1",
4453
"@types/jest": "^27.4.0",
45-
"@types/markdown-it": "^12.2.3",
46-
"@types/node": "^16.11.1",
47-
"@types/react": "^18.0.26",
48-
"@types/react-dom": "^18.0.10",
49-
"@typescript-eslint/eslint-plugin": "^5.8.0",
50-
"@typescript-eslint/parser": "^5.9.0",
51-
"@vitejs/plugin-react": "^1.0.0",
54+
"@typescript-eslint/eslint-plugin": "^7.2.0",
55+
"@typescript-eslint/parser": "^7.2.0",
56+
"@vitejs/plugin-react": "^4.2.1",
5257
"autoprefixer": "^10.4.14",
5358
"concurrently": "^6.3.0",
54-
"eslint-config-react-app": "^7.0.0",
55-
"eslint-plugin-react": "^7.27.1",
56-
"eslint-plugin-react-hooks": "^4.4.0",
59+
"eslint": "^8.57.0",
60+
"eslint-plugin-react-hooks": "^4.6.0",
61+
"eslint-plugin-react-refresh": "^0.4.6",
5762
"find-process": "^1.4.5",
5863
"jest": "^27.5.1",
5964
"mock-match-media": "^0.3.0",
@@ -63,20 +68,9 @@
6368
"shelljs": "^0.8.5",
6469
"tailwindcss": "^3.3.2",
6570
"ts-jest": "^27.1.3",
66-
"typescript": "^4.5.2",
67-
"vite": "^2.9.13"
68-
},
69-
"eslintConfig": {
70-
"extends": "react-app",
71-
"plugins": [
72-
"react-hooks"
73-
],
74-
"rules": {
75-
"no-unused-vars": "off",
76-
"@typescript-eslint/no-unused-vars": "off",
77-
"react-hooks/rules-of-hooks": "error",
78-
"react-hooks/exhaustive-deps": "warn"
79-
}
71+
"typescript": "^5.2.2",
72+
"vite": "^5.2.0",
73+
"vite-node": "^1.6.0"
8074
},
8175
"prettier": {
8276
"printWidth": 100,

react/_full-app/tailwind.config.js renamed to react/_full-app/tailwind.config.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import colors from 'tailwindcss/colors'
44

5-
// eslint-disable-next-line import/no-anonymous-default-export
6-
export default {
5+
export const config = {
76
// We go up a directory from _full-app to capture all the lessons
87
content: ['./index.html', '../**/*.{js,ts,jsx,tsx}'],
98
theme: {
@@ -24,3 +23,5 @@ export default {
2423
},
2524
plugins: [],
2625
}
26+
27+
export default config

scripts/plop-component/component-with-scss.hbs

-8
This file was deleted.

scripts/plop-component/component.hbs

-7
This file was deleted.

scripts/plop-component/index.hbs

-2
This file was deleted.

scripts/plop-component/scss.hbs

-3
This file was deleted.

scripts/plopfile.mjs

-51
This file was deleted.

scripts/select-lesson.js renamed to scripts/select-lesson.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
const path = require('path')
2-
const fs = require('fs')
3-
const readlineSync = require('readline-sync')
1+
import path from 'path'
2+
import fs from 'fs'
3+
import readlineSync from 'readline-sync'
44

55
const FULL_APP = 'FULL APP'
66

7-
exports.selectReactLesson = selectReactLesson
8-
exports.selectRemixLesson = selectRemixLesson
9-
107
/****************************************
118
Select React Lesson
129
*****************************************/
1310

14-
function selectReactLesson(coursesPath, preferences, savePreferences) {
11+
export function selectReactLesson(coursesPath, preferences, savePreferences) {
1512
/**
1613
* Choose a Course and Lesson
1714
*/
@@ -140,7 +137,7 @@ function selectReactLesson(coursesPath, preferences, savePreferences) {
140137
Select Remix Lesson
141138
*****************************************/
142139

143-
function selectRemixLesson(lessonsPath) {
140+
export function selectRemixLesson(lessonsPath) {
144141
/**
145142
* Choose a Course and Lesson
146143
*/

scripts/start-db.js renamed to scripts/start-db.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const fs = require('fs')
2-
const path = require('path')
3-
const shell = require('shelljs')
4-
const concurrently = require('concurrently')
1+
import fs from 'fs'
2+
import path from 'path'
3+
import shell from 'shelljs'
4+
import concurrently from 'concurrently'
55

6-
exports.startDatabase = (dbDir) => {
6+
export function startDatabase(dbDir: string) {
77
const dbPath = path.join(dbDir, 'db.json')
88

99
try {
@@ -16,7 +16,7 @@ exports.startDatabase = (dbDir) => {
1616
command: `npx json-server --watch ${dbPath} -p 3333 --quiet`,
1717
name: 'npx json-server database',
1818
},
19-
]).catch((err) => {
19+
]).catch(() => {
2020
console.error(
2121
'JSON-SERVER was not able to start. Port 3333 might still be open from a previous run. Try running `npm run kill-db-port` to kill the port\n\n'
2222
)

scripts/start.js renamed to scripts/start.ts

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const shell = require('shelljs')
2-
const path = require('path')
3-
const fs = require('fs')
4-
const readlineSync = require('readline-sync')
5-
const { createServer } = require('vite')
6-
const react = require('@vitejs/plugin-react')
7-
const { selectReactLesson, selectRemixLesson } = require('./select-lesson')
8-
const { startDatabase } = require('./start-db')
1+
import shell from 'shelljs'
2+
import path from 'path'
3+
import fs from 'fs'
4+
import readlineSync from 'readline-sync'
5+
import { createServer } from 'vite'
6+
import react from '@vitejs/plugin-react'
7+
import { selectReactLesson, selectRemixLesson } from './select-lesson'
8+
import { startDatabase } from './start-db'
99

1010
if (process.cwd().indexOf(' ') >= 0) {
1111
console.error(`We cant start this app if your path has spaces:\n${process.cwd()}\n\n`)
@@ -17,15 +17,15 @@ if (process.cwd().indexOf(' ') >= 0) {
1717
*****************************************/
1818

1919
const preferencesPath = path.resolve(__dirname, '..', 'preferences.json')
20-
let preferences = {}
20+
let preferences: Record<string, string> = {}
2121
try {
2222
const data = fs.readFileSync(preferencesPath, 'utf8')
2323
preferences = JSON.parse(data)
2424
} catch (err) {
2525
// no-op
2626
}
2727

28-
function savePreferences(updates) {
28+
function savePreferences(updates: Record<string, string>) {
2929
try {
3030
fs.writeFileSync(preferencesPath, JSON.stringify({ ...preferences, ...updates }, null, 2))
3131
} catch (err) {
@@ -94,7 +94,7 @@ function startRemix() {
9494
React SPA (Vite Server)
9595
*****************************************/
9696

97-
async function startReact(coursesPath) {
97+
async function startReact(coursesPath: string) {
9898
// const coursesPath = path.resolve(__dirname, '..', 'react')
9999

100100
const { lessonPath, selectedLessonType, selectedLesson } = selectReactLesson(
@@ -111,7 +111,7 @@ async function startReact(coursesPath) {
111111
const appRoot = '~'
112112

113113
// Get aliases
114-
const alias = {}
114+
const alias: Record<string, string> = {}
115115

116116
if (lessonPath) {
117117
// const aliasBasePath = `${courseAppNames[selectedCourse]}`
@@ -139,13 +139,15 @@ async function startReact(coursesPath) {
139139

140140
const port = 3000
141141
const server = await createServer({
142+
configFile: false,
143+
root: appPath,
144+
server: {
145+
port,
146+
},
142147
plugins: [react()],
143148
resolve: {
144149
alias,
145150
},
146-
server: {
147-
port,
148-
},
149151
optimizeDeps: { include: ['firebase/app', 'firebase/firestore'] },
150152
})
151153

tsconfig.json

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
{
22
"compilerOptions": {
3-
"strict": true,
4-
"allowJs": true,
5-
"allowSyntheticDefaultImports": true,
6-
"esModuleInterop": false,
7-
"target": "ESNext",
3+
"target": "ES2020",
84
"useDefineForClassFields": true,
9-
"lib": ["DOM", "DOM.Iterable", "ESNext"],
10-
"skipLibCheck": false,
11-
"forceConsistentCasingInFileNames": true,
5+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
126
"module": "ESNext",
13-
"moduleResolution": "Node",
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
10+
"moduleResolution": "Bundler",
11+
"allowImportingTsExtensions": true,
1412
"resolveJsonModule": true,
1513
"isolatedModules": true,
1614
"noEmit": true,
1715
"jsx": "react-jsx",
18-
// Only needed for types with react 18 beta
19-
"types": ["react/next", "react-dom/next", "jest"],
16+
17+
/* Linting */
18+
"strict": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true,
21+
"noFallthroughCasesInSwitch": true,
22+
2023
"baseUrl": "./",
2124
"paths": {
2225
"~/*": ["react/_full-app/*"]
2326
}
24-
}
27+
},
28+
"include": ["react"],
29+
"exclude": ["node_modules"],
30+
"references": [{ "path": "./tsconfig.node.json" }]
2531
}

tsconfig.node.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"skipLibCheck": true,
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
7+
"allowSyntheticDefaultImports": true,
8+
"strict": true
9+
},
10+
// Without this empty include, we were getting
11+
// JSX linting errors and import errors
12+
"include": [""]
13+
}

0 commit comments

Comments
 (0)