@storybook/react-vite 9.2.0-alpha.3 → 10.0.0-beta.0
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 +5 -1
- package/dist/_node-chunks/chunk-S3I4ISWP.js +17 -0
- package/dist/_node-chunks/react-docgen-MISGQNYC.js +217 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -1
- package/dist/node/index.d.ts +46 -5
- package/dist/node/index.js +23 -1
- package/dist/preset.d.ts +46 -5
- package/dist/preset.js +57 -1
- package/package.json +24 -49
- package/preset.js +1 -1
- package/dist/index.mjs +0 -2
- package/dist/node/index.mjs +0 -3
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
# Storybook for React & Vite
|
|
2
2
|
|
|
3
|
-
|
|
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_sxlqeh4uf3f from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_sxlqeh4uf3f from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_sxlqeh4uf3f from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_sxlqeh4uf3f.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_sxlqeh4uf3f.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_sxlqeh4uf3f.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_sxlqeh4uf3f from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_sxlqeh4uf3f from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_sxlqeh4uf3f from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_sxlqeh4uf3f.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_sxlqeh4uf3f.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_sxlqeh4uf3f.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-S3I4ISWP.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
|
|
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
|
-
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@storybook/react";
|
|
3
|
+
import { __definePreview } from "@storybook/react";
|
|
4
|
+
export {
|
|
5
|
+
__definePreview as definePreview
|
|
6
|
+
};
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,8 +1,49 @@
|
|
|
1
|
-
import { StorybookConfig } from '
|
|
2
|
-
import '@storybook/
|
|
3
|
-
import '
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
package/dist/node/index.js
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_sxlqeh4uf3f from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_sxlqeh4uf3f from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_sxlqeh4uf3f from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_sxlqeh4uf3f.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_sxlqeh4uf3f.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_sxlqeh4uf3f.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-S3I4ISWP.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 {
|
|
3
|
-
import '@
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_sxlqeh4uf3f from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_sxlqeh4uf3f from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_sxlqeh4uf3f from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_sxlqeh4uf3f.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_sxlqeh4uf3f.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_sxlqeh4uf3f.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-S3I4ISWP.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-MISGQNYC.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": "
|
|
4
|
-
"description": "Storybook for React and Vite: Develop
|
|
3
|
+
"version": "10.0.0-beta.0",
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
|
|
42
|
-
|
|
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/
|
|
67
|
-
"prep": "jiti ../../../scripts/
|
|
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": "
|
|
73
|
-
"@storybook/react": "
|
|
58
|
+
"@storybook/builder-vite": "10.0.0-beta.0",
|
|
59
|
+
"@storybook/react": "10.0.0-beta.0",
|
|
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": "^
|
|
69
|
+
"vite": "^7.0.4"
|
|
84
70
|
},
|
|
85
71
|
"peerDependencies": {
|
|
86
|
-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
|
87
|
-
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
|
88
|
-
"storybook": "^
|
|
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.0",
|
|
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
|
-
"
|
|
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
|
-
|
|
1
|
+
export * from './dist/preset.js';
|
package/dist/index.mjs
DELETED
package/dist/node/index.mjs
DELETED