change-case icon indicating copy to clipboard operation
change-case copied to clipboard

Single module import

Open btxtiger opened this issue 4 years ago • 10 comments

Hi, I just wanted to let you know that I created a package that includes all methods in a single module, in case you would mention it in your readme for people who do not want to install each method separately. https://github.com/btxtiger/change-case-all npm install --save change-case-all

btxtiger avatar Apr 12 '20 23:04 btxtiger

There’s already change-case. Is the difference that it also contains the extended methods? I didn’t include those intentionally due to being a different API, but if there’s a good reason to do it we could add it here.

blakeembrey avatar Apr 13 '20 03:04 blakeembrey

Yes, I have a large project, where I used change-case 3.x, where all methods still were included. That was an easier workflow, than knowing all import names. I could just write import { } from 'change case' to get a suggestion list. If you offer to include them back, I'm also happy with it.

btxtiger avatar Apr 13 '20 09:04 btxtiger

+1 from me. I was quite surprised that auto-imports did not work in IntelliJ when I only used the change-case dependency in my package.json: see SO: "Why does auto-import of some packages not work?"

tmtron avatar Apr 25 '20 06:04 tmtron

@tmtron how would you suggest fixing the issue in IntelliJ?

blakeembrey avatar Apr 25 '20 06:04 blakeembrey

I wouldn't call it a fix - because nothing is broken - actually it's just like a convenience to make auto-import work. I only use IntelliJ, but I guess that this also affects other editors, so it's "nice to have".

What works in IntelliJ for me is to replace the change-case dependency with change-case-all in my package.json file.
Since change-case-all directly (re-)exports all functions, the IDE can pick up those functions and suggest them in the auto-import dialogue.

I'm not sure what the best way would be to support this, but I guess you could just add change-case-all as another package in this repo and then users could decide if they want to

  • use fine-grained separate imports (maybe useful when someone does not use any module bundlers?)
  • the current change-case "super" package
  • or the new change-case-all package.

Maybe you can even replace your current change-case with ``change-case-all`? But I'm not sure, if this would have any cons or brake backward-compatibility..

It would be better to have change-case-all directly in this repository, to make sure, that it stays up-to-date whenever you build a new release.

tmtron avatar Apr 25 '20 07:04 tmtron

Ok, I think I may have been confused because the StackOverflow example you linked to talked about a package already included in the main package. Are you saying it’s because you want to import a different package not related to the StackOverflow post?

blakeembrey avatar Apr 25 '20 16:04 blakeembrey

@tmtron I can not confirm the issue you are encountering. Auto imports work fine using latest Webstorm. I think it is something broken in your editor index cache. Delete the .idea folder in your project dir and restart your IntelliJ again.

btxtiger avatar Apr 25 '20 17:04 btxtiger

I'm sorry for the confusion. Unfortunately, I had fixed my GitHub example (which is referenced by the SO question) by adding the snake-case package (in addition to change-case).
I've reverted this change now in the main branch, so that the issue is reproducible again.

But fortunately I can reproduce it even on Stackblitz: here are 2 very simple examples and I hope this clarifies what I am trying to say:

change-case-all

Open the change-case-all Stackblitz Example, place the cursor at the end of snakeCase and press CTRL+SPACE: auto-import works:

image

change-case

Open the change-case-all Stackblitz Example, place the cursor at the end of snakeCase and press CTRL+SPACE: auto-import does not work:

image

I can reproduce this in multiple PCs/Editors:

  • on my PC with IntelliJ Ultra 2020.1 (Invalidate/Caches & restart does not help)
  • on my PC with Visual Studio Code 1.44.2
  • on my Laptop with IntelliJ Ultra 2020.1
  • on Stackblitz (see links above)

tmtron avatar Apr 26 '20 07:04 tmtron

It seems like there might be two issues tied up in this issue. I would very much like the extended functions (e.g. titleCase) to be included in the main package. The ones that don't get used get tree-shaken out anyway. I think it would be much more convenient to pull them all out of the same package. change-case is one of the utility knife libraries I install at the start of every project for this very reason. I end up needing at least one function no matter what the circumstance, and it doesn't bloat my projects to use.

mikestopcontinues avatar Nov 13 '20 15:11 mikestopcontinues

Same issue for me with VS Code and ESLint.

Installing individual packages explicitly fixed the issue but it's obviously not a very clean solution (thank you for the tip @tmtron).

Deckluhm avatar Jun 10 '21 15:06 Deckluhm

In change-case@5 I've opted to merge all the case changing libraries into one package and deprecated all the single line packages (upper-case, upper-case-first, lower-case, lower-case-first, is-upper-case, and is-lower-case).

Let me know if any of those removals are of major importance to you and I can undeprecate them for the latest release.

At this point, only title-case, sponge-case and swap-case exist aside from change-case. Merging them together isn't something I intend to do at this point in time.

blakeembrey avatar Sep 30 '23 03:09 blakeembrey