Search Terms
esm, commonjs, dual packages
Question
foo/package.json
foo/index.mjs (this is ESM)
foo/index.cjs (this is CJS)
foo/index.d.ts (this is type definitions)
for example, index.mjs and index.cjs has function declare function arch(): 'x64' | 'x86';
For cjs, index.d.ts should be
declare function arch(): 'x64' | 'x86';
export = arch;
For mjs, index.d.ts should be
declare function arch(): 'x64' | 'x86';
export default arch;
For both, index.d.ts should be
declare function arch(): 'x64' | 'x86';
declare const Arch: typeof arch & {
readonly default: typeof arch;
}
export = Arch;
But If I use export = Arch;
import arch = require('arch');
arch.default() // This has no error. But `arch.default` is not exists.
Search Terms
esm, commonjs, dual packages
Question
for example, index.mjs and index.cjs has function
declare function arch(): 'x64' | 'x86';For cjs,
index.d.tsshould beFor mjs,
index.d.tsshould beFor both,
index.d.tsshould beBut If I use
export = Arch;