From: Jérôme Benoit Date: Sun, 14 Feb 2021 19:55:26 +0000 (+0100) Subject: Minify production build X-Git-Tag: v1.0.1-0~104^2~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fc20191350f323b57faa6a9c5eca53a76e2cce55;p=e-mobility-charging-stations-simulator.git Minify production build And fix GitHub CI. Signed-off-by: Jérôme Benoit --- diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d42c3e0b..583ffff1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,5 +20,5 @@ jobs: node-version: ${{ matrix.node-version }} - name: npm install run: npm ci - - name: npm run build:prod - run: npm run build:prod + - name: npm run build + run: npm run build diff --git a/.vscode/launch.json b/.vscode/launch.json index 8c879c6e..5c8aa82b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,7 +7,7 @@ { "type": "pwa-node", "request": "launch", - "name": "Debug Program via npm", + "name": "Debug Simulator via npm", "cwd": "${workspaceFolder}", "preLaunchTask": "Build", "runtimeExecutable": "npm", @@ -19,6 +19,21 @@ "/**" ], "stopOnEntry": true + }, + { + "type": "pwa-node", + "request": "launch", + "name": "Debug Simulator Development Build via npm", + "cwd": "${workspaceFolder}", + "runtimeExecutable": "npm", + "runtimeArgs": [ + "run-script", + "start:dev:debug" + ], + "skipFiles": [ + "/**" + ], + "stopOnEntry": true } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 343bcdc2..62d34164 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,6 +5,11 @@ "label": "Build", "type": "npm", "script": "build" + }, + { + "label": "Development Build", + "type": "npm", + "script": "build:dev" } ] } diff --git a/mta.yaml b/mta.yaml index ecb76309..6fa93508 100644 --- a/mta.yaml +++ b/mta.yaml @@ -7,7 +7,7 @@ build-parameters: - builder: custom commands: - npm install - - npm run build:prod + - npm run build resources: - name: dynatrace-service diff --git a/package-lock.json b/package-lock.json index c2084424..c2c176e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -709,9 +709,9 @@ "dev": true }, "@types/node": { - "version": "14.14.27", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.27.tgz", - "integrity": "sha512-Ecfmo4YDQPwuqTCl1yBxLV5ihKfRlkBmzUEDcfIRvDxOTGQEeikr317Ln7Gcv0tjA8dVgKI3rniqW2G1OyKDng==", + "version": "14.14.28", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.28.tgz", + "integrity": "sha512-lg55ArB+ZiHHbBBttLpzD07akz0QPrZgUODNakeC09i62dnrywr9mFErHuaPlB6I7z+sEbK+IYmplahvplCj2g==", "dev": true }, "@types/offscreencanvas": { @@ -5417,6 +5417,34 @@ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, + "jest-worker": { + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz", + "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==", + "dev": true, + "requires": { + "@types/node": "*", + "merge-stream": "^2.0.0", + "supports-color": "^7.0.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -5936,6 +5964,12 @@ "source-map": "^0.5.6" } }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, "merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -8110,6 +8144,37 @@ "del": "^5.1.0" } }, + "rollup-plugin-terser": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", + "integrity": "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.4", + "jest-worker": "^26.2.1", + "serialize-javascript": "^4.0.0", + "terser": "^5.0.0" + }, + "dependencies": { + "source-map": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true + }, + "terser": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.6.0.tgz", + "integrity": "sha512-vyqLMoqadC1uR0vywqOZzriDYzgEkNJFK4q9GeyOBHIbiECHiWLKcWfbQWAUaPfxkjDhapSlZB9f7fkMrvkVjA==", + "dev": true, + "requires": { + "commander": "^2.20.0", + "source-map": "~0.7.2", + "source-map-support": "~0.5.19" + } + } + } + }, "rollup-plugin-typescript2": { "version": "0.29.0", "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.29.0.tgz", @@ -8244,6 +8309,15 @@ "semver": "^5.0.3" } }, + "serialize-javascript": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", + "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", diff --git a/package.json b/package.json index dc329d53..223314a5 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,8 @@ "prestart": "npm run build", "start": "cross-env NODE_ENV=production node -r source-map-support/register dist/start.js", "start:debug": "cross-env NODE_ENV=production node -r source-map-support/register --inspect dist/start.js", + "start:dev": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register dist/start.js", + "start:dev:debug": "npm run build:dev && cross-env NODE_ENV=development node -r source-map-support/register --inspect dist/start.js", "start:prof": "cross-env NODE_ENV=production node -r source-map-support/register --prof dist/start.js", "start:doctorprof": "cross-env NODE_ENV=production clinic doctor -- node -r source-map-support/register dist/start.js", "start:flameprof": "cross-env NODE_ENV=production clinic flame -- node -r source-map-support/register dist/start.js", @@ -59,7 +61,7 @@ "utf-8-validate": "^5.0.4" }, "devDependencies": { - "@types/node": "^14.14.27", + "@types/node": "^14.14.28", "@types/uuid": "^8.3.0", "@types/ws": "^7.4.0", "@typescript-eslint/eslint-plugin": "^4.15.0", @@ -73,6 +75,7 @@ "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-copy": "^3.3.0", "rollup-plugin-delete": "^2.0.0", + "rollup-plugin-terser": "^7.0.2", "rollup-plugin-typescript2": "^0.29.0", "typescript": "^4.1.5" } diff --git a/rollup.config.js b/rollup.config.js index 16624fce..2184bb6e 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,19 +1,22 @@ import analyze from 'rollup-plugin-analyzer'; import copy from 'rollup-plugin-copy'; import del from 'rollup-plugin-delete'; +import { terser } from 'rollup-plugin-terser'; import typescript from 'rollup-plugin-typescript2'; const isDevelopmentBuild = process.env.BUILD === 'development'; export default { input: ['src/start.ts', 'src/charging-station/StationWorker.ts'], - output: { + output: + { dir: 'dist', format: 'cjs', exports: 'auto', sourcemap: true, preserveModules: true, - preserveModulesRoot: 'src' + preserveModulesRoot: 'src', + ...!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] } }, external: ['crypto', 'perf_hooks', 'fs', 'path', 'poolifier', 'uuid', 'ws', 'winston-daily-rotate-file', 'winston/lib/winston/transports', 'winston', 'worker_threads'], plugins: [