storybook-react-rsbuild 2.1.6 → 3.0.0-beta.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/dist/_node-chunks/chunk-736S2ISL.js +21 -0
- package/dist/_node-chunks/generate-ZW2DFGJB.js +162 -0
- package/dist/_node-chunks/options-IABV5J64.js +24 -0
- package/dist/_node-chunks/react-docgen-typescript-FEITIOSV.js +114 -0
- package/dist/_node-chunks/typescript-Q2KR3T37.js +33 -0
- package/dist/index.d.ts +3 -54
- package/dist/index.js +5 -32
- package/dist/loaders/react-docgen-loader.d.ts +3 -10
- package/dist/loaders/react-docgen-loader.js +69 -125
- package/dist/node/index.d.ts +3 -9
- package/dist/node/index.js +14 -26
- package/dist/preset.js +30 -431
- package/package.json +17 -27
- package/preset.js +1 -1
- package/dist/index.mjs +0 -2
- package/dist/loaders/react-docgen-loader.mjs +0 -195
- package/dist/node/index.mjs +0 -6
- package/dist/preset.d.ts +0 -10
package/dist/preset.js
CHANGED
|
@@ -1,411 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
|
-
var __export = (target, all) => {
|
|
12
|
-
for (var name in all)
|
|
13
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from))
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
-
|
|
33
|
-
// src/plugins/react-docgen-typescript/utils/filter.ts
|
|
34
|
-
var defaultPropFilter;
|
|
35
|
-
var init_filter = __esm({
|
|
36
|
-
"src/plugins/react-docgen-typescript/utils/filter.ts"() {
|
|
37
|
-
"use strict";
|
|
38
|
-
defaultPropFilter = (prop) => {
|
|
39
|
-
return !prop.parent?.fileName.includes("node_modules");
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// src/plugins/react-docgen-typescript/utils/typescript.ts
|
|
45
|
-
var typescript_exports = {};
|
|
46
|
-
__export(typescript_exports, {
|
|
47
|
-
getTSConfigFile: () => getTSConfigFile
|
|
48
|
-
});
|
|
49
|
-
function getTSConfigFile(tsconfigPath) {
|
|
50
|
-
try {
|
|
51
|
-
const basePath = (0, import_node_path.dirname)(tsconfigPath);
|
|
52
|
-
const configFile = import_typescript.default.readConfigFile(tsconfigPath, import_typescript.default.sys.readFile);
|
|
53
|
-
return import_typescript.default.parseJsonConfigFileContent(
|
|
54
|
-
configFile.config,
|
|
55
|
-
import_typescript.default.sys,
|
|
56
|
-
basePath,
|
|
57
|
-
{},
|
|
58
|
-
tsconfigPath
|
|
59
|
-
);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
return {};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
var import_node_path, import_typescript;
|
|
65
|
-
var init_typescript = __esm({
|
|
66
|
-
"src/plugins/react-docgen-typescript/utils/typescript.ts"() {
|
|
67
|
-
"use strict";
|
|
68
|
-
import_node_path = require("path");
|
|
69
|
-
import_typescript = __toESM(require("typescript"));
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// src/plugins/react-docgen-typescript/utils/options.ts
|
|
74
|
-
var options_exports = {};
|
|
75
|
-
__export(options_exports, {
|
|
76
|
-
getGenerateOptions: () => getGenerateOptions
|
|
77
|
-
});
|
|
78
|
-
function getGenerateOptions(options) {
|
|
79
|
-
const { setDisplayName: setDisplayName2 = true, typePropName = "type" } = options;
|
|
80
|
-
return {
|
|
81
|
-
setDisplayName: setDisplayName2,
|
|
82
|
-
typePropName
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
var init_options = __esm({
|
|
86
|
-
"src/plugins/react-docgen-typescript/utils/options.ts"() {
|
|
87
|
-
"use strict";
|
|
88
|
-
}
|
|
89
|
-
});
|
|
1
|
+
import CJS_COMPAT_NODE_URL_456fc18c5bc9e809 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_456fc18c5bc9e809 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_456fc18c5bc9e809 from "node:module";
|
|
90
4
|
|
|
91
|
-
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
generateDocgenCodeBlock: () => generateDocgenCodeBlock
|
|
95
|
-
});
|
|
96
|
-
function createLiteral(value) {
|
|
97
|
-
switch (typeof value) {
|
|
98
|
-
case "string":
|
|
99
|
-
return import_typescript2.default.factory.createStringLiteral(value);
|
|
100
|
-
case "number":
|
|
101
|
-
return import_typescript2.default.factory.createNumericLiteral(value);
|
|
102
|
-
case "boolean":
|
|
103
|
-
return value ? import_typescript2.default.factory.createTrue() : import_typescript2.default.factory.createFalse();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function insertTsIgnoreBeforeStatement(statement) {
|
|
107
|
-
import_typescript2.default.setSyntheticLeadingComments(statement, [
|
|
108
|
-
{
|
|
109
|
-
text: " @ts-ignore",
|
|
110
|
-
// Leading space is important here
|
|
111
|
-
kind: import_typescript2.default.SyntaxKind.SingleLineCommentTrivia,
|
|
112
|
-
pos: -1,
|
|
113
|
-
end: -1
|
|
114
|
-
}
|
|
115
|
-
]);
|
|
116
|
-
return statement;
|
|
117
|
-
}
|
|
118
|
-
function setDisplayName(d) {
|
|
119
|
-
return insertTsIgnoreBeforeStatement(
|
|
120
|
-
import_typescript2.default.factory.createExpressionStatement(
|
|
121
|
-
import_typescript2.default.factory.createBinaryExpression(
|
|
122
|
-
import_typescript2.default.factory.createPropertyAccessExpression(
|
|
123
|
-
import_typescript2.default.factory.createIdentifier(d.displayName),
|
|
124
|
-
import_typescript2.default.factory.createIdentifier("displayName")
|
|
125
|
-
),
|
|
126
|
-
import_typescript2.default.SyntaxKind.EqualsToken,
|
|
127
|
-
import_typescript2.default.factory.createStringLiteral(d.displayName)
|
|
128
|
-
)
|
|
129
|
-
)
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
function createPropDefinition(propName, prop, options) {
|
|
133
|
-
const setDefaultValue = (defaultValue) => import_typescript2.default.factory.createPropertyAssignment(
|
|
134
|
-
import_typescript2.default.factory.createStringLiteral("defaultValue"),
|
|
135
|
-
// Use a more extensive check on defaultValue. Sometimes the parser
|
|
136
|
-
// returns an empty object.
|
|
137
|
-
defaultValue?.value !== void 0 && (typeof defaultValue.value === "string" || typeof defaultValue.value === "number" || typeof defaultValue.value === "boolean") ? import_typescript2.default.factory.createObjectLiteralExpression([
|
|
138
|
-
import_typescript2.default.factory.createPropertyAssignment(
|
|
139
|
-
import_typescript2.default.factory.createIdentifier("value"),
|
|
140
|
-
createLiteral(defaultValue.value)
|
|
141
|
-
)
|
|
142
|
-
]) : import_typescript2.default.factory.createNull()
|
|
143
|
-
);
|
|
144
|
-
const setStringLiteralField = (fieldName, fieldValue) => import_typescript2.default.factory.createPropertyAssignment(
|
|
145
|
-
import_typescript2.default.factory.createStringLiteral(fieldName),
|
|
146
|
-
import_typescript2.default.factory.createStringLiteral(fieldValue)
|
|
147
|
-
);
|
|
148
|
-
const setDescription = (description) => setStringLiteralField("description", description);
|
|
149
|
-
const setName = (name) => setStringLiteralField("name", name);
|
|
150
|
-
const setRequired = (required) => import_typescript2.default.factory.createPropertyAssignment(
|
|
151
|
-
import_typescript2.default.factory.createStringLiteral("required"),
|
|
152
|
-
required ? import_typescript2.default.factory.createTrue() : import_typescript2.default.factory.createFalse()
|
|
153
|
-
);
|
|
154
|
-
const setValue = (typeValue) => Array.isArray(typeValue) && typeValue.every((value) => typeof value.value === "string") ? import_typescript2.default.factory.createPropertyAssignment(
|
|
155
|
-
import_typescript2.default.factory.createStringLiteral("value"),
|
|
156
|
-
import_typescript2.default.factory.createArrayLiteralExpression(
|
|
157
|
-
typeValue.map(
|
|
158
|
-
(value) => import_typescript2.default.factory.createObjectLiteralExpression([
|
|
159
|
-
setStringLiteralField("value", value.value)
|
|
160
|
-
])
|
|
161
|
-
)
|
|
162
|
-
)
|
|
163
|
-
) : void 0;
|
|
164
|
-
const setType = (typeName, typeValue) => {
|
|
165
|
-
const objectFields = [setStringLiteralField("name", typeName)];
|
|
166
|
-
const valueField = setValue(typeValue);
|
|
167
|
-
if (valueField) {
|
|
168
|
-
objectFields.push(valueField);
|
|
169
|
-
}
|
|
170
|
-
return import_typescript2.default.factory.createPropertyAssignment(
|
|
171
|
-
import_typescript2.default.factory.createStringLiteral(options.typePropName),
|
|
172
|
-
import_typescript2.default.factory.createObjectLiteralExpression(objectFields)
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
return import_typescript2.default.factory.createPropertyAssignment(
|
|
176
|
-
import_typescript2.default.factory.createStringLiteral(propName),
|
|
177
|
-
import_typescript2.default.factory.createObjectLiteralExpression([
|
|
178
|
-
setDefaultValue(prop.defaultValue),
|
|
179
|
-
setDescription(prop.description),
|
|
180
|
-
setName(prop.name),
|
|
181
|
-
setRequired(prop.required),
|
|
182
|
-
setType(prop.type.name, prop.type.value)
|
|
183
|
-
])
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
function setComponentDocGen(d, options) {
|
|
187
|
-
return insertTsIgnoreBeforeStatement(
|
|
188
|
-
import_typescript2.default.factory.createExpressionStatement(
|
|
189
|
-
import_typescript2.default.factory.createBinaryExpression(
|
|
190
|
-
// SimpleComponent.__docgenInfo
|
|
191
|
-
import_typescript2.default.factory.createPropertyAccessExpression(
|
|
192
|
-
import_typescript2.default.factory.createIdentifier(d.displayName),
|
|
193
|
-
import_typescript2.default.factory.createIdentifier("__docgenInfo")
|
|
194
|
-
),
|
|
195
|
-
import_typescript2.default.SyntaxKind.EqualsToken,
|
|
196
|
-
import_typescript2.default.factory.createObjectLiteralExpression([
|
|
197
|
-
// SimpleComponent.__docgenInfo.description
|
|
198
|
-
import_typescript2.default.factory.createPropertyAssignment(
|
|
199
|
-
import_typescript2.default.factory.createStringLiteral("description"),
|
|
200
|
-
import_typescript2.default.factory.createStringLiteral(d.description)
|
|
201
|
-
),
|
|
202
|
-
// SimpleComponent.__docgenInfo.displayName
|
|
203
|
-
import_typescript2.default.factory.createPropertyAssignment(
|
|
204
|
-
import_typescript2.default.factory.createStringLiteral("displayName"),
|
|
205
|
-
import_typescript2.default.factory.createStringLiteral(d.displayName)
|
|
206
|
-
),
|
|
207
|
-
// SimpleComponent.__docgenInfo.props
|
|
208
|
-
import_typescript2.default.factory.createPropertyAssignment(
|
|
209
|
-
import_typescript2.default.factory.createStringLiteral("props"),
|
|
210
|
-
import_typescript2.default.factory.createObjectLiteralExpression(
|
|
211
|
-
Object.entries(d.props).map(
|
|
212
|
-
([propName, prop]) => createPropDefinition(propName, prop, options)
|
|
213
|
-
)
|
|
214
|
-
)
|
|
215
|
-
)
|
|
216
|
-
])
|
|
217
|
-
)
|
|
218
|
-
)
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
function generateDocgenCodeBlock(options) {
|
|
222
|
-
const sourceFile = import_typescript2.default.createSourceFile(
|
|
223
|
-
options.filename,
|
|
224
|
-
options.source,
|
|
225
|
-
import_typescript2.default.ScriptTarget.ESNext
|
|
226
|
-
);
|
|
227
|
-
const wrapInTryStatement = (statements) => import_typescript2.default.factory.createTryStatement(
|
|
228
|
-
import_typescript2.default.factory.createBlock(statements, true),
|
|
229
|
-
import_typescript2.default.factory.createCatchClause(
|
|
230
|
-
import_typescript2.default.factory.createVariableDeclaration(
|
|
231
|
-
import_typescript2.default.factory.createIdentifier("__react_docgen_typescript_loader_error")
|
|
232
|
-
),
|
|
233
|
-
import_typescript2.default.factory.createBlock([])
|
|
234
|
-
),
|
|
235
|
-
void 0
|
|
236
|
-
);
|
|
237
|
-
const codeBlocks = options.componentDocs.map(
|
|
238
|
-
(d) => wrapInTryStatement(
|
|
239
|
-
[
|
|
240
|
-
options.setDisplayName ? setDisplayName(d) : null,
|
|
241
|
-
setComponentDocGen(d, options)
|
|
242
|
-
].filter((s2) => s2 !== null)
|
|
243
|
-
)
|
|
244
|
-
);
|
|
245
|
-
const printer = import_typescript2.default.createPrinter({ newLine: import_typescript2.default.NewLineKind.LineFeed });
|
|
246
|
-
const printNode = (sourceNode) => printer.printNode(import_typescript2.default.EmitHint.Unspecified, sourceNode, sourceFile);
|
|
247
|
-
const s = new import_magic_string.default(options.source);
|
|
248
|
-
for (const node of codeBlocks) {
|
|
249
|
-
s.append(printNode(node));
|
|
250
|
-
}
|
|
251
|
-
return {
|
|
252
|
-
code: s.toString(),
|
|
253
|
-
map: s.generateMap()
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
var import_magic_string, import_typescript2;
|
|
257
|
-
var init_generate = __esm({
|
|
258
|
-
"src/plugins/react-docgen-typescript/utils/generate.ts"() {
|
|
259
|
-
"use strict";
|
|
260
|
-
import_magic_string = __toESM(require("magic-string"));
|
|
261
|
-
import_typescript2 = __toESM(require("typescript"));
|
|
262
|
-
}
|
|
263
|
-
});
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_456fc18c5bc9e809.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_456fc18c5bc9e809.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_456fc18c5bc9e809.createRequire(import.meta.url);
|
|
264
8
|
|
|
265
|
-
//
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
var init_react_docgen_typescript = __esm({
|
|
272
|
-
"src/plugins/react-docgen-typescript/index.ts"() {
|
|
273
|
-
"use strict";
|
|
274
|
-
import_pluginutils = require("@rollup/pluginutils");
|
|
275
|
-
init_filter();
|
|
276
|
-
getDocgen = async (config) => {
|
|
277
|
-
const docGen = await import("react-docgen-typescript");
|
|
278
|
-
const {
|
|
279
|
-
tsconfigPath,
|
|
280
|
-
compilerOptions,
|
|
281
|
-
propFilter = defaultPropFilter,
|
|
282
|
-
setDisplayName: setDisplayName2,
|
|
283
|
-
typePropName,
|
|
284
|
-
...rest
|
|
285
|
-
} = config;
|
|
286
|
-
const docgenOptions = {
|
|
287
|
-
propFilter,
|
|
288
|
-
...rest
|
|
289
|
-
};
|
|
290
|
-
return docGen.withCompilerOptions(
|
|
291
|
-
// Compiler Options are passed in to the custom program.
|
|
292
|
-
{},
|
|
293
|
-
docgenOptions
|
|
294
|
-
);
|
|
295
|
-
};
|
|
296
|
-
startWatch = async (config, onProgramCreatedOrUpdated) => {
|
|
297
|
-
const { default: ts3 } = await import("typescript");
|
|
298
|
-
const { getTSConfigFile: getTSConfigFile2 } = await Promise.resolve().then(() => (init_typescript(), typescript_exports));
|
|
299
|
-
let compilerOptions = {
|
|
300
|
-
jsx: ts3.JsxEmit.React,
|
|
301
|
-
module: ts3.ModuleKind.CommonJS,
|
|
302
|
-
target: ts3.ScriptTarget.Latest
|
|
303
|
-
};
|
|
304
|
-
const tsconfigPath = config.tsconfigPath ?? "./tsconfig.json";
|
|
305
|
-
if (config.compilerOptions) {
|
|
306
|
-
compilerOptions = {
|
|
307
|
-
...compilerOptions,
|
|
308
|
-
...config.compilerOptions
|
|
309
|
-
};
|
|
310
|
-
} else {
|
|
311
|
-
const { options: tsOptions } = getTSConfigFile2(tsconfigPath);
|
|
312
|
-
compilerOptions = { ...compilerOptions, ...tsOptions };
|
|
313
|
-
}
|
|
314
|
-
const host = ts3.createWatchCompilerHost(
|
|
315
|
-
tsconfigPath,
|
|
316
|
-
compilerOptions,
|
|
317
|
-
ts3.sys,
|
|
318
|
-
ts3.createSemanticDiagnosticsBuilderProgram,
|
|
319
|
-
void 0,
|
|
320
|
-
() => {
|
|
321
|
-
}
|
|
322
|
-
);
|
|
323
|
-
host.afterProgramCreate = (program) => {
|
|
324
|
-
onProgramCreatedOrUpdated(program.getProgram());
|
|
325
|
-
};
|
|
326
|
-
return new Promise((resolve) => {
|
|
327
|
-
const watch = ts3.createWatchProgram(host);
|
|
328
|
-
resolve([watch.getProgram().getProgram(), watch.close]);
|
|
329
|
-
});
|
|
330
|
-
};
|
|
331
|
-
react_docgen_typescript_default = (config = {}) => {
|
|
332
|
-
let tsProgram;
|
|
333
|
-
let docGenParser;
|
|
334
|
-
let generateDocgenCodeBlock2;
|
|
335
|
-
let generateOptions;
|
|
336
|
-
let filter;
|
|
337
|
-
const moduleInvalidationQueue = /* @__PURE__ */ new Map();
|
|
338
|
-
let closeWatch;
|
|
339
|
-
return {
|
|
340
|
-
name: "rsbuild-plugin-react-docgen-typescript",
|
|
341
|
-
setup(api) {
|
|
342
|
-
api.modifyRsbuildConfig(async () => {
|
|
343
|
-
const { getGenerateOptions: getGenerateOptions2 } = await Promise.resolve().then(() => (init_options(), options_exports));
|
|
344
|
-
generateDocgenCodeBlock2 = (await Promise.resolve().then(() => (init_generate(), generate_exports))).generateDocgenCodeBlock;
|
|
345
|
-
docGenParser = await getDocgen(config);
|
|
346
|
-
generateOptions = getGenerateOptions2(config);
|
|
347
|
-
[tsProgram, closeWatch] = await startWatch(config, (program) => {
|
|
348
|
-
tsProgram = program;
|
|
349
|
-
for (const [
|
|
350
|
-
filepath,
|
|
351
|
-
invalidateModule
|
|
352
|
-
] of moduleInvalidationQueue.entries()) {
|
|
353
|
-
invalidateModule();
|
|
354
|
-
moduleInvalidationQueue.delete(filepath);
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
filter = (0, import_pluginutils.createFilter)(
|
|
358
|
-
config.include ?? ["**/**.tsx"],
|
|
359
|
-
config.exclude ?? ["**/**.stories.tsx"]
|
|
360
|
-
);
|
|
361
|
-
});
|
|
362
|
-
api.transform(
|
|
363
|
-
{
|
|
364
|
-
test: (id) => {
|
|
365
|
-
return filter(id);
|
|
366
|
-
}
|
|
367
|
-
},
|
|
368
|
-
async ({ code: src, resource: id }) => {
|
|
369
|
-
try {
|
|
370
|
-
const componentDocs = docGenParser.parseWithProgramProvider(
|
|
371
|
-
id,
|
|
372
|
-
() => tsProgram
|
|
373
|
-
);
|
|
374
|
-
if (!componentDocs.length) {
|
|
375
|
-
return { code: src };
|
|
376
|
-
}
|
|
377
|
-
const res = generateDocgenCodeBlock2({
|
|
378
|
-
filename: id,
|
|
379
|
-
source: src,
|
|
380
|
-
componentDocs,
|
|
381
|
-
...generateOptions
|
|
382
|
-
});
|
|
383
|
-
return res;
|
|
384
|
-
} catch (e) {
|
|
385
|
-
return src;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
);
|
|
389
|
-
api.onCloseBuild(() => {
|
|
390
|
-
closeWatch();
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
});
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__require
|
|
14
|
+
} from "./_node-chunks/chunk-736S2ISL.js";
|
|
397
15
|
|
|
398
16
|
// src/preset.ts
|
|
399
|
-
|
|
400
|
-
__export(preset_exports, {
|
|
401
|
-
core: () => core,
|
|
402
|
-
rsbuildFinal: () => rsbuildFinal
|
|
403
|
-
});
|
|
404
|
-
module.exports = __toCommonJS(preset_exports);
|
|
405
|
-
var import_node_path2 = require("path");
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
406
18
|
|
|
407
19
|
// src/react-docs.ts
|
|
408
|
-
|
|
20
|
+
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
409
21
|
|
|
410
22
|
// src/requirer.ts
|
|
411
23
|
function requirer(resolver, path) {
|
|
@@ -414,14 +26,11 @@ function requirer(resolver, path) {
|
|
|
414
26
|
|
|
415
27
|
// src/react-docs.ts
|
|
416
28
|
var rsbuildFinalDocs = async (config, options) => {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions || {};
|
|
420
|
-
if (typeof reactDocgen !== "string") {
|
|
29
|
+
let typescriptOptions = await options.presets.apply("typescript", {}), debug = options.loglevel === "debug", { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions || {};
|
|
30
|
+
if (typeof reactDocgen != "string")
|
|
421
31
|
return config;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
return (0, import_core.mergeRsbuildConfig)(config, {
|
|
32
|
+
if (reactDocgen !== "react-docgen-typescript")
|
|
33
|
+
return mergeRsbuildConfig(config, {
|
|
425
34
|
tools: {
|
|
426
35
|
rspack: {
|
|
427
36
|
module: {
|
|
@@ -430,7 +39,7 @@ var rsbuildFinalDocs = async (config, options) => {
|
|
|
430
39
|
test: /\.(cjs|mjs|tsx?|jsx?)$/,
|
|
431
40
|
enforce: "pre",
|
|
432
41
|
loader: requirer(
|
|
433
|
-
|
|
42
|
+
__require.resolve,
|
|
434
43
|
"storybook-react-rsbuild/loaders/react-docgen-loader"
|
|
435
44
|
),
|
|
436
45
|
options: {
|
|
@@ -443,47 +52,37 @@ var rsbuildFinalDocs = async (config, options) => {
|
|
|
443
52
|
}
|
|
444
53
|
}
|
|
445
54
|
});
|
|
446
|
-
}
|
|
447
55
|
let typescriptPresent;
|
|
448
56
|
try {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
typescriptPresent = false;
|
|
453
|
-
}
|
|
454
|
-
if (reactDocgen === "react-docgen-typescript" && typescriptPresent) {
|
|
57
|
+
__require.resolve("typescript"), typescriptPresent = !0;
|
|
58
|
+
} catch {
|
|
59
|
+
typescriptPresent = !1;
|
|
455
60
|
}
|
|
456
|
-
|
|
457
|
-
return
|
|
61
|
+
let reactDocGenTsPlugin = await import("./_node-chunks/react-docgen-typescript-FEITIOSV.js");
|
|
62
|
+
return mergeRsbuildConfig(config, {
|
|
458
63
|
plugins: [
|
|
459
64
|
await reactDocGenTsPlugin.default({
|
|
460
65
|
...reactDocgenTypescriptOptions,
|
|
461
66
|
// We *need* this set so that RDT returns default values in the same format as react-docgen
|
|
462
|
-
savePropValueAsString:
|
|
67
|
+
savePropValueAsString: !0
|
|
463
68
|
})
|
|
464
69
|
]
|
|
465
70
|
});
|
|
466
71
|
};
|
|
467
72
|
|
|
468
73
|
// src/preset.ts
|
|
469
|
-
var getAbsolutePath = (input) =>
|
|
470
|
-
|
|
471
|
-
const finalConfig = rsbuildFinalDocs(config, options);
|
|
472
|
-
return finalConfig;
|
|
473
|
-
};
|
|
474
|
-
var core = async (config, options) => {
|
|
475
|
-
const framework = await options.presets.apply("framework");
|
|
74
|
+
var getAbsolutePath = (input) => dirname(__require.resolve(join(input, "package.json"))), rsbuildFinal = async (config, options) => rsbuildFinalDocs(config, options), core = async (config, options) => {
|
|
75
|
+
let framework = await options.presets.apply("framework");
|
|
476
76
|
return {
|
|
477
77
|
...config,
|
|
478
78
|
builder: {
|
|
479
79
|
name: getAbsolutePath("storybook-builder-rsbuild"),
|
|
480
|
-
options: typeof framework
|
|
80
|
+
options: typeof framework == "string" ? {} : framework.options.builder || {}
|
|
481
81
|
},
|
|
482
82
|
renderer: getAbsolutePath("@storybook/react")
|
|
483
83
|
};
|
|
484
84
|
};
|
|
485
|
-
|
|
486
|
-
0 && (module.exports = {
|
|
85
|
+
export {
|
|
487
86
|
core,
|
|
488
87
|
rsbuildFinal
|
|
489
|
-
}
|
|
88
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-react-rsbuild",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
4
|
"description": "Storybook for React and Rsbuild: Develop React components in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -18,34 +18,24 @@
|
|
|
18
18
|
"directory": "packages/framework-react"
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
|
+
"type": "module",
|
|
21
22
|
"exports": {
|
|
22
23
|
".": {
|
|
23
24
|
"types": "./dist/index.d.ts",
|
|
24
|
-
"
|
|
25
|
-
"require": "./dist/index.js",
|
|
26
|
-
"import": "./dist/index.mjs"
|
|
27
|
-
},
|
|
28
|
-
"./preset": {
|
|
29
|
-
"types": "./dist/preset.d.ts",
|
|
30
|
-
"require": "./dist/preset.js"
|
|
31
|
-
},
|
|
32
|
-
"./react-docs": {
|
|
33
|
-
"types": "./dist/react-docs.d.ts",
|
|
34
|
-
"require": "./dist/react-docs.js"
|
|
25
|
+
"default": "./dist/index.js"
|
|
35
26
|
},
|
|
36
27
|
"./loaders/react-docgen-loader": {
|
|
37
28
|
"types": "./dist/loaders/react-docgen-loader.d.ts",
|
|
38
|
-
"
|
|
29
|
+
"default": "./dist/loaders/react-docgen-loader.js"
|
|
39
30
|
},
|
|
40
31
|
"./node": {
|
|
41
32
|
"types": "./dist/node/index.d.ts",
|
|
42
|
-
"
|
|
43
|
-
"import": "./dist/node/index.mjs",
|
|
44
|
-
"require": "./dist/node/index.js"
|
|
33
|
+
"default": "./dist/node/index.js"
|
|
45
34
|
},
|
|
46
|
-
"./package.json": "./package.json"
|
|
35
|
+
"./package.json": "./package.json",
|
|
36
|
+
"./preset": "./dist/preset.js"
|
|
47
37
|
},
|
|
48
|
-
"main": "dist/index.
|
|
38
|
+
"main": "dist/index.mjs",
|
|
49
39
|
"module": "dist/index.mjs",
|
|
50
40
|
"types": "dist/index.d.ts",
|
|
51
41
|
"files": [
|
|
@@ -57,31 +47,31 @@
|
|
|
57
47
|
],
|
|
58
48
|
"dependencies": {
|
|
59
49
|
"@rollup/pluginutils": "^5.3.0",
|
|
60
|
-
"@storybook/react": "^
|
|
50
|
+
"@storybook/react": "^10.0.0",
|
|
61
51
|
"@storybook/react-docgen-typescript-plugin": "^1.0.1",
|
|
62
52
|
"find-up": "^5.0.0",
|
|
63
53
|
"magic-string": "^0.30.21",
|
|
64
|
-
"react-docgen": "^
|
|
54
|
+
"react-docgen": "^8.0.2",
|
|
65
55
|
"react-docgen-typescript": "^2.4.0",
|
|
66
56
|
"resolve": "^1.22.11",
|
|
67
57
|
"tsconfig-paths": "^4.2.0",
|
|
68
|
-
"storybook-builder-rsbuild": "
|
|
58
|
+
"storybook-builder-rsbuild": "3.0.0-beta.1"
|
|
69
59
|
},
|
|
70
60
|
"devDependencies": {
|
|
71
61
|
"@rsbuild/core": "^1.5.17",
|
|
72
|
-
"@types/node": "^
|
|
62
|
+
"@types/node": "^22.0.0",
|
|
73
63
|
"@types/react": "^18.3.26",
|
|
74
64
|
"@types/resolve": "^1.20.6",
|
|
75
65
|
"react": "18.3.1",
|
|
76
66
|
"react-dom": "18.3.1",
|
|
77
|
-
"storybook": "
|
|
67
|
+
"storybook": "10.0.7",
|
|
78
68
|
"typescript": "^5.9.3"
|
|
79
69
|
},
|
|
80
70
|
"peerDependencies": {
|
|
81
71
|
"@rsbuild/core": "^1.5.0",
|
|
82
72
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
|
|
83
73
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
|
|
84
|
-
"storybook": "^
|
|
74
|
+
"storybook": "^10.0.0",
|
|
85
75
|
"typescript": ">= 4.2.x"
|
|
86
76
|
},
|
|
87
77
|
"peerDependenciesMeta": {
|
|
@@ -105,8 +95,8 @@
|
|
|
105
95
|
"platform": "node"
|
|
106
96
|
},
|
|
107
97
|
"scripts": {
|
|
108
|
-
"build": "pnpm run prep
|
|
109
|
-
"check": "jiti ../../scripts/
|
|
110
|
-
"prep": "jiti ../../scripts/
|
|
98
|
+
"build": "pnpm run prep",
|
|
99
|
+
"check": "jiti ../../scripts/check/check-package.ts",
|
|
100
|
+
"prep": "jiti ../../scripts/build/build-package.ts"
|
|
111
101
|
}
|
|
112
102
|
}
|
package/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './dist/preset.js'
|
package/dist/index.mjs
DELETED