Closed hugomrdias closed 1 year ago
I hadn't considered that people were running Node.js in ESM mode. We made the change primarily to support Webpack and other bundlers, which use the module
field, but I guess Node.js doesn't, even when ESM mode is enabled?
@hugomrdias Can you try adding this to the package.json
of key-tree
in your node_modules
(just for testing), and let me know if that resolves it?
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"types": "./dist/types/index.d.ts"
},
"./dist/cjs/*": {
"require": "./dist/cjs/*.js",
"types": "./dist/types/*.d.ts"
},
"./dist/esm/*": {
"import": "./dist/esm/*.js",
"types": "./dist/types/*.d.ts"
}
},
you need to add a package.json file in the esm folder with type: module
, its all the link
the dual packaging setup does not support esm version in node and cjs version does not do named exports correctly
More information about dual packaging here https://github.com/sheremet-va/dual-packaging.