add esbuild for federation

This commit is contained in:
einhornimmond 2025-05-01 10:03:51 +02:00
parent 8d3cc2224d
commit 9249d68263
4 changed files with 25 additions and 6 deletions

View File

@ -68,7 +68,7 @@ jobs:
- name: Federation | Unit tests
id: test
run: |
cd out && turbo federation#lint federation#test
cd out && turbo federation#lint federation#test federation#build federation#typecheck
echo "success=$([ $? -eq 0 ] && echo true || echo false)" >> $GITHUB_OUTPUT
lint:

View File

@ -75,7 +75,7 @@ RUN yarn install --frozen-lockfile --production=false \
# Build the project
COPY --chown=app:app --from=builder /app/out/full/ .
RUN turbo build
RUN turbo build typecheck
##################################################################################
# TEST ###########################################################################
@ -95,6 +95,12 @@ FROM base as production
# Copy "binary"-files from build image
COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/federation/build/src/index.js ./index.js
# We also install the native node_modules which cannot be bundled
# TODO: find a elegant way to use the right versions from yarn.lock
RUN yarn add sodium-native@4.0.0 \
&& rm -rf /tmp/* ~/.cache node_modules/.cache \
&& yarn cache clean
# Copy log4js-config.json to provide log configuration
COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/federation/log4js-config.json ./log4js-config.json

View File

@ -0,0 +1,13 @@
import { build } from 'esbuild'
build({
entryPoints: ['src/index.ts'],
outdir: 'build',
platform: 'node',
target: 'node18.20.7',
bundle: true,
keepNames: true,
// legalComments: 'inline',
external: ['sodium-native'],
minify: true,
})

View File

@ -8,11 +8,11 @@
"license": "Apache-2.0",
"private": false,
"scripts": {
"build": "tsc --build",
"clean": "tsc --build --clean",
"start": "cross-env TZ=UTC TS_NODE_BASEURL=./build node -r tsconfig-paths/register build/src/index.js",
"build": "tsx esbuild.config.ts",
"start": "cross-env TZ=UTC node build/index.js",
"dev": "cross-env TZ=UTC tsx watch src/index.ts",
"typecheck": "tsc --noEmit",
"test": "cross-env TZ=UTC NODE_ENV=development DB_DATABASE=gradido_test_federation jest --runInBand --forceExit --detectOpenHandles",
"dev": "cross-env TZ=UTC nodemon -w src --ext ts --exec ts-node -r dotenv/config -r tsconfig-paths/register src/index.ts",
"lint": "biome check --error-on-warnings .",
"lint:fix": "biome check --error-on-warnings . --write"
},