@storybook/preset-react-webpack 10.5.7 → 10.5.9

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_5irnw2daxkk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_5irnw2daxkk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_5irnw2daxkk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_xx067yh45tl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_xx067yh45tl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_xx067yh45tl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_5irnw2daxkk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_5irnw2daxkk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_5irnw2daxkk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_xx067yh45tl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_xx067yh45tl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_xx067yh45tl.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_5irnw2daxkk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_5irnw2daxkk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_5irnw2daxkk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_xx067yh45tl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_xx067yh45tl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_xx067yh45tl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_5irnw2daxkk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_5irnw2daxkk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_5irnw2daxkk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_xx067yh45tl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_xx067yh45tl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_xx067yh45tl.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_5irnw2daxkk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_5irnw2daxkk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_5irnw2daxkk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_xx067yh45tl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_xx067yh45tl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_xx067yh45tl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_5irnw2daxkk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_5irnw2daxkk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_5irnw2daxkk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_xx067yh45tl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_xx067yh45tl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_xx067yh45tl.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,48 +1,19 @@
1
- import CJS_COMPAT_NODE_URL_5irnw2daxkk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_5irnw2daxkk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_5irnw2daxkk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_xx067yh45tl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_xx067yh45tl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_xx067yh45tl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_5irnw2daxkk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_5irnw2daxkk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_5irnw2daxkk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_xx067yh45tl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_xx067yh45tl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_xx067yh45tl.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
 
13
13
  // src/loaders/react-docgen-loader.ts
14
- import { getProjectRoot } from "storybook/internal/common";
15
- import { logger } from "storybook/internal/node-logger";
16
-
17
- // ../../../node_modules/empathic/find.mjs
18
- import { join as join2 } from "node:path";
19
- import { existsSync, statSync } from "node:fs";
20
-
21
- // ../../../node_modules/empathic/walk.mjs
22
14
  import { dirname } from "node:path";
23
-
24
- // ../../../node_modules/empathic/resolve.mjs
25
- import { isAbsolute, join, resolve } from "node:path";
26
- function absolute(input, root) {
27
- return isAbsolute(input) ? input : resolve(root || ".", input);
28
- }
29
-
30
- // ../../../node_modules/empathic/walk.mjs
31
- function up(base, options) {
32
- let { last, cwd } = options || {}, tmp = absolute(base, cwd), root = absolute(last || "/", cwd), prev, arr = [];
33
- for (; prev !== root && (arr.push(tmp), tmp = dirname(prev = tmp), tmp !== prev); )
34
- ;
35
- return arr;
36
- }
37
-
38
- // ../../../node_modules/empathic/find.mjs
39
- function up2(name, options) {
40
- let dir, tmp, start = options && options.cwd || "";
41
- for (dir of up(start, options))
42
- if (tmp = join2(dir, name), existsSync(tmp)) return tmp;
43
- }
44
-
45
- // src/loaders/react-docgen-loader.ts
15
+ import { findTsconfigPathForFile } from "storybook/internal/common";
16
+ import { logger } from "storybook/internal/node-logger";
46
17
  import MagicString from "magic-string";
47
18
  import {
48
19
  ERROR_CODES,
@@ -56,7 +27,7 @@ import * as TsconfigPaths from "tsconfig-paths";
56
27
 
57
28
  // src/loaders/docgen-resolver.ts
58
29
  import { extname } from "node:path";
59
- import resolve2 from "resolve";
30
+ import resolve from "resolve";
60
31
  var ReactDocgenResolveError = class extends Error {
61
32
  constructor(filename) {
62
33
  super(`'${filename}' was ignored by react-docgen.`);
@@ -89,7 +60,7 @@ function defaultLookupModule(filename, basedir) {
89
60
  includeCoreModules: !1
90
61
  };
91
62
  try {
92
- return resolve2.sync(filename, resolveOptions);
63
+ return resolve.sync(filename, resolveOptions);
93
64
  } catch (error) {
94
65
  let ext = extname(filename), newFilename;
95
66
  switch (ext) {
@@ -98,7 +69,7 @@ function defaultLookupModule(filename, basedir) {
98
69
  case ".cjs": {
99
70
  let base = filename.slice(0, -2);
100
71
  try {
101
- return resolve2.sync(`${base}ts`, { ...resolveOptions, extensions: [] });
72
+ return resolve.sync(`${base}ts`, { ...resolveOptions, extensions: [] });
102
73
  } catch {
103
74
  newFilename = `${base}tsx`;
104
75
  }
@@ -110,7 +81,7 @@ function defaultLookupModule(filename, basedir) {
110
81
  default:
111
82
  throw error;
112
83
  }
113
- return resolve2.sync(newFilename, {
84
+ return resolve.sync(newFilename, {
114
85
  ...resolveOptions,
115
86
  // we already know that there is an extension at this point, so no need to check other extensions
116
87
  extensions: []
@@ -143,19 +114,11 @@ var { getNameOrValue, isReactForwardRefCall } = utils, actualNameHandler = funct
143
114
  }
144
115
  documentation.set("actualName", "");
145
116
  }
146
- }, defaultHandlers = Object.values(docgenHandlers).map((handler) => handler), defaultResolver = new docgenResolver.FindExportedDefinitionsResolver(), handlers = [...defaultHandlers, actualNameHandler], tsconfigPathsInitialized = !1, matchPath;
117
+ }, defaultHandlers = Object.values(docgenHandlers).map((handler) => handler), defaultResolver = new docgenResolver.FindExportedDefinitionsResolver(), handlers = [...defaultHandlers, actualNameHandler];
147
118
  async function reactDocgenLoader(source, map) {
148
119
  let callback = this.async(), options = this.getOptions() || {}, { debug = !1 } = options;
149
- if (!tsconfigPathsInitialized) {
150
- let projectRoot = getProjectRoot(), cwd = process.cwd(), tsconfigPath = up2("tsconfig.json", { cwd, last: projectRoot }) ?? up2("tsconfig.base.json", { cwd, last: projectRoot }) ?? up2("tsconfig.app.json", { cwd, last: projectRoot }), tsconfig = TsconfigPaths.loadConfig(tsconfigPath);
151
- tsconfig.resultType === "success" && (logger.debug("Using tsconfig paths for react-docgen"), matchPath = TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths, [
152
- "browser",
153
- "module",
154
- "main"
155
- ])), tsconfigPathsInitialized = !0;
156
- }
157
120
  try {
158
- let docgenResults = parse(source, {
121
+ let matchPath = createTsconfigMatchPath(this.resourcePath), docgenResults = parse(source, {
159
122
  filename: this.resourcePath,
160
123
  resolver: defaultResolver,
161
124
  handlers,
@@ -196,6 +159,25 @@ function getReactDocgenImporter(matchingPath) {
196
159
  throw new ReactDocgenResolveError(filename);
197
160
  });
198
161
  }
162
+ var matchPathByTsconfigPath = /* @__PURE__ */ new Map();
163
+ function createTsconfigMatchPath(filePath) {
164
+ let tsconfigPath = findTsconfigPathForFile(dirname(filePath), filePath);
165
+ if (!tsconfigPath)
166
+ return;
167
+ let cached = matchPathByTsconfigPath.get(tsconfigPath);
168
+ if (cached)
169
+ return cached;
170
+ let tsconfig = TsconfigPaths.loadConfig(tsconfigPath);
171
+ if (tsconfig.resultType !== "success")
172
+ return;
173
+ logger.debug("Using tsconfig paths for react-docgen");
174
+ let matchPath = TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths, [
175
+ "browser",
176
+ "module",
177
+ "main"
178
+ ]);
179
+ return matchPathByTsconfigPath.set(tsconfigPath, matchPath), matchPath;
180
+ }
199
181
  export {
200
182
  reactDocgenLoader as default,
201
183
  getReactDocgenImporter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/preset-react-webpack",
3
- "version": "10.5.7",
3
+ "version": "10.5.9",
4
4
  "description": "Storybook for React: Develop React Component in isolation with Hot Reloading",
5
5
  "keywords": [
6
6
  "storybook"
@@ -39,7 +39,7 @@
39
39
  "!src/**/*"
40
40
  ],
41
41
  "dependencies": {
42
- "@storybook/core-webpack": "10.5.7",
42
+ "@storybook/core-webpack": "10.5.9",
43
43
  "@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.0c3f3b7.0",
44
44
  "@types/semver": "^7.7.1",
45
45
  "magic-string": "^0.30.5",
@@ -57,7 +57,7 @@
57
57
  "peerDependencies": {
58
58
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
59
59
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
60
- "storybook": "^10.5.7"
60
+ "storybook": "^10.5.9"
61
61
  },
62
62
  "peerDependenciesMeta": {
63
63
  "typescript": {