Closed azan-n closed 1 year ago
This isn't really an SD thing, but a challenge generally within the current JS world. Here are some relevant pages on the subject:
https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html https://antfu.me/posts/publish-esm-and-cjs https://github.com/johnloy/esm-commonjs-interop-manual
I have style-dictionary project with the following configuration:
Subsequently, I've set up the package.json as follows:
I am exporting only for the web and will need to use the tokens in both CJS environments (like a
tailwind.config.js
), and within ESM code (like a component with dynamic colour changes).Currently, I import the tokens in projects which are bound to using
moduleResolution: "node"
in thetsconfig.json
which is probably why thepackagejson.exports
is not working correctly. Is there a way I could export a package with ESM/CJS interop?