Add initial support for ESM build
[e-mobility-charging-stations-simulator.git] / src / charging-station / Bootstrap.ts
index cf7208efef1785057f35ac2ae162b98d8e59a698..82aef5cd28c65a1c4be1246c6a6a2ac9fc2b6443 100644 (file)
@@ -20,6 +20,7 @@ import Utils from '../utils/Utils';
 import WorkerAbstract from '../worker/WorkerAbstract';
 import WorkerFactory from '../worker/WorkerFactory';
 import chalk from 'chalk';
+import { fileURLToPath } from 'url';
 import { isMainThread } from 'worker_threads';
 import path from 'path';
 import { version } from '../../package.json';
@@ -38,9 +39,9 @@ export default class Bootstrap {
   private constructor() {
     this.started = false;
     this.workerScript = path.join(
-      path.resolve(__dirname, '../'),
+      path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../'),
       'charging-station',
-      'ChargingStationWorker.js'
+      'ChargingStationWorker' + path.extname(fileURLToPath(import.meta.url))
     );
     this.initialize();
     this.initWorkerImplementation();
@@ -188,7 +189,7 @@ export default class Bootstrap {
     const workerData: ChargingStationWorkerData = {
       index,
       templateFile: path.join(
-        path.resolve(__dirname, '../'),
+        path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../'),
         'assets',
         'station-templates',
         path.basename(stationTemplateUrl.file)