From: Jérôme Benoit Date: Tue, 3 Oct 2023 14:41:33 +0000 (+0200) Subject: refactor: convert commonjs files to esm X-Git-Tag: v1.2.24~118 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b0c4f887c7cbe5168955a360264c0b9dc091b22f;p=e-mobility-charging-stations-simulator.git refactor: convert commonjs files to esm Signed-off-by: Jérôme Benoit --- diff --git a/.eslintignore b/.eslintignore index b4a13ad4..3895cf42 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,3 @@ dist/ # FIXME: ESM import parse error -build-requirements.mjs +build-requirements.js diff --git a/build-requirements.mjs b/build-requirements.js similarity index 100% rename from build-requirements.mjs rename to build-requirements.js diff --git a/docker/Dockerfile b/docker/Dockerfile index 96d856ec..593b11b2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,7 +2,7 @@ FROM node:lts-alpine AS builder # Build simulator WORKDIR /usr/builder -COPY .npmrc package.json pnpm-lock.yaml tsconfig.json rollup.config.mjs build-requirements.mjs skip-preinstall.cjs prepare.cjs ./ +COPY .npmrc package.json pnpm-lock.yaml tsconfig.json rollup.config.js build-requirements.js skip-preinstall.js prepare.js ./ COPY src ./src COPY docker/config.json ./src/assets/config.json COPY docker/idtags.json ./src/assets/idtags.json diff --git a/package.json b/package.json index 3b7cf950..f57e6b77 100644 --- a/package.json +++ b/package.json @@ -53,9 +53,9 @@ "useTsNode": true }, "scripts": { - "preinstall": "node skip-preinstall.cjs || npx --yes only-allow pnpm", - "prepare": "node prepare.cjs", - "build-requirements": "node --no-warnings build-requirements.mjs", + "preinstall": "node skip-preinstall.js || npx --yes only-allow pnpm", + "prepare": "node prepare.js", + "build-requirements": "node --no-warnings build-requirements.js", "start": "pnpm build && cross-env NODE_ENV=production node dist/start.js", "start:dev": "pnpm build:dev && cross-env NODE_ENV=development node -r source-map-support/register dist/start.js", "start:dev:debug": "pnpm build:dev && cross-env NODE_ENV=development node -r source-map-support/register --inspect dist/start.js", diff --git a/prepare.cjs b/prepare.js similarity index 55% rename from prepare.cjs rename to prepare.js index 6038d204..8c299a62 100644 --- a/prepare.cjs +++ b/prepare.js @@ -1,8 +1,10 @@ -const { env } = require('node:process'); +import { env } from 'node:process'; + +// eslint-disable-next-line n/no-unpublished-import +import { install } from 'husky'; const isCIEnvironment = env.CI !== undefined; const isCFEnvironment = env.VCAP_APPLICATION !== undefined; if (isCFEnvironment === false && isCIEnvironment === false) { - // eslint-disable-next-line n/no-unpublished-require - require('husky').install(); + install(); } diff --git a/rollup.config.mjs b/rollup.config.js similarity index 100% rename from rollup.config.mjs rename to rollup.config.js diff --git a/skip-preinstall.cjs b/skip-preinstall.js similarity index 83% rename from skip-preinstall.cjs rename to skip-preinstall.js index 5be82290..8f5c9d55 100644 --- a/skip-preinstall.cjs +++ b/skip-preinstall.js @@ -1,4 +1,4 @@ -const { env, exit } = require('node:process'); +import { env, exit } from 'node:process'; const skipPreinstall = env.SKIP_PREINSTALL || env.VCAP_APPLICATION !== undefined; if (skipPreinstall) {