@storybook/csf-plugin 8.2.0-alpha.0 → 8.2.0-alpha.10

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,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')});
2
+
3
+ export { __require };
package/dist/index.js CHANGED
@@ -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 src_exports={};__export(src_exports,{esbuild:()=>esbuild,rollup:()=>rollup,unplugin:()=>unplugin,vite:()=>vite,webpack:()=>webpack});module.exports=__toCommonJS(src_exports);var import_unplugin=require("unplugin"),import_promises=__toESM(require("fs/promises")),import_csf_tools=require("@storybook/csf-tools"),STORIES_REGEX=/(?<!node_modules.*)\.(story|stories)\.[tj]sx?$/,logger=console,unplugin=(0,import_unplugin.createUnplugin)(options=>({name:"unplugin-csf",transformInclude(id){return STORIES_REGEX.test(id)},async transform(code,id){let sourceCode=await import_promises.default.readFile(id,"utf-8");try{let makeTitle=userTitle=>userTitle||"default",csf=(0,import_csf_tools.loadCsf)(code,{makeTitle}).parse(),csfSource=(0,import_csf_tools.loadCsf)(sourceCode,{makeTitle}).parse();return(0,import_csf_tools.enrichCsf)(csf,csfSource,options),(0,import_csf_tools.formatCsf)(csf,{sourceMaps:!0})}catch(err){return err.message?.startsWith("CSF:")||logger.warn(err.message),code}}})),{esbuild}=unplugin,{webpack}=unplugin,{rollup}=unplugin,{vite}=unplugin;0&&(module.exports={esbuild,rollup,unplugin,vite,webpack});
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,{esbuild:()=>esbuild,rollup:()=>rollup,unplugin:()=>unplugin,vite:()=>vite,webpack:()=>webpack});module.exports=__toCommonJS(src_exports);var import_unplugin=require("unplugin");var import_csf_tools=require("@storybook/csf-tools"),import_promises=__toESM(require("fs/promises"));var STORIES_REGEX=/(?<!node_modules.*)\.(story|stories)\.[tj]sx?$/;var logger=console;function rollupBasedPlugin(options){return{name:"plugin-csf",async transform(code,id){if(!STORIES_REGEX.test(id))return;let sourceCode=await import_promises.default.readFile(id,"utf-8");try{let makeTitle=userTitle=>userTitle||"default",csf=(0,import_csf_tools.loadCsf)(code,{makeTitle}).parse(),csfSource=(0,import_csf_tools.loadCsf)(sourceCode,{makeTitle}).parse();(0,import_csf_tools.enrichCsf)(csf,csfSource,options);let inputSourceMap=this.getCombinedSourcemap();return(0,import_csf_tools.formatCsf)(csf,{sourceMaps:!0,inputSourceMap},code)}catch(err){return err.message?.startsWith("CSF:")||logger.warn(err.message),code}}}}var unplugin=(0,import_unplugin.createUnplugin)(options=>({name:"unplugin-csf",rollup:{...rollupBasedPlugin(options)},vite:{enforce:"pre",...rollupBasedPlugin(options)},webpack(compiler){compiler.options.module.rules.unshift({test:STORIES_REGEX,enforce:"post",use:{options,loader:require.resolve("@storybook/csf-plugin/dist/webpack-loader")}})},rspack(compiler){compiler.options.module.rules.unshift({test:STORIES_REGEX,enforce:"post",use:{options,loader:require.resolve("@storybook/csf-plugin/dist/webpack-loader")}})}})),{esbuild}=unplugin,{webpack}=unplugin,{rollup}=unplugin,{vite}=unplugin;0&&(module.exports={esbuild,rollup,unplugin,vite,webpack});
package/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
+ import { __require } from './chunk-MXFP7CYD.mjs';
1
2
  import { createUnplugin } from 'unplugin';
2
- import fs from 'fs/promises';
3
3
  import { loadCsf, enrichCsf, formatCsf } from '@storybook/csf-tools';
4
+ import fs from 'fs/promises';
4
5
 
5
- var STORIES_REGEX=new RegExp("(?<!node_modules.*)\\.(story|stories)\\.[tj]sx?$"),logger=console,unplugin=createUnplugin(options=>({name:"unplugin-csf",transformInclude(id){return STORIES_REGEX.test(id)},async transform(code,id){let sourceCode=await fs.readFile(id,"utf-8");try{let makeTitle=userTitle=>userTitle||"default",csf=loadCsf(code,{makeTitle}).parse(),csfSource=loadCsf(sourceCode,{makeTitle}).parse();return enrichCsf(csf,csfSource,options),formatCsf(csf,{sourceMaps:!0})}catch(err){return err.message?.startsWith("CSF:")||logger.warn(err.message),code}}})),{esbuild}=unplugin,{webpack}=unplugin,{rollup}=unplugin,{vite}=unplugin;
6
+ var STORIES_REGEX=new RegExp("(?<!node_modules.*)\\.(story|stories)\\.[tj]sx?$");var logger=console;function rollupBasedPlugin(options){return {name:"plugin-csf",async transform(code,id){if(!STORIES_REGEX.test(id))return;let sourceCode=await fs.readFile(id,"utf-8");try{let makeTitle=userTitle=>userTitle||"default",csf=loadCsf(code,{makeTitle}).parse(),csfSource=loadCsf(sourceCode,{makeTitle}).parse();enrichCsf(csf,csfSource,options);let inputSourceMap=this.getCombinedSourcemap();return formatCsf(csf,{sourceMaps:!0,inputSourceMap},code)}catch(err){return err.message?.startsWith("CSF:")||logger.warn(err.message),code}}}}var unplugin=createUnplugin(options=>({name:"unplugin-csf",rollup:{...rollupBasedPlugin(options)},vite:{enforce:"pre",...rollupBasedPlugin(options)},webpack(compiler){compiler.options.module.rules.unshift({test:STORIES_REGEX,enforce:"post",use:{options,loader:__require.resolve("@storybook/csf-plugin/dist/webpack-loader")}});},rspack(compiler){compiler.options.module.rules.unshift({test:STORIES_REGEX,enforce:"post",use:{options,loader:__require.resolve("@storybook/csf-plugin/dist/webpack-loader")}});}})),{esbuild}=unplugin,{webpack}=unplugin,{rollup}=unplugin,{vite}=unplugin;
6
7
 
7
8
  export { esbuild, rollup, unplugin, vite, webpack };
@@ -0,0 +1,10 @@
1
+ import { EnrichCsfOptions } from '@storybook/csf-tools';
2
+
3
+ interface LoaderContext {
4
+ async: () => (err: Error | null, result?: string, map?: any) => void;
5
+ getOptions: () => EnrichCsfOptions;
6
+ resourcePath: string;
7
+ }
8
+ declare function loader(this: LoaderContext, content: string, map: any): Promise<void>;
9
+
10
+ export { loader as default };
@@ -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 webpack_loader_exports={};__export(webpack_loader_exports,{default:()=>webpack_loader_default});module.exports=__toCommonJS(webpack_loader_exports);var import_promises=__toESM(require("fs/promises")),import_csf_tools=require("@storybook/csf-tools");async function loader(content,map){let callback=this.async(),options=this.getOptions(),id=this.resourcePath,sourceCode=await import_promises.default.readFile(id,"utf-8");try{let makeTitle=userTitle=>userTitle||"default",csf=(0,import_csf_tools.loadCsf)(content,{makeTitle}).parse(),csfSource=(0,import_csf_tools.loadCsf)(sourceCode,{makeTitle}).parse();(0,import_csf_tools.enrichCsf)(csf,csfSource,options);let formattedCsf=(0,import_csf_tools.formatCsf)(csf,{sourceMaps:!0,inputSourceMap:map},content);if(typeof formattedCsf=="string")return callback(null,formattedCsf,map);callback(null,formattedCsf.code,formattedCsf.map)}catch(err){err.message?.startsWith("CSF:")||console.warn(err.message),callback(null,content,map)}}var webpack_loader_default=loader;
@@ -0,0 +1,7 @@
1
+ import './chunk-MXFP7CYD.mjs';
2
+ import fs from 'fs/promises';
3
+ import { loadCsf, enrichCsf, formatCsf } from '@storybook/csf-tools';
4
+
5
+ async function loader(content,map){let callback=this.async(),options=this.getOptions(),id=this.resourcePath,sourceCode=await fs.readFile(id,"utf-8");try{let makeTitle=userTitle=>userTitle||"default",csf=loadCsf(content,{makeTitle}).parse(),csfSource=loadCsf(sourceCode,{makeTitle}).parse();enrichCsf(csf,csfSource,options);let formattedCsf=formatCsf(csf,{sourceMaps:!0,inputSourceMap:map},content);if(typeof formattedCsf=="string")return callback(null,formattedCsf,map);callback(null,formattedCsf.code,formattedCsf.map);}catch(err){err.message?.startsWith("CSF:")||console.warn(err.message),callback(null,content,map);}}var webpack_loader_default=loader;
6
+
7
+ export { webpack_loader_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/csf-plugin",
3
- "version": "8.2.0-alpha.0",
3
+ "version": "8.2.0-alpha.10",
4
4
  "description": "Enrich CSF files via static analysis",
5
5
  "keywords": [
6
6
  "storybook"
@@ -24,8 +24,14 @@
24
24
  ".": {
25
25
  "types": "./dist/index.d.ts",
26
26
  "node": "./dist/index.js",
27
- "require": "./dist/index.js",
28
- "import": "./dist/index.mjs"
27
+ "import": "./dist/index.mjs",
28
+ "require": "./dist/index.js"
29
+ },
30
+ "./dist/webpack-loader": {
31
+ "types": "./dist/webpack-loader.d.ts",
32
+ "node": "./dist/webpack-loader.js",
33
+ "import": "./dist/webpack-loader.mjs",
34
+ "require": "./dist/webpack-loader.js"
29
35
  },
30
36
  "./package.json": "./package.json"
31
37
  },
@@ -44,7 +50,7 @@
44
50
  "prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts"
45
51
  },
46
52
  "dependencies": {
47
- "@storybook/csf-tools": "8.2.0-alpha.0",
53
+ "@storybook/csf-tools": "8.2.0-alpha.10",
48
54
  "unplugin": "^1.3.1"
49
55
  },
50
56
  "devDependencies": {
@@ -55,7 +61,8 @@
55
61
  },
56
62
  "bundler": {
57
63
  "entries": [
58
- "./src/index.ts"
64
+ "./src/index.ts",
65
+ "./src/webpack-loader.ts"
59
66
  ],
60
67
  "externals": [
61
68
  "webpack",
@@ -65,5 +72,5 @@
65
72
  ],
66
73
  "platform": "node"
67
74
  },
68
- "gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae17"
75
+ "gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16"
69
76
  }