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

Remove lodash.deepClone in favor of Object.assign #36

Merged
merged 4 commits into from
Dec 26, 2024

Conversation

gm112
Copy link

@gm112 gm112 commented Dec 17, 2024

Removes a dependency in favor of a native equivalent!

@Pridestalkerr
Copy link

Object.assign() creates a shallow copy as opposed to lodash.cloneDeep().
They would only be equivalent if all keys inside those objects are primitives, otherwise everything else (such as nested objects) will have the same reference.

This change may actually work, but really need to make sure that mutations arent performed on the cloned objects.

@mcampa
Copy link
Owner

mcampa commented Dec 26, 2024

seems reasonable, thanks

@mcampa mcampa merged commit 2e9b526 into mcampa:master Dec 26, 2024
3 checks passed
@lawandothman
Copy link

lawandothman commented Jan 8, 2025

Hey @mcampa

I don't think this has been removed properly from the build output cuz I've started getting this error in 2.1.1

Error: :esbuild: ✘ [ERROR] Could not resolve "lodash.clonedeep"
. build:esbuild:     ../../node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/trpc-to-openapi/dist/esm/generator/paths.mjs:2:22:
. build:esbuild:       2 │ import cloneDeep from 'lodash.clonedeep';
. build:esbuild:         ╵                       ~~~~~~~~~~~~~~~~~~
. build:esbuild:   You can mark the path "lodash.clonedeep" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

I can still see references to it in dist/esm/adapters/node-http/core.mjs on npm too for example
image

@mcampa
Copy link
Owner

mcampa commented Jan 8, 2025

Ahh, thanks for letting me know @lawandothman. I probably published to npm without running a build first. I need to setup a Github Action that publishes the build to npm to prevent this from happening in the future.

I just published 2.1.2 to fix the issue, you can use that version. Please let me know if you find any other issue.

@lawandothman
Copy link

Yep that fixed the build @mcampa - thank you 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants