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

Build: Bundle lib/preview-web with ts-up #19319

Closed
wants to merge 7 commits into from
Closed
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
7 changes: 3 additions & 4 deletions code/lib/core-client/src/preview/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import {
waitForQuiescence,
emitter,
mockChannel,
} from '@storybook/preview-web/dist/cjs/PreviewWeb.mockdata';
// @ts-expect-error (Converted from ts-ignore)
import { WebView } from '@storybook/preview-web/dist/cjs/WebView';
} from '@storybook/preview-web/dist/PreviewWeb.mockdata';
import { WebView } from '@storybook/preview-web/dist/WebView';
import { setGlobalRender } from '@storybook/client-api';

import { start } from './start';

jest.mock('@storybook/preview-web/dist/cjs/WebView');
jest.mock('@storybook/preview-web/dist/WebView');
jest.spyOn(WebView.prototype, 'prepareForDocs').mockReturnValue('docs-root');
jest.spyOn(WebView.prototype, 'prepareForStory').mockReturnValue('story-root');

Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-client/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module '@storybook/preview-web/dist/cjs/PreviewWeb.mockdata';
declare module '@storybook/preview-web/dist/PreviewWeb.mockdata';

declare class AnsiToHtml {
constructor(options: { escapeHtml: boolean });
Expand Down
34 changes: 30 additions & 4 deletions code/lib/preview-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,27 @@
},
"license": "MIT",
"sideEffects": false,
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./PreviewWeb.mockdata": {
"require": "./dist/PreviewWeb.mockdata.js",
"import": "./dist/PreviewWeb.mockdata.mjs",
"types": "./dist/PreviewWeb.mockdata.d.ts"
},
"./WebView": {
"require": "./dist/WebView.js",
"import": "./dist/WebView.mjs",
"types": "./dist/WebView.d.ts"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"README.md",
Expand All @@ -31,7 +49,7 @@
],
"scripts": {
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
"prep": "node ../../../scripts/prepare.js"
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/addons": "7.0.0-alpha.35",
Expand All @@ -50,12 +68,20 @@
},
"devDependencies": {
"@storybook/channel-postmessage": "7.0.0-alpha.35",
"@types/events": "^3.0.0",
"react": "16.14.0",
"ts-jest": "^28.0.8",
"typescript": "~4.6.3"
},
"publishConfig": {
"access": "public"
},
"bundler": {
"entries": [
"./src/index.ts",
"./src/WebView.ts",
"./src/PreviewWeb.mockdata.ts"
]
},
"gitHead": "d8972df8c6c1c4716131a856751f5914acddaad1"
}
6 changes: 3 additions & 3 deletions code/lib/preview-web/src/PreviewWeb.mockdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
STORY_THREW_EXCEPTION,
} from '@storybook/core-events';
import { StoryIndex, TeardownRenderToDOM } from '@storybook/store';
import { RenderPhase } from './PreviewWeb';
import type { RenderPhase } from './render/StoryRender';

export const componentOneExports = {
default: {
Expand Down Expand Up @@ -42,7 +42,7 @@ export const extraComponentOneExports = {
e: {},
};
export const importFn = jest.fn(
async (path) =>
async (path: string) =>
({
'./src/ComponentOne.stories.js': componentOneExports,
'./src/ComponentTwo.stories.js': componentTwoExports,
Expand Down Expand Up @@ -146,7 +146,7 @@ export const waitForEvents = (
// ensure you call `mockChannel.emit.mockClear()` before `waitFor...`
if (
mockChannel.emit.mock.calls.find(
(call) => events.includes(call[0]) && predicate(...call.slice(1))
(call: any[]) => events.includes(call[0]) && predicate(...call.slice(1))
)
) {
return Promise.resolve(null);
Expand Down
2 changes: 0 additions & 2 deletions code/lib/preview-web/src/PreviewWeb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export class PreviewWeb<TFramework extends AnyFramework> extends Preview<TFramew

view: WebView;

previewEntryError?: Error;

currentSelection?: Selection;

currentRender?: PossibleRender<TFramework>;
Expand Down
8 changes: 8 additions & 0 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8382,6 +8382,7 @@ __metadata:
"@storybook/core-events": 7.0.0-alpha.35
"@storybook/csf": 0.0.2--canary.0899bb7.0
"@storybook/store": 7.0.0-alpha.35
"@types/events": ^3.0.0
ansi-to-html: ^0.6.11
global: ^4.4.0
lodash: ^4.17.21
Expand Down Expand Up @@ -9756,6 +9757,13 @@ __metadata:
languageName: node
linkType: hard

"@types/events@npm:^3.0.0":
version: 3.0.0
resolution: "@types/events@npm:3.0.0"
checksum: c23b6abb253df754eca21cdfb6c4e66e7b1dc977d08934e4e01b436c776c971e4f7cac2876c9d060d72169ce451a757c9983e6a0388e155161957ce48cef0cd1
languageName: node
linkType: hard

"@types/express-serve-static-core@npm:*, @types/express-serve-static-core@npm:^4.17.18":
version: 4.17.31
resolution: "@types/express-serve-static-core@npm:4.17.31"
Expand Down