From 06aad80165d09a8863ab8103149a8ff518b10641 Mon Sep 17 00:00:00 2001 From: lutangar Date: Tue, 2 Nov 2021 19:11:20 +0100 Subject: chore(refactor): remove shared folder dependencies to the server Many files from the `shared` folder were importing files from the `server` folder. When attempting to use Typescript project references to describe dependencies, it highlighted a circular dependency beetween `shared` <-> `server`. The Typescript project forbid such usages. Using project references greatly improve performance by rebuilding only the updated project and not all source files. > see https://www.typescriptlang.org/docs/handbook/project-references.html --- scripts/build/server.sh | 7 +++++-- scripts/client-build-stats.ts | 2 +- scripts/setup/cli.sh | 2 +- scripts/tsconfig.json | 10 ++++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 scripts/tsconfig.json (limited to 'scripts') diff --git a/scripts/build/server.sh b/scripts/build/server.sh index b903f8250..865bdd095 100755 --- a/scripts/build/server.sh +++ b/scripts/build/server.sh @@ -4,7 +4,10 @@ set -eu rm -rf ./dist -npm run tsc -cp "./tsconfig.json" "./dist" +npm run tsc -- -b --verbose +cp "./tsconfig.base.json" "./tsconfig.json" "./dist/" +cp "./scripts/tsconfig.json" "./dist/scripts/" +cp "./server/tsconfig.json" "./dist/server/" +cp "./shared/tsconfig.json" "./dist/shared/" cp -r "./server/static" "./server/assets" "./dist/server" cp -r "./server/lib/emails" "./dist/server/lib" diff --git a/scripts/client-build-stats.ts b/scripts/client-build-stats.ts index 70ceda975..91844dfcd 100644 --- a/scripts/client-build-stats.ts +++ b/scripts/client-build-stats.ts @@ -3,7 +3,7 @@ registerTSPaths() import { readdir, stat } from 'fs-extra' import { join } from 'path' -import { root } from '@server/helpers/core-utils' +import { root } from '@shared/core-utils' async function run () { const result = { diff --git a/scripts/setup/cli.sh b/scripts/setup/cli.sh index ea327e5a1..d0ad2ec5f 100755 --- a/scripts/setup/cli.sh +++ b/scripts/setup/cli.sh @@ -11,6 +11,6 @@ rm -rf ./dist/server/tools/ yarn install --pure-lockfile ) -npm run tsc -- --build ./server/tools/tsconfig.json +npm run tsc -- --build --verbose ./server/tools/tsconfig.json cp -r "./server/tools/node_modules" "./dist/server/tools" cp "./tsconfig.json" "./dist" diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 000000000..0d9716f2d --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": "../dist/scripts", + }, + "references": [ + { "path": "../shared" }, + { "path": "../server" } + ] +} -- cgit v1.2.3