Try to understand how Babel work in TSConfig documentation for option allowSyntheticDefaultImports
#16335
-
From their explanation: This is the line I don't know which plugin does what it means by "Babel will automatically create a default if one isn’t created". I know that we have preset
// @filename: utilFunctions.js
const getStringLength = (str) => str.length;
module.exports = {
getStringLength,
};
// @filename: index.ts
import utils from "./utilFunctions";
const count = utils.getStringLength("Check JS"); The error:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
It's |
Beta Was this translation helpful? Give feedback.
It's
@babel/plugin-transform-modules-commonjs
. It's not just Babel btw, every tool does that when compiling ESM to CJS :) Also Node.js does the same.