@storybook/preset-react-webpack 11.0.0-beta.0 → 11.0.0-beta.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.
@@ -0,0 +1,49 @@
1
+ import CJS_COMPAT_NODE_URL_u7h7cccg9s from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_u7h7cccg9s from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_u7h7cccg9s from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_u7h7cccg9s.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_u7h7cccg9s.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_u7h7cccg9s.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ var __create = Object.create;
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __require = /* @__PURE__ */ ((x) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(x, {
18
+ get: (a, b) => (typeof require < "u" ? require : a)[b]
19
+ }) : x)(function(x) {
20
+ if (typeof require < "u") return require.apply(this, arguments);
21
+ throw Error('Dynamic require of "' + x + '" is not supported');
22
+ });
23
+ var __commonJS = (cb, mod) => function() {
24
+ try {
25
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
26
+ } catch (e) {
27
+ throw mod = 0, e;
28
+ }
29
+ };
30
+ var __copyProps = (to, from, except, desc) => {
31
+ if (from && typeof from == "object" || typeof from == "function")
32
+ for (let key of __getOwnPropNames(from))
33
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
+ // If the importer is in node compatibility mode or this is not an ESM
38
+ // file that has been converted to a CommonJS file using a Babel-
39
+ // compatible transform (i.e. "__esModule" has not been set), then set
40
+ // "default" to the CommonJS "module.exports" for node compatibility.
41
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
42
+ mod
43
+ ));
44
+
45
+ export {
46
+ __require,
47
+ __commonJS,
48
+ __toESM
49
+ };
@@ -1,35 +1,37 @@
1
- import CJS_COMPAT_NODE_URL_2nrki1kueis from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_2nrki1kueis from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_2nrki1kueis from "node:module";
1
+ import CJS_COMPAT_NODE_URL_u7h7cccg9s from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_u7h7cccg9s from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_u7h7cccg9s from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_2nrki1kueis.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_2nrki1kueis.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_2nrki1kueis.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_u7h7cccg9s.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_u7h7cccg9s.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_u7h7cccg9s.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
+ import "./_node-chunks/chunk-RYTQ27I2.js";
12
13
 
13
14
  // src/framework-preset-react-docs.ts
14
15
  import { fileURLToPath } from "node:url";
15
16
  import {
16
- getTypeScriptForDocgenError,
17
- isDocgenServerDisabledInMainConfig
18
- } from "storybook/internal/common";
19
- import { deprecate } from "storybook/internal/node-logger";
20
- var webpackFinal = async (config, options) => {
17
+ isReactBuilderDocgenPackageInstalled,
18
+ prepareReactBuilderDocgen
19
+ } from "@storybook/react/internal/builder-docgen";
20
+ var resolve = (specifier) => import.meta.resolve(specifier), webpackFinal = async (config, options) => {
21
21
  if ((await options.presets.apply("features", {}))?.docgenServer)
22
22
  return config;
23
23
  let typescriptOptions = await options.presets.apply("typescript", {}), debug = options.loglevel === "debug", { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions || {};
24
24
  if (typeof reactDocgen != "string")
25
25
  return config;
26
- await isDocgenServerDisabledInMainConfig(options) && deprecate(
27
- `Builder docgen (\`typescript.reactDocgen: '${reactDocgen}'\`) is deprecated and will be removed in Storybook 12. It runs because your Storybook main config sets \`features.docgenServer: false\`. Remove that setting to use server-side docgen.`
28
- );
29
- let typescriptUsable = !getTypeScriptForDocgenError(
30
- (specifier) => import.meta.resolve(specifier)
31
- );
32
- if (reactDocgen !== "react-docgen-typescript" || !typescriptUsable)
26
+ let mode = await prepareReactBuilderDocgen({
27
+ reactDocgen,
28
+ builder: "webpack",
29
+ resolve,
30
+ options
31
+ });
32
+ if (!mode)
33
+ return config;
34
+ if (!(mode === "react-docgen-typescript"))
33
35
  return {
34
36
  ...config,
35
37
  module: {
@@ -50,25 +52,24 @@ var webpackFinal = async (config, options) => {
50
52
  ]
51
53
  }
52
54
  };
53
- let { ReactDocgenTypeScriptPlugin } = await import("@storybook/react-docgen-typescript-plugin");
55
+ let { ReactDocgenTypeScriptPlugin } = await import("@storybook/react-docgen-typescript-plugin"), javaScriptDocgenRules = isReactBuilderDocgenPackageInstalled(resolve, "react-docgen") ? [
56
+ {
57
+ test: /\.(cjs|mjs|jsx?)$/,
58
+ enforce: "pre",
59
+ loader: fileURLToPath(
60
+ import.meta.resolve("@storybook/preset-react-webpack/react-docgen-loader")
61
+ ),
62
+ options: {
63
+ debug
64
+ },
65
+ exclude: /(\.(stories|story)\.(js|jsx|ts|tsx))|(node_modules)/
66
+ }
67
+ ] : [];
54
68
  return {
55
69
  ...config,
56
70
  module: {
57
71
  ...config.module ?? {},
58
- rules: [
59
- ...config.module?.rules ?? [],
60
- {
61
- test: /\.(cjs|mjs|jsx?)$/,
62
- enforce: "pre",
63
- loader: fileURLToPath(
64
- import.meta.resolve("@storybook/preset-react-webpack/react-docgen-loader")
65
- ),
66
- options: {
67
- debug
68
- },
69
- exclude: /(\.(stories|story)\.(js|jsx|ts|tsx))|(node_modules)/
70
- }
71
- ]
72
+ rules: [...config.module?.rules ?? [], ...javaScriptDocgenRules]
72
73
  },
73
74
  plugins: [
74
75
  ...config.plugins || [],
package/dist/index.d.ts CHANGED
@@ -1,8 +1,18 @@
1
1
  import { PresetProperty } from "storybook/internal/types";
2
2
  import { BuilderResult, StorybookConfig as StorybookConfig$1, TypescriptOptions as TypescriptOptions$1, WebpackConfiguration } from "@storybook/core-webpack";
3
- import { PluginOptions } from "@storybook/react-docgen-typescript-plugin";
3
+ import { ReactDocgenTypescriptParserOptions } from "@storybook/react";
4
4
 
5
5
  //#region code/presets/react-webpack/.dts-emit/code/presets/react-webpack/src/types.d.ts
6
+ /** Options of `@storybook/react-docgen-typescript-plugin`, copied from its declarations. */
7
+ type ReactDocgenTypescriptOptions = ReactDocgenTypescriptParserOptions & {
8
+ docgenCollectionName?: string | null;
9
+ setDisplayName?: boolean;
10
+ typePropName?: string;
11
+ tsconfigPath?: string; /** TypeScript `CompilerOptions`. */
12
+ compilerOptions?: Record<string, any>;
13
+ exclude?: string[];
14
+ include?: string[];
15
+ };
6
16
  interface ReactOptions {
7
17
  strictMode?: boolean;
8
18
  }
@@ -21,7 +31,7 @@ type TypescriptOptions = TypescriptOptions$1 & {
21
31
  * @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
22
32
  * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
23
33
  */
24
- reactDocgenTypescriptOptions: PluginOptions;
34
+ reactDocgenTypescriptOptions: ReactDocgenTypescriptOptions;
25
35
  };
26
36
  type StorybookConfig<TWebpackConfiguration = WebpackConfiguration> = StorybookConfig$1<TWebpackConfiguration> & {
27
37
  typescript?: Partial<TypescriptOptions>;
@@ -30,4 +40,4 @@ type StorybookConfig<TWebpackConfiguration = WebpackConfiguration> = StorybookCo
30
40
  //#region code/presets/react-webpack/.dts-emit/code/presets/react-webpack/src/index.d.ts
31
41
  declare const addons: PresetProperty<'addons'>;
32
42
  //#endregion
33
- export { type BuilderResult, ReactOptions, StorybookConfig, TypescriptOptions, addons };
43
+ export { type BuilderResult, ReactDocgenTypescriptOptions, ReactOptions, StorybookConfig, TypescriptOptions, addons };
package/dist/index.js CHANGED
@@ -1,14 +1,15 @@
1
- import CJS_COMPAT_NODE_URL_2nrki1kueis from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_2nrki1kueis from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_2nrki1kueis from "node:module";
1
+ import CJS_COMPAT_NODE_URL_u7h7cccg9s from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_u7h7cccg9s from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_u7h7cccg9s from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_2nrki1kueis.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_2nrki1kueis.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_2nrki1kueis.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_u7h7cccg9s.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_u7h7cccg9s.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_u7h7cccg9s.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
+ import "./_node-chunks/chunk-RYTQ27I2.js";
12
13
 
13
14
  // src/index.ts
14
15
  import { fileURLToPath } from "node:url";