Skip to content

Commit

Permalink
import individual components from dir
Browse files Browse the repository at this point in the history
- same as downstream in Workflows, in order to code split properly, can't use the `src/` or `src/components/` imports as they have side effects (and therefore can't be tree-shaken)
  - instead have to do individual component imports to tree shake properly

- this seems to substantially improve performance from lethargic minutes of loading on first page load to seconds
  - I believe Storybook tries to code split things itself, so maybe it was making a giant bundle for each story file?

Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
  • Loading branch information
agilgur5 committed Jul 19, 2024
1 parent d7a4c73 commit 6a82512
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions stories/data-loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { App } from './utils';

import { DataLoader } from '../src/components/data-loader';

// import '../src/styles/main.scss';

function loadData(input: string): Promise<string> {
return new Promise((resolve) => window.setTimeout(() => resolve(`hello ${input}`), 50));
}
Expand Down
3 changes: 2 additions & 1 deletion stories/dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';

import { DropDown, DropDownMenu } from '../src/components';
import { DropDown } from '../src/components/dropdown/dropdown';
import { DropDownMenu } from '../src/components/dropdown-menu';

storiesOf('Dropdown', module)
.add('default', () => <DropDown anchor={() => <a>Click me</a>}><p>Dropdown content here</p></DropDown>)
Expand Down
3 changes: 2 additions & 1 deletion stories/forms.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import { Form, Text } from 'react-form';
import { FormField, FormSelect } from '../src/components';

import { FormField, FormSelect } from '../src/components/form-field/form-field';

storiesOf('Forms', module)
.add('default', () => (
Expand Down
2 changes: 1 addition & 1 deletion stories/logs-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { storiesOf } from '@storybook/react';
import * as React from 'react';
import { Observable } from 'rxjs';

import { LogsViewer } from '../src/components';
import { LogsViewer } from '../src/components/logs-viewer/logs-viewer';

storiesOf('LogsViewer', module).add('default', () => (
<div>
Expand Down
2 changes: 1 addition & 1 deletion stories/notifications.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';

import { NotificationType} from '../src/components';
import { NotificationType } from '../src/components/notifications/notifications';

import { App } from './utils';

Expand Down
3 changes: 2 additions & 1 deletion stories/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Route, Router } from 'react-router';
import { timer } from 'rxjs';
import { map } from 'rxjs/operators';

import { Layout, Page } from '../src/components';
import { Layout } from '../src/components/layout/layout';
import { Page } from '../src/components/page/page';

const navItems = [{ path: location.pathname, title: 'Sample', iconClassName: 'argo-icon-docs' }];
const breadcrumbs = [{
Expand Down
3 changes: 2 additions & 1 deletion stories/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import * as React from 'react';
import { Checkbox as ReactCheckbox} from 'react-form';
import { Text } from 'react-form';

import { Checkbox, FormField } from '../src/components';
import { Checkbox } from '../src/components/checkbox';
import { FormField } from '../src/components/form-field/form-field';
import { App } from './utils';

storiesOf('Popup', module)
Expand Down
2 changes: 1 addition & 1 deletion stories/select.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';

import { Select } from '../src/components';
import { Select } from '../src/components/select/select';

storiesOf('Select', module)
.add('default', () => {
Expand Down
3 changes: 2 additions & 1 deletion stories/tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import { Tabs } from '../src/components';

import { Tabs } from '../src/components/tabs/tabs';

storiesOf('Tabs', module)
.add('basic tabs', () => (
Expand Down
5 changes: 4 additions & 1 deletion stories/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as PropTypes from 'prop-types';
import * as React from 'react';

import { Notifications, NotificationsApi, NotificationsManager, Popup, PopupApi, PopupManager, PopupProps} from '../src/components';
import { Notifications } from '../src/components/notifications/notifications';
import { NotificationsApi, NotificationsManager } from '../src/components/notifications/notification-manager';
import { Popup, PopupProps } from '../src/components/popup/popup';
import { PopupApi, PopupManager } from '../src/components/popup/popup-manager';

export class App extends React.Component<{ children: (apis: {
notifications: NotificationsApi,
Expand Down

0 comments on commit 6a82512

Please sign in to comment.