storybook-react-rsbuild 3.4.2 → 3.6.0
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/chunks/generate-1782ed11.js +86 -0
- package/dist/chunks/options-7e849a08.js +9 -0
- package/dist/chunks/react-docgen-typescript-9f56b1df.js +99 -0
- package/dist/chunks/typescript-69cd7fa9.js +13 -0
- package/dist/index.d.ts +75 -54
- package/dist/index.js +1 -5
- package/dist/loaders/react-docgen-loader.d.ts +12 -10
- package/dist/loaders/react-docgen-loader.js +154 -180
- package/dist/node/index.d.ts +71 -55
- package/dist/node/index.js +3 -18
- package/dist/preset.d.ts +74 -55
- package/dist/preset.js +84 -90
- package/package.json +10 -11
- package/dist/_node-chunks/chunk-TPE2Q567.js +0 -21
- package/dist/_node-chunks/generate-4YW4NBRQ.js +0 -168
- package/dist/_node-chunks/options-YEVZIRR2.js +0 -24
- package/dist/_node-chunks/react-docgen-typescript-R6NQ22Y3.js +0 -114
- package/dist/_node-chunks/typescript-VNYISKUD.js +0 -33
package/dist/preset.js
CHANGED
|
@@ -1,98 +1,92 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434 from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_a0ef041aa6a9c434.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
import {
|
|
13
|
-
__require
|
|
14
|
-
} from "./_node-chunks/chunk-TPE2Q567.js";
|
|
15
|
-
|
|
16
|
-
// src/preset.ts
|
|
17
|
-
import { fileURLToPath } from "node:url";
|
|
18
|
-
|
|
19
|
-
// src/react-docs.ts
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
20
3
|
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
23
6
|
function requirer(resolver, path) {
|
|
24
|
-
|
|
7
|
+
return resolver(path);
|
|
25
8
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
9
|
+
const rsbuildFinalDocs = async (config, options)=>{
|
|
10
|
+
const features = await options.presets.apply('features', {});
|
|
11
|
+
if (features?.experimentalDocgenServer) return config;
|
|
12
|
+
const typescriptOptions = await options.presets.apply("typescript", {});
|
|
13
|
+
const debug = 'debug' === options.loglevel;
|
|
14
|
+
const { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions || {};
|
|
15
|
+
if ('string' != typeof reactDocgen) return config;
|
|
16
|
+
const reactDocgenLoaderRule = (test)=>({
|
|
17
|
+
test,
|
|
18
|
+
enforce: 'pre',
|
|
19
|
+
loader: requirer(require.resolve, 'storybook-react-rsbuild/loaders/react-docgen-loader'),
|
|
20
|
+
options: {
|
|
21
|
+
debug
|
|
22
|
+
},
|
|
23
|
+
exclude: /(\.(stories|story)\.(js|jsx|ts|tsx))|(node_modules)/
|
|
24
|
+
});
|
|
25
|
+
let typescriptPresent;
|
|
26
|
+
try {
|
|
27
|
+
require.resolve("typescript");
|
|
28
|
+
typescriptPresent = true;
|
|
29
|
+
} catch (_e) {
|
|
30
|
+
typescriptPresent = false;
|
|
31
|
+
}
|
|
32
|
+
const useReactDocgenTypescript = "react-docgen-typescript" === reactDocgen && typescriptPresent;
|
|
33
|
+
if (!useReactDocgenTypescript) return mergeRsbuildConfig(config, {
|
|
34
|
+
tools: {
|
|
35
|
+
rspack: {
|
|
36
|
+
module: {
|
|
37
|
+
rules: [
|
|
38
|
+
reactDocgenLoaderRule(/\.(cjs|mjs|tsx?|jsx?)$/)
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
58
42
|
}
|
|
59
|
-
}
|
|
60
43
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
]
|
|
80
|
-
});
|
|
44
|
+
const reactDocGenTsPlugin = await import("./chunks/react-docgen-typescript-9f56b1df.js");
|
|
45
|
+
return mergeRsbuildConfig(config, {
|
|
46
|
+
tools: {
|
|
47
|
+
rspack: {
|
|
48
|
+
module: {
|
|
49
|
+
rules: [
|
|
50
|
+
reactDocgenLoaderRule(/\.(cjs|mjs|jsx?)$/)
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
plugins: [
|
|
56
|
+
reactDocGenTsPlugin.default({
|
|
57
|
+
...reactDocgenTypescriptOptions,
|
|
58
|
+
savePropValueAsString: true
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
});
|
|
81
62
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
63
|
+
const preset_require = createRequire(import.meta.url);
|
|
64
|
+
const rsbuildFinal = async (config, options)=>{
|
|
65
|
+
const finalConfig = await rsbuildFinalDocs(mergeRsbuildConfig({
|
|
66
|
+
resolve: {
|
|
67
|
+
alias: {
|
|
68
|
+
'@storybook/react': preset_require.resolve('@storybook/react')
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, config), options);
|
|
72
|
+
if (options.features?.developmentModeForBuild) return mergeRsbuildConfig(finalConfig, {
|
|
73
|
+
source: {
|
|
74
|
+
define: {
|
|
75
|
+
'process.env.NODE_ENV': JSON.stringify('development')
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return finalConfig;
|
|
94
80
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
const core = async (config, options)=>{
|
|
82
|
+
const frameworkOptions = await options.presets.apply('frameworkOptions');
|
|
83
|
+
return {
|
|
84
|
+
...config,
|
|
85
|
+
builder: {
|
|
86
|
+
name: fileURLToPath(import.meta.resolve('storybook-builder-rsbuild')),
|
|
87
|
+
options: frameworkOptions?.builder || {}
|
|
88
|
+
},
|
|
89
|
+
renderer: fileURLToPath(import.meta.resolve('@storybook/react/preset'))
|
|
90
|
+
};
|
|
98
91
|
};
|
|
92
|
+
export { core, rsbuildFinal };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-react-rsbuild",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Storybook for React and Rsbuild: Develop React components in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -47,31 +47,31 @@
|
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@rollup/pluginutils": "^5.4.0",
|
|
50
|
-
"@storybook/react": "^10.
|
|
50
|
+
"@storybook/react": "^10.6.0",
|
|
51
51
|
"@storybook/react-docgen-typescript-plugin": "^1.0.1",
|
|
52
|
-
"
|
|
53
|
-
"magic-string": "^0.30.21",
|
|
52
|
+
"magic-string": "^1.4.1",
|
|
54
53
|
"react-docgen": "^8.0.3",
|
|
55
54
|
"react-docgen-typescript": "^2.4.0",
|
|
56
55
|
"resolve": "^1.22.12",
|
|
57
56
|
"tsconfig-paths": "^4.2.0",
|
|
58
|
-
"storybook-builder-rsbuild": "3.
|
|
57
|
+
"storybook-builder-rsbuild": "3.6.0"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
|
61
|
-
"@
|
|
60
|
+
"@microsoft/api-extractor": "^7.59.1",
|
|
61
|
+
"@rsbuild/core": "^2.2.6",
|
|
62
62
|
"@types/node": "^22.0.0",
|
|
63
63
|
"@types/react": "^18.3.31",
|
|
64
64
|
"@types/resolve": "^1.20.6",
|
|
65
65
|
"react": "18.3.1",
|
|
66
66
|
"react-dom": "18.3.1",
|
|
67
|
-
"storybook": "10.
|
|
67
|
+
"storybook": "10.6.0",
|
|
68
68
|
"typescript": "^5.9.3"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@rsbuild/core": "^1.5.0 || ^2.0.0-0",
|
|
72
72
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
73
73
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
74
|
-
"storybook": "^10.
|
|
74
|
+
"storybook": "^10.6.0",
|
|
75
75
|
"typescript": ">= 4.2.x"
|
|
76
76
|
},
|
|
77
77
|
"peerDependenciesMeta": {
|
|
@@ -95,8 +95,7 @@
|
|
|
95
95
|
"platform": "node"
|
|
96
96
|
},
|
|
97
97
|
"scripts": {
|
|
98
|
-
"build": "
|
|
99
|
-
"
|
|
100
|
-
"prep": "jiti ../../scripts/build/build-package.ts"
|
|
98
|
+
"build": "rstack lib",
|
|
99
|
+
"dev": "rstack lib --watch"
|
|
101
100
|
}
|
|
102
101
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_a0ef041aa6a9c434 from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434 from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434 from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_a0ef041aa6a9c434.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
var __require = /* @__PURE__ */ ((x) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(x, {
|
|
13
|
-
get: (a, b) => (typeof require < "u" ? require : a)[b]
|
|
14
|
-
}) : x)(function(x) {
|
|
15
|
-
if (typeof require < "u") return require.apply(this, arguments);
|
|
16
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
__require
|
|
21
|
-
};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_a0ef041aa6a9c434 from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434 from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434 from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_a0ef041aa6a9c434.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
import "./chunk-TPE2Q567.js";
|
|
13
|
-
|
|
14
|
-
// src/plugins/react-docgen-typescript/utils/generate.ts
|
|
15
|
-
import MagicString from "magic-string";
|
|
16
|
-
import ts from "typescript";
|
|
17
|
-
function createLiteral(value) {
|
|
18
|
-
switch (typeof value) {
|
|
19
|
-
case "string":
|
|
20
|
-
return ts.factory.createStringLiteral(value);
|
|
21
|
-
case "number":
|
|
22
|
-
return ts.factory.createNumericLiteral(value);
|
|
23
|
-
case "boolean":
|
|
24
|
-
return value ? ts.factory.createTrue() : ts.factory.createFalse();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function insertTsIgnoreBeforeStatement(statement) {
|
|
28
|
-
return ts.setSyntheticLeadingComments(statement, [
|
|
29
|
-
{
|
|
30
|
-
text: " @ts-ignore",
|
|
31
|
-
// Leading space is important here
|
|
32
|
-
kind: ts.SyntaxKind.SingleLineCommentTrivia,
|
|
33
|
-
pos: -1,
|
|
34
|
-
end: -1
|
|
35
|
-
}
|
|
36
|
-
]), statement;
|
|
37
|
-
}
|
|
38
|
-
function setDisplayName(d) {
|
|
39
|
-
return insertTsIgnoreBeforeStatement(
|
|
40
|
-
ts.factory.createExpressionStatement(
|
|
41
|
-
ts.factory.createBinaryExpression(
|
|
42
|
-
ts.factory.createPropertyAccessExpression(
|
|
43
|
-
ts.factory.createIdentifier(d.displayName),
|
|
44
|
-
ts.factory.createIdentifier("displayName")
|
|
45
|
-
),
|
|
46
|
-
ts.SyntaxKind.EqualsToken,
|
|
47
|
-
ts.factory.createStringLiteral(d.displayName)
|
|
48
|
-
)
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
function createPropDefinition(propName, prop, options) {
|
|
53
|
-
let setDefaultValue = (defaultValue) => ts.factory.createPropertyAssignment(
|
|
54
|
-
ts.factory.createStringLiteral("defaultValue"),
|
|
55
|
-
// Use a more extensive check on defaultValue. Sometimes the parser
|
|
56
|
-
// returns an empty object.
|
|
57
|
-
defaultValue?.value !== void 0 && (typeof defaultValue.value == "string" || typeof defaultValue.value == "number" || typeof defaultValue.value == "boolean") ? ts.factory.createObjectLiteralExpression([
|
|
58
|
-
ts.factory.createPropertyAssignment(
|
|
59
|
-
ts.factory.createIdentifier("value"),
|
|
60
|
-
createLiteral(defaultValue.value)
|
|
61
|
-
)
|
|
62
|
-
]) : ts.factory.createNull()
|
|
63
|
-
), setStringLiteralField = (fieldName, fieldValue) => ts.factory.createPropertyAssignment(
|
|
64
|
-
ts.factory.createStringLiteral(fieldName),
|
|
65
|
-
ts.factory.createStringLiteral(fieldValue)
|
|
66
|
-
), setDescription = (description) => setStringLiteralField("description", description), setName = (name) => setStringLiteralField("name", name), setRequired = (required) => ts.factory.createPropertyAssignment(
|
|
67
|
-
ts.factory.createStringLiteral("required"),
|
|
68
|
-
required ? ts.factory.createTrue() : ts.factory.createFalse()
|
|
69
|
-
), setValue = (typeValue) => Array.isArray(typeValue) && typeValue.every((value) => typeof value.value == "string") ? ts.factory.createPropertyAssignment(
|
|
70
|
-
ts.factory.createStringLiteral("value"),
|
|
71
|
-
ts.factory.createArrayLiteralExpression(
|
|
72
|
-
typeValue.map(
|
|
73
|
-
(value) => ts.factory.createObjectLiteralExpression([
|
|
74
|
-
setStringLiteralField("value", value.value)
|
|
75
|
-
])
|
|
76
|
-
)
|
|
77
|
-
)
|
|
78
|
-
) : void 0, setType = (typeName, typeValue) => {
|
|
79
|
-
let objectFields = [setStringLiteralField("name", typeName)], valueField = setValue(typeValue);
|
|
80
|
-
return valueField && objectFields.push(valueField), ts.factory.createPropertyAssignment(
|
|
81
|
-
ts.factory.createStringLiteral(options.typePropName),
|
|
82
|
-
ts.factory.createObjectLiteralExpression(objectFields)
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
return ts.factory.createPropertyAssignment(
|
|
86
|
-
ts.factory.createStringLiteral(propName),
|
|
87
|
-
ts.factory.createObjectLiteralExpression([
|
|
88
|
-
setDefaultValue(prop.defaultValue),
|
|
89
|
-
setDescription(prop.description),
|
|
90
|
-
setName(prop.name),
|
|
91
|
-
setRequired(prop.required),
|
|
92
|
-
setType(prop.type.name, prop.type.value)
|
|
93
|
-
])
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
function setComponentDocGen(d, options) {
|
|
97
|
-
return insertTsIgnoreBeforeStatement(
|
|
98
|
-
ts.factory.createExpressionStatement(
|
|
99
|
-
ts.factory.createBinaryExpression(
|
|
100
|
-
// SimpleComponent.__docgenInfo
|
|
101
|
-
ts.factory.createPropertyAccessExpression(
|
|
102
|
-
ts.factory.createIdentifier(d.displayName),
|
|
103
|
-
ts.factory.createIdentifier("__docgenInfo")
|
|
104
|
-
),
|
|
105
|
-
ts.SyntaxKind.EqualsToken,
|
|
106
|
-
ts.factory.createObjectLiteralExpression([
|
|
107
|
-
// SimpleComponent.__docgenInfo.description
|
|
108
|
-
ts.factory.createPropertyAssignment(
|
|
109
|
-
ts.factory.createStringLiteral("description"),
|
|
110
|
-
ts.factory.createStringLiteral(d.description)
|
|
111
|
-
),
|
|
112
|
-
// SimpleComponent.__docgenInfo.displayName
|
|
113
|
-
ts.factory.createPropertyAssignment(
|
|
114
|
-
ts.factory.createStringLiteral("displayName"),
|
|
115
|
-
ts.factory.createStringLiteral(d.displayName)
|
|
116
|
-
),
|
|
117
|
-
// SimpleComponent.__docgenInfo.props
|
|
118
|
-
ts.factory.createPropertyAssignment(
|
|
119
|
-
ts.factory.createStringLiteral("props"),
|
|
120
|
-
ts.factory.createObjectLiteralExpression(
|
|
121
|
-
Object.entries(d.props).map(
|
|
122
|
-
([propName, prop]) => createPropDefinition(propName, prop, options)
|
|
123
|
-
)
|
|
124
|
-
)
|
|
125
|
-
)
|
|
126
|
-
])
|
|
127
|
-
)
|
|
128
|
-
)
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
function generateDocgenCodeBlock(options) {
|
|
132
|
-
let sourceFile = ts.createSourceFile(
|
|
133
|
-
options.filename,
|
|
134
|
-
options.source,
|
|
135
|
-
ts.ScriptTarget.ESNext
|
|
136
|
-
), wrapInTryStatement = (statements) => ts.factory.createTryStatement(
|
|
137
|
-
ts.factory.createBlock(statements, !0),
|
|
138
|
-
ts.factory.createCatchClause(
|
|
139
|
-
ts.factory.createVariableDeclaration(
|
|
140
|
-
ts.factory.createIdentifier("__react_docgen_typescript_loader_error")
|
|
141
|
-
),
|
|
142
|
-
ts.factory.createBlock([])
|
|
143
|
-
),
|
|
144
|
-
void 0
|
|
145
|
-
), codeBlocks = options.componentDocs.map(
|
|
146
|
-
(d) => wrapInTryStatement(
|
|
147
|
-
[
|
|
148
|
-
options.setDisplayName ? setDisplayName(d) : null,
|
|
149
|
-
setComponentDocGen(d, options)
|
|
150
|
-
].filter((s2) => s2 !== null)
|
|
151
|
-
)
|
|
152
|
-
), printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }), printNode = (sourceNode) => printer.printNode(ts.EmitHint.Unspecified, sourceNode, sourceFile), s = new MagicString(options.source, {
|
|
153
|
-
filename: options.filename
|
|
154
|
-
});
|
|
155
|
-
for (let node of codeBlocks)
|
|
156
|
-
s.append(printNode(node));
|
|
157
|
-
return {
|
|
158
|
-
code: s.toString(),
|
|
159
|
-
map: s.generateMap({
|
|
160
|
-
source: options.filename,
|
|
161
|
-
includeContent: !0,
|
|
162
|
-
hires: !0
|
|
163
|
-
})
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
export {
|
|
167
|
-
generateDocgenCodeBlock
|
|
168
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_a0ef041aa6a9c434 from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434 from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434 from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_a0ef041aa6a9c434.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
import "./chunk-TPE2Q567.js";
|
|
13
|
-
|
|
14
|
-
// src/plugins/react-docgen-typescript/utils/options.ts
|
|
15
|
-
function getGenerateOptions(options) {
|
|
16
|
-
let { setDisplayName = !0, typePropName = "type" } = options;
|
|
17
|
-
return {
|
|
18
|
-
setDisplayName,
|
|
19
|
-
typePropName
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
getGenerateOptions
|
|
24
|
-
};
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_a0ef041aa6a9c434 from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434 from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434 from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_a0ef041aa6a9c434.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
import "./chunk-TPE2Q567.js";
|
|
13
|
-
|
|
14
|
-
// src/plugins/react-docgen-typescript/index.ts
|
|
15
|
-
import { createFilter } from "@rollup/pluginutils";
|
|
16
|
-
|
|
17
|
-
// src/plugins/react-docgen-typescript/utils/filter.ts
|
|
18
|
-
var defaultPropFilter = (prop) => !prop.parent?.fileName.includes("node_modules");
|
|
19
|
-
|
|
20
|
-
// src/plugins/react-docgen-typescript/index.ts
|
|
21
|
-
var getDocgen = async (config) => {
|
|
22
|
-
let docGen = await import("react-docgen-typescript"), {
|
|
23
|
-
tsconfigPath,
|
|
24
|
-
compilerOptions,
|
|
25
|
-
propFilter = defaultPropFilter,
|
|
26
|
-
setDisplayName,
|
|
27
|
-
typePropName,
|
|
28
|
-
...rest
|
|
29
|
-
} = config, docgenOptions = {
|
|
30
|
-
propFilter,
|
|
31
|
-
...rest
|
|
32
|
-
};
|
|
33
|
-
return docGen.withCompilerOptions(
|
|
34
|
-
// Compiler Options are passed in to the custom program.
|
|
35
|
-
{},
|
|
36
|
-
docgenOptions
|
|
37
|
-
);
|
|
38
|
-
}, startWatch = async (config, onProgramCreatedOrUpdated) => {
|
|
39
|
-
let { default: ts } = await import("typescript"), { getTSConfigFile } = await import("./typescript-VNYISKUD.js"), compilerOptions = {
|
|
40
|
-
jsx: ts.JsxEmit.React,
|
|
41
|
-
module: ts.ModuleKind.CommonJS,
|
|
42
|
-
target: ts.ScriptTarget.Latest
|
|
43
|
-
}, tsconfigPath = config.tsconfigPath ?? "./tsconfig.json";
|
|
44
|
-
if (config.compilerOptions)
|
|
45
|
-
compilerOptions = {
|
|
46
|
-
...compilerOptions,
|
|
47
|
-
...config.compilerOptions
|
|
48
|
-
};
|
|
49
|
-
else {
|
|
50
|
-
let { options: tsOptions } = getTSConfigFile(tsconfigPath);
|
|
51
|
-
compilerOptions = { ...compilerOptions, ...tsOptions };
|
|
52
|
-
}
|
|
53
|
-
let host = ts.createWatchCompilerHost(
|
|
54
|
-
tsconfigPath,
|
|
55
|
-
compilerOptions,
|
|
56
|
-
ts.sys,
|
|
57
|
-
ts.createSemanticDiagnosticsBuilderProgram,
|
|
58
|
-
void 0,
|
|
59
|
-
() => {
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
return host.afterProgramCreate = (program) => {
|
|
63
|
-
onProgramCreatedOrUpdated(program.getProgram());
|
|
64
|
-
}, new Promise((resolve) => {
|
|
65
|
-
let watch = ts.createWatchProgram(host);
|
|
66
|
-
resolve([watch.getProgram().getProgram(), watch.close]);
|
|
67
|
-
});
|
|
68
|
-
}, react_docgen_typescript_default = (config = {}) => {
|
|
69
|
-
let tsProgram, docGenParser, generateDocgenCodeBlock, generateOptions, filter, moduleInvalidationQueue = /* @__PURE__ */ new Map(), closeWatch;
|
|
70
|
-
return {
|
|
71
|
-
name: "rsbuild-plugin-react-docgen-typescript",
|
|
72
|
-
setup(api) {
|
|
73
|
-
api.modifyRsbuildConfig(async () => {
|
|
74
|
-
let { getGenerateOptions } = await import("./options-YEVZIRR2.js");
|
|
75
|
-
generateDocgenCodeBlock = (await import("./generate-4YW4NBRQ.js")).generateDocgenCodeBlock, docGenParser = await getDocgen(config), generateOptions = getGenerateOptions(config), [tsProgram, closeWatch] = await startWatch(config, (program) => {
|
|
76
|
-
tsProgram = program;
|
|
77
|
-
for (let [
|
|
78
|
-
filepath,
|
|
79
|
-
invalidateModule
|
|
80
|
-
] of moduleInvalidationQueue.entries())
|
|
81
|
-
invalidateModule(), moduleInvalidationQueue.delete(filepath);
|
|
82
|
-
}), filter = createFilter(
|
|
83
|
-
config.include ?? ["**/**.tsx"],
|
|
84
|
-
config.exclude ?? ["**/**.stories.tsx"]
|
|
85
|
-
);
|
|
86
|
-
}), api.transform(
|
|
87
|
-
{
|
|
88
|
-
test: (id) => filter(id)
|
|
89
|
-
},
|
|
90
|
-
async ({ code: src, resource: id }) => {
|
|
91
|
-
try {
|
|
92
|
-
let componentDocs = docGenParser.parseWithProgramProvider(
|
|
93
|
-
id,
|
|
94
|
-
() => tsProgram
|
|
95
|
-
);
|
|
96
|
-
return componentDocs.length ? generateDocgenCodeBlock({
|
|
97
|
-
filename: id,
|
|
98
|
-
source: src,
|
|
99
|
-
componentDocs,
|
|
100
|
-
...generateOptions
|
|
101
|
-
}) : { code: src };
|
|
102
|
-
} catch {
|
|
103
|
-
return src;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
), api.onCloseBuild(() => {
|
|
107
|
-
closeWatch();
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
export {
|
|
113
|
-
react_docgen_typescript_default as default
|
|
114
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_a0ef041aa6a9c434 from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434 from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434 from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_a0ef041aa6a9c434.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
import "./chunk-TPE2Q567.js";
|
|
13
|
-
|
|
14
|
-
// src/plugins/react-docgen-typescript/utils/typescript.ts
|
|
15
|
-
import { dirname } from "node:path";
|
|
16
|
-
import ts from "typescript";
|
|
17
|
-
function getTSConfigFile(tsconfigPath) {
|
|
18
|
-
try {
|
|
19
|
-
let basePath = dirname(tsconfigPath), configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
|
|
20
|
-
return ts.parseJsonConfigFileContent(
|
|
21
|
-
configFile.config,
|
|
22
|
-
ts.sys,
|
|
23
|
-
basePath,
|
|
24
|
-
{},
|
|
25
|
-
tsconfigPath
|
|
26
|
-
);
|
|
27
|
-
} catch {
|
|
28
|
-
return {};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
getTSConfigFile
|
|
33
|
-
};
|