storybook-addon-rslib 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/index.d.ts CHANGED
@@ -1,41 +1,48 @@
1
- import { RsbuildConfig } from '@rsbuild/core';
2
- import { LibConfig } from '@rslib/core';
3
-
4
- interface AddonOptions {
5
- rslib?: {
6
- /**
7
- * `cwd` passed to loadConfig of Rslib
8
- * @default undefined
9
- */
10
- cwd?: string;
11
- /**
12
- * `path` passed to loadConfig of Rslib
13
- * @default undefined
14
- */
15
- configPath?: string;
16
- /**
17
- * The lib config index in `lib` field to use, will be merged with the other fields in the config.
18
- * Set to a number to use the lib config at that index.
19
- * Set to `false` to disable using the lib config.
20
- * @default 0
21
- */
22
- libIndex?: number | false;
23
- /**
24
- * Modify the Rslib lib config before transforming it to Rsbuild config which will be merged
25
- * with Storybook. You can modify the configuration in the config parameters in place.
26
- * @experimental subject to change at any time
27
- * @default undefined
28
- */
29
- modifyLibConfig?: (config: LibConfig) => void;
30
- /**
31
- * Modify the Rsbuild config transformed from lib config after inherited fields are stripped
32
- * and before merging with Storybook config. You can modify the configuration in the config
33
- * parameters in place, including explicitly restoring stripped fields.
34
- * @experimental subject to change at any time
35
- * @default undefined
36
- */
37
- modifyLibRsbuildConfig?: (config: RsbuildConfig) => void;
38
- };
39
- }
40
-
41
- export type { AddonOptions };
1
+ import type { LibConfig } from '@rslib/core';
2
+ import { RsbuildConfig } from '@rsbuild/core';
3
+
4
+ export declare interface AddonOptions {
5
+ rslib?: {
6
+ /**
7
+ * `cwd` passed to loadConfig of Rslib
8
+ * @default undefined
9
+ */
10
+ cwd?: string;
11
+ /**
12
+ * `path` passed to loadConfig of Rslib
13
+ * @default undefined
14
+ */
15
+ configPath?: string;
16
+ /**
17
+ * The lib config index in `lib` field to use, will be merged with the other fields in the config.
18
+ * Set to a number to use the lib config at that index.
19
+ * Set to `false` to disable using the lib config.
20
+ * @default 0
21
+ */
22
+ libIndex?: number | false;
23
+ /**
24
+ * Modify the Rslib lib config before transforming it to Rsbuild config which will be merged
25
+ * with Storybook. You can modify the configuration in the config parameters in place.
26
+ * @experimental subject to change at any time
27
+ * @default undefined
28
+ */
29
+ modifyLibConfig?: (config: LibConfig) => void;
30
+ /**
31
+ * Modify the Rsbuild config transformed from lib config after inherited fields are stripped
32
+ * and before merging with Storybook config. You can modify the configuration in the config
33
+ * parameters in place, including explicitly restoring stripped fields.
34
+ * @experimental subject to change at any time
35
+ * @default undefined
36
+ */
37
+ modifyLibRsbuildConfig?: (config: RsbuildConfig) => void;
38
+ };
39
+ }
40
+
41
+ /** Convert an Rslib config into the Rsbuild config of one lib entry, without running a library build. */
42
+ export declare function rslibConfigToRsbuildConfig(rslibConfig: {
43
+ [K in keyof RsbuildConfig]?: unknown;
44
+ } & {
45
+ lib?: unknown;
46
+ }, { libIndex, modifyLibConfig, }: Pick<NonNullable<AddonOptions['rslib']>, 'libIndex' | 'modifyLibConfig'>): RsbuildConfig;
47
+
48
+ export { }
package/dist/index.js CHANGED
@@ -1,11 +1,13 @@
1
- import CJS_COMPAT_NODE_URL_dde08712c3d45749 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_dde08712c3d45749 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_dde08712c3d45749 from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_dde08712c3d45749.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_dde08712c3d45749.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_dde08712c3d45749.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
1
+ import "node:module";
2
+ import { mergeRsbuildConfig } from "@rsbuild/core";
3
+ function rslibConfigToRsbuildConfig(rslibConfig, { libIndex = 0, modifyLibConfig }) {
4
+ const libConfigs = Array.isArray(rslibConfig.lib) ? rslibConfig.lib : [
5
+ {}
6
+ ];
7
+ const libConfig = false === libIndex ? {} : libConfigs[libIndex];
8
+ if (void 0 === libConfig) throw new Error(`Lib config not found at index ${libIndex}, expect a lib config but got ${libConfig}`);
9
+ if ('function' == typeof modifyLibConfig) modifyLibConfig(libConfig);
10
+ const { lib: _lib, environments: _environments, ...topLevel } = rslibConfig;
11
+ return mergeRsbuildConfig(topLevel, libConfig);
12
+ }
13
+ export { rslibConfigToRsbuildConfig };
package/dist/preset.js CHANGED
@@ -1,43 +1,27 @@
1
- import CJS_COMPAT_NODE_URL_dde08712c3d45749 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_dde08712c3d45749 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_dde08712c3d45749 from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_dde08712c3d45749.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_dde08712c3d45749.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_dde08712c3d45749.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
-
13
- // src/preset.ts
1
+ import "node:module";
14
2
  import { mergeRsbuildConfig } from "@rsbuild/core";
15
3
  import { loadConfig } from "@rslib/core";
16
- import {
17
- stripInheritedConfig
18
- } from "storybook-builder-rsbuild";
19
- var rsbuildFinal = async (config, options) => {
20
- let { rslib = {} } = options, {
21
- cwd,
22
- configPath,
23
- libIndex = 0,
24
- modifyLibConfig,
25
- modifyLibRsbuildConfig
26
- } = rslib, { content } = await loadConfig({
27
- cwd,
28
- path: configPath
29
- }), libConfigs = content.lib === void 0 ? [{}] : content.lib, libConfig = libIndex === !1 ? {} : Array.isArray(libConfigs) ? libConfigs[libIndex] : void 0;
30
- if (!libConfig)
31
- throw new Error(
32
- `Lib config not found at index ${libIndex}, expect a lib config but got ${libConfig}`
33
- );
34
- typeof modifyLibConfig == "function" && modifyLibConfig(libConfig);
35
- let { lib: _lib, ...nonLibConfig } = content, mergedLibConfig = mergeRsbuildConfig(
36
- nonLibConfig,
37
- libConfig
38
- );
39
- return stripInheritedConfig(mergedLibConfig, "the loaded Rslib config"), typeof modifyLibRsbuildConfig == "function" && modifyLibRsbuildConfig(mergedLibConfig), mergeRsbuildConfig(config, mergedLibConfig);
40
- };
41
- export {
42
- rsbuildFinal
4
+ import { stripInheritedConfig } from "storybook-builder-rsbuild";
5
+ function rslibConfigToRsbuildConfig(rslibConfig, { libIndex = 0, modifyLibConfig }) {
6
+ const libConfigs = Array.isArray(rslibConfig.lib) ? rslibConfig.lib : [
7
+ {}
8
+ ];
9
+ const libConfig = false === libIndex ? {} : libConfigs[libIndex];
10
+ if (void 0 === libConfig) throw new Error(`Lib config not found at index ${libIndex}, expect a lib config but got ${libConfig}`);
11
+ if ('function' == typeof modifyLibConfig) modifyLibConfig(libConfig);
12
+ const { lib: _lib, environments: _environments, ...topLevel } = rslibConfig;
13
+ return mergeRsbuildConfig(topLevel, libConfig);
14
+ }
15
+ const rsbuildFinal = async (config, options)=>{
16
+ const { rslib = {} } = options;
17
+ const { cwd, configPath, modifyLibRsbuildConfig, ...libOptions } = rslib;
18
+ const { content } = await loadConfig({
19
+ cwd,
20
+ path: configPath
21
+ });
22
+ const inherited = rslibConfigToRsbuildConfig(content, libOptions);
23
+ stripInheritedConfig(inherited, 'the loaded Rslib config');
24
+ if ('function' == typeof modifyLibRsbuildConfig) modifyLibRsbuildConfig(inherited);
25
+ return mergeRsbuildConfig(config, inherited);
43
26
  };
27
+ export { rsbuildFinal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-rslib",
3
- "version": "3.4.2",
3
+ "version": "3.6.0",
4
4
  "description": "Storybook addon for loading configuration of Rslib",
5
5
  "keywords": [
6
6
  "storybook",
@@ -36,17 +36,18 @@
36
36
  "!src/**/*"
37
37
  ],
38
38
  "devDependencies": {
39
- "@rsbuild/core": "^2.1.10",
40
- "@rslib/core": "^0.23.2",
39
+ "@microsoft/api-extractor": "^7.59.1",
40
+ "@rsbuild/core": "^2.2.6",
41
+ "@rslib/core": "~1.0.1",
41
42
  "@types/node": "^22.0.0",
42
- "storybook": "10.5.5",
43
+ "storybook": "10.6.0",
43
44
  "typescript": "^5.9.3",
44
- "storybook-builder-rsbuild": "3.4.2"
45
+ "storybook-builder-rsbuild": "3.6.0"
45
46
  },
46
47
  "peerDependencies": {
47
48
  "@rsbuild/core": "^1.5.0 || ^2.0.0-0",
48
- "@rslib/core": ">= 0.1.1 || >= 0.2",
49
- "storybook-builder-rsbuild": "^3.4.2"
49
+ "@rslib/core": ">= 0.1.1 || >= 0.2 || >= 1.0.0-0",
50
+ "storybook-builder-rsbuild": "^3.6.0"
50
51
  },
51
52
  "peerDependenciesMeta": {
52
53
  "typescript": {
@@ -64,8 +65,7 @@
64
65
  "platform": "node"
65
66
  },
66
67
  "scripts": {
67
- "build": "pnpm run prep --production",
68
- "check": "jiti ../../scripts/check/check-package.ts",
69
- "prep": "jiti ../../scripts/build/build-package.ts"
68
+ "build": "rstack lib",
69
+ "dev": "rstack lib --watch"
70
70
  }
71
71
  }