From 37fa0ef47c3db0f5c4b08d3e7618c1babea734c1 Mon Sep 17 00:00:00 2001 From: jiaah <25231717+jiaah@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:55:49 +0900 Subject: [PATCH] chore: Add exports field for utils and types modules from Shared package --- packages/api/package.json | 2 +- packages/api/src/index.ts | 2 +- packages/api/tsconfig.json | 43 +++++++++++-------- packages/shared/package.json | 12 +++++- packages/shared/tsconfig.json | 12 ++---- .../{src => utils}/__tests__/index.test.ts | 0 packages/shared/{src => utils}/index.ts | 0 packages/web/app/page.tsx | 2 +- packages/web/tsconfig.json | 3 ++ 9 files changed, 47 insertions(+), 29 deletions(-) rename packages/shared/{src => utils}/__tests__/index.test.ts (100%) rename packages/shared/{src => utils}/index.ts (100%) diff --git a/packages/api/package.json b/packages/api/package.json index 1156e52..a76b3b6 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -23,4 +23,4 @@ "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0" } -} +} \ No newline at end of file diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index 8460ccf..9119763 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -1,4 +1,4 @@ -import { logger } from '@freedivah/shared'; +import { logger } from '@freedivah/shared/utils'; logger('Shared is connected', { state: 'ON', diff --git a/packages/api/tsconfig.json b/packages/api/tsconfig.json index 0ea99f7..987c530 100644 --- a/packages/api/tsconfig.json +++ b/packages/api/tsconfig.json @@ -1,19 +1,28 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src", - "module": "commonjs", - "moduleResolution": "node", - "noEmit": false, - "baseUrl": ".", - "paths": { - "@freedivah/shared": ["../shared/src"] - } - }, - "references": [ - { "path": "../shared" } - ], - "include": ["src/**/*.ts"], - "exclude": ["node_modules", "dist"] + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src", + "module": "commonjs", + "moduleResolution": "node", + "noEmit": false, + "baseUrl": ".", + "paths": { + "@freedivah/shared": [ + "../shared" + ] + } + }, + "references": [ + { + "path": "../shared" + } + ], + "include": [ + "src/**/*.ts" + ], + "exclude": [ + "node_modules", + "dist" + ] } \ No newline at end of file diff --git a/packages/shared/package.json b/packages/shared/package.json index 658260f..d146e91 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -11,7 +11,17 @@ "test:watch": "jest --watch", "test:coverage": "jest --coverage" }, + "exports": { + "./utils": { + "types": "./dist/utils/index.d.ts", + "default": "./dist/utils/index.js" + }, + "./types": { + "types": "./dist/types/index.d.ts", + "default": "./dist/types/index.js" + } + }, "devDependencies": { "ts-jest": "^29.2.5" } -} +} \ No newline at end of file diff --git a/packages/shared/tsconfig.json b/packages/shared/tsconfig.json index b473dce..b7ddb27 100644 --- a/packages/shared/tsconfig.json +++ b/packages/shared/tsconfig.json @@ -3,18 +3,14 @@ "compilerOptions": { "composite": true, "outDir": "./dist", - "rootDir": "./src", + "rootDir": ".", "declaration": true, "moduleResolution": "node", - "baseUrl": ".", - "paths": { - "*": [ - "src/*" - ] - } + "baseUrl": "." }, "include": [ - "src/**/*" + "**/*.ts", + "utils/index.ts" ], "exclude": [ "node_modules", diff --git a/packages/shared/src/__tests__/index.test.ts b/packages/shared/utils/__tests__/index.test.ts similarity index 100% rename from packages/shared/src/__tests__/index.test.ts rename to packages/shared/utils/__tests__/index.test.ts diff --git a/packages/shared/src/index.ts b/packages/shared/utils/index.ts similarity index 100% rename from packages/shared/src/index.ts rename to packages/shared/utils/index.ts diff --git a/packages/web/app/page.tsx b/packages/web/app/page.tsx index 71df938..367aa47 100644 --- a/packages/web/app/page.tsx +++ b/packages/web/app/page.tsx @@ -1,4 +1,4 @@ -import { logger } from "@freedivah/shared"; +import { logger } from "@freedivah/shared/utils"; logger('Shared is connected', { state: 'ON', diff --git a/packages/web/tsconfig.json b/packages/web/tsconfig.json index 96b626b..d259163 100644 --- a/packages/web/tsconfig.json +++ b/packages/web/tsconfig.json @@ -6,6 +6,9 @@ "@/*": [ "./src/*" ], + "@shared/*": [ + "../shared/*" + ], "@styles/*": [ "./src/styles/*" ],