@storybook/react-vite 10.1.0-alpha.10 → 10.1.0-alpha.11

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.
@@ -1,17 +1,14 @@
1
- import CJS_COMPAT_NODE_URL_1biedw5rzjx from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_1biedw5rzjx from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_1biedw5rzjx from "node:module";
1
+ import CJS_COMPAT_NODE_URL_6x0q2yvwyyv from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_6x0q2yvwyyv from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_6x0q2yvwyyv from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_1biedw5rzjx.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_1biedw5rzjx.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_1biedw5rzjx.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_6x0q2yvwyyv.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_6x0q2yvwyyv.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_6x0q2yvwyyv.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
- import {
13
- __name
14
- } from "./chunk-VWTIRKS4.js";
15
12
 
16
13
  // src/plugins/react-docgen.ts
17
14
  import { existsSync } from "node:fs";
@@ -31,23 +28,21 @@ import * as TsconfigPaths from "tsconfig-paths";
31
28
 
32
29
  // src/plugins/docgen-handlers/actualNameHandler.ts
33
30
  import { utils } from "react-docgen";
34
- var { getNameOrValue, isReactForwardRefCall } = utils;
35
- var actualNameHandler = /* @__PURE__ */ __name(function actualNameHandler2(documentation, componentDefinition) {
36
- documentation.set("definedInFile", componentDefinition.hub.file.opts.filename);
37
- if ((componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id")) {
31
+ var { getNameOrValue, isReactForwardRefCall } = utils, actualNameHandler = function(documentation, componentDefinition) {
32
+ if (documentation.set("definedInFile", componentDefinition.hub.file.opts.filename), (componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id"))
38
33
  documentation.set(
39
34
  "actualName",
40
35
  getNameOrValue(componentDefinition.get("id"))
41
36
  );
42
- } else if (componentDefinition.isArrowFunctionExpression() || componentDefinition.isFunctionExpression() || isReactForwardRefCall(componentDefinition)) {
37
+ else if (componentDefinition.isArrowFunctionExpression() || componentDefinition.isFunctionExpression() || isReactForwardRefCall(componentDefinition)) {
43
38
  let currentPath = componentDefinition;
44
- while (currentPath.parentPath) {
39
+ for (; currentPath.parentPath; ) {
45
40
  if (currentPath.parentPath.isVariableDeclarator()) {
46
41
  documentation.set("actualName", getNameOrValue(currentPath.parentPath.get("id")));
47
42
  return;
48
43
  }
49
44
  if (currentPath.parentPath.isAssignmentExpression()) {
50
- const leftPath = currentPath.parentPath.get("left");
45
+ let leftPath = currentPath.parentPath.get("left");
51
46
  if (leftPath.isIdentifier() || leftPath.isLiteral()) {
52
47
  documentation.set("actualName", getNameOrValue(leftPath));
53
48
  return;
@@ -57,8 +52,7 @@ var actualNameHandler = /* @__PURE__ */ __name(function actualNameHandler2(docum
57
52
  }
58
53
  documentation.set("actualName", "");
59
54
  }
60
- }, "actualNameHandler");
61
- var actualNameHandler_default = actualNameHandler;
55
+ }, actualNameHandler_default = actualNameHandler;
62
56
 
63
57
  // src/plugins/docgen-resolver.ts
64
58
  import { extname } from "node:path";
@@ -69,11 +63,7 @@ var ReactDocgenResolveError = class extends Error {
69
63
  // the magic string that react-docgen uses to check if a module is ignored
70
64
  this.code = "MODULE_NOT_FOUND";
71
65
  }
72
- static {
73
- __name(this, "ReactDocgenResolveError");
74
- }
75
- };
76
- var RESOLVE_EXTENSIONS = [
66
+ }, RESOLVE_EXTENSIONS = [
77
67
  ".js",
78
68
  ".cts",
79
69
  // These were originally not in the code, I added them
@@ -92,17 +82,16 @@ var RESOLVE_EXTENSIONS = [
92
82
  ".jsx"
93
83
  ];
94
84
  function defaultLookupModule(filename, basedir) {
95
- const resolveOptions = {
85
+ let resolveOptions = {
96
86
  basedir,
97
87
  extensions: RESOLVE_EXTENSIONS,
98
88
  // we do not need to check core modules as we cannot import them anyway
99
- includeCoreModules: false
89
+ includeCoreModules: !1
100
90
  };
101
91
  try {
102
92
  return resolve.sync(filename, resolveOptions);
103
93
  } catch (error) {
104
- const ext = extname(filename);
105
- let newFilename;
94
+ let ext = extname(filename), newFilename;
106
95
  switch (ext) {
107
96
  case ".js":
108
97
  case ".mjs":
@@ -122,93 +111,64 @@ function defaultLookupModule(filename, basedir) {
122
111
  });
123
112
  }
124
113
  }
125
- __name(defaultLookupModule, "defaultLookupModule");
126
114
 
127
115
  // src/plugins/react-docgen.ts
128
- var defaultHandlers = Object.values(docgenHandlers).map((handler) => handler);
129
- var defaultResolver = new docgenResolver.FindExportedDefinitionsResolver();
130
- var handlers = [...defaultHandlers, actualNameHandler_default];
116
+ var defaultHandlers = Object.values(docgenHandlers).map((handler) => handler), defaultResolver = new docgenResolver.FindExportedDefinitionsResolver(), handlers = [...defaultHandlers, actualNameHandler_default];
131
117
  async function reactDocgen({
132
118
  include = /\.(mjs|tsx?|jsx?)$/,
133
119
  exclude = [/node_modules\/.*/]
134
120
  } = {}) {
135
- const cwd = process.cwd();
136
- const filter = createFilter(include, exclude);
137
- const tsconfigPath = find.up("tsconfig.json", { cwd, last: getProjectRoot() });
138
- const tsconfig = TsconfigPaths.loadConfig(tsconfigPath);
139
- let matchPath;
140
- if (tsconfig.resultType === "success") {
141
- matchPath = TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths, [
142
- "browser",
143
- "module",
144
- "main"
145
- ]);
146
- }
147
- return {
121
+ let cwd = process.cwd(), filter = createFilter(include, exclude), tsconfigPath = find.up("tsconfig.json", { cwd, last: getProjectRoot() }), tsconfig = TsconfigPaths.loadConfig(tsconfigPath), matchPath;
122
+ return tsconfig.resultType === "success" && (matchPath = TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths, [
123
+ "browser",
124
+ "module",
125
+ "main"
126
+ ])), {
148
127
  name: "storybook:react-docgen-plugin",
149
128
  enforce: "pre",
150
129
  async transform(src, id) {
151
- if (!filter(relative(cwd, id))) {
152
- return;
153
- }
154
- try {
155
- const docgenResults = parse(src, {
156
- resolver: defaultResolver,
157
- handlers,
158
- importer: getReactDocgenImporter(matchPath),
159
- filename: id
160
- });
161
- const s = new MagicString(src);
162
- docgenResults.forEach((info) => {
163
- const { actualName, definedInFile, ...docgenInfo } = info;
164
- if (actualName && definedInFile == id) {
165
- const docNode = JSON.stringify(docgenInfo);
166
- s.append(`;${actualName}.__docgenInfo=${docNode}`);
167
- }
168
- });
169
- return {
170
- code: s.toString(),
171
- map: s.generateMap({ hires: true, source: id })
172
- };
173
- } catch (e) {
174
- if (e.code === ERROR_CODES.MISSING_DEFINITION) {
175
- return;
130
+ if (filter(relative(cwd, id)))
131
+ try {
132
+ let docgenResults = parse(src, {
133
+ resolver: defaultResolver,
134
+ handlers,
135
+ importer: getReactDocgenImporter(matchPath),
136
+ filename: id
137
+ }), s = new MagicString(src);
138
+ return docgenResults.forEach((info) => {
139
+ let { actualName, definedInFile, ...docgenInfo } = info;
140
+ if (actualName && definedInFile == id) {
141
+ let docNode = JSON.stringify(docgenInfo);
142
+ s.append(`;${actualName}.__docgenInfo=${docNode}`);
143
+ }
144
+ }), {
145
+ code: s.toString(),
146
+ map: s.generateMap({ hires: !0, source: id })
147
+ };
148
+ } catch (e) {
149
+ if (e.code === ERROR_CODES.MISSING_DEFINITION)
150
+ return;
151
+ throw e;
176
152
  }
177
- throw e;
178
- }
179
153
  }
180
154
  };
181
155
  }
182
- __name(reactDocgen, "reactDocgen");
183
156
  function getReactDocgenImporter(matchPath) {
184
157
  return makeFsImporter((filename, basedir) => {
185
- const mappedFilenameByPaths = (() => {
186
- if (matchPath) {
187
- const match = matchPath(filename);
188
- return match || filename;
189
- } else {
190
- return filename;
191
- }
192
- })();
193
- const result = defaultLookupModule(mappedFilenameByPaths, basedir);
158
+ let mappedFilenameByPaths = matchPath && matchPath(filename) || filename, result = defaultLookupModule(mappedFilenameByPaths, basedir);
194
159
  if (result.includes(`${sep}react-native${sep}index.js`)) {
195
- const replaced = result.replace(
160
+ let replaced = result.replace(
196
161
  `${sep}react-native${sep}index.js`,
197
162
  `${sep}react-native-web${sep}dist${sep}index.js`
198
163
  );
199
- if (existsSync(replaced)) {
200
- if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext))) {
201
- return replaced;
202
- }
203
- }
164
+ if (existsSync(replaced) && RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext)))
165
+ return replaced;
204
166
  }
205
- if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext))) {
167
+ if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext)))
206
168
  return result;
207
- }
208
169
  throw new ReactDocgenResolveError(filename);
209
170
  });
210
171
  }
211
- __name(getReactDocgenImporter, "getReactDocgenImporter");
212
172
  export {
213
173
  getReactDocgenImporter,
214
174
  reactDocgen
@@ -1,23 +1,19 @@
1
- import CJS_COMPAT_NODE_URL_1biedw5rzjx from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_1biedw5rzjx from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_1biedw5rzjx from "node:module";
1
+ import CJS_COMPAT_NODE_URL_6x0q2yvwyyv from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_6x0q2yvwyyv from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_6x0q2yvwyyv from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_1biedw5rzjx.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_1biedw5rzjx.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_1biedw5rzjx.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_6x0q2yvwyyv.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_6x0q2yvwyyv.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_6x0q2yvwyyv.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
- import {
13
- __name
14
- } from "../_node-chunks/chunk-VWTIRKS4.js";
15
12
 
16
13
  // src/node/index.ts
17
14
  function defineMain(config) {
18
15
  return config;
19
16
  }
20
- __name(defineMain, "defineMain");
21
17
  export {
22
18
  defineMain
23
19
  };
package/dist/preset.js CHANGED
@@ -1,47 +1,37 @@
1
- import CJS_COMPAT_NODE_URL_1biedw5rzjx from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_1biedw5rzjx from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_1biedw5rzjx from "node:module";
1
+ import CJS_COMPAT_NODE_URL_6x0q2yvwyyv from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_6x0q2yvwyyv from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_6x0q2yvwyyv from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_1biedw5rzjx.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_1biedw5rzjx.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_1biedw5rzjx.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_6x0q2yvwyyv.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_6x0q2yvwyyv.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_6x0q2yvwyyv.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
- import {
13
- __name
14
- } from "./_node-chunks/chunk-VWTIRKS4.js";
15
12
 
16
13
  // src/preset.ts
17
14
  var core = {
18
15
  builder: import.meta.resolve("@storybook/builder-vite"),
19
16
  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(
17
+ }, viteFinal = async (config, { presets }) => {
18
+ let plugins = [...config?.plugins ?? []], { reactDocgen: reactDocgenOption, reactDocgenTypescriptOptions } = await presets.apply(
24
19
  "typescript",
25
20
  {}
26
- );
27
- let typescriptPresent;
21
+ ), typescriptPresent;
28
22
  try {
29
- import.meta.resolve("typescript");
30
- typescriptPresent = true;
31
- } catch (e) {
32
- typescriptPresent = false;
23
+ import.meta.resolve("typescript"), typescriptPresent = !0;
24
+ } catch {
25
+ typescriptPresent = !1;
33
26
  }
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-633W46WC.js");
27
+ if (reactDocgenOption === "react-docgen-typescript" && typescriptPresent && plugins.push(
28
+ (await import("@joshwooding/vite-plugin-react-docgen-typescript")).default({
29
+ ...reactDocgenTypescriptOptions,
30
+ // We *need* this set so that RDT returns default values in the same format as react-docgen
31
+ savePropValueAsString: !0
32
+ })
33
+ ), typeof reactDocgenOption == "string") {
34
+ let { reactDocgen } = await import("./_node-chunks/react-docgen-BDT2FE6V.js");
45
35
  plugins.unshift(
46
36
  // If react-docgen is specified, use it for everything, otherwise only use it for non-typescript files
47
37
  await reactDocgen({
@@ -50,7 +40,7 @@ var viteFinal = /* @__PURE__ */ __name(async (config, { presets }) => {
50
40
  );
51
41
  }
52
42
  return { ...config, plugins };
53
- }, "viteFinal");
43
+ };
54
44
  export {
55
45
  core,
56
46
  viteFinal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-vite",
3
- "version": "10.1.0-alpha.10",
3
+ "version": "10.1.0-alpha.11",
4
4
  "description": "Storybook for React and Vite: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
6
  "storybook",
@@ -55,8 +55,8 @@
55
55
  "dependencies": {
56
56
  "@joshwooding/vite-plugin-react-docgen-typescript": "0.6.1",
57
57
  "@rollup/pluginutils": "^5.0.2",
58
- "@storybook/builder-vite": "10.1.0-alpha.10",
59
- "@storybook/react": "10.1.0-alpha.10",
58
+ "@storybook/builder-vite": "10.1.0-alpha.11",
59
+ "@storybook/react": "10.1.0-alpha.11",
60
60
  "empathic": "^2.0.0",
61
61
  "magic-string": "^0.30.0",
62
62
  "react-docgen": "^8.0.0",
@@ -71,11 +71,11 @@
71
71
  "peerDependencies": {
72
72
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
73
73
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
74
- "storybook": "^10.1.0-alpha.10",
74
+ "storybook": "^10.1.0-alpha.11",
75
75
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
76
76
  },
77
77
  "publishConfig": {
78
78
  "access": "public"
79
79
  },
80
- "gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae17"
80
+ "gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae1l"
81
81
  }
@@ -1,17 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_1biedw5rzjx from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_1biedw5rzjx from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_1biedw5rzjx from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_1biedw5rzjx.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_1biedw5rzjx.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_1biedw5rzjx.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
- };