test: fix ts-node configuration with ESM and mocha
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 20 Mar 2023 01:13:36 +0000 (02:13 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 20 Mar 2023 01:13:36 +0000 (02:13 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
.eslintrc.json
.husky/commit-msg
.mocharc.json
commitlint.config.cjs [moved from commitlint.config.js with 100% similarity]
docker/Dockerfile
package.json
prepare.cjs [moved from prepare.js with 100% similarity]
src/scripts/deleteChargingStations.cjs [moved from src/scripts/deleteChargingStations.js with 100% similarity]
src/scripts/setCSPublicFlag.cjs [moved from src/scripts/setCSPublicFlag.js with 100% similarity]
tsconfig.json

index 9227eed54551d8c9926d755971dc4511b9b34e05..c6ce61da806a2597cf8a41ee54721c2aeba60677 100644 (file)
       }
     },
     {
-      "files": ["**/*.js", "**/*.mjs"],
+      "files": ["**/*.js", "**/*.cjs", "**/*.mjs"],
       "plugins": ["jsdoc"],
       "extends": ["plugin:jsdoc/recommended", "plugin:n/recommended"],
       "rules": {
index c160a7712333eb282e933e1b5009ae81b9d4c677..e526e5514be2853a939cc9c750d7bad103fc5a25 100755 (executable)
@@ -1,4 +1,4 @@
 #!/usr/bin/env sh
 . "$(dirname -- "$0")/_/husky.sh"
 
-npx --no -- commitlint --edit ${1}
+npx --no -- commitlint --config commitlint.config.cjs --edit ${1}
index 922eb321dc6c665c791027e543f23ac27f4b6656..dd2d1062d4e2247eb1455ca652492a040cacb795 100644 (file)
@@ -13,5 +13,6 @@
   "full-trace": true,
   "enable-source-maps": true,
   "exit": true,
-  "require": ["ts-node/register/transpile-only", "mochawesome/register"]
+  "node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"],
+  "require": ["mochawesome/register"]
 }
similarity index 100%
rename from commitlint.config.js
rename to commitlint.config.cjs
index 1921770c551c1915a4d20f681bcc64af2097c7f9..cc86f95d7993fe6e6d825a96643d729b3297b57b 100644 (file)
@@ -2,7 +2,7 @@ FROM node:lts-alpine as builder
 
 # Build simulator
 WORKDIR /usr/builder
-COPY .npmrc package.json package-lock.json tsconfig.json rollup.config.mjs prepare.js build-requirements.mjs ./
+COPY .npmrc package.json package-lock.json tsconfig.json rollup.config.mjs prepare.cjs build-requirements.mjs ./
 COPY src ./src
 COPY docker/config.json ./src/assets/config.json
 COPY docker/authorization-tags.json ./src/assets/authorization-tags.json
index b5d24c3e183ae5dc48f71f7aba8c4d68000b1bd8..ea0e84b78ff0d0d8c9e7d4724752528001c768ff 100644 (file)
@@ -25,6 +25,7 @@
       "url": "http://www.apache.org/licenses/LICENSE-2.0"
     }
   ],
+  "type": "module",
   "exports": [
     "./dist/start.mjs"
   ],
@@ -39,7 +40,7 @@
     "useTsNode": true
   },
   "scripts": {
-    "prepare": "node prepare.js",
+    "prepare": "node prepare.cjs",
     "build-requirements": "node --no-warnings build-requirements.mjs",
     "start": "npm run build && cross-env NODE_ENV=production node -r source-map-support/register dist/start.mjs",
     "start:dev": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register dist/start.mjs",
@@ -53,8 +54,8 @@
     "build": "npm run rollup",
     "build:dev": "npm run rollup -- --environment BUILD:development",
     "build:dev:watch": "npm run rollup -- --environment BUILD:development --watch",
-    "lint": "cross-env TIMING=1 eslint --cache --ext .js,.mjs,.ts src",
-    "lint:fix": "cross-env TIMING=1 eslint --cache --fix --ext .js,.mjs,.ts src",
+    "lint": "cross-env TIMING=1 eslint --cache --ext .js,.cjs,.mjs,.ts src",
+    "lint:fix": "cross-env TIMING=1 eslint --cache --fix --ext .js,.cjs,.mjs,.ts src",
     "format": "prettier --cache --write .",
     "test": "c8 mocha test/**/*Test.ts",
     "test:debug": "mocha --no-parallel --inspect test/**/*Test.ts",
similarity index 100%
rename from prepare.js
rename to prepare.cjs
index 11eb8e2a597e32ae1f0efce54694d799ef721b92..f30d942d87bbe1c3876ded107e7906c0a49d1ecb 100644 (file)
     // "skipLibCheck": true,                  /* Skip type checking of declaration files. */
     "forceConsistentCasingInFileNames": true  /* Disallow inconsistently-cased references to the same file. */
   },
-  "exclude": ["ui/web/**/*.ts"],
-  "ts-node": {
-    "compilerOptions": {
-      "module": "commonjs",
-      "verbatimModuleSyntax": false,
-    }
-  }
+  "exclude": ["ui/web/**/*.ts"]
 }