@storybook/builder-webpack5 10.1.0-alpha.10 → 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.
@@ -0,0 +1,45 @@
1
+ import CJS_COMPAT_NODE_URL_m38t2lu80n from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_m38t2lu80n from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_m38t2lu80n from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_m38t2lu80n.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_m38t2lu80n.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_m38t2lu80n.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ var __create = Object.create;
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __require = /* @__PURE__ */ ((x) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(x, {
18
+ get: (a, b) => (typeof require < "u" ? require : a)[b]
19
+ }) : x)(function(x) {
20
+ if (typeof require < "u") return require.apply(this, arguments);
21
+ throw Error('Dynamic require of "' + x + '" is not supported');
22
+ });
23
+ var __commonJS = (cb, mod) => function() {
24
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from == "object" || typeof from == "function")
28
+ for (let key of __getOwnPropNames(from))
29
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ return to;
31
+ };
32
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
+ // If the importer is in node compatibility mode or this is not an ESM
34
+ // file that has been converted to a CommonJS file using a Babel-
35
+ // compatible transform (i.e. "__esModule" has not been set), then set
36
+ // "default" to the CommonJS "module.exports" for node compatibility.
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
38
+ mod
39
+ ));
40
+
41
+ export {
42
+ __require,
43
+ __commonJS,
44
+ __toESM
45
+ };
@@ -0,0 +1,60 @@
1
+ import CJS_COMPAT_NODE_URL_m38t2lu80n from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_m38t2lu80n from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_m38t2lu80n from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_m38t2lu80n.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_m38t2lu80n.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_m38t2lu80n.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+
13
+ // src/preview/virtual-module-mapping.ts
14
+ import { join, resolve } from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+ import {
17
+ getBuilderOptions,
18
+ loadPreviewOrConfigFile,
19
+ normalizeStories,
20
+ readTemplate
21
+ } from "storybook/internal/common";
22
+ import { toImportFn } from "@storybook/core-webpack";
23
+
24
+ // ../../node_modules/slash/index.js
25
+ function slash(path) {
26
+ return path.startsWith("\\\\?\\") ? path : path.replace(/\\/g, "/");
27
+ }
28
+
29
+ // src/preview/virtual-module-mapping.ts
30
+ var getVirtualModules = async (options) => {
31
+ let virtualModules = {}, builderOptions = await getBuilderOptions(options), workingDir = process.cwd(), isProd = options.configType === "PRODUCTION", nonNormalizedStories = await options.presets.apply("stories", []), entries = [], stories = normalizeStories(nonNormalizedStories, {
32
+ configDir: options.configDir,
33
+ workingDir
34
+ }), previewAnnotations = [
35
+ ...(await options.presets.apply("previewAnnotations", [], options)).map(
36
+ (entry) => typeof entry == "object" ? entry.absolute : slash(entry)
37
+ ),
38
+ loadPreviewOrConfigFile(options)
39
+ ].filter(Boolean), storiesFilename = "storybook-stories.js", storiesPath = resolve(join(workingDir, storiesFilename)), needPipelinedImport = !!builderOptions.lazyCompilation && !isProd;
40
+ virtualModules[storiesPath] = toImportFn(stories, { needPipelinedImport });
41
+ let configEntryPath = resolve(join(workingDir, "storybook-config-entry.js"));
42
+ return virtualModules[configEntryPath] = (await readTemplate(
43
+ fileURLToPath(
44
+ import.meta.resolve("@storybook/builder-webpack5/templates/virtualModuleModernEntry.js")
45
+ )
46
+ )).replaceAll("'{{storiesFilename}}'", `'./${storiesFilename}'`).replaceAll(
47
+ "'{{previewAnnotations}}'",
48
+ previewAnnotations.filter(Boolean).map((entry) => `'${entry}'`).join(",")
49
+ ).replaceAll(
50
+ "'{{previewAnnotations_requires}}'",
51
+ previewAnnotations.filter(Boolean).map((entry) => `require('${entry}')`).join(",")
52
+ ).replace(/\\/g, "\\\\"), entries.push(configEntryPath), {
53
+ virtualModules,
54
+ entries
55
+ };
56
+ };
57
+
58
+ export {
59
+ getVirtualModules
60
+ };