Why does module.importInterop=node
disable _interop_require_default
#9749
-
I have a TS package (call it |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 14 replies
-
https://swc.rs/docs/configuration/modules#importinterop |
Beta Was this translation helpful? Give feedback.
-
Use |
Beta Was this translation helpful? Give feedback.
importInterop=node
meansinterop=node
for imports, and common js.of node.js does not use__esModule
. It's expected by the design of commonjs implementation in nodejs.__esModule
is a workaround implemented by tools likebabel
andswc
.The problem is that the package you are trying to use is compiled using some tool with
export interop mode = babel/swc
, and it's using the export interop mode ofbabel
/swc
. It's not the form of a common js (which is required forimportInterop=node
) module expected for node.js. It's for babel, swc, tsc, etc... So you are expected to consume it via a tool that supports__esModule
.