@storybook/builder-webpack5 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.
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_o0h2pkg2c5 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_o0h2pkg2c5 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_o0h2pkg2c5 from "node:module";
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
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_o0h2pkg2c5.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_o0h2pkg2c5.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_o0h2pkg2c5.createRequire(import.meta.url);
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
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -13,24 +13,20 @@ var __create = Object.create;
13
13
  var __defProp = Object.defineProperty;
14
14
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
15
  var __getOwnPropNames = Object.getOwnPropertyNames;
16
- var __getProtoOf = Object.getPrototypeOf;
17
- var __hasOwnProp = Object.prototype.hasOwnProperty;
18
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
19
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
20
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
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]
21
19
  }) : x)(function(x) {
22
- if (typeof require !== "undefined") return require.apply(this, arguments);
20
+ if (typeof require < "u") return require.apply(this, arguments);
23
21
  throw Error('Dynamic require of "' + x + '" is not supported');
24
22
  });
25
- var __commonJS = (cb, mod) => function __require2() {
23
+ var __commonJS = (cb, mod) => function() {
26
24
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
27
25
  };
28
26
  var __copyProps = (to, from, except, desc) => {
29
- if (from && typeof from === "object" || typeof from === "function") {
27
+ if (from && typeof from == "object" || typeof from == "function")
30
28
  for (let key of __getOwnPropNames(from))
31
- if (!__hasOwnProp.call(to, key) && key !== except)
32
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
- }
29
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
30
  return to;
35
31
  };
36
32
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
@@ -38,12 +34,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
38
34
  // file that has been converted to a CommonJS file using a Babel-
39
35
  // compatible transform (i.e. "__esModule" has not been set), then set
40
36
  // "default" to the CommonJS "module.exports" for node compatibility.
41
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
42
38
  mod
43
39
  ));
44
40
 
45
41
  export {
46
- __name,
47
42
  __require,
48
43
  __commonJS,
49
44
  __toESM
@@ -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
+ };