btree-typescript
btree-typescript copied to clipboard
No esm build, just common js
Thank you, incredibly fast lib.
Without esm build i.e.
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm"
its impossible to use this library if "type": "module",
is set in package.json.
i.e having commonjs I need add .default
and this breaks typings
import BTree from 'sorted-btree';
var tree = new BTree.default<number, [number, number]>(undefined, (a, b) => a - b);
To have near zero setup of esm+commonjs support I can recoomend https://github.com/developit/microbundle
What environment are you running in? I don't have a reason to think that CommonJS modules are broken inside apps that use "type": "module"
. Node.js documentation just says:
Node.js will treat as CommonJS all other forms of input, such as .js files where the nearest parent package.json file contains no top-level "type" field
Perhaps you can use a workaround like this:
import BTree_ from 'sorted-btree';
const BTree = (BTree_ as any).default as typeof BTree_;
This https://github.com/lukeed/tsm as loader for node i.e. node --loader tsm