forgive me if I post the question in the wrong place, as I'm not too sure if it's a babel-loader issue, or typescript issue.
so basically I'm using a 3rd party library which is commonJS module with default export
// XX/index.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.default = "this is the export string";
when I consume it directly from my project, which is Creat-react-app (typescript + babel-loader), below code works fine
import XX from 'xx';
console.log(XX); // XX is the exported string , i.e. it's module.exports.default
However, I have another esm library/module yy, which depends on xx,and when I debug the code I noticed that inside node_modules/yy/index.js, imported XX is the module object , i.e. module.exports instead of module.exports.default.
Is is the expect behaviour or is this a defect in babel/typescript?
// node_module/yy/index.js
import XX from 'xx';
console.log(XX); // <------------- XX is an object {__esModule: true, default: 'this is the exported strign'}
export const YY='something'
// src/index.js
import XX from 'xx'; //OK XX is `module.exports.default`
import {YY} from 'yy'; // Error: inside node_module/yy/index.js, XX is `module.exports`
can someone please shed some light on this ? thanks! (and sorry I've put the question in the wrong channel)
hi guys,
forgive me if I post the question in the wrong place, as I'm not too sure if it's a
babel-loader
issue, ortypescript
issue.so basically I'm using a 3rd party library which is commonJS module with default export
when I consume it directly from my project, which is
Creat-react-app
(typescript
+babel-loader
), below code works fineHowever, I have another esm library/module
yy
, which depends onxx
,and when I debug the code I noticed that insidenode_modules/yy/index.js
, importedXX
is the module object , i.e.module.exports
instead ofmodule.exports.default
. Is is the expect behaviour or is this a defect inbabel
/typescript
?can someone please shed some light on this ? thanks! (and sorry I've put the question in the wrong channel)