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

[1.x] Upgrade dependencies #1991

Open
wants to merge 11 commits into
base: v1
Choose a base branch
from
Open
Show file tree
Hide file tree
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 .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16.15
node-version: 20.15

- name: Cache node modules
uses: actions/cache@v2
Expand Down
5,133 changes: 2,244 additions & 2,889 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"playgrounds/*"
],
"dependencies": {
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^3.2.4",
"prettier-plugin-svelte": "^3.2.3",
"prettier-plugin-tailwindcss": "^0.5.14"
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.1.0",
"prettier-plugin-svelte": "^3.2.7",
"prettier-plugin-tailwindcss": "^0.6.8"
},
"scripts": {
"format": "prettier --write ."
Expand Down
60 changes: 40 additions & 20 deletions packages/core/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import esbuild from 'esbuild'
import * as esbuild from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals'

const watch = process.argv.slice(1).includes('--watch')
Expand All @@ -9,7 +9,10 @@ const config = {
minify: true,
sourcemap: true,
target: 'es2020',
plugins: [nodeExternalsPlugin()],
plugins: [
nodeExternalsPlugin(),
rebuildLogger(),
],
}

const builds = [
Expand All @@ -19,22 +22,39 @@ const builds = [
{ entryPoints: ['src/server.ts'], format: 'cjs', outfile: 'dist/server.js', platform: 'node' },
]

builds.forEach((build) => {
esbuild
.build({ ...config, ...build, ...watcher(build) })
.then(() => console.log(`${watch ? 'Watching' : 'Built'} ${build.entryPoints} (${build.format})…`))
.catch(() => process.exit(1))
})

function watcher(build) {
return watch
? {
watch: {
onRebuild: (error) =>
error
? console.error('Watch failed:', error)
: console.log(`Rebuilding ${build.entryPoints} (${build.format})…`),
},
}
: {}
try {
const buildContexts = await Promise.all(builds.map(build => esbuild.context({ ...config, ...build })))

await Promise.all(buildContexts.map(async (ctx, index) => {
if (watch) {
await ctx.watch()
} else {
await ctx.rebuild()
await ctx.dispose()
}

console.log(`${watch ? 'Watching' : 'Built'} ${builds[index].entryPoints} (${builds[index].format})...`)
}))

watch && console.log('Watching for changes. Press Ctrl+C to exit.')
} catch (error) {
process.exit(1)
}

function rebuildLogger() {
return {
name: 'rebuild-logger',
setup(build) {
let ignoreFirstRun = true

build.onEnd(() => {
if (ignoreFirstRun) {
ignoreFirstRun = false
return
}

console.log(`Rebuilt ${build.initialOptions.entryPoints} (${build.initialOptions.format})…`)
})
},
}
}
13 changes: 6 additions & 7 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,17 @@
"prepublishOnly": "npm run build"
},
"dependencies": {
"axios": "^1.6.0",
"deepmerge": "^4.0.0",
"axios": "^1.7.7",
"deepmerge": "^4.1.1",
"nprogress": "^0.2.0",
"qs": "^6.9.0"
},
"devDependencies": {
"@types/deepmerge": "^2.2.0",
"@types/node": "^14.0",
"@types/node": "^20.14.8",
"@types/nprogress": "^0.2.0",
"@types/qs": "^6.9.0",
"esbuild": "^0.16.13",
"esbuild-node-externals": "^1.6.0",
"typescript": "^4.9.4"
"esbuild": "^0.23.0",
"esbuild-node-externals": "^1.14.0",
"typescript": "^5.6.2"
}
}
1 change: 0 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"noUnusedParameters": true,
"preserveConstEnums": true,
"removeComments": false,
"typeRoots": ["./node_modules/@types"],
"strict": true
}
}
60 changes: 40 additions & 20 deletions packages/react/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import esbuild from 'esbuild'
import * as esbuild from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals'

const watch = process.argv.slice(1).includes('--watch')
Expand All @@ -9,7 +9,10 @@ const config = {
minify: true,
sourcemap: true,
target: 'es2020',
plugins: [nodeExternalsPlugin()],
plugins: [
nodeExternalsPlugin(),
rebuildLogger(),
],
}

const builds = [
Expand All @@ -19,22 +22,39 @@ const builds = [
{ entryPoints: ['src/server.ts'], format: 'cjs', outfile: 'dist/server.js', platform: 'node' },
]

builds.forEach((build) => {
esbuild
.build({ ...config, ...build, ...watcher(build) })
.then(() => console.log(`${watch ? 'Watching' : 'Built'} ${build.entryPoints} (${build.format})…`))
.catch(() => process.exit(1))
})

function watcher(build) {
return watch
? {
watch: {
onRebuild: (error) =>
error
? console.error('Watch failed:', error)
: console.log(`Rebuilding ${build.entryPoints} (${build.format})…`),
},
}
: {}
try {
const buildContexts = await Promise.all(builds.map(build => esbuild.context({ ...config, ...build })))

await Promise.all(buildContexts.map(async (ctx, index) => {
if (watch) {
await ctx.watch()
} else {
await ctx.rebuild()
await ctx.dispose()
}

console.log(`${watch ? 'Watching' : 'Built'} ${builds[index].entryPoints} (${builds[index].format})...`)
}))

watch && console.log('Watching for changes. Press Ctrl+C to exit.')
} catch (error) {
process.exit(1)
}

function rebuildLogger() {
return {
name: 'rebuild-logger',
setup(build) {
let ignoreFirstRun = true

build.onEnd(() => {
if (ignoreFirstRun) {
ignoreFirstRun = false
return
}

console.log(`Rebuilt ${build.initialOptions.entryPoints} (${build.initialOptions.format})…`)
})
},
}
}
8 changes: 4 additions & 4 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@types/react": "^16.9.1",
"@types/react-dom": "^16.9.17",
"esbuild": "^0.16.13",
"@types/react": "^18.3.9",
"@types/react-dom": "^18.3.0",
"esbuild": "^0.23.0",
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
"typescript": "^4.9.4"
"typescript": "^5.6.2"
},
"peerDependencies": {
"react": "^16.9.0 || ^17.0.0 || ^18.0.0"
Expand Down
20 changes: 11 additions & 9 deletions packages/react/src/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ type setDataByObject<TForm> = (data: TForm) => void
type setDataByMethod<TForm> = (data: (previousData: TForm) => TForm) => void
type setDataByKeyValuePair<TForm> = <K extends keyof TForm>(key: K, value: TForm[K]) => void
type FormDataType = object
type FormErrors<TForm> = Partial<Record<keyof TForm, string>>
type SubmitCallbackFunction = (method: Method, url: string, options: Partial<VisitOptions>) => void

export interface InertiaFormProps<TForm extends FormDataType> {
data: TForm
isDirty: boolean
errors: Partial<Record<keyof TForm, string>>
errors: FormErrors<TForm>
hasErrors: boolean
processing: boolean
progress: Progress | null
Expand All @@ -25,7 +27,7 @@ export interface InertiaFormProps<TForm extends FormDataType> {
reset: (...fields: (keyof TForm)[]) => void
clearErrors: (...fields: (keyof TForm)[]) => void
setError(field: keyof TForm, value: string): void
setError(errors: Record<keyof TForm, string>): void
setError(errors: FormErrors<TForm>): void
submit: (method: Method, url: string, options?: VisitOptions) => void
get: (url: string, options?: VisitOptions) => void
patch: (url: string, options?: VisitOptions) => void
Expand Down Expand Up @@ -68,9 +70,9 @@ export default function useForm<TForm extends FormDataType>(
}
}, [])

const submit = useCallback(
const submit = useCallback<SubmitCallbackFunction>(
(method, url, options = {}) => {
const _options = {
const _options: VisitOptions = {
...options,
onCancelToken: (token) => {
cancelToken.current = token
Expand Down Expand Up @@ -125,7 +127,7 @@ export default function useForm<TForm extends FormDataType>(
if (isMounted.current) {
setProcessing(false)
setProgress(null)
setErrors(errors)
setErrors(errors as FormErrors<TForm>)
setHasErrors(true)
}

Expand All @@ -143,7 +145,7 @@ export default function useForm<TForm extends FormDataType>(
return options.onCancel()
}
},
onFinish: () => {
onFinish: (visit) => {
if (isMounted.current) {
setProcessing(false)
setProgress(null)
Expand All @@ -152,7 +154,7 @@ export default function useForm<TForm extends FormDataType>(
cancelToken.current = null

if (options.onFinish) {
return options.onFinish()
return options.onFinish(visit)
}
},
}
Expand Down Expand Up @@ -215,13 +217,13 @@ export default function useForm<TForm extends FormDataType>(
)

const setError = useCallback(
(fieldOrFields: keyof TForm | Record<keyof TForm, string>, maybeValue?: string) => {
(fieldOrFields: keyof TForm | FormErrors<TForm>, maybeValue?: string) => {
setErrors((errors) => {
const newErrors = {
...errors,
...(typeof fieldOrFields === 'string'
? { [fieldOrFields]: maybeValue }
: (fieldOrFields as Record<keyof TForm, string>)),
: (fieldOrFields as FormErrors<TForm>)),
}
setHasErrors(Object.keys(newErrors).length > 0)
return newErrors
Expand Down
3 changes: 1 addition & 2 deletions packages/react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"preserveConstEnums": true,
"removeComments": true,
"typeRoots": ["./node_modules/@types"]
"removeComments": true
// "strict": true
}
}
60 changes: 40 additions & 20 deletions packages/vue2/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import esbuild from 'esbuild'
import * as esbuild from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals'

const watch = process.argv.slice(1).includes('--watch')
Expand All @@ -9,7 +9,10 @@ const config = {
minify: true,
sourcemap: true,
target: 'es2020',
plugins: [nodeExternalsPlugin()],
plugins: [
nodeExternalsPlugin(),
rebuildLogger(),
],
}

const builds = [
Expand All @@ -19,22 +22,39 @@ const builds = [
{ entryPoints: ['src/server.ts'], format: 'cjs', outfile: 'dist/server.js', platform: 'node' },
]

builds.forEach((build) => {
esbuild
.build({ ...config, ...build, ...watcher(build) })
.then(() => console.log(`${watch ? 'Watching' : 'Built'} ${build.entryPoints} (${build.format})…`))
.catch(() => process.exit(1))
})

function watcher(build) {
return watch
? {
watch: {
onRebuild: (error) =>
error
? console.error('Watch failed:', error)
: console.log(`Rebuilding ${build.entryPoints} (${build.format})…`),
},
}
: {}
try {
const buildContexts = await Promise.all(builds.map(build => esbuild.context({ ...config, ...build })))

await Promise.all(buildContexts.map(async (ctx, index) => {
if (watch) {
await ctx.watch()
} else {
await ctx.rebuild()
await ctx.dispose()
}

console.log(`${watch ? 'Watching' : 'Built'} ${builds[index].entryPoints} (${builds[index].format})...`)
}))

watch && console.log('Watching for changes. Press Ctrl+C to exit.')
} catch (error) {
process.exit(1)
}

function rebuildLogger() {
return {
name: 'rebuild-logger',
setup(build) {
let ignoreFirstRun = true

build.onEnd(() => {
if (ignoreFirstRun) {
ignoreFirstRun = false
return
}

console.log(`Rebuilt ${build.initialOptions.entryPoints} (${build.initialOptions.format})…`)
})
},
}
}
Loading
Loading