From 965fb5fc5f48e40dc598755b5b60f4c3c3112338 Mon Sep 17 00:00:00 2001 From: Johannes Obermair Date: Tue, 7 Jan 2025 11:18:50 +0100 Subject: [PATCH] Fix hot-reloading in Demo API --- demo/api/.gitignore | 3 +++ demo/api/nest-cli.json | 6 +----- demo/api/package.json | 5 ++++- pnpm-lock.yaml | 17 +++++++++++++++-- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/demo/api/.gitignore b/demo/api/.gitignore index 2686424738..1dd66e7f23 100644 --- a/demo/api/.gitignore +++ b/demo/api/.gitignore @@ -34,3 +34,6 @@ lerna-debug.log* !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json + +# Hot reloading for API packages +src/reload.ts \ No newline at end of file diff --git a/demo/api/nest-cli.json b/demo/api/nest-cli.json index b505644d0b..ba9fe8d151 100644 --- a/demo/api/nest-cli.json +++ b/demo/api/nest-cli.json @@ -1,8 +1,4 @@ { "collection": "@nestjs/schematics", - "sourceRoot": "src", - "compilerOptions": { - "assets": ["node_modules/@comet/**/src/**/*.ts"], - "watchAssets": true - } + "sourceRoot": "src" } diff --git a/demo/api/package.json b/demo/api/package.json index 8f4a609134..d34136376c 100644 --- a/demo/api/package.json +++ b/demo/api/package.json @@ -21,7 +21,9 @@ "mikro-orm:drop": "mikro-orm schema:drop -r", "mikro-orm:migration:generate": "mikro-orm migration:create", "start": "$npm_execpath prebuild && dotenv -c -e .env.site-configs -- nest start --debug --watch --preserveWatchOutput", - "start:dev": "$npm_execpath prebuild && $npm_execpath db:migrate && $npm_execpath console createBlockIndexViews && NODE_OPTIONS='--max-old-space-size=512' dotenv -c -e .env.site-configs -- nest start --debug --watch --preserveWatchOutput", + "start:dev": "run-p dev:*", + "dev:nest": "$npm_execpath prebuild && $npm_execpath db:migrate && $npm_execpath console createBlockIndexViews && NODE_OPTIONS='--max-old-space-size=512' dotenv -c -e .env.site-configs -- nest start --debug --watch --preserveWatchOutput", + "dev:reload": "rimraf src/reload.ts && chokidar \"node_modules/@comet/cms-api/lib/**\" \"node_modules/@comet/blocks-api/lib/**\" -s -c \"echo '// change' >> src/reload.ts\"", "start:prod": "node dist/main" }, "dependencies": { @@ -100,6 +102,7 @@ "@types/response-time": "^2.3.8", "@types/rimraf": "^3.0.0", "@types/uuid": "^8.0.0", + "chokidar-cli": "^3.0.0", "dotenv-cli": "^7.0.0", "eslint": "^8.0.0", "npm-run-all": "^4.1.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 93542c0b79..639f1422e3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -607,6 +607,9 @@ importers: '@types/uuid': specifier: ^8.0.0 version: 8.3.4 + chokidar-cli: + specifier: ^3.0.0 + version: 3.0.0 dotenv-cli: specifier: ^7.0.0 version: 7.4.2 @@ -18794,6 +18797,17 @@ packages: yargs: 13.3.2 dev: true + /chokidar-cli@3.0.0: + resolution: {integrity: sha512-xVW+Qeh7z15uZRxHOkP93Ux8A0xbPzwK4GaqD8dQOYc34TlkqUhVSS59fK36DOp5WdJlrRzlYSy02Ht99FjZqQ==} + engines: {node: '>= 8.10.0'} + hasBin: true + dependencies: + chokidar: 3.5.3 + lodash.debounce: 4.0.8 + lodash.throttle: 4.1.1 + yargs: 13.3.2 + dev: true + /chokidar@3.5.3: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} engines: {node: '>= 8.10.0'} @@ -24983,7 +24997,7 @@ packages: jest-util: 29.5.0 jest-validate: 29.5.0 prompts: 2.4.2 - yargs: 17.7.1 + yargs: 17.7.2 transitivePeerDependencies: - '@types/node' - supports-color @@ -34555,7 +34569,6 @@ packages: string-width: 4.2.3 y18n: 5.0.8 yargs-parser: 21.1.1 - dev: false /yn@3.1.1: resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}