Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Make Storybook esbuild-compatible #14380

Merged
merged 2 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions addons/backgrounds/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
if (module && module.hot && module.hot.decline) {
module.hot.decline();
}

// make it work with --isolatedModules
export default {};
2 changes: 1 addition & 1 deletion addons/docs/src/lib/docgen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ export enum TypeSystem {
UNKNOWN = 'Unknown',
}

export { PropDef };
export type { PropDef };
2 changes: 2 additions & 0 deletions addons/docs/src/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// make it work with --isolatedModules
export default {};
2 changes: 1 addition & 1 deletion addons/knobs/src/type-defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ export type Knob<T extends KnobType = any> = T extends 'text'
? KnobPlus<T, Pick<OptionsTypeKnob<any>, 'options' | 'value' | 'optionsObj'>>
: never;

export { KnobType };
export type { KnobType };
2 changes: 1 addition & 1 deletion app/angular/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export {

export * from './preview/types-6-0';

export { StoryFnAngularReturnType as IStory } from './preview/types';
export type { StoryFnAngularReturnType as IStory } from './preview/types';

export { moduleMetadata, componentWrapperDecorator } from './preview/decorators';

Expand Down
2 changes: 1 addition & 1 deletion app/angular/src/client/preview/types-6-0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@storybook/addons';
import { StoryFnAngularReturnType } from './types';

export { Args, ArgTypes } from '@storybook/addons';
export type { Args, ArgTypes } from '@storybook/addons';

type AngularComponent = any;
type AngularReturnType = StoryFnAngularReturnType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@
it('work-around', () => {
expect(true).toBe(true);
});

// Make it work with --isolatedModules, we need a dummy export
/* eslint-disable jest/no-export */
export default {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why export default {}; here and export {}; above?

3 changes: 2 additions & 1 deletion app/aurelia/src/client/preview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const storiesOf: ClientApi['storiesOf'] = (kind, m) => {
});
};

export { StoryFnAureliaReturnType, addRegistries, addContainer, Component, addComponents };
export { addRegistries, addContainer, addComponents };
export type { StoryFnAureliaReturnType, Component };

export const configure: ClientApi['configure'] = (...args) => api.configure(framework, ...args);
export const addDecorator: ClientApi['addDecorator'] = api.clientApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@
it('work-around', () => {
expect(true).toBe(true);
});

// Make it work with --isolatedModules, we need a dummy export
/* eslint-disable jest/no-export */
export default {};
2 changes: 1 addition & 1 deletion app/react/src/client/preview/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReactElement } from 'react';

// eslint-disable-next-line import/no-extraneous-dependencies
export type { RenderContext } from '@storybook/client-api';
export { StoryContext } from '@storybook/addons';
export type { StoryContext } from '@storybook/addons';

export interface ShowErrorArgs {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion app/web-components/src/client/preview/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TemplateResult, SVGTemplateResult } from 'lit-html';

export type { RenderContext } from '@storybook/core';
export { Args, ArgTypes, Parameters, StoryContext } from '@storybook/addons';
export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/addons';

export type StoryFnHtmlReturnType = string | Node | TemplateResult | SVGTemplateResult;

Expand Down
2 changes: 1 addition & 1 deletion lib/api/shortcut.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/cjs/lib/shortcut');
export * from './dist/esm/lib/shortcut';
6 changes: 4 additions & 2 deletions lib/api/src/modules/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import { getEventMetadata } from '../lib/events';
import {
denormalizeStoryParameters,
transformStoriesRawToStoriesHash,
isStory,
isRoot,
} from '../lib/stories';
import type {
StoriesHash,
Story,
Group,
StoryId,
isStory,
Root,
isRoot,
StoriesRaw,
SetStoriesPayload,
} from '../lib/stories';
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/src/components/layout/draggers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ const Handle = styled.div<{ isDragging: boolean; axis: Axis }>(
}
);

export { Draggable, Handle, DraggableEvent, DraggableData };
export { Draggable, Handle };
export type { DraggableEvent, DraggableData };
2 changes: 1 addition & 1 deletion lib/ui/src/components/sidebar/SearchResults.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { StoriesHash } from '@storybook/api';
import type { StoriesHash } from '@storybook/api';

import { mockDataset } from './mockdata';
import { SearchResults } from './SearchResults';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/components/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { FunctionComponent, useMemo } from 'react';

import { styled } from '@storybook/theming';
import { ScrollArea, Spaced } from '@storybook/components';
import { StoriesHash, State } from '@storybook/api';
import type { StoriesHash, State } from '@storybook/api';

import { Heading } from './Heading';

Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/components/sidebar/Tree.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { StoriesHash } from '@storybook/api';
import type { StoriesHash } from '@storybook/api';

import { Tree } from './Tree';
import { stories } from './mockdata.large';
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/src/components/sidebar/Tree.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Group, Story, StoriesHash, isRoot, isStory } from '@storybook/api';
import type { Group, Story, StoriesHash } from '@storybook/api';
import { isRoot, isStory } from '@storybook/api';
import { styled } from '@storybook/theming';
import { Icons } from '@storybook/components';
import { transparentize } from 'polished';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/components/sidebar/data.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StoriesHash } from '@storybook/api';
import type { StoriesHash } from '@storybook/api';
import { collapseDocsOnlyStories, collapseAllStories } from './data';

type Item = StoriesHash[keyof StoriesHash];
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/components/sidebar/data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Story, StoriesHash } from '@storybook/api';
import type { Story, StoriesHash } from '@storybook/api';
import { Item } from './types';

export const DEFAULT_REF_ID = 'storybook_internal';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/components/sidebar/mockdata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StoriesHash } from '@storybook/api';
import type { StoriesHash } from '@storybook/api';

export type MockDataSet = Record<string, StoriesHash>;

Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/components/sidebar/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StoriesHash, State } from '@storybook/api';
import type { StoriesHash, State } from '@storybook/api';
import { ControllerStateAndHelpers } from 'downshift';

export type Refs = State['refs'];
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/src/components/sidebar/useExpanded.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StoriesHash, useStorybookApi } from '@storybook/api';
import type { StoriesHash } from '@storybook/api';
import { useStorybookApi } from '@storybook/api';
import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from '@storybook/core-events';
import { document } from 'global';
import throttle from 'lodash/throttle';
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/src/components/sidebar/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import memoize from 'memoizerific';
import { document, window, DOCS_MODE } from 'global';
import { SyntheticEvent } from 'react';
import { StoriesHash, isRoot } from '@storybook/api';
import type { StoriesHash } from '@storybook/api';
import { isRoot } from '@storybook/api';

import { DEFAULT_REF_ID } from './data';
import { Item, RefType, Dataset, SearchItem } from './types';
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/src/containers/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { PREVIEW_URL } from 'global';
import React from 'react';

import { Consumer, Combo, StoriesHash, isRoot, isGroup, isStory } from '@storybook/api';
import type { Combo, StoriesHash } from '@storybook/api';
import { Consumer, isRoot, isGroup, isStory } from '@storybook/api';

import { Preview } from '../components/preview/preview';

Expand Down
3 changes: 2 additions & 1 deletion lib/ui/src/containers/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FunctionComponent } from 'react';

import { Consumer, Combo, StoriesHash } from '@storybook/api';
import type { Combo, StoriesHash } from '@storybook/api';
import { Consumer } from '@storybook/api';

import { Sidebar as SidebarComponent } from '../components/sidebar/Sidebar';
import { useMenu } from './menu';
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
eirslett marked this conversation as resolved.
Show resolved Hide resolved
"target": "es5",
"types": ["jest"],
"lib": ["es2017", "dom"]
Expand Down