storybook-addon-rslib 0.1.2

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 Rspack Contrib
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,59 @@
1
+ # storybook-addon-rslib
2
+
3
+ ## Usage
4
+
5
+ 1. Install the addon
6
+
7
+ ```bash
8
+ pnpm add storybook-addon-rslib -D
9
+ ```
10
+
11
+ 2. Add it to `main.js`
12
+
13
+ ```ts
14
+ export default {
15
+ addons: ['storybook-addon-rslib'],
16
+ }
17
+ ```
18
+
19
+ or with config
20
+
21
+ ```ts
22
+ export default {
23
+ addons: [
24
+ {
25
+ name: 'storybook-addon-rslib',
26
+ options: {
27
+ // Check options section.
28
+ },
29
+ },
30
+ ],
31
+ }
32
+ ```
33
+
34
+ ## Options
35
+
36
+ ```ts
37
+ export interface AddonOptions {
38
+ rslib?: {
39
+ /**
40
+ * `cwd` passed to loadConfig of Rslib
41
+ * @default undefined
42
+ */
43
+ cwd?: string
44
+ /**
45
+ * `path` passed to loadConfig of Rslib
46
+ * @default undefined
47
+ */
48
+ configPath?: string
49
+ /**
50
+ * The lib config index in `lib` field to use, will be merged with the other fields in the config.
51
+ * Set to a number to use the lib config at that index.
52
+ * Set to `false` to disable using the lib config.
53
+ * @experimental subject to change at any time
54
+ * @default 0
55
+ */
56
+ libIndex?: number | false
57
+ }
58
+ }
59
+ ```
@@ -0,0 +1,24 @@
1
+ interface AddonOptions {
2
+ rslib?: {
3
+ /**
4
+ * `cwd` passed to loadConfig of Rslib
5
+ * @default undefined
6
+ */
7
+ cwd?: string;
8
+ /**
9
+ * `path` passed to loadConfig of Rslib
10
+ * @default undefined
11
+ */
12
+ configPath?: string;
13
+ /**
14
+ * The lib config index in `lib` field to use, will be merged with the other fields in the config.
15
+ * Set to a number to use the lib config at that index.
16
+ * Set to `false` to disable using the lib config.
17
+ * @experimental subject to change at any time
18
+ * @default 0
19
+ */
20
+ libIndex?: number | false;
21
+ };
22
+ }
23
+
24
+ export { AddonOptions };
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,5 @@
1
+ import { StorybookConfigRsbuild } from 'storybook-builder-rsbuild';
2
+
3
+ declare const rsbuildFinal: StorybookConfigRsbuild['rsbuildFinal'];
4
+
5
+ export { rsbuildFinal };
package/dist/preset.js ADDED
@@ -0,0 +1,54 @@
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
+ rsbuildFinal: () => rsbuildFinal
24
+ });
25
+ module.exports = __toCommonJS(preset_exports);
26
+ var import_core = require("@rsbuild/core");
27
+ var import_core2 = require("@rslib/core");
28
+ var rsbuildFinal = async (config, options) => {
29
+ const { rslib = {} } = options;
30
+ const { cwd, configPath, libIndex = 0 } = rslib;
31
+ const rslibConfig = await (0, import_core2.loadConfig)({
32
+ cwd,
33
+ path: configPath
34
+ });
35
+ const libConfig = libIndex === false ? {} : rslibConfig.lib[libIndex];
36
+ if (!libConfig) {
37
+ throw new Error(
38
+ `Lib config not found at index ${libIndex}, expect a lib config but got ${libConfig}`
39
+ );
40
+ }
41
+ const { lib: _lib, ...nonLibConfig } = rslibConfig;
42
+ const mergedLibConfig = (0, import_core.mergeRsbuildConfig)(
43
+ nonLibConfig,
44
+ libConfig
45
+ );
46
+ delete mergedLibConfig.source?.entry;
47
+ delete mergedLibConfig.output?.distPath;
48
+ delete mergedLibConfig.output?.filename;
49
+ return (0, import_core.mergeRsbuildConfig)(config, mergedLibConfig);
50
+ };
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ rsbuildFinal
54
+ });
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "storybook-addon-rslib",
3
+ "version": "0.1.2",
4
+ "description": "Storybook addon for loading configuration of Rslib",
5
+ "keywords": [
6
+ "storybook",
7
+ "storybook-addons",
8
+ "rsbuild",
9
+ "rspack",
10
+ "rslib"
11
+ ],
12
+ "bugs": {
13
+ "url": "https://github.com/rspack-contrib/storybook-rsbuild/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/rspack-contrib/storybook-rsbuild",
18
+ "directory": "packages/addon-rslib"
19
+ },
20
+ "license": "MIT",
21
+ "exports": {
22
+ ".": {
23
+ "require": "./dist/index.cjs",
24
+ "import": "./dist/index.js"
25
+ },
26
+ "./preset": "./dist/preset.cjs",
27
+ "./package.json": "./package.json"
28
+ },
29
+ "main": "dist/index.js",
30
+ "types": "dist/index.d.ts",
31
+ "files": [
32
+ "dist/**/*",
33
+ "README.md",
34
+ "*.js",
35
+ "*.d.ts",
36
+ "!src/**/*"
37
+ ],
38
+ "devDependencies": {
39
+ "@rsbuild/core": "1.0.17",
40
+ "@rslib/core": "0.0.13",
41
+ "@types/node": "^18.0.0",
42
+ "storybook": "8.4.0-alpha.7",
43
+ "typescript": "^5.6.3",
44
+ "storybook-builder-rsbuild": "0.1.2"
45
+ },
46
+ "peerDependencies": {
47
+ "@rsbuild/core": "^1.0.1",
48
+ "@rslib/core": "*",
49
+ "storybook-builder-rsbuild": "*"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "typescript": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "engines": {
57
+ "node": ">=18.0.0"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "bundler": {
63
+ "entries": [
64
+ "./src/index.ts",
65
+ "./src/preset.ts"
66
+ ],
67
+ "platform": "node"
68
+ },
69
+ "scripts": {
70
+ "build": "pnpm run prep --optimized",
71
+ "check": "node --loader ../../scripts/node_modules/esbuild-register/loader.js -r ../../scripts/node_modules/esbuild-register/register.js ../../scripts/prepare/check.ts",
72
+ "prep": "node --loader ../../scripts/node_modules/esbuild-register/loader.js -r ../../scripts/node_modules/esbuild-register/register.js ../../scripts/prepare/bundle.ts"
73
+ }
74
+ }
package/preset.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/preset')