@storybook/react-vite 9.2.0-alpha.3 → 10.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
1
  # Storybook for React & Vite
2
2
 
3
- See [documentation](https://storybook.js.org/docs/get-started/frameworks/react-vite?renderer=react) for installation instructions, usage examples, APIs, and more.
3
+ Develop, document, and test UI components in isolation.
4
+
5
+ See [documentation](https://storybook.js.org/docs/get-started/frameworks/react-vite?renderer=react&ref=readme) for installation instructions, usage examples, APIs, and more.
6
+
7
+ Learn more about Storybook at [storybook.js.org](https://storybook.js.org/?ref=readme).
@@ -0,0 +1,17 @@
1
+ import CJS_COMPAT_NODE_URL_vgvnxl4cp0a from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_vgvnxl4cp0a from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_vgvnxl4cp0a from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_vgvnxl4cp0a.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_vgvnxl4cp0a.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_vgvnxl4cp0a.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ var __defProp = Object.defineProperty;
13
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
14
+
15
+ export {
16
+ __name
17
+ };
@@ -0,0 +1,217 @@
1
+ import CJS_COMPAT_NODE_URL_vgvnxl4cp0a from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_vgvnxl4cp0a from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_vgvnxl4cp0a from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_vgvnxl4cp0a.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_vgvnxl4cp0a.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_vgvnxl4cp0a.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ __name
14
+ } from "./chunk-5SAYGJWO.js";
15
+
16
+ // src/plugins/react-docgen.ts
17
+ import { existsSync } from "node:fs";
18
+ import { relative, sep } from "node:path";
19
+ import { getProjectRoot } from "storybook/internal/common";
20
+ import { logger } from "storybook/internal/node-logger";
21
+ import { createFilter } from "@rollup/pluginutils";
22
+ import { findUp } from "find-up";
23
+ import MagicString from "magic-string";
24
+ import {
25
+ ERROR_CODES,
26
+ builtinHandlers as docgenHandlers,
27
+ builtinResolvers as docgenResolver,
28
+ makeFsImporter,
29
+ parse
30
+ } from "react-docgen";
31
+ import * as TsconfigPaths from "tsconfig-paths";
32
+
33
+ // src/plugins/docgen-handlers/actualNameHandler.ts
34
+ import { utils } from "react-docgen";
35
+ var { getNameOrValue, isReactForwardRefCall } = utils;
36
+ var actualNameHandler = /* @__PURE__ */ __name(function actualNameHandler2(documentation, componentDefinition) {
37
+ documentation.set("definedInFile", componentDefinition.hub.file.opts.filename);
38
+ if ((componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id")) {
39
+ documentation.set(
40
+ "actualName",
41
+ getNameOrValue(componentDefinition.get("id"))
42
+ );
43
+ } else if (componentDefinition.isArrowFunctionExpression() || componentDefinition.isFunctionExpression() || isReactForwardRefCall(componentDefinition)) {
44
+ let currentPath = componentDefinition;
45
+ while (currentPath.parentPath) {
46
+ if (currentPath.parentPath.isVariableDeclarator()) {
47
+ documentation.set("actualName", getNameOrValue(currentPath.parentPath.get("id")));
48
+ return;
49
+ }
50
+ if (currentPath.parentPath.isAssignmentExpression()) {
51
+ const leftPath = currentPath.parentPath.get("left");
52
+ if (leftPath.isIdentifier() || leftPath.isLiteral()) {
53
+ documentation.set("actualName", getNameOrValue(leftPath));
54
+ return;
55
+ }
56
+ }
57
+ currentPath = currentPath.parentPath;
58
+ }
59
+ documentation.set("actualName", "");
60
+ }
61
+ }, "actualNameHandler");
62
+ var actualNameHandler_default = actualNameHandler;
63
+
64
+ // src/plugins/docgen-resolver.ts
65
+ import { extname } from "node:path";
66
+ import resolve from "resolve";
67
+ var ReactDocgenResolveError = class extends Error {
68
+ constructor(filename) {
69
+ super(`'${filename}' was ignored by react-docgen.`);
70
+ // the magic string that react-docgen uses to check if a module is ignored
71
+ this.code = "MODULE_NOT_FOUND";
72
+ }
73
+ static {
74
+ __name(this, "ReactDocgenResolveError");
75
+ }
76
+ };
77
+ var RESOLVE_EXTENSIONS = [
78
+ ".js",
79
+ ".cts",
80
+ // These were originally not in the code, I added them
81
+ ".mts",
82
+ // These were originally not in the code, I added them
83
+ ".ctsx",
84
+ // These were originally not in the code, I added them
85
+ ".mtsx",
86
+ // These were originally not in the code, I added them
87
+ ".ts",
88
+ ".tsx",
89
+ ".mjs",
90
+ ".cjs",
91
+ ".mts",
92
+ ".cts",
93
+ ".jsx"
94
+ ];
95
+ function defaultLookupModule(filename, basedir) {
96
+ const resolveOptions = {
97
+ basedir,
98
+ extensions: RESOLVE_EXTENSIONS,
99
+ // we do not need to check core modules as we cannot import them anyway
100
+ includeCoreModules: false
101
+ };
102
+ try {
103
+ return resolve.sync(filename, resolveOptions);
104
+ } catch (error) {
105
+ const ext = extname(filename);
106
+ let newFilename;
107
+ switch (ext) {
108
+ case ".js":
109
+ case ".mjs":
110
+ case ".cjs":
111
+ newFilename = `${filename.slice(0, -2)}ts`;
112
+ break;
113
+ case ".jsx":
114
+ newFilename = `${filename.slice(0, -3)}tsx`;
115
+ break;
116
+ default:
117
+ throw error;
118
+ }
119
+ return resolve.sync(newFilename, {
120
+ ...resolveOptions,
121
+ // we already know that there is an extension at this point, so no need to check other extensions
122
+ extensions: []
123
+ });
124
+ }
125
+ }
126
+ __name(defaultLookupModule, "defaultLookupModule");
127
+
128
+ // src/plugins/react-docgen.ts
129
+ var defaultHandlers = Object.values(docgenHandlers).map((handler) => handler);
130
+ var defaultResolver = new docgenResolver.FindExportedDefinitionsResolver();
131
+ var handlers = [...defaultHandlers, actualNameHandler_default];
132
+ async function reactDocgen({
133
+ include = /\.(mjs|tsx?|jsx?)$/,
134
+ exclude = [/node_modules\/.*/]
135
+ } = {}) {
136
+ const cwd = process.cwd();
137
+ const filter = createFilter(include, exclude);
138
+ const tsconfigPath = await findUp("tsconfig.json", { cwd, stopAt: getProjectRoot() });
139
+ const tsconfig = TsconfigPaths.loadConfig(tsconfigPath);
140
+ let matchPath;
141
+ if (tsconfig.resultType === "success") {
142
+ logger.info("Using tsconfig paths for react-docgen");
143
+ matchPath = TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths, [
144
+ "browser",
145
+ "module",
146
+ "main"
147
+ ]);
148
+ }
149
+ return {
150
+ name: "storybook:react-docgen-plugin",
151
+ enforce: "pre",
152
+ async transform(src, id) {
153
+ if (!filter(relative(cwd, id))) {
154
+ return;
155
+ }
156
+ try {
157
+ const docgenResults = parse(src, {
158
+ resolver: defaultResolver,
159
+ handlers,
160
+ importer: getReactDocgenImporter(matchPath),
161
+ filename: id
162
+ });
163
+ const s = new MagicString(src);
164
+ docgenResults.forEach((info) => {
165
+ const { actualName, definedInFile, ...docgenInfo } = info;
166
+ if (actualName && definedInFile == id) {
167
+ const docNode = JSON.stringify(docgenInfo);
168
+ s.append(`;${actualName}.__docgenInfo=${docNode}`);
169
+ }
170
+ });
171
+ return {
172
+ code: s.toString(),
173
+ map: s.generateMap({ hires: true, source: id })
174
+ };
175
+ } catch (e) {
176
+ if (e.code === ERROR_CODES.MISSING_DEFINITION) {
177
+ return;
178
+ }
179
+ throw e;
180
+ }
181
+ }
182
+ };
183
+ }
184
+ __name(reactDocgen, "reactDocgen");
185
+ function getReactDocgenImporter(matchPath) {
186
+ return makeFsImporter((filename, basedir) => {
187
+ const mappedFilenameByPaths = (() => {
188
+ if (matchPath) {
189
+ const match = matchPath(filename);
190
+ return match || filename;
191
+ } else {
192
+ return filename;
193
+ }
194
+ })();
195
+ const result = defaultLookupModule(mappedFilenameByPaths, basedir);
196
+ if (result.includes(`${sep}react-native${sep}index.js`)) {
197
+ const replaced = result.replace(
198
+ `${sep}react-native${sep}index.js`,
199
+ `${sep}react-native-web${sep}dist${sep}index.js`
200
+ );
201
+ if (existsSync(replaced)) {
202
+ if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext))) {
203
+ return replaced;
204
+ }
205
+ }
206
+ }
207
+ if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext))) {
208
+ return result;
209
+ }
210
+ throw new ReactDocgenResolveError(filename);
211
+ });
212
+ }
213
+ __name(getReactDocgenImporter, "getReactDocgenImporter");
214
+ export {
215
+ getReactDocgenImporter,
216
+ reactDocgen
217
+ };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from '@storybook/react';
2
2
  export { __definePreview as definePreview } from '@storybook/react';
3
- import { StorybookConfig as StorybookConfig$1, TypescriptOptions as TypescriptOptions$1, CompatibleString } from 'storybook/internal/types';
3
+ import { StorybookConfig as StorybookConfig$1, CompatibleString, TypescriptOptions as TypescriptOptions$1 } from 'storybook/internal/types';
4
4
  import { BuilderOptions, StorybookConfigVite } from '@storybook/builder-vite';
5
5
  import docgenTypescript from '@joshwooding/vite-plugin-react-docgen-typescript';
6
6
 
@@ -47,4 +47,4 @@ type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigVite | keyof
47
47
  typescript?: Partial<TypescriptOptions>;
48
48
  };
49
49
 
50
- export { FrameworkOptions, StorybookConfig };
50
+ export type { FrameworkOptions, StorybookConfig };
package/dist/index.js CHANGED
@@ -1 +1,6 @@
1
- "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default"));var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var index_exports={};__export(index_exports,{definePreview:()=>import_react.__definePreview});module.exports=__toCommonJS(index_exports);__reExport(index_exports,require("@storybook/react"),module.exports);var import_react=require("@storybook/react");0&&(module.exports={definePreview,...require("@storybook/react")});
1
+ // src/index.ts
2
+ export * from "@storybook/react";
3
+ import { __definePreview } from "@storybook/react";
4
+ export {
5
+ __definePreview as definePreview
6
+ };
@@ -1,8 +1,49 @@
1
- import { StorybookConfig } from '../index.js';
2
- import '@storybook/react';
3
- import 'storybook/internal/types';
4
- import '@storybook/builder-vite';
5
- import '@joshwooding/vite-plugin-react-docgen-typescript';
1
+ import { StorybookConfig as StorybookConfig$1, CompatibleString, TypescriptOptions as TypescriptOptions$1 } from 'storybook/internal/types';
2
+ import { StorybookConfigVite, BuilderOptions } from '@storybook/builder-vite';
3
+ import docgenTypescript from '@joshwooding/vite-plugin-react-docgen-typescript';
4
+
5
+ type FrameworkName = CompatibleString<'@storybook/react-vite'>;
6
+ type BuilderName = CompatibleString<'@storybook/builder-vite'>;
7
+ type FrameworkOptions = {
8
+ builder?: BuilderOptions;
9
+ strictMode?: boolean;
10
+ /**
11
+ * Use React's legacy root API to mount components
12
+ *
13
+ * React has introduced a new root API with React 18.x to enable a whole set of new features (e.g.
14
+ * concurrent features) If this flag is true, the legacy Root API is used to mount components to
15
+ * make it easier to migrate step by step to React 18.
16
+ *
17
+ * @default false
18
+ */
19
+ legacyRootApi?: boolean;
20
+ };
21
+ type StorybookConfigFramework = {
22
+ framework: FrameworkName | {
23
+ name: FrameworkName;
24
+ options: FrameworkOptions;
25
+ };
26
+ core?: StorybookConfig$1['core'] & {
27
+ builder?: BuilderName | {
28
+ name: BuilderName;
29
+ options: BuilderOptions;
30
+ };
31
+ };
32
+ };
33
+ type TypescriptOptions = TypescriptOptions$1 & {
34
+ /**
35
+ * Sets the type of Docgen when working with React and TypeScript
36
+ *
37
+ * @default `'react-docgen'`
38
+ */
39
+ reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
40
+ /** Configures `@joshwooding/vite-plugin-react-docgen-typescript` */
41
+ reactDocgenTypescriptOptions: Parameters<typeof docgenTypescript>[0];
42
+ };
43
+ /** The interface for Storybook configuration in `main.ts` files. */
44
+ type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigVite | keyof StorybookConfigFramework | 'typescript'> & StorybookConfigVite & StorybookConfigFramework & {
45
+ typescript?: Partial<TypescriptOptions>;
46
+ };
6
47
 
7
48
  declare function defineMain(config: StorybookConfig): StorybookConfig;
8
49
 
@@ -1 +1,23 @@
1
- "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var node_exports={};__export(node_exports,{defineMain:()=>defineMain});module.exports=__toCommonJS(node_exports);function defineMain(config){return config}0&&(module.exports={defineMain});
1
+ import CJS_COMPAT_NODE_URL_vgvnxl4cp0a from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_vgvnxl4cp0a from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_vgvnxl4cp0a from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_vgvnxl4cp0a.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_vgvnxl4cp0a.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_vgvnxl4cp0a.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ __name
14
+ } from "../_node-chunks/chunk-5SAYGJWO.js";
15
+
16
+ // src/node/index.ts
17
+ function defineMain(config) {
18
+ return config;
19
+ }
20
+ __name(defineMain, "defineMain");
21
+ export {
22
+ defineMain
23
+ };
package/dist/preset.d.ts CHANGED
@@ -1,8 +1,49 @@
1
- import { PresetProperty } from 'storybook/internal/types';
2
- import { StorybookConfig } from './index.js';
3
- import '@storybook/react';
4
- import '@storybook/builder-vite';
5
- import '@joshwooding/vite-plugin-react-docgen-typescript';
1
+ import { StorybookConfig as StorybookConfig$1, CompatibleString, TypescriptOptions as TypescriptOptions$1, PresetProperty } from 'storybook/internal/types';
2
+ import { StorybookConfigVite, BuilderOptions } from '@storybook/builder-vite';
3
+ import docgenTypescript from '@joshwooding/vite-plugin-react-docgen-typescript';
4
+
5
+ type FrameworkName = CompatibleString<'@storybook/react-vite'>;
6
+ type BuilderName = CompatibleString<'@storybook/builder-vite'>;
7
+ type FrameworkOptions = {
8
+ builder?: BuilderOptions;
9
+ strictMode?: boolean;
10
+ /**
11
+ * Use React's legacy root API to mount components
12
+ *
13
+ * React has introduced a new root API with React 18.x to enable a whole set of new features (e.g.
14
+ * concurrent features) If this flag is true, the legacy Root API is used to mount components to
15
+ * make it easier to migrate step by step to React 18.
16
+ *
17
+ * @default false
18
+ */
19
+ legacyRootApi?: boolean;
20
+ };
21
+ type StorybookConfigFramework = {
22
+ framework: FrameworkName | {
23
+ name: FrameworkName;
24
+ options: FrameworkOptions;
25
+ };
26
+ core?: StorybookConfig$1['core'] & {
27
+ builder?: BuilderName | {
28
+ name: BuilderName;
29
+ options: BuilderOptions;
30
+ };
31
+ };
32
+ };
33
+ type TypescriptOptions = TypescriptOptions$1 & {
34
+ /**
35
+ * Sets the type of Docgen when working with React and TypeScript
36
+ *
37
+ * @default `'react-docgen'`
38
+ */
39
+ reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
40
+ /** Configures `@joshwooding/vite-plugin-react-docgen-typescript` */
41
+ reactDocgenTypescriptOptions: Parameters<typeof docgenTypescript>[0];
42
+ };
43
+ /** The interface for Storybook configuration in `main.ts` files. */
44
+ type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigVite | keyof StorybookConfigFramework | 'typescript'> & StorybookConfigVite & StorybookConfigFramework & {
45
+ typescript?: Partial<TypescriptOptions>;
46
+ };
6
47
 
7
48
  declare const core: PresetProperty<'core'>;
8
49
  declare const viteFinal: NonNullable<StorybookConfig['viteFinal']>;
package/dist/preset.js CHANGED
@@ -1 +1,57 @@
1
- "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __esm=(fn,res)=>function(){return fn&&(res=(0,fn[__getOwnPropNames(fn)[0]])(fn=0)),res};var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var import_react_docgen,getNameOrValue,isReactForwardRefCall,actualNameHandler,actualNameHandler_default,init_actualNameHandler=__esm({"src/plugins/docgen-handlers/actualNameHandler.ts"(){"use strict";import_react_docgen=require("react-docgen"),{getNameOrValue,isReactForwardRefCall}=import_react_docgen.utils,actualNameHandler=function(documentation,componentDefinition){if(documentation.set("definedInFile",componentDefinition.hub.file.opts.filename),(componentDefinition.isClassDeclaration()||componentDefinition.isFunctionDeclaration())&&componentDefinition.has("id"))documentation.set("actualName",getNameOrValue(componentDefinition.get("id")));else if(componentDefinition.isArrowFunctionExpression()||componentDefinition.isFunctionExpression()||isReactForwardRefCall(componentDefinition)){let currentPath=componentDefinition;for(;currentPath.parentPath;){if(currentPath.parentPath.isVariableDeclarator()){documentation.set("actualName",getNameOrValue(currentPath.parentPath.get("id")));return}if(currentPath.parentPath.isAssignmentExpression()){let leftPath=currentPath.parentPath.get("left");if(leftPath.isIdentifier()||leftPath.isLiteral()){documentation.set("actualName",getNameOrValue(leftPath));return}}currentPath=currentPath.parentPath}documentation.set("actualName","")}},actualNameHandler_default=actualNameHandler}});function defaultLookupModule(filename,basedir){let resolveOptions={basedir,extensions:RESOLVE_EXTENSIONS,includeCoreModules:!1};try{return import_resolve.default.sync(filename,resolveOptions)}catch(error){let ext=(0,import_node_path.extname)(filename),newFilename;switch(ext){case".js":case".mjs":case".cjs":newFilename=`${filename.slice(0,-2)}ts`;break;case".jsx":newFilename=`${filename.slice(0,-3)}tsx`;break;default:throw error}return import_resolve.default.sync(newFilename,{...resolveOptions,extensions:[]})}}var import_node_path,import_resolve,ReactDocgenResolveError,RESOLVE_EXTENSIONS,init_docgen_resolver=__esm({"src/plugins/docgen-resolver.ts"(){"use strict";import_node_path=require("path"),import_resolve=__toESM(require("resolve")),ReactDocgenResolveError=class extends Error{constructor(filename){super(`'${filename}' was ignored by react-docgen.`);this.code="MODULE_NOT_FOUND"}},RESOLVE_EXTENSIONS=[".js",".cts",".mts",".ctsx",".mtsx",".ts",".tsx",".mjs",".cjs",".mts",".cts",".jsx"]}});var react_docgen_exports={};__export(react_docgen_exports,{getReactDocgenImporter:()=>getReactDocgenImporter,reactDocgen:()=>reactDocgen});async function reactDocgen({include=/\.(mjs|tsx?|jsx?)$/,exclude=[/node_modules\/.*/]}={}){let cwd=process.cwd(),filter=(0,import_pluginutils.createFilter)(include,exclude),tsconfigPath=await(0,import_find_up.findUp)("tsconfig.json",{cwd,stopAt:(0,import_common.getProjectRoot)()}),tsconfig=TsconfigPaths.loadConfig(tsconfigPath),matchPath;return tsconfig.resultType==="success"&&(import_node_logger.logger.info("Using tsconfig paths for react-docgen"),matchPath=TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl,tsconfig.paths,["browser","module","main"])),{name:"storybook:react-docgen-plugin",enforce:"pre",async transform(src,id){if(filter((0,import_node_path2.relative)(cwd,id)))try{let docgenResults=(0,import_react_docgen2.parse)(src,{resolver:defaultResolver,handlers,importer:getReactDocgenImporter(matchPath),filename:id}),s=new import_magic_string.default(src);return docgenResults.forEach(info=>{let{actualName,definedInFile,...docgenInfo}=info;if(actualName&&definedInFile==id){let docNode=JSON.stringify(docgenInfo);s.append(`;${actualName}.__docgenInfo=${docNode}`)}}),{code:s.toString(),map:s.generateMap({hires:!0,source:id})}}catch(e){if(e.code===import_react_docgen2.ERROR_CODES.MISSING_DEFINITION)return;throw e}}}}function getReactDocgenImporter(matchPath){return(0,import_react_docgen2.makeFsImporter)((filename,basedir)=>{let mappedFilenameByPaths=matchPath&&matchPath(filename)||filename,result=defaultLookupModule(mappedFilenameByPaths,basedir);if(result.includes(`${import_node_path2.sep}react-native${import_node_path2.sep}index.js`)){let replaced=result.replace(`${import_node_path2.sep}react-native${import_node_path2.sep}index.js`,`${import_node_path2.sep}react-native-web${import_node_path2.sep}dist${import_node_path2.sep}index.js`);if((0,import_node_fs.existsSync)(replaced)&&RESOLVE_EXTENSIONS.find(ext=>result.endsWith(ext)))return replaced}if(RESOLVE_EXTENSIONS.find(ext=>result.endsWith(ext)))return result;throw new ReactDocgenResolveError(filename)})}var import_node_fs,import_node_path2,import_common,import_node_logger,import_pluginutils,import_find_up,import_magic_string,import_react_docgen2,TsconfigPaths,defaultHandlers,defaultResolver,handlers,init_react_docgen=__esm({"src/plugins/react-docgen.ts"(){"use strict";import_node_fs=require("fs"),import_node_path2=require("path"),import_common=require("storybook/internal/common"),import_node_logger=require("storybook/internal/node-logger"),import_pluginutils=require("@rollup/pluginutils"),import_find_up=require("find-up"),import_magic_string=__toESM(require("magic-string")),import_react_docgen2=require("react-docgen"),TsconfigPaths=__toESM(require("tsconfig-paths"));init_actualNameHandler();init_docgen_resolver();defaultHandlers=Object.values(import_react_docgen2.builtinHandlers).map(handler=>handler),defaultResolver=new import_react_docgen2.builtinResolvers.FindExportedDefinitionsResolver,handlers=[...defaultHandlers,actualNameHandler_default]}});var preset_exports={};__export(preset_exports,{core:()=>core,viteFinal:()=>viteFinal});module.exports=__toCommonJS(preset_exports);var import_node_path3=require("path"),getAbsolutePath=input=>(0,import_node_path3.dirname)(require.resolve((0,import_node_path3.join)(input,"package.json"))),core={builder:getAbsolutePath("@storybook/builder-vite"),renderer:getAbsolutePath("@storybook/react")},viteFinal=async(config,{presets})=>{let plugins=[...config?.plugins??[]],{reactDocgen:reactDocgenOption,reactDocgenTypescriptOptions}=await presets.apply("typescript",{}),typescriptPresent;try{require.resolve("typescript"),typescriptPresent=!0}catch{typescriptPresent=!1}if(reactDocgenOption==="react-docgen-typescript"&&typescriptPresent&&plugins.push(require("@joshwooding/vite-plugin-react-docgen-typescript")({...reactDocgenTypescriptOptions,savePropValueAsString:!0})),typeof reactDocgenOption=="string"){let{reactDocgen:reactDocgen2}=await Promise.resolve().then(()=>(init_react_docgen(),react_docgen_exports));plugins.unshift(await reactDocgen2({include:reactDocgenOption==="react-docgen"?/\.(mjs|tsx?|jsx?)$/:/\.(mjs|jsx?)$/}))}return{...config,plugins}};0&&(module.exports={core,viteFinal});
1
+ import CJS_COMPAT_NODE_URL_vgvnxl4cp0a from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_vgvnxl4cp0a from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_vgvnxl4cp0a from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_vgvnxl4cp0a.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_vgvnxl4cp0a.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_vgvnxl4cp0a.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ __name
14
+ } from "./_node-chunks/chunk-5SAYGJWO.js";
15
+
16
+ // src/preset.ts
17
+ var core = {
18
+ builder: import.meta.resolve("@storybook/builder-vite"),
19
+ renderer: import.meta.resolve("@storybook/react/preset")
20
+ };
21
+ var viteFinal = /* @__PURE__ */ __name(async (config, { presets }) => {
22
+ const plugins = [...config?.plugins ?? []];
23
+ const { reactDocgen: reactDocgenOption, reactDocgenTypescriptOptions } = await presets.apply(
24
+ "typescript",
25
+ {}
26
+ );
27
+ let typescriptPresent;
28
+ try {
29
+ import.meta.resolve("typescript");
30
+ typescriptPresent = true;
31
+ } catch (e) {
32
+ typescriptPresent = false;
33
+ }
34
+ if (reactDocgenOption === "react-docgen-typescript" && typescriptPresent) {
35
+ plugins.push(
36
+ (await import("@joshwooding/vite-plugin-react-docgen-typescript")).default({
37
+ ...reactDocgenTypescriptOptions,
38
+ // We *need* this set so that RDT returns default values in the same format as react-docgen
39
+ savePropValueAsString: true
40
+ })
41
+ );
42
+ }
43
+ if (typeof reactDocgenOption === "string") {
44
+ const { reactDocgen } = await import("./_node-chunks/react-docgen-3XDJ5F7O.js");
45
+ plugins.unshift(
46
+ // If react-docgen is specified, use it for everything, otherwise only use it for non-typescript files
47
+ await reactDocgen({
48
+ include: reactDocgenOption === "react-docgen" ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/
49
+ })
50
+ );
51
+ }
52
+ return { ...config, plugins };
53
+ }, "viteFinal");
54
+ export {
55
+ core,
56
+ viteFinal
57
+ };
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@storybook/react-vite",
3
- "version": "9.2.0-alpha.3",
4
- "description": "Storybook for React and Vite: Develop React components in isolation with Hot Reloading.",
3
+ "version": "10.0.0-beta.1",
4
+ "description": "Storybook for React and Vite: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
- "storybook"
6
+ "storybook",
7
+ "storybook-framework",
8
+ "react",
9
+ "vite",
10
+ "component",
11
+ "components"
7
12
  ],
8
13
  "homepage": "https://github.com/storybookjs/storybook/tree/next/code/frameworks/react-vite",
9
14
  "bugs": {
@@ -19,39 +24,20 @@
19
24
  "url": "https://opencollective.com/storybook"
20
25
  },
21
26
  "license": "MIT",
27
+ "type": "module",
22
28
  "exports": {
23
29
  ".": {
24
30
  "types": "./dist/index.d.ts",
25
- "node": "./dist/index.js",
26
- "import": "./dist/index.mjs",
27
- "require": "./dist/index.js"
28
- },
29
- "./preset": {
30
- "types": "./dist/preset.d.ts",
31
- "require": "./dist/preset.js"
31
+ "default": "./dist/index.js"
32
32
  },
33
33
  "./node": {
34
34
  "types": "./dist/node/index.d.ts",
35
- "node": "./dist/node/index.js",
36
- "import": "./dist/node/index.mjs",
37
- "require": "./dist/node/index.js"
35
+ "default": "./dist/node/index.js"
38
36
  },
39
- "./package.json": "./package.json"
40
- },
41
- "main": "dist/index.js",
42
- "module": "dist/index.mjs",
43
- "types": "dist/index.d.ts",
44
- "typesVersions": {
45
- "*": {
46
- "*": [
47
- "dist/index.d.ts"
48
- ],
49
- "preset": [
50
- "dist/preset.d.ts"
51
- ],
52
- "node": [
53
- "dist/node/index.d.ts"
54
- ]
37
+ "./package.json": "./package.json",
38
+ "./preset": {
39
+ "types": "./dist/preset.d.ts",
40
+ "default": "./dist/preset.js"
55
41
  }
56
42
  },
57
43
  "files": [
@@ -63,14 +49,14 @@
63
49
  "!src/**/*"
64
50
  ],
65
51
  "scripts": {
66
- "check": "jiti ../../../scripts/prepare/check.ts",
67
- "prep": "jiti ../../../scripts/prepare/bundle.ts"
52
+ "check": "jiti ../../../scripts/check/check-package.ts",
53
+ "prep": "jiti ../../../scripts/build/build-package.ts"
68
54
  },
69
55
  "dependencies": {
70
56
  "@joshwooding/vite-plugin-react-docgen-typescript": "0.6.1",
71
57
  "@rollup/pluginutils": "^5.0.2",
72
- "@storybook/builder-vite": "9.2.0-alpha.3",
73
- "@storybook/react": "9.2.0-alpha.3",
58
+ "@storybook/builder-vite": "10.0.0-beta.1",
59
+ "@storybook/react": "10.0.0-beta.1",
74
60
  "find-up": "^7.0.0",
75
61
  "magic-string": "^0.30.0",
76
62
  "react-docgen": "^8.0.0",
@@ -80,27 +66,16 @@
80
66
  "devDependencies": {
81
67
  "@types/node": "^22.0.0",
82
68
  "typescript": "^5.8.3",
83
- "vite": "^6.2.5"
69
+ "vite": "^7.0.4"
84
70
  },
85
71
  "peerDependencies": {
86
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
87
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
88
- "storybook": "^9.2.0-alpha.3",
72
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
73
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
74
+ "storybook": "^10.0.0-beta.1",
89
75
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
90
76
  },
91
- "engines": {
92
- "node": ">=20.0.0"
93
- },
94
77
  "publishConfig": {
95
78
  "access": "public"
96
79
  },
97
- "bundler": {
98
- "entries": [
99
- "./src/index.ts",
100
- "./src/preset.ts",
101
- "./src/node/index.ts"
102
- ],
103
- "platform": "node"
104
- },
105
- "gitHead": "ce6a1e4a8d5ad69c699021a0b183df89cfc7b684"
80
+ "gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae16"
106
81
  }
package/preset.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist/preset');
1
+ export * from './dist/preset.js';
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- export * from '@storybook/react';
2
- export { __definePreview as definePreview } from '@storybook/react';
@@ -1,3 +0,0 @@
1
- function defineMain(config){return config}
2
-
3
- export { defineMain };