storybook-react-rsbuild 3.6.0 → 4.0.0-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.
@@ -10,7 +10,7 @@ const getDocgen = async (config)=>{
10
10
  };
11
11
  return docGen.withCompilerOptions({}, docgenOptions);
12
12
  };
13
- const startWatch = async (config, onProgramCreatedOrUpdated)=>{
13
+ const startProgram = async (config, isBuild, onProgramCreatedOrUpdated)=>{
14
14
  const { default: ts } = await import("typescript");
15
15
  const { getTSConfigFile } = await import("./typescript-69cd7fa9.js");
16
16
  let compilerOptions = {
@@ -30,6 +30,21 @@ const startWatch = async (config, onProgramCreatedOrUpdated)=>{
30
30
  ...tsOptions
31
31
  };
32
32
  }
33
+ if (isBuild) {
34
+ const tsConfig = getTSConfigFile(tsconfigPath);
35
+ const program = ts.createProgram({
36
+ rootNames: tsConfig.fileNames ?? [],
37
+ options: {
38
+ ...tsConfig.options,
39
+ ...compilerOptions
40
+ },
41
+ projectReferences: tsConfig.projectReferences
42
+ });
43
+ return [
44
+ program,
45
+ ()=>{}
46
+ ];
47
+ }
33
48
  const host = ts.createWatchCompilerHost(tsconfigPath, compilerOptions, ts.sys, ts.createSemanticDiagnosticsBuilderProgram, void 0, ()=>{});
34
49
  host.afterProgramCreate = (program)=>{
35
50
  onProgramCreatedOrUpdated(program.getProgram());
@@ -58,7 +73,7 @@ const react_docgen_typescript = (config = {})=>{
58
73
  generateDocgenCodeBlock = (await import("./generate-1782ed11.js")).generateDocgenCodeBlock;
59
74
  docGenParser = await getDocgen(config);
60
75
  generateOptions = getGenerateOptions(config);
61
- [tsProgram, closeWatch] = await startWatch(config, (program)=>{
76
+ [tsProgram, closeWatch] = await startProgram(config, 'build' === api.context.action, (program)=>{
62
77
  tsProgram = program;
63
78
  for (const [filepath, invalidateModule] of moduleInvalidationQueue.entries()){
64
79
  invalidateModule();
@@ -90,9 +105,9 @@ const react_docgen_typescript = (config = {})=>{
90
105
  return src;
91
106
  }
92
107
  });
93
- api.onCloseBuild(()=>{
94
- closeWatch();
95
- });
108
+ const close = ()=>closeWatch?.();
109
+ api.onCloseBuild(close);
110
+ api.onCloseDevServer(close);
96
111
  }
97
112
  };
98
113
  };
package/dist/index.d.ts CHANGED
@@ -16,14 +16,6 @@ declare type FrameworkName = CompatibleString<'storybook-react-rsbuild'>;
16
16
  export declare type FrameworkOptions = {
17
17
  builder?: BuilderOptions;
18
18
  strictMode?: boolean;
19
- /**
20
- * Use React's legacy root API to mount components
21
- * @description
22
- * React has introduced a new root API with React 18.x to enable a whole set of new features (e.g. concurrent features)
23
- * If this flag is true, the legacy Root API is used to mount components to make it easier to migrate step by step to React 18.
24
- * @default false
25
- */
26
- legacyRootApi?: boolean;
27
19
  };
28
20
 
29
21
  /**
@@ -58,6 +50,7 @@ declare type TypescriptOptionsReact = {
58
50
  * Sets the type of Docgen when working with React and TypeScript
59
51
  *
60
52
  * @default `'react-docgen'`
53
+ * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
61
54
  */
62
55
  reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
63
56
  /**
@@ -65,6 +58,7 @@ declare type TypescriptOptionsReact = {
65
58
  *
66
59
  * @default
67
60
  * @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
61
+ * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
68
62
  */
69
63
  reactDocgenTypescriptOptions: PluginOptions;
70
64
  };
@@ -15,14 +15,6 @@ declare type FrameworkName = CompatibleString<'storybook-react-rsbuild'>;
15
15
  declare type FrameworkOptions = {
16
16
  builder?: BuilderOptions;
17
17
  strictMode?: boolean;
18
- /**
19
- * Use React's legacy root API to mount components
20
- * @description
21
- * React has introduced a new root API with React 18.x to enable a whole set of new features (e.g. concurrent features)
22
- * If this flag is true, the legacy Root API is used to mount components to make it easier to migrate step by step to React 18.
23
- * @default false
24
- */
25
- legacyRootApi?: boolean;
26
18
  };
27
19
 
28
20
  /**
@@ -57,6 +49,7 @@ declare type TypescriptOptionsReact = {
57
49
  * Sets the type of Docgen when working with React and TypeScript
58
50
  *
59
51
  * @default `'react-docgen'`
52
+ * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
60
53
  */
61
54
  reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
62
55
  /**
@@ -64,6 +57,7 @@ declare type TypescriptOptionsReact = {
64
57
  *
65
58
  * @default
66
59
  * @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
60
+ * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
67
61
  */
68
62
  reactDocgenTypescriptOptions: PluginOptions;
69
63
  };
package/dist/preset.d.ts CHANGED
@@ -16,14 +16,6 @@ declare type FrameworkName = CompatibleString<'storybook-react-rsbuild'>;
16
16
  declare type FrameworkOptions = {
17
17
  builder?: BuilderOptions;
18
18
  strictMode?: boolean;
19
- /**
20
- * Use React's legacy root API to mount components
21
- * @description
22
- * React has introduced a new root API with React 18.x to enable a whole set of new features (e.g. concurrent features)
23
- * If this flag is true, the legacy Root API is used to mount components to make it easier to migrate step by step to React 18.
24
- * @default false
25
- */
26
- legacyRootApi?: boolean;
27
19
  };
28
20
 
29
21
  export declare const rsbuildFinal: NonNullable<StorybookConfig['rsbuildFinal']>;
@@ -60,6 +52,7 @@ declare type TypescriptOptionsReact = {
60
52
  * Sets the type of Docgen when working with React and TypeScript
61
53
  *
62
54
  * @default `'react-docgen'`
55
+ * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
63
56
  */
64
57
  reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
65
58
  /**
@@ -67,6 +60,7 @@ declare type TypescriptOptionsReact = {
67
60
  *
68
61
  * @default
69
62
  * @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
63
+ * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
70
64
  */
71
65
  reactDocgenTypescriptOptions: PluginOptions;
72
66
  };
package/dist/preset.js CHANGED
@@ -3,16 +3,18 @@ const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/
3
3
  import { mergeRsbuildConfig } from "@rsbuild/core";
4
4
  import { createRequire } from "node:module";
5
5
  import { fileURLToPath } from "node:url";
6
+ import { deprecate } from "storybook/internal/node-logger";
6
7
  function requirer(resolver, path) {
7
8
  return resolver(path);
8
9
  }
9
10
  const rsbuildFinalDocs = async (config, options)=>{
10
11
  const features = await options.presets.apply('features', {});
11
- if (features?.experimentalDocgenServer) return config;
12
+ if (features?.docgenServer) return config;
12
13
  const typescriptOptions = await options.presets.apply("typescript", {});
13
14
  const debug = 'debug' === options.loglevel;
14
15
  const { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions || {};
15
16
  if ('string' != typeof reactDocgen) return config;
17
+ deprecate(`Builder docgen (\`typescript.reactDocgen: '${reactDocgen}'\`) is deprecated and will be removed in Storybook 12. It runs because \`features.docgenServer\` is off. Server-side docgen needs the \`typescript\` package: install it and remove any \`docgenServer: false\` from your \`.storybook/main.ts\`.`);
16
18
  const reactDocgenLoaderRule = (test)=>({
17
19
  test,
18
20
  enforce: 'pre',
@@ -41,7 +43,7 @@ const rsbuildFinalDocs = async (config, options)=>{
41
43
  }
42
44
  }
43
45
  });
44
- const reactDocGenTsPlugin = await import("./chunks/react-docgen-typescript-9f56b1df.js");
46
+ const reactDocGenTsPlugin = await import("./chunks/react-docgen-typescript-16ec96c4.js");
45
47
  return mergeRsbuildConfig(config, {
46
48
  tools: {
47
49
  rspack: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-react-rsbuild",
3
- "version": "3.6.0",
3
+ "version": "4.0.0-beta.0",
4
4
  "description": "Storybook for React and Rsbuild: Develop React components in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook",
@@ -47,32 +47,32 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "@rollup/pluginutils": "^5.4.0",
50
- "@storybook/react": "^10.6.0",
50
+ "@storybook/react": "^11.0.0-alpha.9",
51
51
  "@storybook/react-docgen-typescript-plugin": "^1.0.1",
52
- "magic-string": "^1.4.1",
53
- "react-docgen": "^8.0.3",
52
+ "magic-string": "^1.4.3",
53
+ "react-docgen": "^8.0.4",
54
54
  "react-docgen-typescript": "^2.4.0",
55
- "resolve": "^1.22.12",
55
+ "resolve": "^1.22.13",
56
56
  "tsconfig-paths": "^4.2.0",
57
- "storybook-builder-rsbuild": "3.6.0"
57
+ "storybook-builder-rsbuild": "4.0.0-beta.0"
58
58
  },
59
59
  "devDependencies": {
60
- "@microsoft/api-extractor": "^7.59.1",
61
- "@rsbuild/core": "^2.2.6",
62
- "@types/node": "^22.0.0",
60
+ "@microsoft/api-extractor": "^7.59.4",
61
+ "@rsbuild/core": "^2.2.13",
62
+ "@types/node": "^22.12.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.6.0",
67
+ "storybook": "11.0.0-alpha.9",
68
68
  "typescript": "^5.9.3"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@rsbuild/core": "^1.5.0 || ^2.0.0-0",
72
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
73
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
74
- "storybook": "^10.6.0",
75
- "typescript": ">= 4.2.x"
72
+ "react": "^18.0.0 || ^19.0.0",
73
+ "react-dom": "^18.0.0 || ^19.0.0",
74
+ "storybook": "^11.0.0-alpha.9",
75
+ "typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
76
76
  },
77
77
  "peerDependenciesMeta": {
78
78
  "typescript": {
@@ -80,7 +80,7 @@
80
80
  }
81
81
  },
82
82
  "engines": {
83
- "node": ">=18.0.0"
83
+ "node": ">=22.12.0"
84
84
  },
85
85
  "publishConfig": {
86
86
  "access": "public"