zustand: Parcel production builds can't bundle the latest version
Summary
The latest version of Zustand is not compatible with Parcel’s builds. The following error is thrown when the bundled code is run:
index.js:41 Uncaught TypeError: Cannot convert undefined or null to object
at Function.assign (<anonymous>)
at index.js:41:42
Link to reproduction
https://github.com/nicobohne/zustand-parcel-reproduction
Check List
Please do not ask questions in issues.
- I understand this is not a question.
Please fill this template if you’re filling an issue regarding TypeScript.
- I’ve added a link to a typescript playground or codesandbox with a minimal reproduction. Or some other way of reproduction if these two don’t suffice.
- I’ve read the typescript guide, in particular that
create
is to be used ascreate<T>()(...)
and notcreate<T>(...)
.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 15 (6 by maintainers)
I just want to confirm that I have the same issue with 4.1.5 release. 4.1.4 is ok.
Done: #1563
P.S.: Thx for this fantastic library
The
node
field from what I’ve read and understood is only read by webpack, could be worth a try since the source of most issues we’ve had seem to be from webpack users.No direct issue with using a hack, it’s just that we are running in circles with the export thing. We’ve got enough configuration to compile 10 libraries in the codebase which means more moving parts and harder to control what’s going on, plus with the name and direct
module.exports
we are actually fighting against the other tooling since most of them agree on only having named exports.Hence, the recommendation to do the slow removal of the default export. I understand the aesthetic value of
so I’d like to make it work in most cases, going throught older React bundling techniques where both the import styled worked.
Even when there were almost 6-7 other named exports on the library. In theory it’s just
But I’d like to go through it a little more before I implement it here
i could do a empty assign check similar to the above solution but then that’s just boiler code I expect bundlers to add.
Let me play around with rollup a bit, i should be able to get a cleaner solution
Okay, manually edited the bundled file and this seems to fix the error.
Edit: Or even directly editing the source file from zustand with the above changes removes the error from production bundles.