@storybook/preset-server-webpack 9.2.0-alpha.3 → 10.0.0-beta.0
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 +3 -1
- package/dist/_node-chunks/chunk-KQARS7SB.js +17 -0
- package/dist/index.js +44 -1
- package/dist/loader.js +122 -12
- package/package.json +12 -36
- package/preset.js +1 -1
- package/dist/chunk-MXFP7CYD.mjs +0 -3
- package/dist/index.mjs +0 -5
- package/dist/loader.d.ts +0 -3
- package/dist/loader.mjs +0 -23
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Storybook Webpack preset for Server
|
|
2
2
|
|
|
3
|
-
This package is a [preset](https://storybook.js.org/docs/addons/writing-presets) that configures Storybook's webpack settings for handling React.
|
|
3
|
+
This package is a [preset](https://storybook.js.org/docs/addons/writing-presets?ref=readme) that configures Storybook's webpack settings for handling React.
|
|
4
4
|
It's an internal package that's not intended to be used directly by users.
|
|
5
5
|
|
|
6
6
|
- More info on [Storybook for Server](https://github.com/storybookjs/storybook/tree/next/code/frameworks/server-webpack5)
|
|
7
|
+
|
|
8
|
+
Learn more about Storybook at [storybook.js.org](https://storybook.js.org/?ref=readme).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_yf8snrkz7j from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_yf8snrkz7j from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_yf8snrkz7j from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_yf8snrkz7j.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_yf8snrkz7j.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_yf8snrkz7j.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
__name
|
|
17
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_yf8snrkz7j from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_yf8snrkz7j from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_yf8snrkz7j from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_yf8snrkz7j.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_yf8snrkz7j.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_yf8snrkz7j.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__name
|
|
14
|
+
} from "./_node-chunks/chunk-KQARS7SB.js";
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
var webpack = /* @__PURE__ */ __name((config) => {
|
|
19
|
+
const rules = [
|
|
20
|
+
...config.module?.rules || [],
|
|
21
|
+
{
|
|
22
|
+
type: "javascript/auto",
|
|
23
|
+
test: /\.stories\.json$/,
|
|
24
|
+
use: fileURLToPath(import.meta.resolve("@storybook/preset-server-webpack/webpack-loader"))
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "javascript/auto",
|
|
28
|
+
test: /\.stories\.ya?ml/,
|
|
29
|
+
use: [
|
|
30
|
+
fileURLToPath(import.meta.resolve("@storybook/preset-server-webpack/webpack-loader")),
|
|
31
|
+
{
|
|
32
|
+
loader: fileURLToPath(import.meta.resolve("yaml-loader")),
|
|
33
|
+
options: { asJSON: true }
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
config.module = config.module || {};
|
|
39
|
+
config.module.rules = rules;
|
|
40
|
+
return config;
|
|
41
|
+
}, "webpack");
|
|
42
|
+
export {
|
|
43
|
+
webpack
|
|
44
|
+
};
|
package/dist/loader.js
CHANGED
|
@@ -1,18 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_yf8snrkz7j from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_yf8snrkz7j from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_yf8snrkz7j from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_yf8snrkz7j.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_yf8snrkz7j.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_yf8snrkz7j.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__name
|
|
14
|
+
} from "./_node-chunks/chunk-KQARS7SB.js";
|
|
15
|
+
|
|
16
|
+
// src/lib/compiler/stringifier.ts
|
|
17
|
+
import { identifier } from "safe-identifier";
|
|
18
|
+
import { dedent } from "ts-dedent";
|
|
19
|
+
function stringifyObject(object, level = 0, excludeOuterParams = false) {
|
|
20
|
+
if (typeof object === "string") {
|
|
21
|
+
return JSON.stringify(object);
|
|
22
|
+
}
|
|
23
|
+
const indent = " ".repeat(level);
|
|
24
|
+
if (Array.isArray(object)) {
|
|
25
|
+
const arrayStrings = object.map((item) => stringifyObject(item, level + 1));
|
|
26
|
+
const arrayString = arrayStrings.join(`,
|
|
27
|
+
${indent} `);
|
|
28
|
+
if (excludeOuterParams) {
|
|
29
|
+
return arrayString;
|
|
30
|
+
}
|
|
31
|
+
return `[
|
|
3
32
|
${indent} ${arrayString}
|
|
4
|
-
${indent}]
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
33
|
+
${indent}]`;
|
|
34
|
+
}
|
|
35
|
+
if (typeof object === "object") {
|
|
36
|
+
let objectString = "";
|
|
37
|
+
if (Object.keys(object).length > 0) {
|
|
38
|
+
const objectStrings = Object.keys(object).map((key) => {
|
|
39
|
+
const value = stringifyObject(object[key], level + 1);
|
|
40
|
+
return `
|
|
41
|
+
${indent} ${key}: ${value}`;
|
|
42
|
+
});
|
|
43
|
+
objectString = objectStrings.join(",");
|
|
44
|
+
}
|
|
45
|
+
if (excludeOuterParams) {
|
|
46
|
+
return objectString;
|
|
47
|
+
}
|
|
48
|
+
if (objectString.length === 0) {
|
|
49
|
+
return "{}";
|
|
50
|
+
}
|
|
51
|
+
return `{${objectString}
|
|
52
|
+
${indent}}`;
|
|
53
|
+
}
|
|
54
|
+
return object;
|
|
55
|
+
}
|
|
56
|
+
__name(stringifyObject, "stringifyObject");
|
|
57
|
+
function stringifyImports(imports) {
|
|
58
|
+
if (Object.keys(imports).length === 0) {
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
return Object.entries(imports).map(([module, names]) => `import { ${names.sort().join(", ")} } from '${module}';
|
|
62
|
+
`).join("");
|
|
63
|
+
}
|
|
64
|
+
__name(stringifyImports, "stringifyImports");
|
|
65
|
+
function stringifyDecorators(decorators) {
|
|
66
|
+
return decorators && decorators.length > 0 ? `
|
|
8
67
|
decorators: [
|
|
9
|
-
${decorators.join(
|
|
10
|
-
|
|
11
|
-
|
|
68
|
+
${decorators.join(",\n ")}
|
|
69
|
+
],` : "";
|
|
70
|
+
}
|
|
71
|
+
__name(stringifyDecorators, "stringifyDecorators");
|
|
72
|
+
function stringifyDefault(section) {
|
|
73
|
+
const { title, imports, decorators, stories, ...options } = section;
|
|
74
|
+
const decoratorsString = stringifyDecorators(decorators);
|
|
75
|
+
const optionsString = stringifyObject(options, 0, true);
|
|
76
|
+
return dedent`
|
|
12
77
|
export default {
|
|
13
78
|
title: ${JSON.stringify(title)},${decoratorsString}${optionsString}
|
|
14
79
|
};
|
|
15
80
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
__name(stringifyDefault, "stringifyDefault");
|
|
84
|
+
function stringifyStory(story) {
|
|
85
|
+
const { name, ...options } = story;
|
|
86
|
+
const storyId = identifier(name);
|
|
87
|
+
const exportedStory = { name, ...options };
|
|
88
|
+
const storyStrings = [`export const ${storyId} = ${stringifyObject(exportedStory)};`, ""];
|
|
89
|
+
return storyStrings.join("\n");
|
|
90
|
+
}
|
|
91
|
+
__name(stringifyStory, "stringifyStory");
|
|
92
|
+
function stringifySection(section) {
|
|
93
|
+
const sectionString = [
|
|
94
|
+
stringifyImports(section.imports),
|
|
95
|
+
stringifyDefault(section),
|
|
96
|
+
...section.stories.map((story) => stringifyStory(story))
|
|
97
|
+
].join("\n");
|
|
98
|
+
return sectionString;
|
|
99
|
+
}
|
|
100
|
+
__name(stringifySection, "stringifySection");
|
|
101
|
+
|
|
102
|
+
// src/lib/compiler/index.ts
|
|
103
|
+
function createSection(args) {
|
|
104
|
+
return {
|
|
105
|
+
imports: {},
|
|
106
|
+
decorators: [],
|
|
107
|
+
...args
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
__name(createSection, "createSection");
|
|
111
|
+
function compileCsfModule(args) {
|
|
112
|
+
return stringifySection(createSection(args));
|
|
113
|
+
}
|
|
114
|
+
__name(compileCsfModule, "compileCsfModule");
|
|
115
|
+
|
|
116
|
+
// src/loader.ts
|
|
117
|
+
var loader_default = /* @__PURE__ */ __name((content) => {
|
|
118
|
+
try {
|
|
119
|
+
const after = compileCsfModule(JSON.parse(content));
|
|
120
|
+
return after;
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.log(content, e);
|
|
123
|
+
}
|
|
124
|
+
return content;
|
|
125
|
+
}, "default");
|
|
126
|
+
export {
|
|
127
|
+
loader_default as default
|
|
128
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/preset-server-webpack",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-beta.0",
|
|
4
4
|
"description": "Storybook for Server: View HTML snippets from a server in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -19,29 +19,15 @@
|
|
|
19
19
|
"url": "https://opencollective.com/storybook"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
+
"type": "module",
|
|
22
23
|
"exports": {
|
|
23
24
|
".": {
|
|
24
25
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"
|
|
26
|
-
"import": "./dist/index.mjs",
|
|
27
|
-
"require": "./dist/index.js"
|
|
28
|
-
},
|
|
29
|
-
"./preset": {
|
|
30
|
-
"types": "./dist/index.d.ts",
|
|
31
|
-
"node": "./dist/index.js",
|
|
32
|
-
"import": "./dist/index.mjs",
|
|
33
|
-
"require": "./dist/index.js"
|
|
34
|
-
},
|
|
35
|
-
"./dist/loader": {
|
|
36
|
-
"types": "./dist/loader.d.ts",
|
|
37
|
-
"import": "./dist/loader.mjs",
|
|
38
|
-
"require": "./dist/loader.js"
|
|
26
|
+
"default": "./dist/index.js"
|
|
39
27
|
},
|
|
28
|
+
"./loader": "./dist/loader.js",
|
|
40
29
|
"./package.json": "./package.json"
|
|
41
30
|
},
|
|
42
|
-
"main": "dist/index.js",
|
|
43
|
-
"module": "dist/index.mjs",
|
|
44
|
-
"types": "dist/index.d.ts",
|
|
45
31
|
"files": [
|
|
46
32
|
"dist/**/*",
|
|
47
33
|
"README.md",
|
|
@@ -50,35 +36,25 @@
|
|
|
50
36
|
"!src/**/*"
|
|
51
37
|
],
|
|
52
38
|
"scripts": {
|
|
53
|
-
"check": "jiti ../../../scripts/
|
|
54
|
-
"prep": "jiti ../../../scripts/
|
|
39
|
+
"check": "jiti ../../../scripts/check/check-package.ts",
|
|
40
|
+
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
55
41
|
},
|
|
56
42
|
"dependencies": {
|
|
57
|
-
"@storybook/core-webpack": "
|
|
58
|
-
"safe-identifier": "^0.4.
|
|
43
|
+
"@storybook/core-webpack": "10.0.0-beta.0",
|
|
44
|
+
"safe-identifier": "^0.4.2",
|
|
59
45
|
"ts-dedent": "^2.0.0",
|
|
60
|
-
"yaml-loader": "^0.8.
|
|
46
|
+
"yaml-loader": "^0.8.1"
|
|
61
47
|
},
|
|
62
48
|
"devDependencies": {
|
|
63
49
|
"@types/node": "^22.0.0",
|
|
64
50
|
"typescript": "^5.8.3",
|
|
65
|
-
"yaml": "^2.
|
|
51
|
+
"yaml": "^2.8.0"
|
|
66
52
|
},
|
|
67
53
|
"peerDependencies": {
|
|
68
|
-
"storybook": "^
|
|
69
|
-
},
|
|
70
|
-
"engines": {
|
|
71
|
-
"node": ">=20.0.0"
|
|
54
|
+
"storybook": "^10.0.0-beta.0"
|
|
72
55
|
},
|
|
73
56
|
"publishConfig": {
|
|
74
57
|
"access": "public"
|
|
75
58
|
},
|
|
76
|
-
"
|
|
77
|
-
"entries": [
|
|
78
|
-
"./src/index.ts",
|
|
79
|
-
"./src/loader.ts"
|
|
80
|
-
],
|
|
81
|
-
"platform": "node"
|
|
82
|
-
},
|
|
83
|
-
"gitHead": "ce6a1e4a8d5ad69c699021a0b183df89cfc7b684"
|
|
59
|
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae16"
|
|
84
60
|
}
|
package/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './src/index.js';
|
package/dist/chunk-MXFP7CYD.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
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.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { __require } from './chunk-MXFP7CYD.mjs';
|
|
2
|
-
|
|
3
|
-
var webpack=config=>{let rules=[...config.module?.rules||[],{type:"javascript/auto",test:/\.stories\.json$/,use:__require.resolve("@storybook/preset-server-webpack/dist/loader")},{type:"javascript/auto",test:/\.stories\.ya?ml/,use:[__require.resolve("@storybook/preset-server-webpack/dist/loader"),{loader:__require.resolve("yaml-loader"),options:{asJSON:!0}}]}];return config.module=config.module||{},config.module.rules=rules,config};
|
|
4
|
-
|
|
5
|
-
export { webpack };
|
package/dist/loader.d.ts
DELETED
package/dist/loader.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { __require } from './chunk-MXFP7CYD.mjs';
|
|
2
|
-
import { dedent } from 'ts-dedent';
|
|
3
|
-
|
|
4
|
-
var{identifier}=__require("safe-identifier");function stringifyObject(object,level=0,excludeOuterParams=!1){if(typeof object=="string")return JSON.stringify(object);let indent=" ".repeat(level);if(Array.isArray(object)){let arrayString=object.map(item=>stringifyObject(item,level+1)).join(`,
|
|
5
|
-
${indent} `);return excludeOuterParams?arrayString:`[
|
|
6
|
-
${indent} ${arrayString}
|
|
7
|
-
${indent}]`}if(typeof object=="object"){let objectString="";return Object.keys(object).length>0&&(objectString=Object.keys(object).map(key=>{let value=stringifyObject(object[key],level+1);return `
|
|
8
|
-
${indent} ${key}: ${value}`}).join(",")),excludeOuterParams?objectString:objectString.length===0?"{}":`{${objectString}
|
|
9
|
-
${indent}}`}return object}function stringifyImports(imports){return Object.keys(imports).length===0?"":Object.entries(imports).map(([module,names])=>`import { ${names.sort().join(", ")} } from '${module}';
|
|
10
|
-
`).join("")}function stringifyDecorators(decorators){return decorators&&decorators.length>0?`
|
|
11
|
-
decorators: [
|
|
12
|
-
${decorators.join(`,
|
|
13
|
-
`)}
|
|
14
|
-
],`:""}function stringifyDefault(section){let{title,imports,decorators,stories,...options}=section,decoratorsString=stringifyDecorators(decorators),optionsString=stringifyObject(options,0,!0);return dedent`
|
|
15
|
-
export default {
|
|
16
|
-
title: ${JSON.stringify(title)},${decoratorsString}${optionsString}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
`}function stringifyStory(story){let{name,...options}=story,storyId=identifier(name),exportedStory={name,...options};return [`export const ${storyId} = ${stringifyObject(exportedStory)};`,""].join(`
|
|
20
|
-
`)}function stringifySection(section){return [stringifyImports(section.imports),stringifyDefault(section),...section.stories.map(story=>stringifyStory(story))].join(`
|
|
21
|
-
`)}function createSection(args){return {imports:{},decorators:[],...args}}function compileCsfModule(args){return stringifySection(createSection(args))}var loader_default=content=>{try{return compileCsfModule(JSON.parse(content))}catch(e){console.log(content,e);}return content};
|
|
22
|
-
|
|
23
|
-
export { loader_default as default };
|