@storybook/preset-react-webpack 0.0.0-pr-23609-sha-f47ef339

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/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # Storybook Webpack preset for React
2
+
3
+ This package is a [preset](https://storybook.js.org/docs/react/addons/writing-presets#presets-api) that configures Storybook's webpack settings for handling React.
4
+ It's an internal package that's not intended to be used directly by users.
5
+
6
+ - More info on [Storybook for React](https://storybook.js.org/docs/react/get-started/introduction)
@@ -0,0 +1,5 @@
1
+ import { StorybookConfig } from '@storybook/core-webpack';
2
+
3
+ declare const webpackFinal: StorybookConfig['webpack'];
4
+
5
+ export { webpackFinal };
@@ -0,0 +1 @@
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var framework_preset_cra_exports={};__export(framework_preset_cra_exports,{webpackFinal:()=>webpackFinal});module.exports=__toCommonJS(framework_preset_cra_exports);var import_node_logger2=require("@storybook/node-logger");var import_fs=__toESM(require("fs")),import_path=__toESM(require("path")),import_semver=__toESM(require("semver")),import_node_logger=require("@storybook/node-logger"),appDirectory=import_fs.default.realpathSync(process.cwd()),reactScriptsPath;function getReactScriptsPath({noCache}={}){if(reactScriptsPath&&!noCache)return reactScriptsPath;let reactScriptsScriptPath=import_fs.default.realpathSync(import_path.default.join(appDirectory,"/node_modules/.bin/react-scripts"));try{if(/node_modules[\\/]\.bin[\\/]react-scripts/i.test(reactScriptsScriptPath)){let packagePathMatch=import_fs.default.readFileSync(reactScriptsScriptPath,"utf8").match(/"\$basedir[\\/]([^\s]+?[\\/]bin[\\/]react-scripts\.js")/i);packagePathMatch&&packagePathMatch.length>1&&(reactScriptsScriptPath=import_path.default.join(appDirectory,"/node_modules/.bin/",packagePathMatch[1]))}}catch(e){import_node_logger.logger.warn(`Error occurred during react-scripts package path resolving: ${e}`)}reactScriptsPath=import_path.default.join(reactScriptsScriptPath,"../..");let scriptsPkgJson=import_path.default.join(reactScriptsPath,"package.json");return import_fs.default.existsSync(scriptsPkgJson)||(reactScriptsPath="react-scripts"),reactScriptsPath}function isReactScriptsInstalled(requiredVersion="2.0.0"){try{let reactScriptsJson=require(import_path.default.join(getReactScriptsPath(),"package.json"));return!import_semver.default.gtr(requiredVersion,reactScriptsJson.version)}catch{return!1}}var checkForNewPreset=presetsList=>{presetsList.some(preset=>{let presetName=typeof preset=="string"?preset:preset.name;return/@storybook(\/|\\)preset-create-react-app/.test(presetName)})||(import_node_logger2.logger.warn("Storybook support for Create React App is now a separate preset."),import_node_logger2.logger.warn("To use the new preset, install `@storybook/preset-create-react-app` and add it to the list of `addons` in your `.storybook/main.js` config file."),import_node_logger2.logger.warn("The built-in preset has been disabled in Storybook 6.0."))},webpackFinal=(config,{presetsList})=>{var _a,_b;return isReactScriptsInstalled()&&presetsList&&checkForNewPreset(presetsList),(_b=(_a=config.module)==null?void 0:_a.rules)==null||_b.push({test:/\.m?js$/,type:"javascript/auto"},{test:/\.m?js$/,resolve:{fullySpecified:!1}}),config};0&&(module.exports={webpackFinal});
@@ -0,0 +1,8 @@
1
+ import { S as StorybookConfig } from './types-1597a784.js';
2
+ import '@storybook/core-webpack';
3
+ import '@storybook/react-docgen-typescript-plugin';
4
+
5
+ declare const babel: StorybookConfig['babel'];
6
+ declare const webpackFinal: StorybookConfig['webpackFinal'];
7
+
8
+ export { babel, webpackFinal };
@@ -0,0 +1 @@
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var framework_preset_react_docs_exports={};__export(framework_preset_react_docs_exports,{babel:()=>babel,webpackFinal:()=>webpackFinal});module.exports=__toCommonJS(framework_preset_react_docs_exports);var import_docs_tools=require("@storybook/docs-tools"),babel=async(config,options)=>{if(!(0,import_docs_tools.hasDocsOrControls)(options))return config;let typescriptOptions=await options.presets.apply("typescript",{}),{reactDocgen}=typescriptOptions||{};return typeof reactDocgen!="string"?config:{...config,overrides:[...(config==null?void 0:config.overrides)||[],{test:reactDocgen==="react-docgen"?/\.(cjs|mjs|tsx?|jsx?)$/:/\.(cjs|mjs|jsx?)$/,plugins:[[require.resolve("babel-plugin-react-docgen")]]}]}},webpackFinal=async(config,options)=>{if(!(0,import_docs_tools.hasDocsOrControls)(options))return config;let typescriptOptions=await options.presets.apply("typescript",{}),{reactDocgen,reactDocgenTypescriptOptions}=typescriptOptions||{};if(reactDocgen!=="react-docgen-typescript")return config;let{ReactDocgenTypeScriptPlugin}=await import("@storybook/react-docgen-typescript-plugin");return{...config,plugins:[...config.plugins||[],new ReactDocgenTypeScriptPlugin({...reactDocgenTypescriptOptions,savePropValueAsString:!0})]}};0&&(module.exports={babel,webpackFinal});
@@ -0,0 +1,9 @@
1
+ import { S as StorybookConfig } from './types-1597a784.js';
2
+ import '@storybook/core-webpack';
3
+ import '@storybook/react-docgen-typescript-plugin';
4
+
5
+ declare const babel: StorybookConfig['babel'];
6
+ declare const babelDefault: StorybookConfig['babelDefault'];
7
+ declare const webpackFinal: StorybookConfig['webpackFinal'];
8
+
9
+ export { babel, babelDefault, webpackFinal };
@@ -0,0 +1 @@
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var framework_preset_react_exports={};__export(framework_preset_react_exports,{babel:()=>babel,babelDefault:()=>babelDefault,webpackFinal:()=>webpackFinal});module.exports=__toCommonJS(framework_preset_react_exports);var import_path=require("path"),import_react_refresh_webpack_plugin=__toESM(require("@pmmmwh/react-refresh-webpack-plugin")),import_node_logger=require("@storybook/node-logger"),getAbsolutePath=input=>(0,import_path.dirname)(require.resolve((0,import_path.join)(input,"package.json"))),applyFastRefresh=async options=>{let isDevelopment=options.configType==="DEVELOPMENT",framework=await options.presets.apply("framework"),reactOptions=typeof framework=="object"?framework.options:{};return isDevelopment&&(reactOptions.fastRefresh||process.env.FAST_REFRESH==="true")},babel=async(config,options)=>await applyFastRefresh(options)?{...config,plugins:[[require.resolve("react-refresh/babel"),{},"storybook-react-refresh"],...config.plugins||[]]}:config,storybookReactDirName=getAbsolutePath("@storybook/preset-react-webpack"),context=storybookReactDirName.includes("node_modules")?(0,import_path.join)(storybookReactDirName,"../../"):(0,import_path.join)(storybookReactDirName,"../../node_modules"),hasJsxRuntime=()=>{try{return require.resolve("react/jsx-runtime",{paths:[context]}),!0}catch{return!1}},babelDefault=async config=>{let presetReactOptions=hasJsxRuntime()?{runtime:"automatic"}:{};return{...config,presets:[...(config==null?void 0:config.presets)||[],[require.resolve("@babel/preset-react"),presetReactOptions]],plugins:[...(config==null?void 0:config.plugins)||[],require.resolve("babel-plugin-add-react-displayname")]}},webpackFinal=async(config,options)=>{var _a;return await applyFastRefresh(options)?(_a=config.plugins)!=null&&_a.find(p=>p.constructor.name==="ReactRefreshPlugin")?(import_node_logger.logger.warn("=> React refresh is already set. You don't need to set the option"),config):(import_node_logger.logger.info("=> Using React fast refresh"),{...config,plugins:[...config.plugins||[],new import_react_refresh_webpack_plugin.default({overlay:{sockIntegration:"whm"}})]}):config};0&&(module.exports={babel,babelDefault,webpackFinal});
@@ -0,0 +1,8 @@
1
+ import { S as StorybookConfig } from './types-1597a784.js';
2
+ export { R as ReactOptions, T as TypescriptOptions } from './types-1597a784.js';
3
+ export { BuilderResult } from '@storybook/core-webpack';
4
+ import '@storybook/react-docgen-typescript-plugin';
5
+
6
+ declare const addons: StorybookConfig['addons'];
7
+
8
+ export { StorybookConfig, addons };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var src_exports={};__export(src_exports,{addons:()=>addons});module.exports=__toCommonJS(src_exports);var addons=[require.resolve("@storybook/preset-react-webpack/dist/framework-preset-react"),require.resolve("@storybook/preset-react-webpack/dist/framework-preset-cra"),require.resolve("@storybook/preset-react-webpack/dist/framework-preset-react-docs")];0&&(module.exports={addons});
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});var addons=[__require.resolve("@storybook/preset-react-webpack/dist/framework-preset-react"),__require.resolve("@storybook/preset-react-webpack/dist/framework-preset-cra"),__require.resolve("@storybook/preset-react-webpack/dist/framework-preset-react-docs")];
2
+
3
+ export { addons };
@@ -0,0 +1,35 @@
1
+ import { TypescriptOptions as TypescriptOptions$1, WebpackConfiguration, StorybookConfig as StorybookConfig$1 } from '@storybook/core-webpack';
2
+ import { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
3
+
4
+ interface ReactOptions {
5
+ fastRefresh?: boolean;
6
+ strictMode?: boolean;
7
+ /**
8
+ * Use React's legacy root API to mount components
9
+ * @description
10
+ * React has introduced a new root API with React 18.x to enable a whole set of new features (e.g. concurrent features)
11
+ * 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.
12
+ * @default false
13
+ */
14
+ legacyRootApi?: boolean;
15
+ }
16
+ type TypescriptOptions = TypescriptOptions$1 & {
17
+ /**
18
+ * Sets the type of Docgen when working with React and TypeScript
19
+ *
20
+ * @default `'react-docgen-typescript'`
21
+ */
22
+ reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
23
+ /**
24
+ * Configures `react-docgen-typescript-plugin`
25
+ *
26
+ * @default
27
+ * @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
28
+ */
29
+ reactDocgenTypescriptOptions: PluginOptions;
30
+ };
31
+ type StorybookConfig<TWebpackConfiguration = WebpackConfiguration> = StorybookConfig$1<TWebpackConfiguration> & {
32
+ typescript?: Partial<TypescriptOptions>;
33
+ };
34
+
35
+ export { ReactOptions as R, StorybookConfig as S, TypescriptOptions as T };
package/package.json ADDED
@@ -0,0 +1,115 @@
1
+ {
2
+ "name": "@storybook/preset-react-webpack",
3
+ "version": "0.0.0-pr-23609-sha-f47ef339",
4
+ "description": "Storybook for React: Develop React Component in isolation with Hot Reloading",
5
+ "keywords": [
6
+ "storybook"
7
+ ],
8
+ "homepage": "https://github.com/storybookjs/storybook/tree/next/code/presets/react-webpack",
9
+ "bugs": {
10
+ "url": "https://github.com/storybookjs/storybook/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/storybookjs/storybook.git",
15
+ "directory": "code/presets/react-webpack"
16
+ },
17
+ "funding": {
18
+ "type": "opencollective",
19
+ "url": "https://opencollective.com/storybook"
20
+ },
21
+ "license": "MIT",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "node": "./dist/index.js",
26
+ "require": "./dist/index.js",
27
+ "import": "./dist/index.mjs"
28
+ },
29
+ "./preset": {
30
+ "types": "./dist/index.d.ts",
31
+ "node": "./dist/index.js",
32
+ "require": "./dist/index.js",
33
+ "import": "./dist/index.mjs"
34
+ },
35
+ "./dist/framework-preset-cra": {
36
+ "types": "./dist/framework-preset-cra.d.ts",
37
+ "require": "./dist/framework-preset-cra.js",
38
+ "import": "./dist/framework-preset-cra.mjs"
39
+ },
40
+ "./dist/framework-preset-react-docs": {
41
+ "types": "./dist/framework-preset-react-docs.d.ts",
42
+ "require": "./dist/framework-preset-react-docs.js",
43
+ "import": "./dist/framework-preset-react-docs.mjs"
44
+ },
45
+ "./dist/framework-preset-react": {
46
+ "types": "./dist/framework-preset-react.d.ts",
47
+ "require": "./dist/framework-preset-react.js",
48
+ "import": "./dist/framework-preset-react.mjs"
49
+ },
50
+ "./package.json": "./package.json"
51
+ },
52
+ "main": "dist/index.js",
53
+ "module": "dist/index.mjs",
54
+ "types": "dist/index.d.ts",
55
+ "files": [
56
+ "dist/**/*",
57
+ "README.md",
58
+ "*.js",
59
+ "*.d.ts"
60
+ ],
61
+ "scripts": {
62
+ "check": "../../../scripts/prepare/check.ts",
63
+ "prep": "../../../scripts/prepare/bundle.ts"
64
+ },
65
+ "dependencies": {
66
+ "@babel/preset-flow": "^7.22.5",
67
+ "@babel/preset-react": "^7.22.5",
68
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
69
+ "@storybook/core-webpack": "0.0.0-pr-23609-sha-f47ef339",
70
+ "@storybook/docs-tools": "0.0.0-pr-23609-sha-f47ef339",
71
+ "@storybook/node-logger": "0.0.0-pr-23609-sha-f47ef339",
72
+ "@storybook/react": "0.0.0-pr-23609-sha-f47ef339",
73
+ "@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.0c3f3b7.0",
74
+ "@types/node": "^16.0.0",
75
+ "@types/semver": "^7.3.4",
76
+ "babel-plugin-add-react-displayname": "^0.0.5",
77
+ "babel-plugin-react-docgen": "^4.2.1",
78
+ "fs-extra": "^11.1.0",
79
+ "react-refresh": "^0.11.0",
80
+ "semver": "^7.3.7",
81
+ "webpack": "5"
82
+ },
83
+ "devDependencies": {
84
+ "typescript": "~4.9.3"
85
+ },
86
+ "peerDependencies": {
87
+ "@babel/core": "^7.22.0",
88
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
89
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
90
+ },
91
+ "peerDependenciesMeta": {
92
+ "@babel/core": {
93
+ "optional": true
94
+ },
95
+ "typescript": {
96
+ "optional": true
97
+ }
98
+ },
99
+ "engines": {
100
+ "node": ">=16.0.0"
101
+ },
102
+ "publishConfig": {
103
+ "access": "public"
104
+ },
105
+ "bundler": {
106
+ "entries": [
107
+ "./src/index.ts",
108
+ "./src/framework-preset-cra.ts",
109
+ "./src/framework-preset-react-docs.ts",
110
+ "./src/framework-preset-react.ts"
111
+ ],
112
+ "platform": "node"
113
+ },
114
+ "gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae17"
115
+ }
package/preset.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/index');
@@ -0,0 +1,44 @@
1
+ // TODO: Replace, as soon as @types/react-dom 17.0.14 is used
2
+ // Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/fb0f14b7a35cde26ffaa82e7536c062e593e9ae6/types/react-dom/client.d.ts
3
+ declare module 'react-dom/client' {
4
+ import React = require('react');
5
+
6
+ export interface HydrationOptions {
7
+ onHydrated?(suspenseInstance: Comment): void;
8
+ onDeleted?(suspenseInstance: Comment): void;
9
+ /**
10
+ * Prefix for `useId`.
11
+ */
12
+ identifierPrefix?: string;
13
+ onRecoverableError?: (error: unknown) => void;
14
+ }
15
+
16
+ export interface RootOptions {
17
+ /**
18
+ * Prefix for `useId`.
19
+ */
20
+ identifierPrefix?: string;
21
+ onRecoverableError?: (error: unknown) => void;
22
+ }
23
+
24
+ export interface Root {
25
+ render(children: React.ReactChild | Iterable<React.ReactNode>): void;
26
+ unmount(): void;
27
+ }
28
+
29
+ /**
30
+ * Replaces `ReactDOM.render` when the `.render` method is called and enables Concurrent Mode.
31
+ *
32
+ * @see https://reactjs.org/docs/concurrent-mode-reference.html#createroot
33
+ */
34
+ export function createRoot(
35
+ container: Element | Document | DocumentFragment | Comment,
36
+ options?: RootOptions
37
+ ): Root;
38
+
39
+ export function hydrateRoot(
40
+ container: Element | Document | DocumentFragment | Comment,
41
+ initialChildren: React.ReactChild | Iterable<React.ReactNode>,
42
+ options?: HydrationOptions
43
+ ): Root;
44
+ }