From b1579f7123495628c5831c76db2ab54cba335343 Mon Sep 17 00:00:00 2001 From: Andrey Morozov Date: Mon, 30 Jan 2023 20:51:42 +0300 Subject: [PATCH] fix: package exports fixes (#512) --- package.json | 23 ++++++++++++++++++++--- src/toaster-singleton-react-18.ts | 3 ++- src/toaster-singleton.ts | 3 ++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ac614f8a89..ba1d2eac9c 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,26 @@ "type": "git", "url": "https://github.com/gravity-ui/uikit" }, - "main": "build/cjs/index.js", - "module": "build/esm/index.js", - "types": "build/esm/index.d.ts", + "exports": { + ".": { + "require": "./build/cjs/index.js", + "import": "./build/esm/index.js" + }, + "./*": { + "require": "./build/cjs/*.js", + "import": "./build/esm/*.js" + }, + "./styles/*": "./styles/*" + }, + "main": "./build/cjs/index.js", + "module": "./build/esm/index.js", + "types": "./index.d.ts", + "typesVersions": { + "*": { + "*": ["./build/esm/*"], + "index.d.ts": ["./build/esm/index.d.ts"] + } + }, "sideEffects": [ "*.css", "*.scss" diff --git a/src/toaster-singleton-react-18.ts b/src/toaster-singleton-react-18.ts index 3b2e8497a6..777104be2b 100644 --- a/src/toaster-singleton-react-18.ts +++ b/src/toaster-singleton-react-18.ts @@ -4,4 +4,5 @@ import {ToasterSingleton} from './components/Toaster/ToasterSingleton'; ToasterSingleton.injectReactDOMClient(ReactDOMClient); // in SSR case -export const toaster = typeof window === 'object' ? new ToasterSingleton() : null; +export const toaster = + typeof window === 'object' ? new ToasterSingleton() : ({} as ToasterSingleton); diff --git a/src/toaster-singleton.ts b/src/toaster-singleton.ts index e48fab4de7..f1751c1b4b 100644 --- a/src/toaster-singleton.ts +++ b/src/toaster-singleton.ts @@ -1,4 +1,5 @@ import {ToasterSingleton} from './components/Toaster/ToasterSingleton'; // in SSR case -export const toaster = typeof window === 'object' ? new ToasterSingleton() : null; +export const toaster = + typeof window === 'object' ? new ToasterSingleton() : ({} as ToasterSingleton);