exome icon indicating copy to clipboard operation
exome copied to clipboard

Stable Exome ID?

Open kristian-nst opened this issue 11 months ago • 4 comments

Hi. I'm trying to save a store state into localStorage, and trying to get a unique key.

I'm noticing that getId is most likely getting the .name from the class/constructor ?

dev: Image

production: Image

this makes the key differ after each build, because for the same store i've had

  • exome-i-store
  • exome-s-store
  • exome-b-store etc...

am I assuming correctly? would i just need to skip get/setID() and use my own set of strings in some map? :)

thanks ❤️ (my favorite store lib)


PS: Typo :)

Image

kristian-nst avatar Feb 15 '25 08:02 kristian-nst

Hey, glad you like it!

The problem is that minifiers rename class identifiers. There are multiple ways to solve this:

  1. use registerLoadable, then minifiers preserve names for registered stores;
  2. set minifier to explicitly not minify identifiers you want;
  3. roll your own name map solution.

The 1st one should do the trick tho, that is what I usually use.

Thanks for pointing out typo, fixed it 👍

Marcisbee avatar Feb 15 '25 09:02 Marcisbee

Hey :) I actually use registerLoadable :/ Does it has to be called before initializing a store instance? For now I went with 3)

kristian-nst avatar Feb 15 '25 09:02 kristian-nst

Interesting, do you mind sharing some minimal reproduction of it in some repo, codesandbox, stackblitz etc? Very interested in figuring out what's wrong here.

Marcisbee avatar Feb 17 '25 09:02 Marcisbee

Sorry, no time for this repro yet :) But I haven't forgotten

kristian-nst avatar Feb 22 '25 06:02 kristian-nst