Import ES module in CommonJS
I am not familiar with the JS/TS code. It should be a common issue. But I cannot find the answer.... I am writing the Azure Function Code in ts. Here is my tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"strict": false,
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
}
}
I tried to use azure-kusto-node in my source code:
import { Client, KustoConnectionStringBuilder } from "azure-kusto-data";
const kcsb = KustoConnectionStringBuilder.withSystemManagedIdentity(`https://${clusterName}.kusto.windows.net`);
const client = new Client(kcsb);
The error is
[2024-10-29T08:05:18.558Z] Worker was unable to load entry point "dist/src/functions/***.js": require() of ES Module ***\node_modules\azure-kusto-data\dist-esm\src\index.js from ***\dist\src\functions\****.js not supported.
Instead change the require of index.js in ****\dist\src\functions\****.js to a dynamic import() which is available in all CommonJS modules.
Any suggestion?
What version of azure-kusto-node do you use?
Hi @LianwMS ,
Is this still an issue for you?
This is an issue for me as well in 7.0.0-alpha.3 and had to go to 6.0.2
@AsafMah , let's set time with the frontend guys and see if we can do away with this change?
Fixed in 7.0.0 final version