Closed TheEdoRan closed 3 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
next-safe-action-playground | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Aug 13, 2024 10:51am |
next-safe-action-website | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Aug 13, 2024 10:51am |
If you use the tsup tree shaking option, it should package only the code you end up using in the final build output. Lodasb certainly works, but the code is about 5 years old. I don't have experience with the other libraries.
On Mon, Aug 12 2024 at 19:47, Edoardo Ranghieri @.***> wrote:
@.**** commented on this pull request.
In packages/next-safe-action/src/utils.ts https://github.com/TheEdoRan/next-safe-action/pull/229#discussion_r1714481001 :
@@ -2,6 +2,22 @@ export const DEFAULT_SERVER_ERROR_MESSAGE = "Something went wrong while executin
export const isError = (error: unknown): error is Error => error instanceof Error;
+export const deepMerge = (obj1: object, obj2: object) => {
- for (const key of Object.keys(obj2)) {
- const k = key as keyof typeof obj2;
- // eslint-disable-next-line
- if (typeof obj2[k] === "object" && Object.hasOwn(obj1, k)) {
- // @ts-expect-error
The thing is: ramda is published as a whole library, while lodash provides lodash.merge https://www.npmjs.com/package/lodash.merge as a standalone package, which is obviously much smaller in size. deepmerge https://www.npmjs.com/package/deepmerge or deepmerge-ts https://www.npmjs.com/package/deepmerge-ts also appear to be viable options. What do you think?
— Reply to this email directly, view it on GitHub https://github.com/TheEdoRan/next-safe-action/pull/229#discussion_r1714481001, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHDDRYBUBIRYVHK33U37Q3ZRFCQ5AVCNFSM6AAAAABMMT2J3GVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDEMZUGE4TONZRHA . You are receiving this because you commented.Message ID: @.***>
@mcalhoun I chose to use deepmerge-ts, which seems to be an up to date and more performant variant of deepmerge. Apparently, if you install the package as devDependency
and import it in the code, tsup takes care of bundling the external library in the js output, which is nice.
:tada: This PR is included in version 7.6.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Proposed changes
Code in this PR requires context to be an object, it extends it by default, and enables creation of standalone middleware functions via built-in
experimental_createMiddleware
utility.Related issue(s) or discussion(s)
re #222