sindresorhus / camelcase-keys

Convert object keys to camel case
MIT License
689 stars 92 forks source link

Upgrade to current map-obj #102

Closed AlexSwensen closed 1 year ago

AlexSwensen commented 2 years ago

Currently: While using camelcase-keys, im getting a nested error from the built library.

Creating an optimized production build...
Failed to compile.

Attempted import error: 'map-obj' does not contain a default export (imported as 'mapObject').

After digging, the library currently assumes map-obj is exporting a default function, but the 4.3.0 version that was pinned does not export the called function as a default. The current 5.0.2 version of map-obj does, however. I assume no other breaking changes took place besides how the function is exported, so the only fix required was to bump the dependency.

It does however seem that tests are failing. I could use some assistance in next steps to resolve this issue.

AlexSwensen commented 2 years ago

@sindresorhus I don't believe I have enough context to fix the tests... what do you recommend?

Ethan826 commented 2 years ago

Is #94 related to this? I was getting that issue too and have been chasing my tail trying to upgrade to ESM, but running into unrelated blockers with ts-jest, etc.

I know very little about ESM and knew nothing a few days ago, so all this with a grain of salt, but if map-obj was not on ESM as of version 4.3.0 (as it appears not to have been), I imagine that could cause Jest encountered an unexpected token I saw:

({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import mapObject from 'map-obj';
                                                                                  ^^^^^^

I'm piping up mostly because

  1. Maybe this data point helps, and
  2. If these are related, I wonder if some minority of the ESM problems people have had could relate to this—and if so, whether the possibility of version mismatches is something for your helpful ESM gist?

Apologies if this isn't useful and thanks for all the great libraries!

AlexSwensen commented 2 years ago

@Ethan826 I had a similar issue too... my solution was to fork the library and make some changes to it. Once I did that, my problems were solved for my use case. Hopefully, this helps.

Also, the original author is more than welcome to pull from the branch I just linked as well. I just don't know enough about their use case and implementation to know if it's appropriate. All I know is it worked well for me which allowed me to move on and solve other problems.

Joosakur commented 2 years ago

I'm having the same issue. Downgrading to 7.x helped.

AlexSwensen commented 1 year ago

Closing for now as there seems to be no traction on this, and it is no longer relevant to my work.