storybook-react-rsbuild 0.0.1-beta.0 → 0.0.1
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/LICENSE +1 -1
- package/README.md +1 -3
- package/dist/index-8cba017d.d.ts +1249 -0
- package/dist/index.d.ts +5 -2
- package/dist/loaders/react-docgen-loader.d.ts +10 -0
- package/dist/loaders/react-docgen-loader.js +217 -0
- package/dist/loaders/react-docgen-loader.mjs +179 -0
- package/dist/preset.d.ts +10 -2
- package/dist/preset.js +1 -1
- package/package.json +20 -8
- package/dist/chunk-77YOQVQO.mjs +0 -17
- package/dist/chunk-TNRF4JXJ.mjs +0 -80
- package/dist/chunk-WBQAMGXK.mjs +0 -0
- package/dist/preset.mjs +0 -25
- package/dist/react-docs.js +0 -116
- package/dist/react-docs.mjs +0 -7
- package/dist/requirer.js +0 -32
- package/dist/requirer.mjs +0 -6
- package/dist/types.js +0 -18
- package/dist/types.mjs +0 -1
package/dist/index.d.ts
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
import * as react_docgen from 'react-docgen';
|
2
|
+
import * as TsconfigPaths from 'tsconfig-paths';
|
3
|
+
import { LoaderContext } from 'webpack';
|
4
|
+
|
5
|
+
declare function reactDocgenLoader(this: LoaderContext<{
|
6
|
+
debug: boolean;
|
7
|
+
}>, source: string): Promise<void>;
|
8
|
+
declare function getReactDocgenImporter(matchingPath: TsconfigPaths.MatchPath | undefined): react_docgen.Importer;
|
9
|
+
|
10
|
+
export { reactDocgenLoader as default, getReactDocgenImporter };
|
@@ -0,0 +1,217 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
|
30
|
+
// src/loaders/react-docgen-loader.ts
|
31
|
+
var react_docgen_loader_exports = {};
|
32
|
+
__export(react_docgen_loader_exports, {
|
33
|
+
default: () => reactDocgenLoader,
|
34
|
+
getReactDocgenImporter: () => getReactDocgenImporter
|
35
|
+
});
|
36
|
+
module.exports = __toCommonJS(react_docgen_loader_exports);
|
37
|
+
var import_react_docgen = require("react-docgen");
|
38
|
+
var TsconfigPaths = __toESM(require("tsconfig-paths"));
|
39
|
+
var import_find_up = __toESM(require("find-up"));
|
40
|
+
var import_magic_string = __toESM(require("magic-string"));
|
41
|
+
var import_node_logger = require("@storybook/node-logger");
|
42
|
+
|
43
|
+
// src/loaders/docgen-resolver.ts
|
44
|
+
var import_path = require("path");
|
45
|
+
var import_resolve = __toESM(require("resolve"));
|
46
|
+
var ReactDocgenResolveError = class extends Error {
|
47
|
+
constructor(filename) {
|
48
|
+
super(`'${filename}' was ignored by react-docgen.`);
|
49
|
+
// the magic string that react-docgen uses to check if a module is ignored
|
50
|
+
this.code = "MODULE_NOT_FOUND";
|
51
|
+
}
|
52
|
+
};
|
53
|
+
var RESOLVE_EXTENSIONS = [
|
54
|
+
".js",
|
55
|
+
".cts",
|
56
|
+
// These were originally not in the code, I added them
|
57
|
+
".mts",
|
58
|
+
// These were originally not in the code, I added them
|
59
|
+
".ctsx",
|
60
|
+
// These were originally not in the code, I added them
|
61
|
+
".mtsx",
|
62
|
+
// These were originally not in the code, I added them
|
63
|
+
".ts",
|
64
|
+
".tsx",
|
65
|
+
".mjs",
|
66
|
+
".cjs",
|
67
|
+
".mts",
|
68
|
+
".cts",
|
69
|
+
".jsx"
|
70
|
+
];
|
71
|
+
function defaultLookupModule(filename, basedir) {
|
72
|
+
const resolveOptions = {
|
73
|
+
basedir,
|
74
|
+
extensions: RESOLVE_EXTENSIONS,
|
75
|
+
// we do not need to check core modules as we cannot import them anyway
|
76
|
+
includeCoreModules: false
|
77
|
+
};
|
78
|
+
try {
|
79
|
+
return import_resolve.default.sync(filename, resolveOptions);
|
80
|
+
} catch (error) {
|
81
|
+
const ext = (0, import_path.extname)(filename);
|
82
|
+
let newFilename;
|
83
|
+
switch (ext) {
|
84
|
+
case ".js":
|
85
|
+
case ".mjs":
|
86
|
+
case ".cjs":
|
87
|
+
newFilename = `${filename.slice(0, -2)}ts`;
|
88
|
+
break;
|
89
|
+
case ".jsx":
|
90
|
+
newFilename = `${filename.slice(0, -3)}tsx`;
|
91
|
+
break;
|
92
|
+
default:
|
93
|
+
throw error;
|
94
|
+
}
|
95
|
+
return import_resolve.default.sync(newFilename, {
|
96
|
+
...resolveOptions,
|
97
|
+
// we already know that there is an extension at this point, so no need to check other extensions
|
98
|
+
extensions: []
|
99
|
+
});
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
// src/loaders/react-docgen-loader.ts
|
104
|
+
var { getNameOrValue, isReactForwardRefCall } = import_react_docgen.utils;
|
105
|
+
var actualNameHandler = function actualNameHandler2(documentation, componentDefinition) {
|
106
|
+
if ((componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id")) {
|
107
|
+
documentation.set(
|
108
|
+
"actualName",
|
109
|
+
getNameOrValue(componentDefinition.get("id"))
|
110
|
+
);
|
111
|
+
} else if (componentDefinition.isArrowFunctionExpression() || componentDefinition.isFunctionExpression() || isReactForwardRefCall(componentDefinition)) {
|
112
|
+
let currentPath = componentDefinition;
|
113
|
+
while (currentPath.parentPath) {
|
114
|
+
if (currentPath.parentPath.isVariableDeclarator()) {
|
115
|
+
documentation.set(
|
116
|
+
"actualName",
|
117
|
+
getNameOrValue(currentPath.parentPath.get("id"))
|
118
|
+
);
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
if (currentPath.parentPath.isAssignmentExpression()) {
|
122
|
+
const leftPath = currentPath.parentPath.get("left");
|
123
|
+
if (leftPath.isIdentifier() || leftPath.isLiteral()) {
|
124
|
+
documentation.set("actualName", getNameOrValue(leftPath));
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
currentPath = currentPath.parentPath;
|
129
|
+
}
|
130
|
+
documentation.set("actualName", "");
|
131
|
+
}
|
132
|
+
};
|
133
|
+
var defaultHandlers = Object.values(import_react_docgen.builtinHandlers).map((handler) => handler);
|
134
|
+
var defaultResolver = new import_react_docgen.builtinResolvers.FindExportedDefinitionsResolver();
|
135
|
+
var handlers = [...defaultHandlers, actualNameHandler];
|
136
|
+
var tsconfigPathsInitialized = false;
|
137
|
+
var matchPath;
|
138
|
+
async function reactDocgenLoader(source) {
|
139
|
+
const callback = this.async();
|
140
|
+
const options = this.getOptions() || {};
|
141
|
+
const { debug = false } = options;
|
142
|
+
if (!tsconfigPathsInitialized) {
|
143
|
+
const tsconfigPath = await (0, import_find_up.default)("tsconfig.json", { cwd: process.cwd() });
|
144
|
+
const tsconfig = TsconfigPaths.loadConfig(tsconfigPath);
|
145
|
+
if (tsconfig.resultType === "success") {
|
146
|
+
import_node_logger.logger.info("Using tsconfig paths for react-docgen");
|
147
|
+
matchPath = TsconfigPaths.createMatchPath(
|
148
|
+
tsconfig.absoluteBaseUrl,
|
149
|
+
tsconfig.paths,
|
150
|
+
["browser", "module", "main"]
|
151
|
+
);
|
152
|
+
}
|
153
|
+
tsconfigPathsInitialized = true;
|
154
|
+
}
|
155
|
+
try {
|
156
|
+
const docgenResults = (0, import_react_docgen.parse)(source, {
|
157
|
+
filename: this.resourcePath,
|
158
|
+
resolver: defaultResolver,
|
159
|
+
handlers,
|
160
|
+
importer: getReactDocgenImporter(matchPath),
|
161
|
+
babelOptions: {
|
162
|
+
babelrc: false,
|
163
|
+
configFile: false
|
164
|
+
}
|
165
|
+
});
|
166
|
+
const magicString = new import_magic_string.default(source);
|
167
|
+
docgenResults.forEach((info) => {
|
168
|
+
const { actualName, ...docgenInfo } = info;
|
169
|
+
if (actualName) {
|
170
|
+
const docNode = JSON.stringify(docgenInfo);
|
171
|
+
magicString.append(`;${actualName}.__docgenInfo=${docNode}`);
|
172
|
+
}
|
173
|
+
});
|
174
|
+
const map = magicString.generateMap({
|
175
|
+
includeContent: true,
|
176
|
+
source: this.resourcePath
|
177
|
+
});
|
178
|
+
callback(null, magicString.toString(), map);
|
179
|
+
} catch (error) {
|
180
|
+
if (error.code === import_react_docgen.ERROR_CODES.MISSING_DEFINITION) {
|
181
|
+
callback(null, source);
|
182
|
+
} else {
|
183
|
+
if (!debug) {
|
184
|
+
import_node_logger.logger.warn(
|
185
|
+
`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`
|
186
|
+
);
|
187
|
+
} else {
|
188
|
+
import_node_logger.logger.warn(
|
189
|
+
`Failed to parse ${this.resourcePath} with react-docgen. Please use the below error message and the content of the file which causes the error to report the issue to the maintainers of react-docgen. https://github.com/reactjs/react-docgen`
|
190
|
+
);
|
191
|
+
import_node_logger.logger.error(error);
|
192
|
+
}
|
193
|
+
callback(null, source);
|
194
|
+
}
|
195
|
+
}
|
196
|
+
}
|
197
|
+
function getReactDocgenImporter(matchingPath) {
|
198
|
+
return (0, import_react_docgen.makeFsImporter)((filename, basedir) => {
|
199
|
+
const mappedFilenameByPaths = (() => {
|
200
|
+
if (matchingPath) {
|
201
|
+
const match = matchingPath(filename);
|
202
|
+
return match || filename;
|
203
|
+
} else {
|
204
|
+
return filename;
|
205
|
+
}
|
206
|
+
})();
|
207
|
+
const result = defaultLookupModule(mappedFilenameByPaths, basedir);
|
208
|
+
if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext))) {
|
209
|
+
return result;
|
210
|
+
}
|
211
|
+
throw new ReactDocgenResolveError(filename);
|
212
|
+
});
|
213
|
+
}
|
214
|
+
// Annotate the CommonJS export names for ESM import in node:
|
215
|
+
0 && (module.exports = {
|
216
|
+
getReactDocgenImporter
|
217
|
+
});
|
@@ -0,0 +1,179 @@
|
|
1
|
+
import { builtinHandlers, builtinResolvers, parse, ERROR_CODES, makeFsImporter, utils } from 'react-docgen';
|
2
|
+
import * as TsconfigPaths from 'tsconfig-paths';
|
3
|
+
import findUp from 'find-up';
|
4
|
+
import MagicString from 'magic-string';
|
5
|
+
import { logger } from '@storybook/node-logger';
|
6
|
+
import { extname } from 'path';
|
7
|
+
import resolve from 'resolve';
|
8
|
+
|
9
|
+
// src/loaders/react-docgen-loader.ts
|
10
|
+
var ReactDocgenResolveError = class extends Error {
|
11
|
+
constructor(filename) {
|
12
|
+
super(`'${filename}' was ignored by react-docgen.`);
|
13
|
+
// the magic string that react-docgen uses to check if a module is ignored
|
14
|
+
this.code = "MODULE_NOT_FOUND";
|
15
|
+
}
|
16
|
+
};
|
17
|
+
var RESOLVE_EXTENSIONS = [
|
18
|
+
".js",
|
19
|
+
".cts",
|
20
|
+
// These were originally not in the code, I added them
|
21
|
+
".mts",
|
22
|
+
// These were originally not in the code, I added them
|
23
|
+
".ctsx",
|
24
|
+
// These were originally not in the code, I added them
|
25
|
+
".mtsx",
|
26
|
+
// These were originally not in the code, I added them
|
27
|
+
".ts",
|
28
|
+
".tsx",
|
29
|
+
".mjs",
|
30
|
+
".cjs",
|
31
|
+
".mts",
|
32
|
+
".cts",
|
33
|
+
".jsx"
|
34
|
+
];
|
35
|
+
function defaultLookupModule(filename, basedir) {
|
36
|
+
const resolveOptions = {
|
37
|
+
basedir,
|
38
|
+
extensions: RESOLVE_EXTENSIONS,
|
39
|
+
// we do not need to check core modules as we cannot import them anyway
|
40
|
+
includeCoreModules: false
|
41
|
+
};
|
42
|
+
try {
|
43
|
+
return resolve.sync(filename, resolveOptions);
|
44
|
+
} catch (error) {
|
45
|
+
const ext = extname(filename);
|
46
|
+
let newFilename;
|
47
|
+
switch (ext) {
|
48
|
+
case ".js":
|
49
|
+
case ".mjs":
|
50
|
+
case ".cjs":
|
51
|
+
newFilename = `${filename.slice(0, -2)}ts`;
|
52
|
+
break;
|
53
|
+
case ".jsx":
|
54
|
+
newFilename = `${filename.slice(0, -3)}tsx`;
|
55
|
+
break;
|
56
|
+
default:
|
57
|
+
throw error;
|
58
|
+
}
|
59
|
+
return resolve.sync(newFilename, {
|
60
|
+
...resolveOptions,
|
61
|
+
// we already know that there is an extension at this point, so no need to check other extensions
|
62
|
+
extensions: []
|
63
|
+
});
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
// src/loaders/react-docgen-loader.ts
|
68
|
+
var { getNameOrValue, isReactForwardRefCall } = utils;
|
69
|
+
var actualNameHandler = function actualNameHandler2(documentation, componentDefinition) {
|
70
|
+
if ((componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id")) {
|
71
|
+
documentation.set(
|
72
|
+
"actualName",
|
73
|
+
getNameOrValue(componentDefinition.get("id"))
|
74
|
+
);
|
75
|
+
} else if (componentDefinition.isArrowFunctionExpression() || componentDefinition.isFunctionExpression() || isReactForwardRefCall(componentDefinition)) {
|
76
|
+
let currentPath = componentDefinition;
|
77
|
+
while (currentPath.parentPath) {
|
78
|
+
if (currentPath.parentPath.isVariableDeclarator()) {
|
79
|
+
documentation.set(
|
80
|
+
"actualName",
|
81
|
+
getNameOrValue(currentPath.parentPath.get("id"))
|
82
|
+
);
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
if (currentPath.parentPath.isAssignmentExpression()) {
|
86
|
+
const leftPath = currentPath.parentPath.get("left");
|
87
|
+
if (leftPath.isIdentifier() || leftPath.isLiteral()) {
|
88
|
+
documentation.set("actualName", getNameOrValue(leftPath));
|
89
|
+
return;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
currentPath = currentPath.parentPath;
|
93
|
+
}
|
94
|
+
documentation.set("actualName", "");
|
95
|
+
}
|
96
|
+
};
|
97
|
+
var defaultHandlers = Object.values(builtinHandlers).map((handler) => handler);
|
98
|
+
var defaultResolver = new builtinResolvers.FindExportedDefinitionsResolver();
|
99
|
+
var handlers = [...defaultHandlers, actualNameHandler];
|
100
|
+
var tsconfigPathsInitialized = false;
|
101
|
+
var matchPath;
|
102
|
+
async function reactDocgenLoader(source) {
|
103
|
+
const callback = this.async();
|
104
|
+
const options = this.getOptions() || {};
|
105
|
+
const { debug = false } = options;
|
106
|
+
if (!tsconfigPathsInitialized) {
|
107
|
+
const tsconfigPath = await findUp("tsconfig.json", { cwd: process.cwd() });
|
108
|
+
const tsconfig = TsconfigPaths.loadConfig(tsconfigPath);
|
109
|
+
if (tsconfig.resultType === "success") {
|
110
|
+
logger.info("Using tsconfig paths for react-docgen");
|
111
|
+
matchPath = TsconfigPaths.createMatchPath(
|
112
|
+
tsconfig.absoluteBaseUrl,
|
113
|
+
tsconfig.paths,
|
114
|
+
["browser", "module", "main"]
|
115
|
+
);
|
116
|
+
}
|
117
|
+
tsconfigPathsInitialized = true;
|
118
|
+
}
|
119
|
+
try {
|
120
|
+
const docgenResults = parse(source, {
|
121
|
+
filename: this.resourcePath,
|
122
|
+
resolver: defaultResolver,
|
123
|
+
handlers,
|
124
|
+
importer: getReactDocgenImporter(matchPath),
|
125
|
+
babelOptions: {
|
126
|
+
babelrc: false,
|
127
|
+
configFile: false
|
128
|
+
}
|
129
|
+
});
|
130
|
+
const magicString = new MagicString(source);
|
131
|
+
docgenResults.forEach((info) => {
|
132
|
+
const { actualName, ...docgenInfo } = info;
|
133
|
+
if (actualName) {
|
134
|
+
const docNode = JSON.stringify(docgenInfo);
|
135
|
+
magicString.append(`;${actualName}.__docgenInfo=${docNode}`);
|
136
|
+
}
|
137
|
+
});
|
138
|
+
const map = magicString.generateMap({
|
139
|
+
includeContent: true,
|
140
|
+
source: this.resourcePath
|
141
|
+
});
|
142
|
+
callback(null, magicString.toString(), map);
|
143
|
+
} catch (error) {
|
144
|
+
if (error.code === ERROR_CODES.MISSING_DEFINITION) {
|
145
|
+
callback(null, source);
|
146
|
+
} else {
|
147
|
+
if (!debug) {
|
148
|
+
logger.warn(
|
149
|
+
`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`
|
150
|
+
);
|
151
|
+
} else {
|
152
|
+
logger.warn(
|
153
|
+
`Failed to parse ${this.resourcePath} with react-docgen. Please use the below error message and the content of the file which causes the error to report the issue to the maintainers of react-docgen. https://github.com/reactjs/react-docgen`
|
154
|
+
);
|
155
|
+
logger.error(error);
|
156
|
+
}
|
157
|
+
callback(null, source);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}
|
161
|
+
function getReactDocgenImporter(matchingPath) {
|
162
|
+
return makeFsImporter((filename, basedir) => {
|
163
|
+
const mappedFilenameByPaths = (() => {
|
164
|
+
if (matchingPath) {
|
165
|
+
const match = matchingPath(filename);
|
166
|
+
return match || filename;
|
167
|
+
} else {
|
168
|
+
return filename;
|
169
|
+
}
|
170
|
+
})();
|
171
|
+
const result = defaultLookupModule(mappedFilenameByPaths, basedir);
|
172
|
+
if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext))) {
|
173
|
+
return result;
|
174
|
+
}
|
175
|
+
throw new ReactDocgenResolveError(filename);
|
176
|
+
});
|
177
|
+
}
|
178
|
+
|
179
|
+
export { reactDocgenLoader as default, getReactDocgenImporter };
|
package/dist/preset.d.ts
CHANGED
@@ -1,2 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import { S as StorybookConfig, P as PresetProperty } from './index-8cba017d.js';
|
2
|
+
import 'storybook-builder-rsbuild';
|
3
|
+
import 'file-system-cache';
|
4
|
+
import 'http';
|
5
|
+
import '@storybook/react-docgen-typescript-plugin';
|
6
|
+
|
7
|
+
declare const rsbuildFinal: StorybookConfig['rsbuildFinal'];
|
8
|
+
declare const core: PresetProperty<'core'>;
|
9
|
+
|
10
|
+
export { core, rsbuildFinal };
|
package/dist/preset.js
CHANGED
@@ -56,7 +56,7 @@ var rsbuildFinalDocs = async (config, options) => {
|
|
56
56
|
enforce: "pre",
|
57
57
|
loader: requirer(
|
58
58
|
require.resolve,
|
59
|
-
"
|
59
|
+
"storybook-react-rsbuild/loaders/react-docgen-loader"
|
60
60
|
),
|
61
61
|
options: {
|
62
62
|
debug
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "storybook-react-rsbuild",
|
3
|
-
"version": "0.0.1
|
3
|
+
"version": "0.0.1",
|
4
4
|
"description": "Storybook for React and Rsbuild: Develop React components in isolation with Hot Reloading.",
|
5
5
|
"keywords": [
|
6
6
|
"storybook"
|
@@ -21,6 +21,10 @@
|
|
21
21
|
"types": "./dist/react-docs.d.ts",
|
22
22
|
"require": "./dist/react-docs.js"
|
23
23
|
},
|
24
|
+
"./loaders/react-docgen-loader": {
|
25
|
+
"types": "./dist/loaders/react-docgen-loader.d.ts",
|
26
|
+
"require": "./dist/loaders/react-docgen-loader.js"
|
27
|
+
},
|
24
28
|
"./package.json": "./package.json"
|
25
29
|
},
|
26
30
|
"main": "dist/index.js",
|
@@ -34,16 +38,22 @@
|
|
34
38
|
"!src/**/*"
|
35
39
|
],
|
36
40
|
"dependencies": {
|
41
|
+
"@rsbuild/core": "0.6.15",
|
37
42
|
"@storybook/docs-tools": "8.0.10",
|
38
|
-
"@storybook/
|
43
|
+
"@storybook/node-logger": "8.0.10",
|
39
44
|
"@storybook/react": "8.0.10",
|
40
|
-
"@
|
45
|
+
"@storybook/react-docgen-typescript-plugin": "1.0.1",
|
41
46
|
"@types/node": "^18.0.0",
|
42
|
-
"
|
47
|
+
"find-up": "^5.0.0",
|
48
|
+
"magic-string": "^0.30.10",
|
49
|
+
"react-docgen": "^7.0.3",
|
50
|
+
"resolve": "^1.22.8",
|
51
|
+
"tsconfig-paths": "^4.2.0",
|
52
|
+
"storybook-builder-rsbuild": "0.0.1"
|
43
53
|
},
|
44
54
|
"peerDependencies": {
|
45
|
-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
46
|
-
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
55
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
|
56
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
|
47
57
|
"typescript": ">= 4.2.x"
|
48
58
|
},
|
49
59
|
"peerDependenciesMeta": {
|
@@ -60,13 +70,15 @@
|
|
60
70
|
"bundler": {
|
61
71
|
"entries": [
|
62
72
|
"./src/index.ts",
|
63
|
-
"./src/preset.ts"
|
73
|
+
"./src/preset.ts",
|
74
|
+
"./src/loaders/react-docgen-loader.ts"
|
64
75
|
],
|
65
76
|
"platform": "node"
|
66
77
|
},
|
67
78
|
"devDependencies": {
|
68
79
|
"@storybook/types": "8.0.10",
|
69
|
-
"add": "^2.0.6"
|
80
|
+
"add": "^2.0.6",
|
81
|
+
"typescript": "^5.3.2"
|
70
82
|
},
|
71
83
|
"scripts": {
|
72
84
|
"check": "node --loader ../../scripts/node_modules/esbuild-register/loader.js -r ../../scripts/node_modules/esbuild-register/register.js ../../scripts/prepare/check.ts",
|
package/dist/chunk-77YOQVQO.mjs
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
3
|
-
}) : x)(function(x) {
|
4
|
-
if (typeof require !== "undefined")
|
5
|
-
return require.apply(this, arguments);
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
7
|
-
});
|
8
|
-
|
9
|
-
// src/requirer.ts
|
10
|
-
function requirer(resolver, path) {
|
11
|
-
return resolver(path);
|
12
|
-
}
|
13
|
-
|
14
|
-
export {
|
15
|
-
__require,
|
16
|
-
requirer
|
17
|
-
};
|
package/dist/chunk-TNRF4JXJ.mjs
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
__require,
|
3
|
-
requirer
|
4
|
-
} from "./chunk-77YOQVQO.mjs";
|
5
|
-
|
6
|
-
// src/react-docs.ts
|
7
|
-
import { hasDocsOrControls } from "@storybook/docs-tools";
|
8
|
-
import { mergeRsbuildConfig } from "@rsbuild/core";
|
9
|
-
var rsbuildFinal = async (config, options) => {
|
10
|
-
if (!hasDocsOrControls(options))
|
11
|
-
return config;
|
12
|
-
const typescriptOptions = await options.presets.apply("typescript", {});
|
13
|
-
const debug = options.loglevel === "debug";
|
14
|
-
const { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions || {};
|
15
|
-
if (typeof reactDocgen !== "string") {
|
16
|
-
return config;
|
17
|
-
}
|
18
|
-
if (reactDocgen !== "react-docgen-typescript") {
|
19
|
-
return mergeRsbuildConfig(config, {
|
20
|
-
tools: {
|
21
|
-
rspack: {
|
22
|
-
module: {
|
23
|
-
rules: [
|
24
|
-
{
|
25
|
-
test: /\.(cjs|mjs|tsx?|jsx?)$/,
|
26
|
-
enforce: "pre",
|
27
|
-
loader: requirer(
|
28
|
-
__require.resolve,
|
29
|
-
"@storybook/preset-react-webpack/dist/loaders/react-docgen-loader"
|
30
|
-
),
|
31
|
-
options: {
|
32
|
-
debug
|
33
|
-
},
|
34
|
-
exclude: /(\.(stories|story)\.(js|jsx|ts|tsx))|(node_modules)/
|
35
|
-
}
|
36
|
-
]
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}
|
40
|
-
});
|
41
|
-
}
|
42
|
-
const { ReactDocgenTypeScriptPlugin } = await import("@storybook/react-docgen-typescript-plugin");
|
43
|
-
throw new Error(
|
44
|
-
"Rspack didn't support the hooks `react-docgen-typescript`' required"
|
45
|
-
);
|
46
|
-
return mergeRsbuildConfig(config, {
|
47
|
-
tools: {
|
48
|
-
rspack: {
|
49
|
-
module: {
|
50
|
-
rules: [
|
51
|
-
{
|
52
|
-
test: /\.(cjs|mjs|jsx?)$/,
|
53
|
-
enforce: "pre",
|
54
|
-
loader: requirer(
|
55
|
-
__require.resolve,
|
56
|
-
"@storybook/preset-react-webpack/dist/loaders/react-docgen-loader"
|
57
|
-
),
|
58
|
-
options: {
|
59
|
-
debug
|
60
|
-
},
|
61
|
-
exclude: /(\.(stories|story)\.(js|jsx|ts|tsx))|(node_modules)/
|
62
|
-
}
|
63
|
-
]
|
64
|
-
},
|
65
|
-
plugins: [
|
66
|
-
...config.plugins || [],
|
67
|
-
new ReactDocgenTypeScriptPlugin({
|
68
|
-
...reactDocgenTypescriptOptions,
|
69
|
-
// We *need* this set so that RDT returns default values in the same format as react-docgen
|
70
|
-
savePropValueAsString: true
|
71
|
-
})
|
72
|
-
]
|
73
|
-
}
|
74
|
-
}
|
75
|
-
});
|
76
|
-
};
|
77
|
-
|
78
|
-
export {
|
79
|
-
rsbuildFinal
|
80
|
-
};
|
package/dist/chunk-WBQAMGXK.mjs
DELETED
File without changes
|
package/dist/preset.mjs
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
rsbuildFinal
|
3
|
-
} from "./chunk-TNRF4JXJ.mjs";
|
4
|
-
import {
|
5
|
-
__require
|
6
|
-
} from "./chunk-77YOQVQO.mjs";
|
7
|
-
|
8
|
-
// src/preset.ts
|
9
|
-
import { dirname, join } from "path";
|
10
|
-
var getAbsolutePath = (input) => dirname(__require.resolve(join(input, "package.json")));
|
11
|
-
var core = async (config, options) => {
|
12
|
-
const framework = await options.presets.apply("framework");
|
13
|
-
return {
|
14
|
-
...config,
|
15
|
-
builder: {
|
16
|
-
name: getAbsolutePath("@storybook/builder-rsbuild"),
|
17
|
-
options: typeof framework === "string" ? {} : framework.options.builder || {}
|
18
|
-
},
|
19
|
-
renderer: getAbsolutePath("@storybook/react")
|
20
|
-
};
|
21
|
-
};
|
22
|
-
export {
|
23
|
-
core,
|
24
|
-
rsbuildFinal
|
25
|
-
};
|