Azure / azure-kusto-node

JS SDK for the Kusto service
MIT License
53 stars 39 forks source link

Import ES module in CommonJS #332

Open LianwMS opened 3 weeks ago

LianwMS commented 3 weeks ago

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?

AsafMah commented 3 weeks ago

What version of azure-kusto-node do you use?

yogilad commented 1 week ago

Hi @LianwMS ,

Is this still an issue for you?

raphaelmun commented 1 week ago

This is an issue for me as well in 7.0.0-alpha.3 and had to go to 6.0.2