file - setting | commonjs | esm |
---|---|---|
package.json - type | commonjs | module |
tsconfig.json - module | commonjs | es2020 |
tsconfig.json - esModuleInterop | true | not required? |
src/index.ts
commonjs
import { default as Bir } from './bir'
export = Bir
esm
import Bir from "./bir.js";
export default Bir;
definie __dirname missing in esm
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
consider to use
-
npx typedoc src/bir.ts --out docs-api --excludePrivate
-
see example usage