chrisvander / zustand-computed

A Zustand middleware to create computed states.
MIT License
87 stars 10 forks source link

[Error]: Unexpected token 'export' #8

Closed vegancat closed 1 year ago

vegancat commented 1 year ago

I'm not using anything fancy, just zustand + this package and running yarn dev produces error below:

export * from "./computed";
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm

Also there's a typo in readme. create<Type>()(computed(...)) seems to be correct as it used in the example. () in front of create is missing

chrisvander commented 1 year ago

Version 1.3.5 includes a CommonJS build, see if that fixes your issue. It was built initially for ES Module projects.

chrisvander commented 1 year ago

Also, for the README. Are you talking about the selectors example? Since I'm not inferring the mutator type and am typing it explicitly (e.g. [["chrisvander/zustand-computed", ComputedStore]]) I don't need to use the curried create() call.

vegancat commented 1 year ago

Aha, I tried a few approaches to solve the error and all didn't work. give it a shot, if it worked then it has to be something by my side.

and for readme, I didn't know you need to add () to the create only if you're not typing the function explicitly.

vegancat commented 1 year ago

There's a similar library zustand-middleware-computed-state that works fine for me

chrisvander commented 1 year ago

Did you try the CommonJS build?

chrisvander commented 1 year ago

Closing as this should be addressed.