diff --git a/code/frameworks/angular/package.json b/code/frameworks/angular/package.json
index 6ae77192dbeb..bd6261935b6f 100644
--- a/code/frameworks/angular/package.json
+++ b/code/frameworks/angular/package.json
@@ -87,6 +87,7 @@
"@nrwl/workspace": "14.6.1",
"@types/autoprefixer": "^9.7.2",
"@types/tmp": "^0.2.3",
+ "@types/webpack-env": "^1.16.0",
"cross-spawn": "^7.0.3",
"jest": "^27.5.1",
"jest-preset-angular": "^12.0.0",
diff --git a/code/frameworks/angular/src/client/index.ts b/code/frameworks/angular/src/client/index.ts
index f74d4e1b213b..7e79f3fd2fab 100644
--- a/code/frameworks/angular/src/client/index.ts
+++ b/code/frameworks/angular/src/client/index.ts
@@ -1,3 +1,5 @@
+///
+
import './globals';
export * from './public-api';
diff --git a/code/frameworks/ember/src/index.ts b/code/frameworks/ember/src/index.ts
index 9365b8c82146..482cff02a3c0 100644
--- a/code/frameworks/ember/src/index.ts
+++ b/code/frameworks/ember/src/index.ts
@@ -1,3 +1,5 @@
+///
+
export {
storiesOf,
setAddon,
diff --git a/code/lib/client-api/package.json b/code/lib/client-api/package.json
index 30ec867c510a..a5a9c5e7f22a 100644
--- a/code/lib/client-api/package.json
+++ b/code/lib/client-api/package.json
@@ -20,9 +20,17 @@
},
"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"
+ },
+ "./package.json": "./package.json"
+ },
+ "main": "dist/index.js",
+ "module": "dist/index.mjs",
+ "types": "dist/index.d.ts",
"files": [
"dist/**/*",
"README.md",
@@ -31,7 +39,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.34",
@@ -57,5 +65,10 @@
"publishConfig": {
"access": "public"
},
+ "bundler": {
+ "entries": [
+ "./src/index.ts"
+ ]
+ },
"gitHead": "fc90fc875462421c1faa35862ac4bc436de8e75f"
}
diff --git a/code/lib/client-api/src/index.ts b/code/lib/client-api/src/index.ts
index 9ac279239c2d..5a999fb16188 100644
--- a/code/lib/client-api/src/index.ts
+++ b/code/lib/client-api/src/index.ts
@@ -11,6 +11,8 @@ import {
setGlobalRender,
} from './ClientApi';
+export type { GetStorybookKind, GetStorybookStory } from './ClientApi';
+
export * from './types';
export * from './queryparams';
diff --git a/code/lib/core-client/src/preview/executeLoadable.ts b/code/lib/core-client/src/preview/executeLoadable.ts
index 2261190cb4b3..05ab5cfdb464 100644
--- a/code/lib/core-client/src/preview/executeLoadable.ts
+++ b/code/lib/core-client/src/preview/executeLoadable.ts
@@ -1,3 +1,6 @@
+///
+///
+
import { logger } from '@storybook/client-logger';
import { Path, ModuleExports } from '@storybook/store';
import { Loadable, RequireContext, LoaderFunction } from './types';
diff --git a/code/lib/core-client/src/preview/start.ts b/code/lib/core-client/src/preview/start.ts
index 5cd2463ceefb..c8b20f1a55d9 100644
--- a/code/lib/core-client/src/preview/start.ts
+++ b/code/lib/core-client/src/preview/start.ts
@@ -5,7 +5,7 @@ import { PreviewWeb } from '@storybook/preview-web';
import type { AnyFramework, ArgsStoryFn } from '@storybook/csf';
import { createChannel } from '@storybook/channel-postmessage';
import { addons } from '@storybook/addons';
-import Events from '@storybook/core-events';
+import { FORCE_RE_RENDER } from '@storybook/core-events';
import type { Path, WebProjectAnnotations } from '@storybook/store';
import { Loadable } from './types';
@@ -24,16 +24,45 @@ const removedApi = (name: string) => () => {
throw new Error(`@storybook/client-api:${name} was removed in storyStoreV7.`);
};
+interface RendererImplementation {
+ decorateStory?: WebProjectAnnotations['applyDecorators'];
+ render?: ArgsStoryFn;
+}
+
+interface ClientAPIFacade {
+ /* deprecated */
+ addDecorator: (...args: any[]) => never;
+ /* deprecated */
+ addParameters: (...args: any[]) => never;
+ /* deprecated */
+ clearDecorators: (...args: any[]) => never;
+ /* deprecated */
+ addLoader: (...args: any[]) => never;
+ /* deprecated */
+ setAddon: (...args: any[]) => never;
+ /* deprecated */
+ getStorybook: (...args: any[]) => never;
+ /* deprecated */
+ storiesOf: (...args: any[]) => never;
+ /* deprecated */
+ raw: (...args: any[]) => never;
+}
+
+interface StartReturnValue {
+ /* deprecated */
+ forceReRender: () => void;
+ /* deprecated */
+ getStorybook: any;
+ /* deprecated */
+ configure: any;
+ /* deprecated */
+ clientApi: ClientApi | ClientAPIFacade;
+}
+
export function start(
renderToDOM: WebProjectAnnotations['renderToDOM'],
- {
- decorateStory,
- render,
- }: {
- decorateStory?: WebProjectAnnotations['applyDecorators'];
- render?: ArgsStoryFn;
- } = {}
-) {
+ { decorateStory, render }: RendererImplementation = {}
+): StartReturnValue {
if (globalWindow) {
// To enable user code to detect if it is running in Storybook
globalWindow.IS_STORYBOOK = true;
@@ -84,9 +113,8 @@ export function start(
}
return {
- forceReRender: () => channel.emit(Events.FORCE_RE_RENDER),
+ forceReRender: () => channel.emit(FORCE_RE_RENDER),
getStorybook: (): void[] => [],
- raw: (): void => {},
clientApi,
// This gets called each time the user calls configure (i.e. once per HMR)
diff --git a/code/renderers/html/src/index.ts b/code/renderers/html/src/index.ts
index 6f07e864d3e9..9d5afe665e9a 100644
--- a/code/renderers/html/src/index.ts
+++ b/code/renderers/html/src/index.ts
@@ -1,3 +1,5 @@
+///
+
import './globals';
export * from './public-api';
diff --git a/code/renderers/preact/src/index.ts b/code/renderers/preact/src/index.ts
index 731b8a9a1588..32a6b0b3ee94 100644
--- a/code/renderers/preact/src/index.ts
+++ b/code/renderers/preact/src/index.ts
@@ -1,3 +1,5 @@
+///
+
export * from './globals';
export * from './public-api';
diff --git a/code/renderers/react/src/index.ts b/code/renderers/react/src/index.ts
index a1da39cc147e..68dae468dcc1 100644
--- a/code/renderers/react/src/index.ts
+++ b/code/renderers/react/src/index.ts
@@ -1,3 +1,5 @@
+///
+
import './globals';
export * from './public-api';
diff --git a/code/renderers/server/src/index.ts b/code/renderers/server/src/index.ts
index 6f07e864d3e9..9d5afe665e9a 100644
--- a/code/renderers/server/src/index.ts
+++ b/code/renderers/server/src/index.ts
@@ -1,3 +1,5 @@
+///
+
import './globals';
export * from './public-api';
diff --git a/code/renderers/svelte/src/index.ts b/code/renderers/svelte/src/index.ts
index 6f07e864d3e9..9d5afe665e9a 100644
--- a/code/renderers/svelte/src/index.ts
+++ b/code/renderers/svelte/src/index.ts
@@ -1,3 +1,5 @@
+///
+
import './globals';
export * from './public-api';
diff --git a/code/renderers/vue/src/index.ts b/code/renderers/vue/src/index.ts
index 6f07e864d3e9..9d5afe665e9a 100644
--- a/code/renderers/vue/src/index.ts
+++ b/code/renderers/vue/src/index.ts
@@ -1,3 +1,5 @@
+///
+
import './globals';
export * from './public-api';
diff --git a/code/renderers/vue3/src/index.ts b/code/renderers/vue3/src/index.ts
index 6f07e864d3e9..9d5afe665e9a 100644
--- a/code/renderers/vue3/src/index.ts
+++ b/code/renderers/vue3/src/index.ts
@@ -1,3 +1,5 @@
+///
+
import './globals';
export * from './public-api';
diff --git a/code/renderers/web-components/src/index.ts b/code/renderers/web-components/src/index.ts
index e0a88fea3b48..699b1638bb3f 100644
--- a/code/renderers/web-components/src/index.ts
+++ b/code/renderers/web-components/src/index.ts
@@ -1,3 +1,5 @@
+///
+
// @ts-expect-error (Converted from ts-ignore)
import global from 'global';
diff --git a/code/yarn.lock b/code/yarn.lock
index 2f5b80776133..6449f6e663bb 100644
--- a/code/yarn.lock
+++ b/code/yarn.lock
@@ -7150,6 +7150,7 @@ __metadata:
"@types/react": ^16.14.23
"@types/react-dom": ^16.9.14
"@types/tmp": ^0.2.3
+ "@types/webpack-env": ^1.16.0
autoprefixer: ^9.8.6
core-js: ^3.8.2
cross-spawn: ^7.0.3