I've got a commonjs module (test.cjs) that was generated by typescript compiler (with module: commonjs):
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = 1;
exports.foo = 2;
Note: This module is an external library.
Now I want to use the default export in an es6 module (index.ts) (with module: es6):
So I tried this:
import def, { foo } from "./test.cjs";
console.log(def, foo);
The output { default: 1, foo: 2 } 2.
So non-default import is working fine, but default import expects module.exports to be the default.
Is there a way to have the es6 default import import exports.default instead of exports directly?