storybook-react-rsbuild 0.0.3 → 0.0.4

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.
@@ -1,4 +1,4 @@
1
- import { BuilderOptions as BuilderOptions$1, StorybookConfigRsbuild } from 'storybook-builder-rsbuild';
1
+ import { BuilderOptions as BuilderOptions$1, StorybookConfigRsbuild, TypescriptOptions as TypescriptOptions$1 } from 'storybook-builder-rsbuild';
2
2
  import { FileSystemCache } from 'file-system-cache';
3
3
  import { Server } from 'http';
4
4
  import { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
@@ -869,7 +869,7 @@ interface DirectoryMapping {
869
869
  to: string;
870
870
  }
871
871
  interface Presets {
872
- apply(extension: 'typescript', config: TypescriptOptions$1, args?: Options): Promise<TypescriptOptions$1>;
872
+ apply(extension: 'typescript', config: TypescriptOptions, args?: Options): Promise<TypescriptOptions>;
873
873
  apply(extension: 'framework', config?: {}, args?: any): Promise<Preset>;
874
874
  apply(extension: 'babel', config?: {}, args?: any): Promise<any>;
875
875
  apply(extension: 'swc', config?: {}, args?: any): Promise<any>;
@@ -956,7 +956,7 @@ type Options = LoadOptions & StorybookConfigOptions & CLIOptions & BuilderOption
956
956
  /**
957
957
  * Options for TypeScript usage within Storybook.
958
958
  */
959
- interface TypescriptOptions$1 {
959
+ interface TypescriptOptions {
960
960
  /**
961
961
  * Enables type checking within Storybook.
962
962
  *
@@ -1084,7 +1084,7 @@ interface StorybookConfigRaw {
1084
1084
  build?: TestBuildConfig;
1085
1085
  stories: StoriesEntry[];
1086
1086
  framework?: Preset;
1087
- typescript?: Partial<TypescriptOptions$1>;
1087
+ typescript?: Partial<TypescriptOptions>;
1088
1088
  refs?: CoreCommon_StorybookRefs;
1089
1089
  babel?: any;
1090
1090
  swc?: any;
@@ -1212,19 +1212,7 @@ type FrameworkOptions = {
1212
1212
  */
1213
1213
  legacyRootApi?: boolean;
1214
1214
  };
1215
- type StorybookConfigFramework = {
1216
- framework: FrameworkName | {
1217
- name: FrameworkName;
1218
- options: FrameworkOptions;
1219
- };
1220
- core?: StorybookConfig$1['core'] & {
1221
- builder?: BuilderName | {
1222
- name: BuilderName;
1223
- options: BuilderOptions$1;
1224
- };
1225
- };
1226
- };
1227
- type TypescriptOptions = StorybookConfig$1['typescript'] & {
1215
+ type TypescriptOptionsReact = {
1228
1216
  /**
1229
1217
  * Sets the type of Docgen when working with React and TypeScript
1230
1218
  *
@@ -1239,11 +1227,22 @@ type TypescriptOptions = StorybookConfig$1['typescript'] & {
1239
1227
  */
1240
1228
  reactDocgenTypescriptOptions: PluginOptions;
1241
1229
  };
1230
+ type StorybookConfigFramework = {
1231
+ framework: FrameworkName | {
1232
+ name: FrameworkName;
1233
+ options: FrameworkOptions;
1234
+ };
1235
+ core?: StorybookConfig$1['core'] & {
1236
+ builder?: BuilderName | {
1237
+ name: BuilderName;
1238
+ options: BuilderOptions$1;
1239
+ };
1240
+ };
1241
+ typescript?: Partial<TypescriptOptions & TypescriptOptions$1 & TypescriptOptionsReact>;
1242
+ };
1242
1243
  /**
1243
1244
  * The interface for Storybook configuration in `main.ts` files.
1244
1245
  */
1245
- type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigRsbuild | keyof StorybookConfigFramework> & StorybookConfigRsbuild & StorybookConfigFramework & {
1246
- typescript?: Partial<TypescriptOptions>;
1247
- };
1246
+ type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigRsbuild | keyof StorybookConfigFramework> & StorybookConfigRsbuild & StorybookConfigFramework;
1248
1247
 
1249
1248
  export { FrameworkOptions as F, PresetProperty as P, StorybookConfig as S };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { F as FrameworkOptions, S as StorybookConfig } from './index-8df66448.js';
1
+ export { F as FrameworkOptions, S as StorybookConfig } from './index-0d1103e1.js';
2
2
  import 'storybook-builder-rsbuild';
3
3
  import 'file-system-cache';
4
4
  import 'http';
@@ -103,6 +103,7 @@ function defaultLookupModule(filename, basedir) {
103
103
  // src/loaders/react-docgen-loader.ts
104
104
  var { getNameOrValue, isReactForwardRefCall } = import_react_docgen.utils;
105
105
  var actualNameHandler = function actualNameHandler2(documentation, componentDefinition) {
106
+ documentation.set("definedInFile", componentDefinition.hub.file.opts.filename);
106
107
  if ((componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id")) {
107
108
  documentation.set(
108
109
  "actualName",
@@ -177,8 +178,8 @@ async function reactDocgenLoader(source) {
177
178
  });
178
179
  const magicString = new import_magic_string.default(source);
179
180
  docgenResults.forEach((info) => {
180
- const { actualName, ...docgenInfo } = info;
181
- if (actualName) {
181
+ const { actualName, definedInFile, ...docgenInfo } = info;
182
+ if (actualName && definedInFile === this.resourcePath) {
182
183
  const docNode = JSON.stringify(docgenInfo);
183
184
  magicString.append(`;${actualName}.__docgenInfo=${docNode}`);
184
185
  }
@@ -67,6 +67,7 @@ function defaultLookupModule(filename, basedir) {
67
67
  // src/loaders/react-docgen-loader.ts
68
68
  var { getNameOrValue, isReactForwardRefCall } = utils;
69
69
  var actualNameHandler = function actualNameHandler2(documentation, componentDefinition) {
70
+ documentation.set("definedInFile", componentDefinition.hub.file.opts.filename);
70
71
  if ((componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id")) {
71
72
  documentation.set(
72
73
  "actualName",
@@ -141,8 +142,8 @@ async function reactDocgenLoader(source) {
141
142
  });
142
143
  const magicString = new MagicString(source);
143
144
  docgenResults.forEach((info) => {
144
- const { actualName, ...docgenInfo } = info;
145
- if (actualName) {
145
+ const { actualName, definedInFile, ...docgenInfo } = info;
146
+ if (actualName && definedInFile === this.resourcePath) {
146
147
  const docNode = JSON.stringify(docgenInfo);
147
148
  magicString.append(`;${actualName}.__docgenInfo=${docNode}`);
148
149
  }
package/dist/preset.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as StorybookConfig, P as PresetProperty } from './index-8df66448.js';
1
+ import { S as StorybookConfig, P as PresetProperty } from './index-0d1103e1.js';
2
2
  import 'storybook-builder-rsbuild';
3
3
  import 'file-system-cache';
4
4
  import 'http';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-react-rsbuild",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Storybook for React and Rsbuild: Develop React components in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook",
@@ -60,7 +60,7 @@
60
60
  "react-docgen": "^7.0.3",
61
61
  "resolve": "^1.22.8",
62
62
  "tsconfig-paths": "^4.2.0",
63
- "storybook-builder-rsbuild": "0.0.3"
63
+ "storybook-builder-rsbuild": "0.0.4"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@storybook/types": "^8.0.10",