@storybook/preset-server-webpack 10.1.0-alpha.9 → 10.1.0-beta.1
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/dist/index.js +11 -16
- package/dist/loader.js +29 -62
- package/package.json +4 -4
- package/dist/_node-chunks/chunk-TQBRLZ72.js +0 -17
package/dist/index.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_whgkm0yqnh from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_whgkm0yqnh from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_whgkm0yqnh from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_whgkm0yqnh.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_whgkm0yqnh.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_whgkm0yqnh.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
-
import {
|
|
13
|
-
__name
|
|
14
|
-
} from "./_node-chunks/chunk-TQBRLZ72.js";
|
|
15
12
|
|
|
16
13
|
// src/index.ts
|
|
17
14
|
import { fileURLToPath } from "node:url";
|
|
18
|
-
var webpack =
|
|
19
|
-
|
|
15
|
+
var webpack = (config) => {
|
|
16
|
+
let rules = [
|
|
20
17
|
...config.module?.rules || [],
|
|
21
18
|
{
|
|
22
19
|
type: "javascript/auto",
|
|
@@ -30,15 +27,13 @@ var webpack = /* @__PURE__ */ __name((config) => {
|
|
|
30
27
|
fileURLToPath(import.meta.resolve("@storybook/preset-server-webpack/loader")),
|
|
31
28
|
{
|
|
32
29
|
loader: fileURLToPath(import.meta.resolve("yaml-loader")),
|
|
33
|
-
options: { asJSON:
|
|
30
|
+
options: { asJSON: !0 }
|
|
34
31
|
}
|
|
35
32
|
]
|
|
36
33
|
}
|
|
37
34
|
];
|
|
38
|
-
config.module = config.module || {};
|
|
39
|
-
|
|
40
|
-
return config;
|
|
41
|
-
}, "webpack");
|
|
35
|
+
return config.module = config.module || {}, config.module.rules = rules, config;
|
|
36
|
+
};
|
|
42
37
|
export {
|
|
43
38
|
webpack
|
|
44
39
|
};
|
package/dist/loader.js
CHANGED
|
@@ -1,78 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_whgkm0yqnh from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_whgkm0yqnh from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_whgkm0yqnh from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_whgkm0yqnh.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_whgkm0yqnh.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_whgkm0yqnh.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
-
import {
|
|
13
|
-
__name
|
|
14
|
-
} from "./_node-chunks/chunk-TQBRLZ72.js";
|
|
15
12
|
|
|
16
13
|
// src/lib/compiler/stringifier.ts
|
|
17
14
|
import { identifier } from "safe-identifier";
|
|
18
15
|
import { dedent } from "ts-dedent";
|
|
19
|
-
function stringifyObject(object, level = 0, excludeOuterParams =
|
|
20
|
-
if (typeof object
|
|
16
|
+
function stringifyObject(object, level = 0, excludeOuterParams = !1) {
|
|
17
|
+
if (typeof object == "string")
|
|
21
18
|
return JSON.stringify(object);
|
|
22
|
-
|
|
23
|
-
const indent = " ".repeat(level);
|
|
19
|
+
let indent = " ".repeat(level);
|
|
24
20
|
if (Array.isArray(object)) {
|
|
25
|
-
|
|
26
|
-
const arrayString = arrayStrings.join(`,
|
|
21
|
+
let arrayString = object.map((item) => stringifyObject(item, level + 1)).join(`,
|
|
27
22
|
${indent} `);
|
|
28
|
-
|
|
29
|
-
return arrayString;
|
|
30
|
-
}
|
|
31
|
-
return `[
|
|
23
|
+
return excludeOuterParams ? arrayString : `[
|
|
32
24
|
${indent} ${arrayString}
|
|
33
25
|
${indent}]`;
|
|
34
26
|
}
|
|
35
|
-
if (typeof object
|
|
27
|
+
if (typeof object == "object") {
|
|
36
28
|
let objectString = "";
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return `
|
|
29
|
+
return Object.keys(object).length > 0 && (objectString = Object.keys(object).map((key) => {
|
|
30
|
+
let value = stringifyObject(object[key], level + 1);
|
|
31
|
+
return `
|
|
41
32
|
${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}
|
|
33
|
+
}).join(",")), excludeOuterParams ? objectString : objectString.length === 0 ? "{}" : `{${objectString}
|
|
52
34
|
${indent}}`;
|
|
53
35
|
}
|
|
54
36
|
return object;
|
|
55
37
|
}
|
|
56
|
-
__name(stringifyObject, "stringifyObject");
|
|
57
38
|
function stringifyImports(imports) {
|
|
58
|
-
|
|
59
|
-
return "";
|
|
60
|
-
}
|
|
61
|
-
return Object.entries(imports).map(([module, names]) => `import { ${names.sort().join(", ")} } from '${module}';
|
|
39
|
+
return Object.keys(imports).length === 0 ? "" : Object.entries(imports).map(([module, names]) => `import { ${names.sort().join(", ")} } from '${module}';
|
|
62
40
|
`).join("");
|
|
63
41
|
}
|
|
64
|
-
__name(stringifyImports, "stringifyImports");
|
|
65
42
|
function stringifyDecorators(decorators) {
|
|
66
43
|
return decorators && decorators.length > 0 ? `
|
|
67
44
|
decorators: [
|
|
68
|
-
${decorators.join(
|
|
45
|
+
${decorators.join(`,
|
|
46
|
+
`)}
|
|
69
47
|
],` : "";
|
|
70
48
|
}
|
|
71
|
-
__name(stringifyDecorators, "stringifyDecorators");
|
|
72
49
|
function stringifyDefault(section) {
|
|
73
|
-
|
|
74
|
-
const decoratorsString = stringifyDecorators(decorators);
|
|
75
|
-
const optionsString = stringifyObject(options, 0, true);
|
|
50
|
+
let { title, imports, decorators, stories, ...options } = section, decoratorsString = stringifyDecorators(decorators), optionsString = stringifyObject(options, 0, !0);
|
|
76
51
|
return dedent`
|
|
77
52
|
export default {
|
|
78
53
|
title: ${JSON.stringify(title)},${decoratorsString}${optionsString}
|
|
@@ -80,24 +55,19 @@ function stringifyDefault(section) {
|
|
|
80
55
|
|
|
81
56
|
`;
|
|
82
57
|
}
|
|
83
|
-
__name(stringifyDefault, "stringifyDefault");
|
|
84
58
|
function stringifyStory(story) {
|
|
85
|
-
|
|
86
|
-
const storyId =
|
|
87
|
-
|
|
88
|
-
const storyStrings = [`export const ${storyId} = ${stringifyObject(exportedStory)};`, ""];
|
|
89
|
-
return storyStrings.join("\n");
|
|
59
|
+
let { name, ...options } = story, storyId = identifier(name), exportedStory = { name, ...options };
|
|
60
|
+
return [`export const ${storyId} = ${stringifyObject(exportedStory)};`, ""].join(`
|
|
61
|
+
`);
|
|
90
62
|
}
|
|
91
|
-
__name(stringifyStory, "stringifyStory");
|
|
92
63
|
function stringifySection(section) {
|
|
93
|
-
|
|
64
|
+
return [
|
|
94
65
|
stringifyImports(section.imports),
|
|
95
66
|
stringifyDefault(section),
|
|
96
67
|
...section.stories.map((story) => stringifyStory(story))
|
|
97
|
-
].join(
|
|
98
|
-
|
|
68
|
+
].join(`
|
|
69
|
+
`);
|
|
99
70
|
}
|
|
100
|
-
__name(stringifySection, "stringifySection");
|
|
101
71
|
|
|
102
72
|
// src/lib/compiler/index.ts
|
|
103
73
|
function createSection(args) {
|
|
@@ -107,22 +77,19 @@ function createSection(args) {
|
|
|
107
77
|
...args
|
|
108
78
|
};
|
|
109
79
|
}
|
|
110
|
-
__name(createSection, "createSection");
|
|
111
80
|
function compileCsfModule(args) {
|
|
112
81
|
return stringifySection(createSection(args));
|
|
113
82
|
}
|
|
114
|
-
__name(compileCsfModule, "compileCsfModule");
|
|
115
83
|
|
|
116
84
|
// src/loader.ts
|
|
117
|
-
var loader_default =
|
|
85
|
+
var loader_default = (content) => {
|
|
118
86
|
try {
|
|
119
|
-
|
|
120
|
-
return after;
|
|
87
|
+
return compileCsfModule(JSON.parse(content));
|
|
121
88
|
} catch (e) {
|
|
122
89
|
console.log(content, e);
|
|
123
90
|
}
|
|
124
91
|
return content;
|
|
125
|
-
}
|
|
92
|
+
};
|
|
126
93
|
export {
|
|
127
94
|
loader_default as default
|
|
128
95
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/preset-server-webpack",
|
|
3
|
-
"version": "10.1.0-
|
|
3
|
+
"version": "10.1.0-beta.1",
|
|
4
4
|
"description": "Storybook for Server: View HTML snippets from a server in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@storybook/core-webpack": "10.1.0-
|
|
43
|
+
"@storybook/core-webpack": "10.1.0-beta.1",
|
|
44
44
|
"safe-identifier": "^0.4.2",
|
|
45
45
|
"ts-dedent": "^2.0.0",
|
|
46
46
|
"yaml-loader": "^0.8.1"
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"yaml": "^2.8.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"storybook": "^10.1.0-
|
|
54
|
+
"storybook": "^10.1.0-beta.1"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae1l"
|
|
60
60
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_uv3bo8cymko from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_uv3bo8cymko from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_uv3bo8cymko from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_uv3bo8cymko.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_uv3bo8cymko.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_uv3bo8cymko.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
|
-
};
|