Skip to content

Commit

Permalink
shift all types out of main export supporting tree shaking imports pr…
Browse files Browse the repository at this point in the history
…operly
  • Loading branch information
Brianzchen committed Mar 19, 2024
1 parent 0c5be0d commit 93f0457
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 70 deletions.
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ format.single_quotes=true
exact_by_default=true
include_warnings=true
module.name_mapper='^bzc-ui$' -> '<PROJECT_ROOT>/src/index.js'
module.name_mapper='^bzc-ui/types$' -> '<PROJECT_ROOT>/src/types.js'
module.name_mapper='^pkgJson$' -> '<PROJECT_ROOT>/package.json'
module.name_mapper='^utils$' -> '<PROJECT_ROOT>/website/src/utils'

Expand Down
3 changes: 2 additions & 1 deletion src/AppBar/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {
Inline,
Stack,
Typography,
types,
} from '..';

import * as types from '../types';

export const Basic = (): React.Node => (
<Typography>
AppBar is rendered above
Expand Down
66 changes: 0 additions & 66 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,130 +1,64 @@
// @flow
import * as types from './types';

export {
types,
};

export { default as Accordion } from './Accordion';
export type { AccordionT } from './Accordion';
export { default as Anchor } from './Anchor';
export type { AnchorT } from './Anchor';
export { default as AppBar } from './AppBar';
export type { AppBarT } from './AppBar';
export { default as Badge } from './Badge';
export type { BadgeT } from './Badge';
export { default as BaseButton } from './BaseButton';
export type { BaseButtonT } from './BaseButton';
export { default as BaseInput } from './BaseInput';
export type { BaseInputT } from './BaseInput';
export { default as BaseSelect } from './BaseSelect';
export type { BaseSelectT } from './BaseSelect';
export { default as BottomSheet } from './BottomSheet';
export type { BottomSheetT } from './BottomSheet';
export { default as Box } from './Box';
export type { BoxT } from './Box';
export { default as Button } from './Button';
export type { ButtonT } from './Button';
export { default as Calendar } from './Calendar';
export type { CalendarT } from './Calendar';
export { default as Card } from './Card';
export type { CardT } from './Card';
export { default as CardButton } from './CardButton';
export type { CardButtonT } from './CardButton';
export { default as CardTitle } from './CardTitle';
export type { CardTitleT } from './CardTitle';
export { default as Checkbox } from './Checkbox';
export type { CheckboxT } from './Checkbox';
export { default as Circle } from './Circle';
export type { CircleT } from './Circle';
export { default as ClickAwayListener } from './ClickAwayListener';
export type { ClickAwayListenerT } from './ClickAwayListener';
export { default as Delay } from './Delay';
export type { DelayT } from './Delay';
export { default as Divider } from './Divider';
export type { DividerT } from './Divider';
export { default as Draggable } from './Draggable';
export type { DraggableT } from './Draggable';
export { default as Drawer } from './Drawer';
export type { DrawerT } from './Drawer';
export { default as Dropdown } from './Dropdown';
export type { DropdownT } from './Dropdown';
export { default as FileUpload } from './FileUpload';
export type { FileUploadT } from './FileUpload';
export { default as Form } from './Form';
export type { FormT } from './Form';
export { default as FormFieldContainer } from './FormFieldContainer';
export type { FormFieldContainerT } from './FormFieldContainer';
export { default as FormSpy } from './FormSpy';
export type { FormSpyT } from './FormSpy';
export { default as Gap } from './Gap';
export type { GapT } from './Gap';
export { default as GroupedToggleButtons } from './GroupedToggleButtons';
export type { GroupedToggleButtonsT } from './GroupedToggleButtons';
export { default as Icon } from './Icon';
export type { IconT } from './Icon';
export { default as Image } from './Image';
export type { ImageT } from './Image';
export { default as Inline } from './Inline';
export type { InlineT } from './Inline';
export { default as Input } from './Input';
export type { InputT } from './Input';
export { default as Link } from './Link';
export type { LinkT } from './Link';
export { default as LinkButton } from './LinkButton';
export type { LinkButtonT } from './LinkButton';
export { default as LoadingBlock } from './LoadingBlock';
export type { LoadingBlockT } from './LoadingBlock';
export { default as LoadingSpinner } from './LoadingSpinner';
export type { LoadingSpinnerT } from './LoadingSpinner';
export { default as LoadingSpinnerOverlay } from './LoadingSpinnerOverlay';
export type { LoadingSpinnerOverlayT } from './LoadingSpinnerOverlay';
export { default as Markdown } from './Markdown';
export type { MarkdownT } from './Markdown';
export { default as Modal } from './Modal';
export type { ModalT } from './Modal';
export { default as Notification } from './Notification';
export type { NotificationT } from './Notification';
export { default as Overlay } from './Overlay';
export type { OverlayT } from './Overlay';
export { default as Paper } from './Paper';
export type { PaperT } from './Paper';
export { default as Provider } from './Provider';
export type { ProviderT } from './Provider';
export { default as RadioButton } from './RadioButton';
export type { RadioButtonT } from './RadioButton';
export { default as Responsive } from './Responsive';
export type { ResponsiveT } from './Responsive';
export { default as ScrollLoadingListener } from './ScrollLoadingListener';
export type { ScrollLoadingListenerT } from './ScrollLoadingListener';
export { default as Sheet } from './Sheet';
export type { SheetT } from './Sheet';
export { default as Snackbar } from './Snackbar';
export type { SnackbarT } from './Snackbar';
export { default as Select } from './Select';
export type { SelectT } from './Select';
export { default as Stack } from './Stack';
export type { StackT } from './Stack';
export { default as StepBar } from './StepBar';
export type { StepBarT } from './StepBar';
export { default as Stepper } from './Stepper';
export type { StepperT } from './Stepper';
export { default as Tabs } from './Tabs';
export type { TabsT } from './Tabs';
export { default as Table } from './Table';
export type { TableT } from './Table';
export { default as TableData } from './TableData';
export type { TableDataT } from './TableData';
export { default as TableRow } from './TableRow';
export type { TableRowT } from './TableRow';
export { default as TextArea } from './TextArea';
export type { TextAreaT } from './TextArea';
export { default as ToggleButton } from './ToggleButton';
export type { ToggleButtonT } from './ToggleButton';
export { default as ToggleSwitch } from './ToggleSwitch';
export type { ToggleSwitchT } from './ToggleSwitch';
export { default as Typography } from './Typography';
export type { TypographyT } from './Typography';
export { default as bodyScrollLock } from './bodyScrollLock';
export { default as styler } from './styler';
export { default as useFormValues } from './useFormValues';
Expand Down
3 changes: 2 additions & 1 deletion src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fs from 'fs';
import path from 'path';

import * as bzcUi from '.';
import * as types from './types';

describe('bzc-ui', () => {
const exclusions = ['internal', 'theme'];
Expand All @@ -23,7 +24,7 @@ describe('bzc-ui', () => {
});

it('can import types', () => {
const color: bzcUi.types.StyleObjT = {
const color: types.StyleObjT = {
...null,
};

Expand Down
61 changes: 61 additions & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,67 @@
/* eslint-disable no-use-before-define */
import type { StyleObject } from 'aphrodite';

export type { AccordionT } from './Accordion';
export type { AnchorT } from './Anchor';
export type { AppBarT } from './AppBar';
export type { BadgeT } from './Badge';
export type { BaseButtonT } from './BaseButton';
export type { BaseInputT } from './BaseInput';
export type { BaseSelectT } from './BaseSelect';
export type { BottomSheetT } from './BottomSheet';
export type { BoxT } from './Box';
export type { ButtonT } from './Button';
export type { CalendarT } from './Calendar';
export type { CardT } from './Card';
export type { CardButtonT } from './CardButton';
export type { CardTitleT } from './CardTitle';
export type { CheckboxT } from './Checkbox';
export type { CircleT } from './Circle';
export type { ClickAwayListenerT } from './ClickAwayListener';
export type { DelayT } from './Delay';
export type { DividerT } from './Divider';
export type { DraggableT } from './Draggable';
export type { DrawerT } from './Drawer';
export type { DropdownT } from './Dropdown';
export type { FileUploadT } from './FileUpload';
export type { FormT } from './Form';
export type { FormFieldContainerT } from './FormFieldContainer';
export type { FormSpyT } from './FormSpy';
export type { GapT } from './Gap';
export type { GroupedToggleButtonsT } from './GroupedToggleButtons';
export type { IconT } from './Icon';
export type { ImageT } from './Image';
export type { InlineT } from './Inline';
export type { InputT } from './Input';
export type { LinkT } from './Link';
export type { LinkButtonT } from './LinkButton';
export type { LoadingBlockT } from './LoadingBlock';
export type { LoadingSpinnerT } from './LoadingSpinner';
export type { LoadingSpinnerOverlayT } from './LoadingSpinnerOverlay';
export type { MarkdownT } from './Markdown';
export type { ModalT } from './Modal';
export type { NotificationT } from './Notification';
export type { OverlayT } from './Overlay';
export type { PaperT } from './Paper';
export type { ProviderT } from './Provider';
export type { RadioButtonT } from './RadioButton';
export type { ResponsiveT } from './Responsive';
export type { ScrollLoadingListenerT } from './ScrollLoadingListener';
export type { SelectT } from './Select';
export type { SheetT } from './Sheet';
export type { SnackbarT } from './Snackbar';
export type { StackT } from './Stack';
export type { StepBarT } from './StepBar';
export type { StepperT } from './Stepper';
export type { TableT } from './Table';
export type { TableDataT } from './TableData';
export type { TableRowT } from './TableRow';
export type { TabsT } from './Tabs';
export type { TextAreaT } from './TextArea';
export type { ToggleButtonT } from './ToggleButton';
export type { ToggleSwitchT } from './ToggleSwitch';
export type { TypographyT } from './Typography';

// Only types coming from this file should be exposed to consumers
// Once build is complete it can be imported as
// `import type { ColorFuncT } from 'bzc-ui';`
Expand Down
4 changes: 2 additions & 2 deletions website/src/utils/AppBarNotificationContext.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @flow
import * as React from 'react';

import { types } from 'bzc-ui';
import type { NotificationVariantT } from 'bzc-ui/types';

export type AppBarNotificationT = void | {|
variant: types.NotificationVariantT,
variant: NotificationVariantT,
message: string,
|};

Expand Down
1 change: 1 addition & 0 deletions website/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = ({
extensions: ['*', '.js'],
alias: {
'bzc-ui': path.resolve(__dirname, '..', 'src', 'index.js'),
'bzc-ui/types': path.resolve(__dirname, '..', 'src', 'types.js'),
pkgJson: path.resolve(__dirname, '..', 'package.json'),
utils: path.resolve(__dirname, 'src', 'utils', 'index.js'),
},
Expand Down

0 comments on commit 93f0457

Please sign in to comment.