@storybook/csf-plugin 10.1.0-alpha.1 → 10.1.0-alpha.11
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 +43 -60
- package/dist/webpack-loader.js +13 -26
- package/package.json +3 -3
- package/dist/_node-chunks/chunk-M47FMYOI.js +0 -17
package/dist/index.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bxj20usjizh from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bxj20usjizh from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bxj20usjizh from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bxj20usjizh.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bxj20usjizh.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bxj20usjizh.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-M47FMYOI.js";
|
|
15
12
|
|
|
16
13
|
// src/index.ts
|
|
17
14
|
import { fileURLToPath } from "node:url";
|
|
@@ -28,68 +25,54 @@ function rollupBasedPlugin(options) {
|
|
|
28
25
|
return {
|
|
29
26
|
name: "plugin-csf",
|
|
30
27
|
async transform(code, id) {
|
|
31
|
-
if (!STORIES_REGEX.test(id))
|
|
28
|
+
if (!STORIES_REGEX.test(id))
|
|
32
29
|
return;
|
|
33
|
-
|
|
34
|
-
const sourceCode = await readFile(id, "utf-8");
|
|
30
|
+
let sourceCode = await readFile(id, "utf-8");
|
|
35
31
|
try {
|
|
36
|
-
|
|
37
|
-
const csf = loadCsf(code, { makeTitle }).parse();
|
|
38
|
-
const csfSource = loadCsf(sourceCode, {
|
|
32
|
+
let makeTitle = (userTitle) => userTitle || "default", csf = loadCsf(code, { makeTitle }).parse(), csfSource = loadCsf(sourceCode, {
|
|
39
33
|
makeTitle
|
|
40
34
|
}).parse();
|
|
41
|
-
enrichCsf(csf, csfSource, options);
|
|
42
|
-
|
|
43
|
-
return formatCsf(csf, { sourceMaps:
|
|
35
|
+
await enrichCsf(csf, csfSource, options);
|
|
36
|
+
let inputSourceMap = this.getCombinedSourcemap();
|
|
37
|
+
return formatCsf(csf, { sourceMaps: !0, inputSourceMap }, code);
|
|
44
38
|
} catch (err) {
|
|
45
|
-
|
|
46
|
-
logger.warn(err.message);
|
|
47
|
-
}
|
|
48
|
-
return code;
|
|
39
|
+
return err.message?.startsWith("CSF:") || logger.warn(err.message), code;
|
|
49
40
|
}
|
|
50
41
|
}
|
|
51
42
|
};
|
|
52
43
|
}
|
|
53
|
-
__name(rollupBasedPlugin, "rollupBasedPlugin");
|
|
54
44
|
|
|
55
45
|
// src/index.ts
|
|
56
|
-
var unpluginFactory =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
}, "unpluginFactory");
|
|
88
|
-
var unplugin = createUnplugin(unpluginFactory);
|
|
89
|
-
var { esbuild } = unplugin;
|
|
90
|
-
var { webpack } = unplugin;
|
|
91
|
-
var { rollup } = unplugin;
|
|
92
|
-
var { vite } = unplugin;
|
|
46
|
+
var unpluginFactory = (options) => ({
|
|
47
|
+
name: "unplugin-csf",
|
|
48
|
+
rollup: {
|
|
49
|
+
...rollupBasedPlugin(options)
|
|
50
|
+
},
|
|
51
|
+
vite: {
|
|
52
|
+
enforce: "pre",
|
|
53
|
+
...rollupBasedPlugin(options)
|
|
54
|
+
},
|
|
55
|
+
webpack(compiler) {
|
|
56
|
+
compiler.options.module.rules.unshift({
|
|
57
|
+
test: STORIES_REGEX,
|
|
58
|
+
enforce: "post",
|
|
59
|
+
use: {
|
|
60
|
+
options,
|
|
61
|
+
loader: fileURLToPath(import.meta.resolve("@storybook/csf-plugin/webpack-loader"))
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
rspack(compiler) {
|
|
66
|
+
compiler.options.module.rules.unshift({
|
|
67
|
+
test: STORIES_REGEX,
|
|
68
|
+
enforce: "post",
|
|
69
|
+
use: {
|
|
70
|
+
options,
|
|
71
|
+
loader: fileURLToPath(import.meta.resolve("@storybook/csf-plugin/webpack-loader"))
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}), unplugin = createUnplugin(unpluginFactory), { esbuild } = unplugin, { webpack } = unplugin, { rollup } = unplugin, { vite } = unplugin;
|
|
93
76
|
export {
|
|
94
77
|
esbuild,
|
|
95
78
|
rollup,
|
package/dist/webpack-loader.js
CHANGED
|
@@ -1,48 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bxj20usjizh from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bxj20usjizh from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bxj20usjizh from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bxj20usjizh.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bxj20usjizh.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bxj20usjizh.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-M47FMYOI.js";
|
|
15
12
|
|
|
16
13
|
// src/webpack-loader.ts
|
|
17
14
|
import { readFile } from "node:fs/promises";
|
|
18
15
|
import { enrichCsf, formatCsf, loadCsf } from "storybook/internal/csf-tools";
|
|
19
16
|
async function loader(content, map) {
|
|
20
|
-
|
|
21
|
-
const options = this.getOptions();
|
|
22
|
-
const id = this.resourcePath;
|
|
23
|
-
const sourceCode = await readFile(id, "utf-8");
|
|
17
|
+
let callback = this.async(), options = this.getOptions(), id = this.resourcePath, sourceCode = await readFile(id, "utf-8");
|
|
24
18
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
enrichCsf(csf, csfSource, options);
|
|
29
|
-
const formattedCsf = formatCsf(
|
|
19
|
+
let makeTitle = (userTitle) => userTitle || "default", csf = loadCsf(content, { makeTitle }).parse(), csfSource = loadCsf(sourceCode, { makeTitle }).parse();
|
|
20
|
+
await enrichCsf(csf, csfSource, options);
|
|
21
|
+
let formattedCsf = formatCsf(
|
|
30
22
|
csf,
|
|
31
|
-
{ sourceMaps:
|
|
23
|
+
{ sourceMaps: !0, inputSourceMap: map, sourceFileName: id },
|
|
32
24
|
content
|
|
33
25
|
);
|
|
34
|
-
if (typeof formattedCsf
|
|
26
|
+
if (typeof formattedCsf == "string")
|
|
35
27
|
return callback(null, formattedCsf, map);
|
|
36
|
-
}
|
|
37
28
|
callback(null, formattedCsf.code, formattedCsf.map);
|
|
38
29
|
} catch (err) {
|
|
39
|
-
|
|
40
|
-
console.warn(err.message);
|
|
41
|
-
}
|
|
42
|
-
callback(null, content, map);
|
|
30
|
+
err.message?.startsWith("CSF:") || console.warn(err.message), callback(null, content, map);
|
|
43
31
|
}
|
|
44
32
|
}
|
|
45
|
-
__name(loader, "loader");
|
|
46
33
|
var webpack_loader_default = loader;
|
|
47
34
|
export {
|
|
48
35
|
webpack_loader_default as default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/csf-plugin",
|
|
3
|
-
"version": "10.1.0-alpha.
|
|
3
|
+
"version": "10.1.0-alpha.11",
|
|
4
4
|
"description": "Enrich CSF files via static analysis",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"esbuild": "*",
|
|
51
51
|
"rollup": "*",
|
|
52
|
-
"storybook": "^10.1.0-alpha.
|
|
52
|
+
"storybook": "^10.1.0-alpha.11",
|
|
53
53
|
"vite": "*",
|
|
54
54
|
"webpack": "*"
|
|
55
55
|
},
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae1l"
|
|
74
74
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ms9t5wxgf1p from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ms9t5wxgf1p from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ms9t5wxgf1p from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ms9t5wxgf1p.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ms9t5wxgf1p.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ms9t5wxgf1p.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
|
-
};
|