Replies: 2 comments 2 replies
-
@NSeydoux it is only a matter of time before the tooling ecosystem catches up with node's import/require algorithm. Conditional and subpath exports are now available and stable in all Node.js versions that are not End-of-Life, that means LTS Maintenance, Active LTS, and Current. As such I do not feel like stepping down from exclusively using this scheme just yet. FYI I took a stab at a flat index file once or twice already and always dropped the effort for one reason or another. Types not being loaded anymore, adjust type loading mapping, then types didn't work for the actual modules. If you feel like putting in the time then by all means, but it's not before I see the final impact of that PR that I can say I'd accept it. |
Beta Was this translation helpful? Give feedback.
-
I'm done waiting for these ecosystems to catch up. jose v4.x will be coming out today/tomorrow with only top level named exports that solve all these tools' problems. |
Beta Was this translation helpful? Give feedback.
-
Currently, the
jose
library exports ES modules with anexports
map inpackage.json
. This is quite future-proof, and works with up-to-date tools, but a significant part of the JS front-end ecosystem still doesn’t support this, e.g.:Therefore, adopting
jose
for a library (which is our use case) puts some constraints on the dependents of that library. One way to mitigate this, which should be relatively low-cost tojose
, would be to add anindex
file that re-exports all the sub-modules, with a series of exports looking like the following:...and to add the following entry to the
package.json
file, e.g.:Doing this means one could write
import { jwtVerify } from 'jose'
if they do not/cannot supportimport { jwtVerify } from 'jose/jwt/verify'
. This shouldn’t have any impact on users that supportexports
map.Would you have any objections to
jose
supporting this export mode as well as the current one ? If you’re okay with it, I’m happy to create a PR containing the suggested additions.Beta Was this translation helpful? Give feedback.
All reactions