@storybook/react-vite 10.5.7 → 10.5.8

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,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_uizhuxwwe4k from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_uizhuxwwe4k from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_uizhuxwwe4k from "node:module";
1
+ import CJS_COMPAT_NODE_URL_0ncu43qzr9da from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_0ncu43qzr9da from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_0ncu43qzr9da from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_uizhuxwwe4k.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_uizhuxwwe4k.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_uizhuxwwe4k.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_0ncu43qzr9da.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_0ncu43qzr9da.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_0ncu43qzr9da.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -12,11 +12,10 @@ var require = CJS_COMPAT_NODE_MODULE_uizhuxwwe4k.createRequire(import.meta.url);
12
12
 
13
13
  // src/plugins/react-docgen.ts
14
14
  import { existsSync } from "node:fs";
15
- import { relative, sep } from "node:path";
16
- import { getProjectRoot } from "storybook/internal/common";
15
+ import { dirname, relative, sep } from "node:path";
16
+ import { findTsconfigPathForFile } from "storybook/internal/common";
17
17
  import { logger } from "storybook/internal/node-logger";
18
18
  import { createFilter } from "@rollup/pluginutils";
19
- import * as find from "empathic/find";
20
19
  import MagicString from "magic-string";
21
20
  import {
22
21
  ERROR_CODES,
@@ -125,18 +124,14 @@ async function reactDocgen({
125
124
  include = /\.(mjs|tsx?|jsx?)$/,
126
125
  exclude = [/node_modules\/.*/]
127
126
  } = {}) {
128
- let cwd = process.cwd(), filter = createFilter(include, exclude), projectRoot = getProjectRoot(), tsconfigPath = find.up("tsconfig.json", { cwd, last: projectRoot }) ?? find.up("tsconfig.base.json", { cwd, last: projectRoot }) ?? find.up("tsconfig.app.json", { cwd, last: projectRoot }), tsconfig = TsconfigPaths.loadConfig(tsconfigPath), matchPath;
129
- return tsconfig.resultType === "success" && (logger.debug("Using tsconfig paths for react-docgen"), matchPath = TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths, [
130
- "browser",
131
- "module",
132
- "main"
133
- ])), {
127
+ let cwd = process.cwd(), filter = createFilter(include, exclude);
128
+ return {
134
129
  name: "storybook:react-docgen-plugin",
135
130
  enforce: "pre",
136
131
  async transform(src, id) {
137
132
  if (filter(relative(cwd, id)))
138
133
  try {
139
- let docgenResults = parse(src, {
134
+ let matchPath = createTsconfigMatchPath(id), docgenResults = parse(src, {
140
135
  resolver: defaultResolver,
141
136
  handlers,
142
137
  importer: getReactDocgenImporter(matchPath),
@@ -176,6 +171,25 @@ function getReactDocgenImporter(matchPath) {
176
171
  throw new ReactDocgenResolveError(filename);
177
172
  });
178
173
  }
174
+ var matchPathByTsconfigPath = /* @__PURE__ */ new Map();
175
+ function createTsconfigMatchPath(filePath) {
176
+ let tsconfigPath = findTsconfigPathForFile(dirname(filePath), filePath);
177
+ if (!tsconfigPath)
178
+ return;
179
+ let cached = matchPathByTsconfigPath.get(tsconfigPath);
180
+ if (cached)
181
+ return cached;
182
+ let tsconfig = TsconfigPaths.loadConfig(tsconfigPath);
183
+ if (tsconfig.resultType !== "success")
184
+ return;
185
+ logger.debug("Using tsconfig paths for react-docgen");
186
+ let matchPath = TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths, [
187
+ "browser",
188
+ "module",
189
+ "main"
190
+ ]);
191
+ return matchPathByTsconfigPath.set(tsconfigPath, matchPath), matchPath;
192
+ }
179
193
  export {
180
194
  getReactDocgenImporter,
181
195
  reactDocgen
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_uizhuxwwe4k from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_uizhuxwwe4k from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_uizhuxwwe4k from "node:module";
1
+ import CJS_COMPAT_NODE_URL_0ncu43qzr9da from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_0ncu43qzr9da from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_0ncu43qzr9da from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_uizhuxwwe4k.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_uizhuxwwe4k.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_uizhuxwwe4k.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_0ncu43qzr9da.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_0ncu43qzr9da.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_0ncu43qzr9da.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_uizhuxwwe4k from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_uizhuxwwe4k from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_uizhuxwwe4k from "node:module";
1
+ import CJS_COMPAT_NODE_URL_0ncu43qzr9da from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_0ncu43qzr9da from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_0ncu43qzr9da from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_uizhuxwwe4k.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_uizhuxwwe4k.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_uizhuxwwe4k.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_0ncu43qzr9da.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_0ncu43qzr9da.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_0ncu43qzr9da.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -33,7 +33,7 @@ var core = {
33
33
  savePropValueAsString: !0
34
34
  })
35
35
  ), typeof reactDocgenOption == "string") {
36
- let { reactDocgen } = await import("./_node-chunks/react-docgen-HWYGN7W4.js");
36
+ let { reactDocgen } = await import("./_node-chunks/react-docgen-HIS4HSYC.js");
37
37
  plugins.unshift(
38
38
  // If react-docgen is specified, use it for everything, otherwise only use it for non-typescript files
39
39
  await reactDocgen({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-vite",
3
- "version": "10.5.7",
3
+ "version": "10.5.8",
4
4
  "description": "Storybook for React and Vite: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
6
  "storybook",
@@ -54,8 +54,8 @@
54
54
  "dependencies": {
55
55
  "@joshwooding/vite-plugin-react-docgen-typescript": "^0.7.0",
56
56
  "@rollup/pluginutils": "^5.0.2",
57
- "@storybook/builder-vite": "10.5.7",
58
- "@storybook/react": "10.5.7",
57
+ "@storybook/builder-vite": "10.5.8",
58
+ "@storybook/react": "10.5.8",
59
59
  "empathic": "^2.0.0",
60
60
  "magic-string": "^0.30.0",
61
61
  "react-docgen": "^8.0.2",
@@ -70,7 +70,7 @@
70
70
  "peerDependencies": {
71
71
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
72
72
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
73
- "storybook": "^10.5.7",
73
+ "storybook": "^10.5.8",
74
74
  "typescript": ">= 4.9.x",
75
75
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
76
76
  },