Closed smeng9 closed 1 year ago
Thanks for the contribution!
I don't understand much about the new exports
field. This is why I have a few questions (if you know the answers).
By the description, I'm assuming that testing with Vitest code that includes the use-local-storage-state
library throws an error. Am I right and what's the error?
Isn't the below better (having "require" point to the CJS version)? What's the difference? I saw this in the Node.js docs — https://nodejs.org/api/packages.html#conditional-exports.
"exports": {
"import": "./es/index.js",
"require": "./index.js"
}
Is this breaking? Meaning should I release a new major or minor version?
You are correct, vitest throws an error. The error is vitest does not use module
field or jsnext:main
field in the package.json
Error: Failed to resolve entry for package "tg-use-local-storage-state". The package may have incorrect main/module/exports specified in its package.json.
Oh I just noticed there is indeed a cjs copy in the final published package. Your solution would be better. I should use
"exports": { "import": "./es/index.js", "require": "./index.js" }
This should not be breaking. It merely improves the compatibility with vitest.
Awesome. Thanks for your contribution!
This PR introduced this bug: https://github.com/astoilkov/use-local-storage-state/issues/60.
@smeng9 Any ideas why?
I reverted this fix because it breaks type definitions.
Fix exports field for vitest so it can be correctly resolved in test environment