@storybook/preset-react-webpack 10.5.6 → 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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_gtaiolanzal from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_gtaiolanzal from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_gtaiolanzal from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_gtaiolanzal.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_gtaiolanzal.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_gtaiolanzal.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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_gtaiolanzal from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_gtaiolanzal from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_gtaiolanzal from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_gtaiolanzal.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_gtaiolanzal.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_gtaiolanzal.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
import { PresetProperty } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
|
|
1
|
+
import { PresetProperty } from "storybook/internal/types";
|
|
2
|
+
import { BuilderResult, StorybookConfig as StorybookConfig$1, TypescriptOptions as TypescriptOptions$1, WebpackConfiguration } from "@storybook/core-webpack";
|
|
3
|
+
import { PluginOptions } from "@storybook/react-docgen-typescript-plugin";
|
|
5
4
|
|
|
5
|
+
//#region code/presets/react-webpack/.dts-emit/code/presets/react-webpack/src/types.d.ts
|
|
6
6
|
interface ReactOptions {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
strictMode?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Use React's legacy root API to mount components
|
|
10
|
+
*
|
|
11
|
+
* React has introduced a new root API with React 18.x to enable a whole set of new features (e.g.
|
|
12
|
+
* concurrent features) If this flag is true, the legacy Root API is used to mount components to
|
|
13
|
+
* make it easier to migrate step by step to React 18.
|
|
14
|
+
*
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
legacyRootApi?: boolean;
|
|
18
18
|
}
|
|
19
19
|
type TypescriptOptions = TypescriptOptions$1 & {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Sets the type of Docgen when working with React and TypeScript
|
|
22
|
+
*
|
|
23
|
+
* @default `'react-docgen'`
|
|
24
|
+
*/
|
|
25
|
+
reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
|
|
26
|
+
/**
|
|
27
|
+
* Configures `react-docgen-typescript-plugin`
|
|
28
|
+
*
|
|
29
|
+
* @default
|
|
30
|
+
* @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
|
|
31
|
+
*/
|
|
32
|
+
reactDocgenTypescriptOptions: PluginOptions;
|
|
33
33
|
};
|
|
34
34
|
type StorybookConfig<TWebpackConfiguration = WebpackConfiguration> = StorybookConfig$1<TWebpackConfiguration> & {
|
|
35
|
-
|
|
35
|
+
typescript?: Partial<TypescriptOptions>;
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region code/presets/react-webpack/.dts-emit/code/presets/react-webpack/src/index.d.ts
|
|
38
39
|
declare const addons: PresetProperty<'addons'>;
|
|
39
|
-
|
|
40
|
-
export { type ReactOptions,
|
|
40
|
+
//#endregion
|
|
41
|
+
export { type BuilderResult, ReactOptions, StorybookConfig, TypescriptOptions, addons };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_gtaiolanzal from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_gtaiolanzal from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_gtaiolanzal from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_gtaiolanzal.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_gtaiolanzal.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_gtaiolanzal.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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_gtaiolanzal from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_gtaiolanzal from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_gtaiolanzal from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_gtaiolanzal.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_gtaiolanzal.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_gtaiolanzal.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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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]
|
|
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.
|
|
3
|
+
"version": "10.5.8",
|
|
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.
|
|
42
|
+
"@storybook/core-webpack": "10.5.8",
|
|
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.
|
|
60
|
+
"storybook": "^10.5.8"
|
|
61
61
|
},
|
|
62
62
|
"peerDependenciesMeta": {
|
|
63
63
|
"typescript": {
|