storybook-react-rsbuild 0.0.1-beta.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 fi3ework
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Storybook for React & Webpack
2
+
3
+ See [documentation](https://storybook.js.org/docs/8.0/get-started/react-webpack5?renderer=react) for installation instructions, usage examples, APIs, and more.
@@ -0,0 +1,17 @@
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
+ };
@@ -0,0 +1,80 @@
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
+ };
File without changes
@@ -0,0 +1,2 @@
1
+ // dev-mode
2
+ export * from '../src/index';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/index.ts
17
+ var src_exports = {};
18
+ module.exports = __toCommonJS(src_exports);
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,2 @@
1
+ // dev-mode
2
+ export * from '../src/preset';
package/dist/preset.js ADDED
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/preset.ts
21
+ var preset_exports = {};
22
+ __export(preset_exports, {
23
+ core: () => core,
24
+ rsbuildFinal: () => rsbuildFinal
25
+ });
26
+ module.exports = __toCommonJS(preset_exports);
27
+ var import_path = require("path");
28
+
29
+ // src/react-docs.ts
30
+ var import_docs_tools = require("@storybook/docs-tools");
31
+ var import_core = require("@rsbuild/core");
32
+
33
+ // src/requirer.ts
34
+ function requirer(resolver, path) {
35
+ return resolver(path);
36
+ }
37
+
38
+ // src/react-docs.ts
39
+ var rsbuildFinalDocs = async (config, options) => {
40
+ if (!(0, import_docs_tools.hasDocsOrControls)(options))
41
+ return config;
42
+ const typescriptOptions = await options.presets.apply("typescript", {});
43
+ const debug = options.loglevel === "debug";
44
+ const { reactDocgen } = typescriptOptions || {};
45
+ if (typeof reactDocgen !== "string") {
46
+ return config;
47
+ }
48
+ if (reactDocgen !== "react-docgen-typescript") {
49
+ return (0, import_core.mergeRsbuildConfig)(config, {
50
+ tools: {
51
+ rspack: {
52
+ module: {
53
+ rules: [
54
+ {
55
+ test: /\.(cjs|mjs|tsx?|jsx?)$/,
56
+ enforce: "pre",
57
+ loader: requirer(
58
+ require.resolve,
59
+ "@storybook/preset-react-webpack/dist/loaders/react-docgen-loader"
60
+ ),
61
+ options: {
62
+ debug
63
+ },
64
+ exclude: /(\.(stories|story)\.(js|jsx|ts|tsx))|(node_modules)/
65
+ }
66
+ ]
67
+ }
68
+ }
69
+ }
70
+ });
71
+ }
72
+ throw new Error(
73
+ "Rspack didn't support the hooks `react-docgen-typescript`' required"
74
+ );
75
+ };
76
+
77
+ // src/preset.ts
78
+ var getAbsolutePath = (input) => (0, import_path.dirname)(require.resolve((0, import_path.join)(input, "package.json")));
79
+ var rsbuildFinal = async (config, options) => {
80
+ const finalConfig = rsbuildFinalDocs(config, options);
81
+ return finalConfig;
82
+ };
83
+ var core = async (config, options) => {
84
+ const framework = await options.presets.apply("framework");
85
+ return {
86
+ ...config,
87
+ builder: {
88
+ name: getAbsolutePath("storybook-builder-rsbuild"),
89
+ options: typeof framework === "string" ? {} : framework.options.builder || {}
90
+ },
91
+ renderer: getAbsolutePath("@storybook/react")
92
+ };
93
+ };
94
+ // Annotate the CommonJS export names for ESM import in node:
95
+ 0 && (module.exports = {
96
+ core,
97
+ rsbuildFinal
98
+ });
@@ -0,0 +1,25 @@
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
+ };
@@ -0,0 +1,116 @@
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/react-docs.ts
31
+ var react_docs_exports = {};
32
+ __export(react_docs_exports, {
33
+ rsbuildFinal: () => rsbuildFinal
34
+ });
35
+ module.exports = __toCommonJS(react_docs_exports);
36
+ var import_docs_tools = require("@storybook/docs-tools");
37
+ var import_core = require("@rsbuild/core");
38
+
39
+ // src/requirer.ts
40
+ function requirer(resolver, path) {
41
+ return resolver(path);
42
+ }
43
+
44
+ // src/react-docs.ts
45
+ var rsbuildFinal = async (config, options) => {
46
+ if (!(0, import_docs_tools.hasDocsOrControls)(options))
47
+ return config;
48
+ const typescriptOptions = await options.presets.apply("typescript", {});
49
+ const debug = options.loglevel === "debug";
50
+ const { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions || {};
51
+ if (typeof reactDocgen !== "string") {
52
+ return config;
53
+ }
54
+ if (reactDocgen !== "react-docgen-typescript") {
55
+ return (0, import_core.mergeRsbuildConfig)(config, {
56
+ tools: {
57
+ rspack: {
58
+ module: {
59
+ rules: [
60
+ {
61
+ test: /\.(cjs|mjs|tsx?|jsx?)$/,
62
+ enforce: "pre",
63
+ loader: requirer(
64
+ require.resolve,
65
+ "@storybook/preset-react-webpack/dist/loaders/react-docgen-loader"
66
+ ),
67
+ options: {
68
+ debug
69
+ },
70
+ exclude: /(\.(stories|story)\.(js|jsx|ts|tsx))|(node_modules)/
71
+ }
72
+ ]
73
+ }
74
+ }
75
+ }
76
+ });
77
+ }
78
+ const { ReactDocgenTypeScriptPlugin } = await import("@storybook/react-docgen-typescript-plugin");
79
+ throw new Error(
80
+ "Rspack didn't support the hooks `react-docgen-typescript`' required"
81
+ );
82
+ return (0, import_core.mergeRsbuildConfig)(config, {
83
+ tools: {
84
+ rspack: {
85
+ module: {
86
+ rules: [
87
+ {
88
+ test: /\.(cjs|mjs|jsx?)$/,
89
+ enforce: "pre",
90
+ loader: requirer(
91
+ require.resolve,
92
+ "@storybook/preset-react-webpack/dist/loaders/react-docgen-loader"
93
+ ),
94
+ options: {
95
+ debug
96
+ },
97
+ exclude: /(\.(stories|story)\.(js|jsx|ts|tsx))|(node_modules)/
98
+ }
99
+ ]
100
+ },
101
+ plugins: [
102
+ ...config.plugins || [],
103
+ new ReactDocgenTypeScriptPlugin({
104
+ ...reactDocgenTypescriptOptions,
105
+ // We *need* this set so that RDT returns default values in the same format as react-docgen
106
+ savePropValueAsString: true
107
+ })
108
+ ]
109
+ }
110
+ }
111
+ });
112
+ };
113
+ // Annotate the CommonJS export names for ESM import in node:
114
+ 0 && (module.exports = {
115
+ rsbuildFinal
116
+ });
@@ -0,0 +1,7 @@
1
+ import {
2
+ rsbuildFinal
3
+ } from "./chunk-TNRF4JXJ.mjs";
4
+ import "./chunk-77YOQVQO.mjs";
5
+ export {
6
+ rsbuildFinal
7
+ };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/requirer.ts
21
+ var requirer_exports = {};
22
+ __export(requirer_exports, {
23
+ requirer: () => requirer
24
+ });
25
+ module.exports = __toCommonJS(requirer_exports);
26
+ function requirer(resolver, path) {
27
+ return resolver(path);
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ requirer
32
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ requirer
3
+ } from "./chunk-77YOQVQO.mjs";
4
+ export {
5
+ requirer
6
+ };
package/dist/types.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+ import "./chunk-WBQAMGXK.mjs";
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "storybook-react-rsbuild",
3
+ "version": "0.0.1-beta.0",
4
+ "description": "Storybook for React and Rsbuild: Develop React components in isolation with Hot Reloading.",
5
+ "keywords": [
6
+ "storybook"
7
+ ],
8
+ "license": "MIT",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "node": "./dist/index.js",
13
+ "require": "./dist/index.js",
14
+ "import": "./dist/index.mjs"
15
+ },
16
+ "./preset": {
17
+ "types": "./dist/preset.d.ts",
18
+ "require": "./dist/preset.js"
19
+ },
20
+ "./react-docs": {
21
+ "types": "./dist/react-docs.d.ts",
22
+ "require": "./dist/react-docs.js"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "main": "dist/index.js",
27
+ "module": "dist/index.mjs",
28
+ "types": "dist/index.d.ts",
29
+ "files": [
30
+ "dist/**/*",
31
+ "README.md",
32
+ "*.js",
33
+ "*.d.ts",
34
+ "!src/**/*"
35
+ ],
36
+ "dependencies": {
37
+ "@storybook/docs-tools": "8.0.10",
38
+ "@storybook/react-docgen-typescript-plugin": "1.0.1",
39
+ "@storybook/react": "8.0.10",
40
+ "@rsbuild/core": "0.6.15",
41
+ "@types/node": "^18.0.0",
42
+ "storybook-builder-rsbuild": "0.0.1-beta.0"
43
+ },
44
+ "peerDependencies": {
45
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
46
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
47
+ "typescript": ">= 4.2.x"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "typescript": {
51
+ "optional": true
52
+ }
53
+ },
54
+ "engines": {
55
+ "node": ">=18.0.0"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ },
60
+ "bundler": {
61
+ "entries": [
62
+ "./src/index.ts",
63
+ "./src/preset.ts"
64
+ ],
65
+ "platform": "node"
66
+ },
67
+ "devDependencies": {
68
+ "@storybook/types": "8.0.10",
69
+ "add": "^2.0.6"
70
+ },
71
+ "scripts": {
72
+ "check": "node --loader ../../scripts/node_modules/esbuild-register/loader.js -r ../../scripts/node_modules/esbuild-register/register.js ../../scripts/prepare/check.ts",
73
+ "prep": "node --loader ../../scripts/node_modules/esbuild-register/loader.js -r ../../scripts/node_modules/esbuild-register/register.js ../../scripts/prepare/bundle.ts"
74
+ }
75
+ }
package/preset.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/preset');