@storybook/preset-react-webpack 7.0.0-alpha.4 → 7.0.0-alpha.7

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.
Files changed (39) hide show
  1. package/dist/chunk-SGZKGO2H.mjs +1 -0
  2. package/dist/framework-preset-cra.d.ts +5 -0
  3. package/dist/framework-preset-cra.js +1 -0
  4. package/dist/framework-preset-cra.mjs +1 -0
  5. package/dist/framework-preset-react-docs.d.ts +8 -0
  6. package/dist/framework-preset-react-docs.js +1 -0
  7. package/dist/framework-preset-react-docs.mjs +1 -0
  8. package/dist/framework-preset-react-dom-hack.d.ts +5 -0
  9. package/dist/framework-preset-react-dom-hack.js +1 -0
  10. package/dist/framework-preset-react-dom-hack.mjs +1 -0
  11. package/dist/framework-preset-react.d.ts +9 -0
  12. package/dist/framework-preset-react.js +1 -0
  13. package/dist/framework-preset-react.mjs +1 -0
  14. package/dist/index.d.ts +8 -0
  15. package/dist/index.js +1 -0
  16. package/dist/index.mjs +1 -0
  17. package/dist/{types/types.d.ts → types-59b58278.d.ts} +9 -16
  18. package/package.json +55 -10
  19. package/preset.js +1 -1
  20. package/dist/cjs/cra-config.js +0 -69
  21. package/dist/cjs/framework-preset-cra.js +0 -39
  22. package/dist/cjs/framework-preset-react-docs.js +0 -57
  23. package/dist/cjs/framework-preset-react-dom-hack.js +0 -25
  24. package/dist/cjs/framework-preset-react.js +0 -87
  25. package/dist/cjs/index.js +0 -25
  26. package/dist/cjs/types.js +0 -5
  27. package/dist/esm/cra-config.js +0 -49
  28. package/dist/esm/framework-preset-cra.js +0 -27
  29. package/dist/esm/framework-preset-react-docs.js +0 -41
  30. package/dist/esm/framework-preset-react-dom-hack.js +0 -14
  31. package/dist/esm/framework-preset-react.js +0 -63
  32. package/dist/esm/index.js +0 -2
  33. package/dist/esm/types.js +0 -1
  34. package/dist/types/cra-config.d.ts +0 -4
  35. package/dist/types/framework-preset-cra.d.ts +0 -2
  36. package/dist/types/framework-preset-react-docs.d.ts +0 -3
  37. package/dist/types/framework-preset-react-dom-hack.d.ts +0 -2
  38. package/dist/types/framework-preset-react.d.ts +0 -4
  39. package/dist/types/index.d.ts +0 -3
@@ -0,0 +1 @@
1
+ var f=Object.defineProperty,g=Object.defineProperties;var h=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var i=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var e=(a,b,c)=>b in a?f(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c,k=(a,b)=>{for(var c in b||(b={}))i.call(b,c)&&e(a,c,b[c]);if(d)for(var c of d(b))j.call(b,c)&&e(a,c,b[c]);return a},l=(a,b)=>g(a,h(b)),m=(a,b)=>f(a,"name",{value:b,configurable:!0}),n=(a=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(a,{get:(b,c)=>(typeof require!="undefined"?require:b)[c]}):a)(function(a){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+a+'" is not supported')});export{k as a,l as b,m as c,n as d};
@@ -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
+ var b=Object.create;var i=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var a=(t,e)=>i(t,"name",{value:e,configurable:!0});var P=(t,e)=>{for(var r in e)i(t,r,{get:e[r],enumerable:!0})},m=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of j(e))!w.call(t,o)&&o!==r&&i(t,o,{get:()=>e[o],enumerable:!(s=S(e,o))||s.enumerable});return t};var d=(t,e,r)=>(r=t!=null?b(k(t)):{},m(e||!t||!t.__esModule?i(r,"default",{value:t,enumerable:!0}):r,t)),v=t=>m(i({},"__esModule",{value:!0}),t);var $={};P($,{webpackFinal:()=>I});module.exports=v($);var l=require("@storybook/node-logger");var p=d(require("fs")),n=d(require("path")),h=d(require("@storybook/semver")),y=require("@storybook/node-logger"),u=p.default.realpathSync(process.cwd()),c;function R({noCache:t}={}){if(c&&!t)return c;let e=p.default.realpathSync(n.default.join(u,"/node_modules/.bin/react-scripts"));try{if(/node_modules[\\/]\.bin[\\/]react-scripts/i.test(e)){let f=p.default.readFileSync(e,"utf8").match(/"\$basedir[\\/]([^\s]+?[\\/]bin[\\/]react-scripts\.js")/i);f&&f.length>1&&(e=n.default.join(u,"/node_modules/.bin/",f[1]))}}catch(s){y.logger.warn(`Error occurred during react-scripts package path resolving: ${s}`)}c=n.default.join(e,"../..");let r=n.default.join(c,"package.json");return p.default.existsSync(r)||(c="react-scripts"),c}a(R,"getReactScriptsPath");function g(t="2.0.0"){try{let e=require(n.default.join(R(),"package.json"));return!h.default.gtr(t,e.version)}catch{return!1}}a(g,"isReactScriptsInstalled");var x=a(t=>{t.some(r=>{let s=typeof r=="string"?r:r.name;return/@storybook(\/|\\)preset-create-react-app/.test(s)})||(l.logger.warn("Storybook support for Create React App is now a separate preset."),l.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."),l.logger.warn("The built-in preset has been disabled in Storybook 6.0."))},"checkForNewPreset"),I=a((t,{presetsList:e})=>{var r,s;return g()&&e&&x(e),(s=(r=t.module)==null?void 0:r.rules)==null||s.push({test:/\.m?js$/,type:"javascript/auto"},{test:/\.m?js$/,resolve:{fullySpecified:!1}}),t},"webpackFinal");0&&(module.exports={webpackFinal});
@@ -0,0 +1 @@
1
+ import{c as o,d as l}from"./chunk-SGZKGO2H.mjs";import{logger as p}from"@storybook/node-logger";import n from"fs";import c from"path";import h from"@storybook/semver";import{logger as y}from"@storybook/node-logger";var f=n.realpathSync(process.cwd()),a;function g({noCache:e}={}){if(a&&!e)return a;let t=n.realpathSync(c.join(f,"/node_modules/.bin/react-scripts"));try{if(/node_modules[\\/]\.bin[\\/]react-scripts/i.test(t)){let i=n.readFileSync(t,"utf8").match(/"\$basedir[\\/]([^\s]+?[\\/]bin[\\/]react-scripts\.js")/i);i&&i.length>1&&(t=c.join(f,"/node_modules/.bin/",i[1]))}}catch(s){y.warn(`Error occurred during react-scripts package path resolving: ${s}`)}a=c.join(t,"../..");let r=c.join(a,"package.json");return n.existsSync(r)||(a="react-scripts"),a}o(g,"getReactScriptsPath");function d(e="2.0.0"){try{let t=l(c.join(g(),"package.json"));return!h.gtr(e,t.version)}catch{return!1}}o(d,"isReactScriptsInstalled");var b=o(e=>{e.some(r=>{let s=typeof r=="string"?r:r.name;return/@storybook(\/|\\)preset-create-react-app/.test(s)})||(p.warn("Storybook support for Create React App is now a separate preset."),p.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."),p.warn("The built-in preset has been disabled in Storybook 6.0."))},"checkForNewPreset"),x=o((e,{presetsList:t})=>{var r,s;return d()&&t&&b(t),(s=(r=e.module)==null?void 0:r.rules)==null||s.push({test:/\.m?js$/,type:"javascript/auto"},{test:/\.m?js$/,resolve:{fullySpecified:!1}}),e},"webpackFinal");export{x as webpackFinal};
@@ -0,0 +1,8 @@
1
+ import { S as StorybookConfig } from './types-59b58278.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
+ var D=Object.create;var a=Object.defineProperty,x=Object.defineProperties,E=Object.getOwnPropertyDescriptor,S=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,_=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable;var y=(e,t,r)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,n=(e,t)=>{for(var r in t||(t={}))l.call(t,r)&&y(e,r,t[r]);if(u)for(var r of u(t))d.call(t,r)&&y(e,r,t[r]);return e},c=(e,t)=>x(e,S(t)),i=(e,t)=>a(e,"name",{value:t,configurable:!0});var j=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},O=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of T(t))!l.call(e,p)&&p!==r&&a(e,p,{get:()=>t[p],enumerable:!(s=E(t,p))||s.enumerable});return e};var m=(e,t,r)=>(r=e!=null?D(_(e)):{},O(t||!e||!e.__esModule?a(r,"default",{value:e,enumerable:!0}):r,e)),v=e=>O(a({},"__esModule",{value:!0}),e);var b={};j(b,{babel:()=>w,webpackFinal:()=>A});module.exports=v(b);var C=m(require("@storybook/react-docgen-typescript-plugin")),o=require("@storybook/docs-tools"),w=i(async(e,t)=>{if(!(0,o.hasDocsOrControls)(t))return e;let r=await t.presets.apply("typescript",{}),{reactDocgen:s}=r||{};return typeof s!="string"?e:c(n({},e),{overrides:[...(e==null?void 0:e.overrides)||[],{test:s==="react-docgen"?/\.(mjs|tsx?|jsx?)$/:/\.(mjs|jsx?)$/,plugins:[[require.resolve("babel-plugin-react-docgen"),{DOC_GEN_COLLECTION_NAME:"STORYBOOK_REACT_CLASSES"}]]}]})},"babel"),A=i(async(e,t)=>{if(!(0,o.hasDocsOrControls)(t))return e;let r=await t.presets.apply("typescript",{}),{reactDocgen:s,reactDocgenTypescriptOptions:p}=r||{};return s!=="react-docgen-typescript"?e:c(n({},e),{plugins:[...e.plugins||[],new C.default(c(n({},p),{savePropValueAsString:!0}))]})},"webpackFinal");0&&(module.exports={babel,webpackFinal});
@@ -0,0 +1 @@
1
+ import{a as s,b as p,c as n,d as c}from"./chunk-SGZKGO2H.mjs";import u from"@storybook/react-docgen-typescript-plugin";import{hasDocsOrControls as i}from"@storybook/docs-tools";var C=n(async(e,t)=>{if(!i(t))return e;let a=await t.presets.apply("typescript",{}),{reactDocgen:r}=a||{};return typeof r!="string"?e:p(s({},e),{overrides:[...(e==null?void 0:e.overrides)||[],{test:r==="react-docgen"?/\.(mjs|tsx?|jsx?)$/:/\.(mjs|jsx?)$/,plugins:[[c.resolve("babel-plugin-react-docgen"),{DOC_GEN_COLLECTION_NAME:"STORYBOOK_REACT_CLASSES"}]]}]})},"babel"),D=n(async(e,t)=>{if(!i(t))return e;let a=await t.presets.apply("typescript",{}),{reactDocgen:r,reactDocgenTypescriptOptions:o}=a||{};return r!=="react-docgen-typescript"?e:p(s({},e),{plugins:[...e.plugins||[],new u(p(s({},o),{savePropValueAsString:!0}))]})},"webpackFinal");export{C as babel,D as webpackFinal};
@@ -0,0 +1,5 @@
1
+ import { StorybookConfig } from '@storybook/core-webpack';
2
+
3
+ declare const webpackFinal: StorybookConfig['webpackFinal'];
4
+
5
+ export { webpackFinal };
@@ -0,0 +1 @@
1
+ var k=Object.create;var o=Object.defineProperty,x=Object.defineProperties,b=Object.getOwnPropertyDescriptor,v=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertyNames,a=Object.getOwnPropertySymbols,y=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable;var i=(r,e,t)=>e in r?o(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,l=(r,e)=>{for(var t in e||(e={}))c.call(e,t)&&i(r,t,e[t]);if(a)for(var t of a(e))f.call(e,t)&&i(r,t,e[t]);return r},p=(r,e)=>x(r,v(e)),u=(r,e)=>o(r,"name",{value:e,configurable:!0});var h=(r,e)=>{for(var t in e)o(r,t,{get:e[t],enumerable:!0})},g=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of w(e))!c.call(r,n)&&n!==t&&o(r,n,{get:()=>e[n],enumerable:!(s=b(e,n))||s.enumerable});return r};var E=(r,e,t)=>(t=r!=null?k(y(r)):{},g(e||!r||!r.__esModule?o(t,"default",{value:r,enumerable:!0}):t,r)),P=r=>g(o({},"__esModule",{value:!0}),r);var W={};h(W,{webpackFinal:()=>R});module.exports=P(W);var m=require("fs-extra"),d=require("webpack"),R=u(async r=>{let e=await(0,m.readJSON)(require.resolve("react-dom/package.json"));return p(l({},r),{plugins:[...r.plugins||[],e.version.startsWith("18")||e.version.startsWith("0.0.0")?null:new d.IgnorePlugin({resourceRegExp:/react-dom\/client$/,contextRegExp:/(renderers\/react|renderers\\react|@storybook\/react|@storybook\\react)/})].filter(Boolean)})},"webpackFinal");0&&(module.exports={webpackFinal});
@@ -0,0 +1 @@
1
+ import{a as t,b as o,c as a,d as n}from"./chunk-SGZKGO2H.mjs";import{readJSON as s}from"fs-extra";import{IgnorePlugin as c}from"webpack";var m=a(async e=>{let r=await s(n.resolve("react-dom/package.json"));return o(t({},e),{plugins:[...e.plugins||[],r.version.startsWith("18")||r.version.startsWith("0.0.0")?null:new c({resourceRegExp:/react-dom\/client$/,contextRegExp:/(renderers\/react|renderers\\react|@storybook\/react|@storybook\\react)/})].filter(Boolean)})},"webpackFinal");export{m as webpackFinal};
@@ -0,0 +1,9 @@
1
+ import { S as StorybookConfig } from './types-59b58278.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
+ var w=Object.create;var n=Object.defineProperty,v=Object.defineProperties,k=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyDescriptors,q=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,E=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var R=(e,r,t)=>r in e?n(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,p=(e,r)=>{for(var t in r||(r={}))y.call(r,t)&&R(e,t,r[t]);if(h)for(var t of h(r))j.call(r,t)&&R(e,t,r[t]);return e},i=(e,r)=>v(e,x(r)),o=(e,r)=>n(e,"name",{value:r,configurable:!0});var D=(e,r)=>{for(var t in r)n(e,t,{get:r[t],enumerable:!0})},d=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of q(r))!y.call(e,a)&&a!==t&&n(e,a,{get:()=>r[a],enumerable:!(s=k(r,a))||s.enumerable});return e};var u=(e,r,t)=>(t=e!=null?w(E(e)):{},d(r||!e||!e.__esModule?n(t,"default",{value:e,enumerable:!0}):t,e)),F=e=>d(n({},"__esModule",{value:!0}),e);var S={};D(S,{babel:()=>O,babelDefault:()=>_,webpackFinal:()=>N});module.exports=F(S);var l=u(require("path")),b=u(require("@pmmmwh/react-refresh-webpack-plugin")),m=require("@storybook/node-logger"),f=o(async e=>{let r=e.configType==="DEVELOPMENT",t=await e.presets.apply("framework"),s=typeof t=="object"?t.options:{};return r&&(s.fastRefresh||process.env.FAST_REFRESH==="true")},"useFastRefresh"),O=o(async(e,r)=>await f(r)?i(p({},e),{plugins:[[require.resolve("react-refresh/babel"),{},"storybook-react-refresh"],...e.plugins||[]]}):e,"babel"),c=l.default.dirname(require.resolve("@storybook/preset-react-webpack/package.json")),P=c.includes("node_modules")?l.default.join(c,"../../"):l.default.join(c,"../../node_modules"),T=o(()=>{try{return require.resolve("react/jsx-runtime",{paths:[P]}),!0}catch{return!1}},"hasJsxRuntime"),_=o(async e=>{let r=T()?{runtime:"automatic"}:{};return i(p({},e),{presets:[...(e==null?void 0:e.presets)||[],[require.resolve("@babel/preset-react"),r]],plugins:[...(e==null?void 0:e.plugins)||[],require.resolve("babel-plugin-add-react-displayname")]})},"babelDefault"),N=o(async(e,r)=>{var s;return await f(r)?(s=e.plugins)!=null&&s.find(a=>a.constructor.name==="ReactRefreshPlugin")?(m.logger.warn("=> React refresh is already set. You don't need to set the option"),e):(m.logger.info("=> Using React fast refresh"),i(p({},e),{plugins:[...e.plugins||[],new b.default({overlay:{sockIntegration:"whm"}})]})):e},"webpackFinal");0&&(module.exports={babel,babelDefault,webpackFinal});
@@ -0,0 +1 @@
1
+ import{a as n,b as o,c as t,d as s}from"./chunk-SGZKGO2H.mjs";import l from"path";import h from"@pmmmwh/react-refresh-webpack-plugin";import{logger as c}from"@storybook/node-logger";var i=t(async e=>{let r=e.configType==="DEVELOPMENT",u=await e.presets.apply("framework"),a=typeof u=="object"?u.options:{};return r&&(a.fastRefresh||process.env.FAST_REFRESH==="true")},"useFastRefresh"),v=t(async(e,r)=>await i(r)?o(n({},e),{plugins:[[s.resolve("react-refresh/babel"),{},"storybook-react-refresh"],...e.plugins||[]]}):e,"babel"),p=l.dirname(s.resolve("@storybook/preset-react-webpack/package.json")),b=p.includes("node_modules")?l.join(p,"../../"):l.join(p,"../../node_modules"),R=t(()=>{try{return s.resolve("react/jsx-runtime",{paths:[b]}),!0}catch{return!1}},"hasJsxRuntime"),x=t(async e=>{let r=R()?{runtime:"automatic"}:{};return o(n({},e),{presets:[...(e==null?void 0:e.presets)||[],[s.resolve("@babel/preset-react"),r]],plugins:[...(e==null?void 0:e.plugins)||[],s.resolve("babel-plugin-add-react-displayname")]})},"babelDefault"),j=t(async(e,r)=>{var a;return await i(r)?(a=e.plugins)!=null&&a.find(m=>m.constructor.name==="ReactRefreshPlugin")?(c.warn("=> React refresh is already set. You don't need to set the option"),e):(c.info("=> Using React fast refresh"),o(n({},e),{plugins:[...e.plugins||[],new h({overlay:{sockIntegration:"whm"}})]})):e},"webpackFinal");export{v as babel,x as babelDefault,j as webpackFinal};
@@ -0,0 +1,8 @@
1
+ import { S as StorybookConfig } from './types-59b58278.js';
2
+ export { R as ReactOptions, S as StorybookConfig, T as TypescriptOptions } from './types-59b58278.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 { addons };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var u=Object.create;var i=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var n=(e,r)=>{for(var o in r)i(e,o,{get:r[o],enumerable:!0})},t=(e,r,o,q)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of p(r))!d.call(e,s)&&s!==o&&i(e,s,{get:()=>r[s],enumerable:!(q=v(r,s))||q.enumerable});return e};var l=(e,r,o)=>(o=e!=null?u(x(e)):{},t(r||!e||!e.__esModule?i(o,"default",{value:e,enumerable:!0}):o,e)),a=e=>t(i({},"__esModule",{value:!0}),e);var m={};n(m,{addons:()=>f});module.exports=a(m);var f=[require.resolve("@storybook/preset-react-webpack/dist/framework-preset-react"),require.resolve("@storybook/preset-react-webpack/dist/framework-preset-react-dom-hack"),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 @@
1
+ import{d as e}from"./chunk-SGZKGO2H.mjs";var t=[e.resolve("@storybook/preset-react-webpack/dist/framework-preset-react"),e.resolve("@storybook/preset-react-webpack/dist/framework-preset-react-dom-hack"),e.resolve("@storybook/preset-react-webpack/dist/framework-preset-cra"),e.resolve("@storybook/preset-react-webpack/dist/framework-preset-react-docs")];export{t as addons};
@@ -1,7 +1,7 @@
1
- import type { CommonWebpackConfiguration, StorybookConfig as BaseStorybookConfig, TypescriptOptions as BaseTypescriptOptions } from '@storybook/core-webpack';
2
- import type { PluginOptions as ReactDocgenTypescriptOptions } from '@storybook/react-docgen-typescript-plugin';
3
- export type { BuilderResult } from '@storybook/core-webpack';
4
- export interface ReactOptions {
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
5
  fastRefresh?: boolean;
6
6
  strictMode?: boolean;
7
7
  /**
@@ -13,16 +13,7 @@ export interface ReactOptions {
13
13
  */
14
14
  legacyRootApi?: boolean;
15
15
  }
16
- /**
17
- * The interface for Storybook configuration in `main.ts` files.
18
- */
19
- export interface ReactConfig {
20
- framework: string | {
21
- name: '@storybook/react';
22
- options: ReactOptions;
23
- };
24
- }
25
- export declare type TypescriptOptions = BaseTypescriptOptions & {
16
+ declare type TypescriptOptions = TypescriptOptions$1 & {
26
17
  /**
27
18
  * Sets the type of Docgen when working with React and TypeScript
28
19
  *
@@ -35,8 +26,10 @@ export declare type TypescriptOptions = BaseTypescriptOptions & {
35
26
  * @default
36
27
  * @see https://github.com/storybookjs/storybook/blob/next/lib/builder-webpack5/src/config/defaults.js#L4-L6
37
28
  */
38
- reactDocgenTypescriptOptions: ReactDocgenTypescriptOptions;
29
+ reactDocgenTypescriptOptions: PluginOptions;
39
30
  };
40
- export declare type StorybookConfig<TWebpackConfiguration = CommonWebpackConfiguration> = BaseStorybookConfig<TWebpackConfiguration> & ReactConfig & {
31
+ declare type StorybookConfig<TWebpackConfiguration = WebpackConfiguration> = StorybookConfig$1<TWebpackConfiguration> & {
41
32
  typescript?: Partial<TypescriptOptions>;
42
33
  };
34
+
35
+ export { ReactOptions as R, StorybookConfig as S, TypescriptOptions as T };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/preset-react-webpack",
3
- "version": "7.0.0-alpha.4",
3
+ "version": "7.0.0-alpha.7",
4
4
  "description": "Storybook for React: Develop React Component in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook"
@@ -19,9 +19,46 @@
19
19
  "url": "https://opencollective.com/storybook"
20
20
  },
21
21
  "license": "MIT",
22
- "main": "dist/cjs/index.js",
23
- "module": "dist/esm/index.js",
24
- "types": "dist/types/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "require": "./dist/index.js",
25
+ "import": "./dist/index.mjs",
26
+ "types": "./dist/index.d.ts"
27
+ },
28
+ "./preset": {
29
+ "require": "./dist/index.js",
30
+ "import": "./dist/index.mjs",
31
+ "types": "./dist/index.d.ts"
32
+ },
33
+ "./dist/framework-preset-cra": {
34
+ "require": "./dist/framework-preset-cra.js",
35
+ "import": "./dist/framework-preset-cra.mjs",
36
+ "types": "./dist/framework-preset-cra.d.ts"
37
+ },
38
+ "./dist/framework-preset-react-docs": {
39
+ "require": "./dist/framework-preset-react-docs.js",
40
+ "import": "./dist/framework-preset-react-docs.mjs",
41
+ "types": "./dist/framework-preset-react-docs.d.ts"
42
+ },
43
+ "./dist/framework-preset-react-dom-hack": {
44
+ "require": "./dist/framework-preset-react-dom-hack.js",
45
+ "import": "./dist/framework-preset-react-dom-hack.mjs",
46
+ "types": "./dist/framework-preset-react-dom-hack.d.ts"
47
+ },
48
+ "./dist/framework-preset-react": {
49
+ "require": "./dist/framework-preset-react.js",
50
+ "import": "./dist/framework-preset-react.mjs",
51
+ "types": "./dist/framework-preset-react.d.ts"
52
+ },
53
+ "./package.json": {
54
+ "require": "./package.json",
55
+ "import": "./package.json",
56
+ "types": "./package.json"
57
+ }
58
+ },
59
+ "main": "dist/index.js",
60
+ "module": "dist/index.mjs",
61
+ "types": "dist/index.d.ts",
25
62
  "files": [
26
63
  "dist/**/*",
27
64
  "types/**/*",
@@ -30,16 +67,16 @@
30
67
  "*.d.ts"
31
68
  ],
32
69
  "scripts": {
33
- "prepare": "node ../../scripts/prepare.js"
70
+ "prepare": "esrun ../../scripts/prepare/bundle.ts"
34
71
  },
35
72
  "dependencies": {
36
73
  "@babel/preset-flow": "^7.12.1",
37
74
  "@babel/preset-react": "^7.12.10",
38
75
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
39
- "@storybook/core-webpack": "7.0.0-alpha.4",
40
- "@storybook/docs-tools": "7.0.0-alpha.4",
41
- "@storybook/node-logger": "7.0.0-alpha.4",
42
- "@storybook/react": "7.0.0-alpha.4",
76
+ "@storybook/core-webpack": "7.0.0-alpha.7",
77
+ "@storybook/docs-tools": "7.0.0-alpha.7",
78
+ "@storybook/node-logger": "7.0.0-alpha.7",
79
+ "@storybook/react": "7.0.0-alpha.7",
43
80
  "@storybook/react-docgen-typescript-plugin": "1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0",
44
81
  "@storybook/semver": "^7.3.2",
45
82
  "@types/node": "^14.14.20 || ^16.0.0",
@@ -50,6 +87,7 @@
50
87
  "react-refresh": "^0.11.0"
51
88
  },
52
89
  "devDependencies": {
90
+ "@digitak/esrun": "^3.2.2",
53
91
  "@types/util-deprecate": "^1.0.0"
54
92
  },
55
93
  "peerDependencies": {
@@ -74,5 +112,12 @@
74
112
  "publishConfig": {
75
113
  "access": "public"
76
114
  },
77
- "gitHead": "006ed54452dd7c37a8cbe91a84f5312182f7ca00"
115
+ "bundlerEntrypoint": [
116
+ "./src/index.ts",
117
+ "./src/framework-preset-cra.ts",
118
+ "./src/framework-preset-react-docs.ts",
119
+ "./src/framework-preset-react-dom-hack.ts",
120
+ "./src/framework-preset-react.ts"
121
+ ],
122
+ "gitHead": "d334cabd251cd0ed8b845a87707dc84f007d4074"
78
123
  }
package/preset.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist/cjs/index');
1
+ module.exports = require('./dist/index');
@@ -1,69 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getReactScriptsPath = getReactScriptsPath;
7
- exports.isReactScriptsInstalled = isReactScriptsInstalled;
8
-
9
- var _fs = _interopRequireDefault(require("fs"));
10
-
11
- var _path = _interopRequireDefault(require("path"));
12
-
13
- var _semver = _interopRequireDefault(require("@storybook/semver"));
14
-
15
- var _nodeLogger = require("@storybook/node-logger");
16
-
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
19
- const appDirectory = _fs.default.realpathSync(process.cwd());
20
-
21
- let reactScriptsPath;
22
-
23
- function getReactScriptsPath({
24
- noCache
25
- } = {}) {
26
- if (reactScriptsPath && !noCache) return reactScriptsPath;
27
-
28
- let reactScriptsScriptPath = _fs.default.realpathSync(_path.default.join(appDirectory, '/node_modules/.bin/react-scripts'));
29
-
30
- try {
31
- // Note: Since there is no symlink for .bin/react-scripts on Windows
32
- // we'll parse react-scripts file to find actual package path.
33
- // This is important if you use fork of CRA.
34
- const pathIsNotResolved = /node_modules[\\/]\.bin[\\/]react-scripts/i.test(reactScriptsScriptPath);
35
-
36
- if (pathIsNotResolved) {
37
- const content = _fs.default.readFileSync(reactScriptsScriptPath, 'utf8');
38
-
39
- const packagePathMatch = content.match(/"\$basedir[\\/]([^\s]+?[\\/]bin[\\/]react-scripts\.js")/i);
40
-
41
- if (packagePathMatch && packagePathMatch.length > 1) {
42
- reactScriptsScriptPath = _path.default.join(appDirectory, '/node_modules/.bin/', packagePathMatch[1]);
43
- }
44
- }
45
- } catch (e) {
46
- _nodeLogger.logger.warn(`Error occurred during react-scripts package path resolving: ${e}`);
47
- }
48
-
49
- reactScriptsPath = _path.default.join(reactScriptsScriptPath, '../..');
50
-
51
- const scriptsPkgJson = _path.default.join(reactScriptsPath, 'package.json');
52
-
53
- if (!_fs.default.existsSync(scriptsPkgJson)) {
54
- reactScriptsPath = 'react-scripts';
55
- }
56
-
57
- return reactScriptsPath;
58
- }
59
-
60
- function isReactScriptsInstalled(requiredVersion = '2.0.0') {
61
- try {
62
- // eslint-disable-next-line import/no-dynamic-require,global-require
63
- const reactScriptsJson = require(_path.default.join(getReactScriptsPath(), 'package.json'));
64
-
65
- return !_semver.default.gtr(requiredVersion, reactScriptsJson.version);
66
- } catch (e) {
67
- return false;
68
- }
69
- }
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.webpackFinal = void 0;
7
-
8
- var _nodeLogger = require("@storybook/node-logger");
9
-
10
- var _craConfig = require("./cra-config");
11
-
12
- const checkForNewPreset = presetsList => {
13
- const hasNewPreset = presetsList.some(preset => {
14
- const presetName = typeof preset === 'string' ? preset : preset.name;
15
- return /@storybook(\/|\\)preset-create-react-app/.test(presetName);
16
- });
17
-
18
- if (!hasNewPreset) {
19
- _nodeLogger.logger.warn('Storybook support for Create React App is now a separate preset.');
20
-
21
- _nodeLogger.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.');
22
-
23
- _nodeLogger.logger.warn('The built-in preset has been disabled in Storybook 6.0.');
24
- }
25
- };
26
-
27
- const webpackFinal = (config, {
28
- presetsList
29
- }) => {
30
- if ((0, _craConfig.isReactScriptsInstalled)()) {
31
- if (presetsList) {
32
- checkForNewPreset(presetsList);
33
- }
34
- }
35
-
36
- return config;
37
- };
38
-
39
- exports.webpackFinal = webpackFinal;
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.webpackFinal = exports.babel = void 0;
7
-
8
- var _reactDocgenTypescriptPlugin = _interopRequireDefault(require("@storybook/react-docgen-typescript-plugin"));
9
-
10
- var _docsTools = require("@storybook/docs-tools");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- const babel = async (config, options) => {
15
- if (!(0, _docsTools.hasDocsOrControls)(options)) return config;
16
- const typescriptOptions = await options.presets.apply('typescript', {});
17
- const {
18
- reactDocgen
19
- } = typescriptOptions || {};
20
-
21
- if (typeof reactDocgen !== 'string') {
22
- return config;
23
- }
24
-
25
- return Object.assign({}, config, {
26
- overrides: [...((config === null || config === void 0 ? void 0 : config.overrides) || []), {
27
- test: reactDocgen === 'react-docgen' ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
28
- plugins: [[require.resolve('babel-plugin-react-docgen'), {
29
- DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES'
30
- }]]
31
- }]
32
- });
33
- };
34
-
35
- exports.babel = babel;
36
-
37
- const webpackFinal = async (config, options) => {
38
- if (!(0, _docsTools.hasDocsOrControls)(options)) return config;
39
- const typescriptOptions = await options.presets.apply('typescript', {});
40
- const {
41
- reactDocgen,
42
- reactDocgenTypescriptOptions
43
- } = typescriptOptions || {};
44
-
45
- if (reactDocgen !== 'react-docgen-typescript') {
46
- return config;
47
- }
48
-
49
- return Object.assign({}, config, {
50
- plugins: [...(config.plugins || []), new _reactDocgenTypescriptPlugin.default(Object.assign({}, reactDocgenTypescriptOptions, {
51
- // We *need* this set so that RDT returns default values in the same format as react-docgen
52
- savePropValueAsString: true
53
- }))]
54
- });
55
- };
56
-
57
- exports.webpackFinal = webpackFinal;
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.webpackFinal = void 0;
7
-
8
- var _fsExtra = require("fs-extra");
9
-
10
- var _webpack = require("webpack");
11
-
12
- // this is a hack to allow importing react-dom/client even when it's not available
13
- // this should be removed once we drop support for react-dom < 18
14
- const webpackFinal = async config => {
15
- const reactDomPkg = await (0, _fsExtra.readJSON)(require.resolve('react-dom/package.json'));
16
- return Object.assign({}, config, {
17
- plugins: [...(config.plugins || []), reactDomPkg.version.startsWith('18') || reactDomPkg.version.startsWith('0.0.0') ? null : new _webpack.IgnorePlugin({
18
- resourceRegExp: /react-dom\/client$/,
19
- contextRegExp: /(renderers\/react|renderers\\react|@storybook\/react|@storybook\\react)/ // TODO this needs to work for both in our MONOREPO and in the user's NODE_MODULES
20
-
21
- })].filter(Boolean)
22
- });
23
- };
24
-
25
- exports.webpackFinal = webpackFinal;
@@ -1,87 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.webpackFinal = exports.babelDefault = exports.babel = void 0;
7
-
8
- var _path = _interopRequireDefault(require("path"));
9
-
10
- var _reactRefreshWebpackPlugin = _interopRequireDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
11
-
12
- var _nodeLogger = require("@storybook/node-logger");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- const useFastRefresh = async options => {
17
- const isDevelopment = options.configType === 'DEVELOPMENT';
18
- const framework = await options.presets.apply('framework');
19
- const reactOptions = typeof framework === 'object' ? framework.options : {};
20
- return isDevelopment && (reactOptions.fastRefresh || process.env.FAST_REFRESH === 'true');
21
- };
22
-
23
- const babel = async (config, options) => {
24
- if (!(await useFastRefresh(options))) return config;
25
- return Object.assign({}, config, {
26
- plugins: [[require.resolve('react-refresh/babel'), {}, 'storybook-react-refresh'], ...(config.plugins || [])]
27
- });
28
- };
29
-
30
- exports.babel = babel;
31
-
32
- const storybookReactDirName = _path.default.dirname(require.resolve('@storybook/preset-react-webpack/package.json')); // TODO: improve node_modules detection
33
-
34
-
35
- const context = storybookReactDirName.includes('node_modules') ? _path.default.join(storybookReactDirName, '../../') // Real life case, already in node_modules
36
- : _path.default.join(storybookReactDirName, '../../node_modules'); // SB Monorepo
37
-
38
- const hasJsxRuntime = () => {
39
- try {
40
- require.resolve('react/jsx-runtime', {
41
- paths: [context]
42
- });
43
-
44
- return true;
45
- } catch (e) {
46
- return false;
47
- }
48
- };
49
-
50
- const babelDefault = async config => {
51
- const presetReactOptions = hasJsxRuntime() ? {
52
- runtime: 'automatic'
53
- } : {};
54
- return Object.assign({}, config, {
55
- presets: [...((config === null || config === void 0 ? void 0 : config.presets) || []), [require.resolve('@babel/preset-react'), presetReactOptions]],
56
- plugins: [...((config === null || config === void 0 ? void 0 : config.plugins) || []), require.resolve('babel-plugin-add-react-displayname')]
57
- });
58
- };
59
-
60
- exports.babelDefault = babelDefault;
61
-
62
- const webpackFinal = async (config, options) => {
63
- var _config$plugins;
64
-
65
- if (!(await useFastRefresh(options))) return config; // matches the name of the plugin in CRA.
66
-
67
- const hasReactRefresh = !!((_config$plugins = config.plugins) !== null && _config$plugins !== void 0 && _config$plugins.find(p => p.constructor.name === 'ReactRefreshPlugin'));
68
-
69
- if (hasReactRefresh) {
70
- _nodeLogger.logger.warn("=> React refresh is already set. You don't need to set the option");
71
-
72
- return config;
73
- }
74
-
75
- _nodeLogger.logger.info('=> Using React fast refresh');
76
-
77
- return Object.assign({}, config, {
78
- plugins: [...(config.plugins || []), // Storybook uses webpack-hot-middleware https://github.com/storybookjs/storybook/issues/14114
79
- new _reactRefreshWebpackPlugin.default({
80
- overlay: {
81
- sockIntegration: 'whm'
82
- }
83
- })]
84
- });
85
- };
86
-
87
- exports.webpackFinal = webpackFinal;
package/dist/cjs/index.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- addons: true
8
- };
9
- exports.addons = void 0;
10
-
11
- var _types = require("./types");
12
-
13
- Object.keys(_types).forEach(function (key) {
14
- if (key === "default" || key === "__esModule") return;
15
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
16
- if (key in exports && exports[key] === _types[key]) return;
17
- Object.defineProperty(exports, key, {
18
- enumerable: true,
19
- get: function () {
20
- return _types[key];
21
- }
22
- });
23
- });
24
- const addons = [require.resolve('./framework-preset-react'), require.resolve('./framework-preset-react-dom-hack'), require.resolve('./framework-preset-cra'), require.resolve('./framework-preset-react-docs')];
25
- exports.addons = addons;
package/dist/cjs/types.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,49 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import semver from '@storybook/semver';
4
- import { logger } from '@storybook/node-logger';
5
- const appDirectory = fs.realpathSync(process.cwd());
6
- let reactScriptsPath;
7
- export function getReactScriptsPath({
8
- noCache
9
- } = {}) {
10
- if (reactScriptsPath && !noCache) return reactScriptsPath;
11
- let reactScriptsScriptPath = fs.realpathSync(path.join(appDirectory, '/node_modules/.bin/react-scripts'));
12
-
13
- try {
14
- // Note: Since there is no symlink for .bin/react-scripts on Windows
15
- // we'll parse react-scripts file to find actual package path.
16
- // This is important if you use fork of CRA.
17
- const pathIsNotResolved = /node_modules[\\/]\.bin[\\/]react-scripts/i.test(reactScriptsScriptPath);
18
-
19
- if (pathIsNotResolved) {
20
- const content = fs.readFileSync(reactScriptsScriptPath, 'utf8');
21
- const packagePathMatch = content.match(/"\$basedir[\\/]([^\s]+?[\\/]bin[\\/]react-scripts\.js")/i);
22
-
23
- if (packagePathMatch && packagePathMatch.length > 1) {
24
- reactScriptsScriptPath = path.join(appDirectory, '/node_modules/.bin/', packagePathMatch[1]);
25
- }
26
- }
27
- } catch (e) {
28
- logger.warn(`Error occurred during react-scripts package path resolving: ${e}`);
29
- }
30
-
31
- reactScriptsPath = path.join(reactScriptsScriptPath, '../..');
32
- const scriptsPkgJson = path.join(reactScriptsPath, 'package.json');
33
-
34
- if (!fs.existsSync(scriptsPkgJson)) {
35
- reactScriptsPath = 'react-scripts';
36
- }
37
-
38
- return reactScriptsPath;
39
- }
40
- export function isReactScriptsInstalled(requiredVersion = '2.0.0') {
41
- try {
42
- // eslint-disable-next-line import/no-dynamic-require,global-require
43
- const reactScriptsJson = require(path.join(getReactScriptsPath(), 'package.json'));
44
-
45
- return !semver.gtr(requiredVersion, reactScriptsJson.version);
46
- } catch (e) {
47
- return false;
48
- }
49
- }
@@ -1,27 +0,0 @@
1
- import { logger } from '@storybook/node-logger';
2
- import { isReactScriptsInstalled } from './cra-config';
3
-
4
- const checkForNewPreset = presetsList => {
5
- const hasNewPreset = presetsList.some(preset => {
6
- const presetName = typeof preset === 'string' ? preset : preset.name;
7
- return /@storybook(\/|\\)preset-create-react-app/.test(presetName);
8
- });
9
-
10
- if (!hasNewPreset) {
11
- logger.warn('Storybook support for Create React App is now a separate preset.');
12
- 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.');
13
- logger.warn('The built-in preset has been disabled in Storybook 6.0.');
14
- }
15
- };
16
-
17
- export const webpackFinal = (config, {
18
- presetsList
19
- }) => {
20
- if (isReactScriptsInstalled()) {
21
- if (presetsList) {
22
- checkForNewPreset(presetsList);
23
- }
24
- }
25
-
26
- return config;
27
- };
@@ -1,41 +0,0 @@
1
- import ReactDocgenTypescriptPlugin from '@storybook/react-docgen-typescript-plugin';
2
- import { hasDocsOrControls } from '@storybook/docs-tools';
3
- export const babel = async (config, options) => {
4
- if (!hasDocsOrControls(options)) return config;
5
- const typescriptOptions = await options.presets.apply('typescript', {});
6
- const {
7
- reactDocgen
8
- } = typescriptOptions || {};
9
-
10
- if (typeof reactDocgen !== 'string') {
11
- return config;
12
- }
13
-
14
- return Object.assign({}, config, {
15
- overrides: [...(config?.overrides || []), {
16
- test: reactDocgen === 'react-docgen' ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
17
- plugins: [[require.resolve('babel-plugin-react-docgen'), {
18
- DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES'
19
- }]]
20
- }]
21
- });
22
- };
23
- export const webpackFinal = async (config, options) => {
24
- if (!hasDocsOrControls(options)) return config;
25
- const typescriptOptions = await options.presets.apply('typescript', {});
26
- const {
27
- reactDocgen,
28
- reactDocgenTypescriptOptions
29
- } = typescriptOptions || {};
30
-
31
- if (reactDocgen !== 'react-docgen-typescript') {
32
- return config;
33
- }
34
-
35
- return Object.assign({}, config, {
36
- plugins: [...(config.plugins || []), new ReactDocgenTypescriptPlugin(Object.assign({}, reactDocgenTypescriptOptions, {
37
- // We *need* this set so that RDT returns default values in the same format as react-docgen
38
- savePropValueAsString: true
39
- }))]
40
- });
41
- };
@@ -1,14 +0,0 @@
1
- import { readJSON } from 'fs-extra';
2
- import { IgnorePlugin } from 'webpack';
3
- // this is a hack to allow importing react-dom/client even when it's not available
4
- // this should be removed once we drop support for react-dom < 18
5
- export const webpackFinal = async config => {
6
- const reactDomPkg = await readJSON(require.resolve('react-dom/package.json'));
7
- return Object.assign({}, config, {
8
- plugins: [...(config.plugins || []), reactDomPkg.version.startsWith('18') || reactDomPkg.version.startsWith('0.0.0') ? null : new IgnorePlugin({
9
- resourceRegExp: /react-dom\/client$/,
10
- contextRegExp: /(renderers\/react|renderers\\react|@storybook\/react|@storybook\\react)/ // TODO this needs to work for both in our MONOREPO and in the user's NODE_MODULES
11
-
12
- })].filter(Boolean)
13
- });
14
- };
@@ -1,63 +0,0 @@
1
- import path from 'path';
2
- import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
3
- import { logger } from '@storybook/node-logger';
4
-
5
- const useFastRefresh = async options => {
6
- const isDevelopment = options.configType === 'DEVELOPMENT';
7
- const framework = await options.presets.apply('framework');
8
- const reactOptions = typeof framework === 'object' ? framework.options : {};
9
- return isDevelopment && (reactOptions.fastRefresh || process.env.FAST_REFRESH === 'true');
10
- };
11
-
12
- export const babel = async (config, options) => {
13
- if (!(await useFastRefresh(options))) return config;
14
- return Object.assign({}, config, {
15
- plugins: [[require.resolve('react-refresh/babel'), {}, 'storybook-react-refresh'], ...(config.plugins || [])]
16
- });
17
- };
18
- const storybookReactDirName = path.dirname(require.resolve('@storybook/preset-react-webpack/package.json')); // TODO: improve node_modules detection
19
-
20
- const context = storybookReactDirName.includes('node_modules') ? path.join(storybookReactDirName, '../../') // Real life case, already in node_modules
21
- : path.join(storybookReactDirName, '../../node_modules'); // SB Monorepo
22
-
23
- const hasJsxRuntime = () => {
24
- try {
25
- require.resolve('react/jsx-runtime', {
26
- paths: [context]
27
- });
28
-
29
- return true;
30
- } catch (e) {
31
- return false;
32
- }
33
- };
34
-
35
- export const babelDefault = async config => {
36
- const presetReactOptions = hasJsxRuntime() ? {
37
- runtime: 'automatic'
38
- } : {};
39
- return Object.assign({}, config, {
40
- presets: [...(config?.presets || []), [require.resolve('@babel/preset-react'), presetReactOptions]],
41
- plugins: [...(config?.plugins || []), require.resolve('babel-plugin-add-react-displayname')]
42
- });
43
- };
44
- export const webpackFinal = async (config, options) => {
45
- if (!(await useFastRefresh(options))) return config; // matches the name of the plugin in CRA.
46
-
47
- const hasReactRefresh = !!config.plugins?.find(p => p.constructor.name === 'ReactRefreshPlugin');
48
-
49
- if (hasReactRefresh) {
50
- logger.warn("=> React refresh is already set. You don't need to set the option");
51
- return config;
52
- }
53
-
54
- logger.info('=> Using React fast refresh');
55
- return Object.assign({}, config, {
56
- plugins: [...(config.plugins || []), // Storybook uses webpack-hot-middleware https://github.com/storybookjs/storybook/issues/14114
57
- new ReactRefreshWebpackPlugin({
58
- overlay: {
59
- sockIntegration: 'whm'
60
- }
61
- })]
62
- });
63
- };
package/dist/esm/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export const addons = [require.resolve('./framework-preset-react'), require.resolve('./framework-preset-react-dom-hack'), require.resolve('./framework-preset-cra'), require.resolve('./framework-preset-react-docs')];
package/dist/esm/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export declare function getReactScriptsPath({ noCache }?: {
2
- noCache?: boolean;
3
- }): string;
4
- export declare function isReactScriptsInstalled(requiredVersion?: string): boolean;
@@ -1,2 +0,0 @@
1
- import type { StorybookConfig } from '@storybook/core-webpack';
2
- export declare const webpackFinal: StorybookConfig['webpack'];
@@ -1,3 +0,0 @@
1
- import type { StorybookConfig } from './types';
2
- export declare const babel: StorybookConfig['babel'];
3
- export declare const webpackFinal: StorybookConfig['webpackFinal'];
@@ -1,2 +0,0 @@
1
- import type { StorybookConfig } from '@storybook/core-webpack';
2
- export declare const webpackFinal: StorybookConfig['webpackFinal'];
@@ -1,4 +0,0 @@
1
- import type { StorybookConfig } from '@storybook/core-webpack';
2
- export declare const babel: StorybookConfig['babel'];
3
- export declare const babelDefault: StorybookConfig['babelDefault'];
4
- export declare const webpackFinal: StorybookConfig['webpackFinal'];
@@ -1,3 +0,0 @@
1
- import type { StorybookConfig } from './types';
2
- export * from './types';
3
- export declare const addons: StorybookConfig['addons'];