azure-kusto-node icon indicating copy to clipboard operation
azure-kusto-node copied to clipboard

Import ES module in CommonJS

Open LianwMS opened this issue 1 year ago • 4 comments

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?

LianwMS avatar Oct 29 '24 08:10 LianwMS

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

AsafMah avatar Oct 29 '24 09:10 AsafMah

Hi @LianwMS ,

Is this still an issue for you?

yogilad avatar Nov 17 '24 12:11 yogilad

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

raphaelmun avatar Nov 17 '24 13:11 raphaelmun

@AsafMah , let's set time with the frontend guys and see if we can do away with this change?

yogilad avatar Dec 08 '24 12:12 yogilad

Fixed in 7.0.0 final version

AsafMah avatar May 25 '25 03:05 AsafMah