From 68debe6bf57c298871929fcface637c2904fe20c Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Thu, 14 Mar 2024 21:50:33 +0100 Subject: [PATCH] fix: ensure package is tree-shakeable (#30776) --- .../react-platform-adapter/.eslintrc.json | 15 +++++++++++- .../src/XPlatProvider/index.ts | 2 -- .../react-platform-adapter/src/index.ts | 24 +++++++++---------- .../react-platform-adapter/src/jsx/index.ts | 1 - .../src/jsx/jsxPlatformAdapter.native.ts | 5 ++-- .../src/jsx/jsxPlatformAdapter.ts | 2 +- .../src/styling/index.ts | 8 ------- 7 files changed, 29 insertions(+), 28 deletions(-) delete mode 100644 packages/react-components/react-platform-adapter/src/XPlatProvider/index.ts delete mode 100644 packages/react-components/react-platform-adapter/src/jsx/index.ts delete mode 100644 packages/react-components/react-platform-adapter/src/styling/index.ts diff --git a/packages/react-components/react-platform-adapter/.eslintrc.json b/packages/react-components/react-platform-adapter/.eslintrc.json index ceea884c70dcc..3e768a4e52d20 100644 --- a/packages/react-components/react-platform-adapter/.eslintrc.json +++ b/packages/react-components/react-platform-adapter/.eslintrc.json @@ -1,4 +1,17 @@ { "extends": ["plugin:@fluentui/eslint-plugin/react"], - "root": true + "root": true, + "overrides": [ + { + "files": "**/*.ts", + "rules": { + "@rnx-kit/no-export-all": [ + "error", + { + "expand": "all" + } + ] + } + } + ] } diff --git a/packages/react-components/react-platform-adapter/src/XPlatProvider/index.ts b/packages/react-components/react-platform-adapter/src/XPlatProvider/index.ts deleted file mode 100644 index e49ea051e5750..0000000000000 --- a/packages/react-components/react-platform-adapter/src/XPlatProvider/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { XPlatProvider, suppressCssVariableInsertion } from './XPlatProvider'; -export { type XPlatProviderProps } from './XPlatProvider.types'; diff --git a/packages/react-components/react-platform-adapter/src/index.ts b/packages/react-components/react-platform-adapter/src/index.ts index 6a150c72b6b6d..22355950f8504 100644 --- a/packages/react-components/react-platform-adapter/src/index.ts +++ b/packages/react-components/react-platform-adapter/src/index.ts @@ -1,12 +1,12 @@ -export { XPlatProvider, suppressCssVariableInsertion, type XPlatProviderProps } from './XPlatProvider'; -export { jsxPlatformAdapter } from './jsx'; -export { - getStylesFromClassName, - makeStyles, - makeStylesCore, - makeResetStyles, - mergeClasses, - shorthands, - TextDirectionProvider, - useRenderer_unstable, -} from './styling/index'; +export { XPlatProvider, suppressCssVariableInsertion } from './XPlatProvider/XPlatProvider'; +export type { XPlatProviderProps } from './XPlatProvider/XPlatProvider.types'; +export { jsxPlatformAdapter } from './jsx/jsxPlatformAdapter'; +export { getStylesFromClassName } from './styling/classNameMap'; +export { makeResetStyles } from './styling/makeResetStyles'; +export { makeStyles } from './styling/makeStyles'; +export { mergeClasses } from './styling/mergeClasses'; +export { shorthands } from './styling/shorthands'; + +// re-export some griffel types to have fluent use the griffel adapter instead of griffel directly +export { useRenderer_unstable, TextDirectionProvider } from '@griffel/react'; +export { makeStyles as makeStylesCore } from '@griffel/core'; diff --git a/packages/react-components/react-platform-adapter/src/jsx/index.ts b/packages/react-components/react-platform-adapter/src/jsx/index.ts deleted file mode 100644 index 784f1eb639848..0000000000000 --- a/packages/react-components/react-platform-adapter/src/jsx/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './jsxPlatformAdapter'; diff --git a/packages/react-components/react-platform-adapter/src/jsx/jsxPlatformAdapter.native.ts b/packages/react-components/react-platform-adapter/src/jsx/jsxPlatformAdapter.native.ts index c56ddf91853b9..ac247320176a9 100644 --- a/packages/react-components/react-platform-adapter/src/jsx/jsxPlatformAdapter.native.ts +++ b/packages/react-components/react-platform-adapter/src/jsx/jsxPlatformAdapter.native.ts @@ -1,8 +1,7 @@ import type * as React from 'react'; - import { html } from 'react-strict-dom'; -import { getStylesFromClassName } from '../styling/index'; -import { JSXRuntime } from './types'; +import { getStylesFromClassName } from '../styling/classNameMap'; +import type { JSXRuntime } from './types'; const modifyPropsForNative =
( props: (P & { children?: React.ReactNode; className?: string; style?: React.CSSProperties }) | null, diff --git a/packages/react-components/react-platform-adapter/src/jsx/jsxPlatformAdapter.ts b/packages/react-components/react-platform-adapter/src/jsx/jsxPlatformAdapter.ts index b777ab5e232f7..aba2aa68e64d3 100644 --- a/packages/react-components/react-platform-adapter/src/jsx/jsxPlatformAdapter.ts +++ b/packages/react-components/react-platform-adapter/src/jsx/jsxPlatformAdapter.ts @@ -1,4 +1,4 @@ -import { JSXRuntime } from './types'; +import type { JSXRuntime } from './types'; export const jsxPlatformAdapter = (reactJsx: JSXRuntime) => { return reactJsx; diff --git a/packages/react-components/react-platform-adapter/src/styling/index.ts b/packages/react-components/react-platform-adapter/src/styling/index.ts deleted file mode 100644 index 5d23c3366482e..0000000000000 --- a/packages/react-components/react-platform-adapter/src/styling/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './classNameMap'; -export * from './makeResetStyles'; -export * from './makeStyles'; -export * from './mergeClasses'; -export * from './shorthands'; -// re-export some griffel types to have fluent use the griffel adapter instead of griffel directly -export { useRenderer_unstable, TextDirectionProvider } from '@griffel/react'; -export { makeStyles as makeStylesCore } from '@griffel/core';