@storybook/builder-webpack5 9.2.0-alpha.3 → 10.0.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/README.md CHANGED
@@ -9,3 +9,5 @@ export default {
9
9
  },
10
10
  };
11
11
  ```
12
+
13
+ Learn more about Storybook at [storybook.js.org](https://storybook.js.org/?ref=readme).
@@ -0,0 +1,85 @@
1
+ import CJS_COMPAT_NODE_URL_rmubg21st2 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_rmubg21st2 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_rmubg21st2 from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_rmubg21st2.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_rmubg21st2.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_rmubg21st2.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 "./chunk-UUTIIQLO.js";
15
+
16
+ // src/preview/virtual-module-mapping.ts
17
+ import { join, resolve } from "node:path";
18
+ import { fileURLToPath } from "node:url";
19
+ import {
20
+ getBuilderOptions,
21
+ loadPreviewOrConfigFile,
22
+ normalizeStories,
23
+ readTemplate
24
+ } from "storybook/internal/common";
25
+ import { toImportFn } from "@storybook/core-webpack";
26
+
27
+ // ../../node_modules/slash/index.js
28
+ function slash(path) {
29
+ const isExtendedLengthPath = path.startsWith("\\\\?\\");
30
+ if (isExtendedLengthPath) {
31
+ return path;
32
+ }
33
+ return path.replace(/\\/g, "/");
34
+ }
35
+ __name(slash, "slash");
36
+
37
+ // src/preview/virtual-module-mapping.ts
38
+ var getVirtualModules = /* @__PURE__ */ __name(async (options) => {
39
+ const virtualModules = {};
40
+ const builderOptions = await getBuilderOptions(options);
41
+ const workingDir = process.cwd();
42
+ const isProd = options.configType === "PRODUCTION";
43
+ const nonNormalizedStories = await options.presets.apply("stories", []);
44
+ const entries = [];
45
+ const stories = normalizeStories(nonNormalizedStories, {
46
+ configDir: options.configDir,
47
+ workingDir
48
+ });
49
+ const previewAnnotations = [
50
+ ...(await options.presets.apply("previewAnnotations", [], options)).map(
51
+ (entry) => {
52
+ if (typeof entry === "object") {
53
+ return entry.absolute;
54
+ }
55
+ return slash(entry);
56
+ }
57
+ ),
58
+ loadPreviewOrConfigFile(options)
59
+ ].filter(Boolean);
60
+ const storiesFilename = "storybook-stories.js";
61
+ const storiesPath = resolve(join(workingDir, storiesFilename));
62
+ const needPipelinedImport = !!builderOptions.lazyCompilation && !isProd;
63
+ virtualModules[storiesPath] = toImportFn(stories, { needPipelinedImport });
64
+ const configEntryPath = resolve(join(workingDir, "storybook-config-entry.js"));
65
+ virtualModules[configEntryPath] = (await readTemplate(
66
+ fileURLToPath(
67
+ import.meta.resolve("@storybook/builder-webpack5/templates/virtualModuleModernEntry.js")
68
+ )
69
+ )).replaceAll(`'{{storiesFilename}}'`, `'./${storiesFilename}'`).replaceAll(
70
+ `'{{previewAnnotations}}'`,
71
+ previewAnnotations.filter(Boolean).map((entry) => `'${entry}'`).join(",")
72
+ ).replaceAll(
73
+ `'{{previewAnnotations_requires}}'`,
74
+ previewAnnotations.filter(Boolean).map((entry) => `require('${entry}')`).join(",")
75
+ ).replace(/\\/g, "\\\\");
76
+ entries.push(configEntryPath);
77
+ return {
78
+ virtualModules,
79
+ entries
80
+ };
81
+ }, "getVirtualModules");
82
+
83
+ export {
84
+ getVirtualModules
85
+ };
@@ -0,0 +1,50 @@
1
+ import CJS_COMPAT_NODE_URL_rmubg21st2 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_rmubg21st2 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_rmubg21st2 from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_rmubg21st2.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_rmubg21st2.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_rmubg21st2.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;
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]
21
+ }) : x)(function(x) {
22
+ if (typeof require !== "undefined") return require.apply(this, arguments);
23
+ throw Error('Dynamic require of "' + x + '" is not supported');
24
+ });
25
+ var __commonJS = (cb, mod) => function __require2() {
26
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ 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
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
+ // If the importer is in node compatibility mode or this is not an ESM
38
+ // file that has been converted to a CommonJS file using a Babel-
39
+ // compatible transform (i.e. "__esModule" has not been set), then set
40
+ // "default" to the CommonJS "module.exports" for node compatibility.
41
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
42
+ mod
43
+ ));
44
+
45
+ export {
46
+ __name,
47
+ __require,
48
+ __commonJS,
49
+ __toESM
50
+ };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Options as Options$1, Builder } from 'storybook/internal/types';
2
- import webpackDep__default, { Configuration, Stats } from 'webpack';
3
- import { StorybookConfig, Options, BuilderResult as BuilderResult$1, TypescriptOptions as TypescriptOptions$1 } from '@storybook/core-webpack';
2
+ import webpackModule, { Configuration, Stats } from 'webpack';
3
+ import { TypescriptOptions as TypescriptOptions$1, StorybookConfig, Options, BuilderResult as BuilderResult$1 } from '@storybook/core-webpack';
4
4
  import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
5
5
 
6
6
  type TypeScriptOptionsBase = Partial<TypescriptOptions$1>;
@@ -31,13 +31,13 @@ declare const getVirtualModules: (options: Options$1) => Promise<{
31
31
  entries: string[];
32
32
  }>;
33
33
 
34
- declare const WebpackDefinePlugin: typeof webpackDep__default.DefinePlugin;
35
- declare const WebpackIgnorePlugin: typeof webpackDep__default.IgnorePlugin;
34
+ declare const WebpackDefinePlugin: typeof webpackModule.DefinePlugin;
35
+ declare const WebpackIgnorePlugin: typeof webpackModule.IgnorePlugin;
36
36
  declare const printDuration: (startTime: [number, number]) => string;
37
37
  type WebpackBuilder = Builder<Configuration, Stats>;
38
38
  type BuilderStartOptions = Parameters<WebpackBuilder['start']>['0'];
39
39
  declare const executor: {
40
- get: (options: Options$1) => Promise<typeof webpackDep__default>;
40
+ get: (options: Options$1) => Promise<typeof webpackModule>;
41
41
  };
42
42
  declare const getConfig: WebpackBuilder['getConfig'];
43
43
  declare const bail: WebpackBuilder['bail'];
@@ -50,4 +50,4 @@ declare const build: (options: BuilderStartOptions) => Promise<void | Stats>;
50
50
  declare const corePresets: string[];
51
51
  declare const overridePresets: string[];
52
52
 
53
- export { BuilderOptions, BuilderResult, StorybookConfigWebpack, TypescriptOptions, WebpackDefinePlugin, WebpackIgnorePlugin, bail, build, corePresets, executor, getConfig, getVirtualModules, overridePresets, printDuration, start };
53
+ export { type BuilderOptions, type BuilderResult, type StorybookConfigWebpack, type TypescriptOptions, WebpackDefinePlugin, WebpackIgnorePlugin, bail, build, corePresets, executor, getConfig, getVirtualModules, overridePresets, printDuration, start };