Bundle ReScript libraries with dual-package exports

I built a library bundler called nanobundle that supports the imports/exports map in the package.json.

imports/exports map is quite important when building libraries in ReScript because the ReScript compiler only builds a module spec at once.

You may need some bundler features to support both CJS/ESM at once. For example:


That’s great! Do you have a write up or similar somewhere of a good approach for packaging a lib written in ReScript for multiple output formats etc? Essentially everything you need to think about when packaging a ReScript lib for consumption outside of ReScript. That would be quite valuable for the community to have I think.

1 Like

Looks like the tool I wished for :fire:
I’ll try it out for rescript-struct and rescript-stdlib-vendorer and share feedback :+1:

I also have a draft of an article about creating a ReScript library for Js/Ts consumers. Will be a great addition if the tool works as I expect.

1 Like

Didn’t work for me :frowning_face: The problem is with me using commonjs output.

Could you file your issue to the nanobundle repo?

The nanobundle worked fine. I’m just more of a specific case.

Here’s the logic I wanted to have: