From d415e61ac0500255ace26f28df147d4f3107da63 Mon Sep 17 00:00:00 2001 From: robonen Date: Tue, 15 Oct 2024 06:21:12 +0700 Subject: [PATCH] feat(packages/platform): add global isClient util and build config --- packages/platform/build.config.ts | 9 +++++++++ packages/platform/src/index.ts | 1 + packages/platform/src/multi/global/index.ts | 9 +++++++++ packages/platform/tsconfig.json | 5 ++++- 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 packages/platform/build.config.ts create mode 100644 packages/platform/src/index.ts diff --git a/packages/platform/build.config.ts b/packages/platform/build.config.ts new file mode 100644 index 0000000..9195cb6 --- /dev/null +++ b/packages/platform/build.config.ts @@ -0,0 +1,9 @@ +import { defineBuildConfig } from 'unbuild'; + +export default defineBuildConfig({ + rollup: { + esbuild: { + // minify: true, + }, + }, +}); \ No newline at end of file diff --git a/packages/platform/src/index.ts b/packages/platform/src/index.ts new file mode 100644 index 0000000..68b6bee --- /dev/null +++ b/packages/platform/src/index.ts @@ -0,0 +1 @@ +export * from './multi'; \ No newline at end of file diff --git a/packages/platform/src/multi/global/index.ts b/packages/platform/src/multi/global/index.ts index 6cad097..4cc30db 100644 --- a/packages/platform/src/multi/global/index.ts +++ b/packages/platform/src/multi/global/index.ts @@ -17,3 +17,12 @@ export const _global = : typeof self !== 'undefined' ? self : undefined; + +/** + * @name isClient + * @category Multi + * @description Check if the current environment is the client + * + * @since 0.0.2 + */ +export const isClient = typeof window !== 'undefined' && typeof document !== 'undefined'; \ No newline at end of file diff --git a/packages/platform/tsconfig.json b/packages/platform/tsconfig.json index d6d22e4..2d43941 100644 --- a/packages/platform/tsconfig.json +++ b/packages/platform/tsconfig.json @@ -1,3 +1,6 @@ { - "extends": "@robonen/tsconfig/tsconfig.json" + "extends": "@robonen/tsconfig/tsconfig.json", + "compilerOptions": { + "lib": ["DOM"] + } } \ No newline at end of file