@storybook/preset-react-webpack 9.1.0-alpha.4 → 9.1.0-alpha.6

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 +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 react_docgen_loader_exports={};__export(react_docgen_loader_exports,{default:()=>reactDocgenLoader,getReactDocgenImporter:()=>getReactDocgenImporter});module.exports=__toCommonJS(react_docgen_loader_exports);var import_node_logger=require("storybook/internal/node-logger"),import_find_up=__toESM(require("find-up")),import_magic_string=__toESM(require("magic-string")),import_react_docgen=require("react-docgen"),TsconfigPaths=__toESM(require("tsconfig-paths"));var import_node_path=require("path"),import_resolve=__toESM(require("resolve")),ReactDocgenResolveError=class extends Error{constructor(filename){super(`'${filename}' was ignored by react-docgen.`);this.code="MODULE_NOT_FOUND"}},RESOLVE_EXTENSIONS=[".js",".cts",".mts",".ctsx",".mtsx",".ts",".tsx",".mjs",".cjs",".mts",".cts",".jsx"];function defaultLookupModule(filename,basedir){let resolveOptions={basedir,extensions:RESOLVE_EXTENSIONS,includeCoreModules:!1};try{return import_resolve.default.sync(filename,resolveOptions)}catch(error){let ext=(0,import_node_path.extname)(filename),newFilename;switch(ext){case".js":case".mjs":case".cjs":newFilename=`${filename.slice(0,-2)}ts`;break;case".jsx":newFilename=`${filename.slice(0,-3)}tsx`;break;default:throw error}return import_resolve.default.sync(newFilename,{...resolveOptions,extensions:[]})}}var{getNameOrValue,isReactForwardRefCall}=import_react_docgen.utils,actualNameHandler=function(documentation,componentDefinition){if(documentation.set("definedInFile",componentDefinition.hub.file.opts.filename),(componentDefinition.isClassDeclaration()||componentDefinition.isFunctionDeclaration())&&componentDefinition.has("id"))documentation.set("actualName",getNameOrValue(componentDefinition.get("id")));else if(componentDefinition.isArrowFunctionExpression()||componentDefinition.isFunctionExpression()||isReactForwardRefCall(componentDefinition)){let currentPath=componentDefinition;for(;currentPath.parentPath;){if(currentPath.parentPath.isVariableDeclarator()){documentation.set("actualName",getNameOrValue(currentPath.parentPath.get("id")));return}if(currentPath.parentPath.isAssignmentExpression()){let leftPath=currentPath.parentPath.get("left");if(leftPath.isIdentifier()||leftPath.isLiteral()){documentation.set("actualName",getNameOrValue(leftPath));return}}currentPath=currentPath.parentPath}documentation.set("actualName","")}},defaultHandlers=Object.values(import_react_docgen.builtinHandlers).map(handler=>handler),defaultResolver=new import_react_docgen.builtinResolvers.FindExportedDefinitionsResolver,handlers=[...defaultHandlers,actualNameHandler],tsconfigPathsInitialized=!1,matchPath;async function reactDocgenLoader(source,map){let callback=this.async(),options=this.getOptions()||{},{debug=!1}=options;if(!tsconfigPathsInitialized){let tsconfigPath=await(0,import_find_up.default)("tsconfig.json",{cwd:process.cwd()}),tsconfig=TsconfigPaths.loadConfig(tsconfigPath);tsconfig.resultType==="success"&&(import_node_logger.logger.info("Using tsconfig paths for react-docgen"),matchPath=TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl,tsconfig.paths,["browser","module","main"])),tsconfigPathsInitialized=!0}try{let docgenResults=(0,import_react_docgen.parse)(source,{filename:this.resourcePath,resolver:defaultResolver,handlers,importer:getReactDocgenImporter(matchPath),babelOptions:{babelrc:!1,configFile:!1}}),magicString=new import_magic_string.default(source);docgenResults.forEach(info=>{let{actualName,definedInFile,...docgenInfo}=info;if(actualName&&definedInFile==this.resourcePath){let docNode=JSON.stringify(docgenInfo);magicString.append(`;${actualName}.__docgenInfo=${docNode}`)}}),callback(null,magicString.toString(),map??magicString.generateMap({hires:!0,source:this.resourcePath,includeContent:!0}))}catch(error){error.code===import_react_docgen.ERROR_CODES.MISSING_DEFINITION||(debug?(import_node_logger.logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Please use the below error message and the content of the file which causes the error to report the issue to the maintainers of react-docgen. https://github.com/reactjs/react-docgen`),import_node_logger.logger.error(error)):import_node_logger.logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`)),callback(null,source)}}function getReactDocgenImporter(matchingPath){return(0,import_react_docgen.makeFsImporter)((filename,basedir)=>{let mappedFilenameByPaths=matchingPath&&matchingPath(filename)||filename,result=defaultLookupModule(mappedFilenameByPaths,basedir);if(RESOLVE_EXTENSIONS.find(ext=>result.endsWith(ext)))return result;throw new ReactDocgenResolveError(filename)})}0&&(module.exports={getReactDocgenImporter});
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 react_docgen_loader_exports={};__export(react_docgen_loader_exports,{default:()=>reactDocgenLoader,getReactDocgenImporter:()=>getReactDocgenImporter});module.exports=__toCommonJS(react_docgen_loader_exports);var import_common=require("storybook/internal/common"),import_node_logger=require("storybook/internal/node-logger"),import_find_up=require("find-up"),import_magic_string=__toESM(require("magic-string")),import_react_docgen=require("react-docgen"),TsconfigPaths=__toESM(require("tsconfig-paths"));var import_node_path=require("path"),import_resolve=__toESM(require("resolve")),ReactDocgenResolveError=class extends Error{constructor(filename){super(`'${filename}' was ignored by react-docgen.`);this.code="MODULE_NOT_FOUND"}},RESOLVE_EXTENSIONS=[".js",".cts",".mts",".ctsx",".mtsx",".ts",".tsx",".mjs",".cjs",".mts",".cts",".jsx"];function defaultLookupModule(filename,basedir){let resolveOptions={basedir,extensions:RESOLVE_EXTENSIONS,includeCoreModules:!1};try{return import_resolve.default.sync(filename,resolveOptions)}catch(error){let ext=(0,import_node_path.extname)(filename),newFilename;switch(ext){case".js":case".mjs":case".cjs":newFilename=`${filename.slice(0,-2)}ts`;break;case".jsx":newFilename=`${filename.slice(0,-3)}tsx`;break;default:throw error}return import_resolve.default.sync(newFilename,{...resolveOptions,extensions:[]})}}var{getNameOrValue,isReactForwardRefCall}=import_react_docgen.utils,actualNameHandler=function(documentation,componentDefinition){if(documentation.set("definedInFile",componentDefinition.hub.file.opts.filename),(componentDefinition.isClassDeclaration()||componentDefinition.isFunctionDeclaration())&&componentDefinition.has("id"))documentation.set("actualName",getNameOrValue(componentDefinition.get("id")));else if(componentDefinition.isArrowFunctionExpression()||componentDefinition.isFunctionExpression()||isReactForwardRefCall(componentDefinition)){let currentPath=componentDefinition;for(;currentPath.parentPath;){if(currentPath.parentPath.isVariableDeclarator()){documentation.set("actualName",getNameOrValue(currentPath.parentPath.get("id")));return}if(currentPath.parentPath.isAssignmentExpression()){let leftPath=currentPath.parentPath.get("left");if(leftPath.isIdentifier()||leftPath.isLiteral()){documentation.set("actualName",getNameOrValue(leftPath));return}}currentPath=currentPath.parentPath}documentation.set("actualName","")}},defaultHandlers=Object.values(import_react_docgen.builtinHandlers).map(handler=>handler),defaultResolver=new import_react_docgen.builtinResolvers.FindExportedDefinitionsResolver,handlers=[...defaultHandlers,actualNameHandler],tsconfigPathsInitialized=!1,matchPath;async function reactDocgenLoader(source,map){let callback=this.async(),options=this.getOptions()||{},{debug=!1}=options;if(!tsconfigPathsInitialized){let tsconfigPath=await(0,import_find_up.findUp)("tsconfig.json",{cwd:process.cwd(),stopAt:(0,import_common.getProjectRoot)()}),tsconfig=TsconfigPaths.loadConfig(tsconfigPath);tsconfig.resultType==="success"&&(import_node_logger.logger.info("Using tsconfig paths for react-docgen"),matchPath=TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl,tsconfig.paths,["browser","module","main"])),tsconfigPathsInitialized=!0}try{let docgenResults=(0,import_react_docgen.parse)(source,{filename:this.resourcePath,resolver:defaultResolver,handlers,importer:getReactDocgenImporter(matchPath),babelOptions:{babelrc:!1,configFile:!1}}),magicString=new import_magic_string.default(source);docgenResults.forEach(info=>{let{actualName,definedInFile,...docgenInfo}=info;if(actualName&&definedInFile==this.resourcePath){let docNode=JSON.stringify(docgenInfo);magicString.append(`;${actualName}.__docgenInfo=${docNode}`)}}),callback(null,magicString.toString(),map??magicString.generateMap({hires:!0,source:this.resourcePath,includeContent:!0}))}catch(error){error.code===import_react_docgen.ERROR_CODES.MISSING_DEFINITION||(debug?(import_node_logger.logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Please use the below error message and the content of the file which causes the error to report the issue to the maintainers of react-docgen. https://github.com/reactjs/react-docgen`),import_node_logger.logger.error(error)):import_node_logger.logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`)),callback(null,source)}}function getReactDocgenImporter(matchingPath){return(0,import_react_docgen.makeFsImporter)((filename,basedir)=>{let mappedFilenameByPaths=matchingPath&&matchingPath(filename)||filename,result=defaultLookupModule(mappedFilenameByPaths,basedir);if(RESOLVE_EXTENSIONS.find(ext=>result.endsWith(ext)))return result;throw new ReactDocgenResolveError(filename)})}0&&(module.exports={getReactDocgenImporter});
@@ -1,12 +1,13 @@
1
1
  import '../chunk-MXFP7CYD.mjs';
2
+ import { getProjectRoot } from 'storybook/internal/common';
2
3
  import { logger } from 'storybook/internal/node-logger';
3
- import findUp from 'find-up';
4
+ import { findUp } from 'find-up';
4
5
  import MagicString from 'magic-string';
5
6
  import { builtinHandlers, builtinResolvers, parse, ERROR_CODES, makeFsImporter, utils } from 'react-docgen';
6
7
  import * as TsconfigPaths from 'tsconfig-paths';
7
8
  import { extname } from 'node:path';
8
9
  import resolve from 'resolve';
9
10
 
10
- var ReactDocgenResolveError=class extends Error{constructor(filename){super(`'${filename}' was ignored by react-docgen.`);this.code="MODULE_NOT_FOUND";}},RESOLVE_EXTENSIONS=[".js",".cts",".mts",".ctsx",".mtsx",".ts",".tsx",".mjs",".cjs",".mts",".cts",".jsx"];function defaultLookupModule(filename,basedir){let resolveOptions={basedir,extensions:RESOLVE_EXTENSIONS,includeCoreModules:!1};try{return resolve.sync(filename,resolveOptions)}catch(error){let ext=extname(filename),newFilename;switch(ext){case".js":case".mjs":case".cjs":newFilename=`${filename.slice(0,-2)}ts`;break;case".jsx":newFilename=`${filename.slice(0,-3)}tsx`;break;default:throw error}return resolve.sync(newFilename,{...resolveOptions,extensions:[]})}}var{getNameOrValue,isReactForwardRefCall}=utils,actualNameHandler=function(documentation,componentDefinition){if(documentation.set("definedInFile",componentDefinition.hub.file.opts.filename),(componentDefinition.isClassDeclaration()||componentDefinition.isFunctionDeclaration())&&componentDefinition.has("id"))documentation.set("actualName",getNameOrValue(componentDefinition.get("id")));else if(componentDefinition.isArrowFunctionExpression()||componentDefinition.isFunctionExpression()||isReactForwardRefCall(componentDefinition)){let currentPath=componentDefinition;for(;currentPath.parentPath;){if(currentPath.parentPath.isVariableDeclarator()){documentation.set("actualName",getNameOrValue(currentPath.parentPath.get("id")));return}if(currentPath.parentPath.isAssignmentExpression()){let leftPath=currentPath.parentPath.get("left");if(leftPath.isIdentifier()||leftPath.isLiteral()){documentation.set("actualName",getNameOrValue(leftPath));return}}currentPath=currentPath.parentPath;}documentation.set("actualName","");}},defaultHandlers=Object.values(builtinHandlers).map(handler=>handler),defaultResolver=new builtinResolvers.FindExportedDefinitionsResolver,handlers=[...defaultHandlers,actualNameHandler],tsconfigPathsInitialized=!1,matchPath;async function reactDocgenLoader(source,map){let callback=this.async(),options=this.getOptions()||{},{debug=!1}=options;if(!tsconfigPathsInitialized){let tsconfigPath=await findUp("tsconfig.json",{cwd:process.cwd()}),tsconfig=TsconfigPaths.loadConfig(tsconfigPath);tsconfig.resultType==="success"&&(logger.info("Using tsconfig paths for react-docgen"),matchPath=TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl,tsconfig.paths,["browser","module","main"])),tsconfigPathsInitialized=!0;}try{let docgenResults=parse(source,{filename:this.resourcePath,resolver:defaultResolver,handlers,importer:getReactDocgenImporter(matchPath),babelOptions:{babelrc:!1,configFile:!1}}),magicString=new MagicString(source);docgenResults.forEach(info=>{let{actualName,definedInFile,...docgenInfo}=info;if(actualName&&definedInFile==this.resourcePath){let docNode=JSON.stringify(docgenInfo);magicString.append(`;${actualName}.__docgenInfo=${docNode}`);}}),callback(null,magicString.toString(),map??magicString.generateMap({hires:!0,source:this.resourcePath,includeContent:!0}));}catch(error){error.code===ERROR_CODES.MISSING_DEFINITION||(debug?(logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Please use the below error message and the content of the file which causes the error to report the issue to the maintainers of react-docgen. https://github.com/reactjs/react-docgen`),logger.error(error)):logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`)),callback(null,source);}}function getReactDocgenImporter(matchingPath){return makeFsImporter((filename,basedir)=>{let mappedFilenameByPaths=matchingPath&&matchingPath(filename)||filename,result=defaultLookupModule(mappedFilenameByPaths,basedir);if(RESOLVE_EXTENSIONS.find(ext=>result.endsWith(ext)))return result;throw new ReactDocgenResolveError(filename)})}
11
+ var ReactDocgenResolveError=class extends Error{constructor(filename){super(`'${filename}' was ignored by react-docgen.`);this.code="MODULE_NOT_FOUND";}},RESOLVE_EXTENSIONS=[".js",".cts",".mts",".ctsx",".mtsx",".ts",".tsx",".mjs",".cjs",".mts",".cts",".jsx"];function defaultLookupModule(filename,basedir){let resolveOptions={basedir,extensions:RESOLVE_EXTENSIONS,includeCoreModules:!1};try{return resolve.sync(filename,resolveOptions)}catch(error){let ext=extname(filename),newFilename;switch(ext){case".js":case".mjs":case".cjs":newFilename=`${filename.slice(0,-2)}ts`;break;case".jsx":newFilename=`${filename.slice(0,-3)}tsx`;break;default:throw error}return resolve.sync(newFilename,{...resolveOptions,extensions:[]})}}var{getNameOrValue,isReactForwardRefCall}=utils,actualNameHandler=function(documentation,componentDefinition){if(documentation.set("definedInFile",componentDefinition.hub.file.opts.filename),(componentDefinition.isClassDeclaration()||componentDefinition.isFunctionDeclaration())&&componentDefinition.has("id"))documentation.set("actualName",getNameOrValue(componentDefinition.get("id")));else if(componentDefinition.isArrowFunctionExpression()||componentDefinition.isFunctionExpression()||isReactForwardRefCall(componentDefinition)){let currentPath=componentDefinition;for(;currentPath.parentPath;){if(currentPath.parentPath.isVariableDeclarator()){documentation.set("actualName",getNameOrValue(currentPath.parentPath.get("id")));return}if(currentPath.parentPath.isAssignmentExpression()){let leftPath=currentPath.parentPath.get("left");if(leftPath.isIdentifier()||leftPath.isLiteral()){documentation.set("actualName",getNameOrValue(leftPath));return}}currentPath=currentPath.parentPath;}documentation.set("actualName","");}},defaultHandlers=Object.values(builtinHandlers).map(handler=>handler),defaultResolver=new builtinResolvers.FindExportedDefinitionsResolver,handlers=[...defaultHandlers,actualNameHandler],tsconfigPathsInitialized=!1,matchPath;async function reactDocgenLoader(source,map){let callback=this.async(),options=this.getOptions()||{},{debug=!1}=options;if(!tsconfigPathsInitialized){let tsconfigPath=await findUp("tsconfig.json",{cwd:process.cwd(),stopAt:getProjectRoot()}),tsconfig=TsconfigPaths.loadConfig(tsconfigPath);tsconfig.resultType==="success"&&(logger.info("Using tsconfig paths for react-docgen"),matchPath=TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl,tsconfig.paths,["browser","module","main"])),tsconfigPathsInitialized=!0;}try{let docgenResults=parse(source,{filename:this.resourcePath,resolver:defaultResolver,handlers,importer:getReactDocgenImporter(matchPath),babelOptions:{babelrc:!1,configFile:!1}}),magicString=new MagicString(source);docgenResults.forEach(info=>{let{actualName,definedInFile,...docgenInfo}=info;if(actualName&&definedInFile==this.resourcePath){let docNode=JSON.stringify(docgenInfo);magicString.append(`;${actualName}.__docgenInfo=${docNode}`);}}),callback(null,magicString.toString(),map??magicString.generateMap({hires:!0,source:this.resourcePath,includeContent:!0}));}catch(error){error.code===ERROR_CODES.MISSING_DEFINITION||(debug?(logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Please use the below error message and the content of the file which causes the error to report the issue to the maintainers of react-docgen. https://github.com/reactjs/react-docgen`),logger.error(error)):logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`)),callback(null,source);}}function getReactDocgenImporter(matchingPath){return makeFsImporter((filename,basedir)=>{let mappedFilenameByPaths=matchingPath&&matchingPath(filename)||filename,result=defaultLookupModule(mappedFilenameByPaths,basedir);if(RESOLVE_EXTENSIONS.find(ext=>result.endsWith(ext)))return result;throw new ReactDocgenResolveError(filename)})}
11
12
 
12
13
  export { reactDocgenLoader as default, getReactDocgenImporter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/preset-react-webpack",
3
- "version": "9.1.0-alpha.4",
3
+ "version": "9.1.0-alpha.6",
4
4
  "description": "Storybook for React: Develop React Component in isolation with Hot Reloading",
5
5
  "keywords": [
6
6
  "storybook"
@@ -64,10 +64,10 @@
64
64
  "prep": "jiti ../../../scripts/prepare/bundle.ts"
65
65
  },
66
66
  "dependencies": {
67
- "@storybook/core-webpack": "9.1.0-alpha.4",
67
+ "@storybook/core-webpack": "9.1.0-alpha.6",
68
68
  "@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.0c3f3b7.0",
69
69
  "@types/semver": "^7.3.4",
70
- "find-up": "^5.0.0",
70
+ "find-up": "^7.0.0",
71
71
  "magic-string": "^0.30.5",
72
72
  "react-docgen": "^7.1.1",
73
73
  "resolve": "^1.22.8",
@@ -82,7 +82,7 @@
82
82
  "peerDependencies": {
83
83
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
84
84
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
85
- "storybook": "^9.1.0-alpha.4"
85
+ "storybook": "^9.1.0-alpha.6"
86
86
  },
87
87
  "peerDependenciesMeta": {
88
88
  "typescript": {