Im trying to use the library bpmn.io in a local type script project in order to extend it.
So i try to import its components using the statement import {BpmnModeler, BpmnViewer} from 'bpmn-js'
. The library apparently uses es6 modules internally to import and export stuff around.
When i try to run this code using ts-node <path/to/my/index.ts>
(entry point of my typescript project), i get an unexpected token 'export' in the terminal, at the default export from the bpmn.io library.
Below is my tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"lib": [
"es2020"
],
"allowJs": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"composite": true,
"strict": true,
"moduleResolution": "node",
"rootDirs": [
"."
],
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"references": [],
"watchOptions": {
"fallbackPolling": "dynamicPriority",
"excludeDirectories": [
"**/node_modules",
"build"
]
}
}
I believe this happens because i have module: "commonjs"
option set in the tsconfig.json above. But if i change it to module: "es6"
then i must set the type="module"
option in my package.json which results in unknonwn file extension .ts error. Kind of in a circle of problems here