creevey 0.8.0-beta.0 → 0.8.0

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.
Files changed (199) hide show
  1. package/CHANGELOG.md +30 -7
  2. package/README.md +9 -1
  3. package/addon/README.md +3 -0
  4. package/addon/package.json +4 -0
  5. package/docs/config.md +29 -26
  6. package/jest.config.js +6 -0
  7. package/lib/cjs/client/addon/Manager.js +122 -271
  8. package/lib/cjs/client/addon/components/Addon.js +17 -38
  9. package/lib/cjs/client/addon/components/Icons.js +11 -7
  10. package/lib/cjs/client/addon/components/Panel.js +17 -13
  11. package/lib/cjs/client/addon/components/TestSelect.js +11 -9
  12. package/lib/cjs/client/addon/components/Tools.js +21 -40
  13. package/lib/cjs/client/addon/decorator.js +1 -1
  14. package/lib/cjs/client/addon/index.js +31 -0
  15. package/lib/cjs/client/addon/preset.ie11.js +74 -0
  16. package/lib/cjs/client/addon/preset.js +13 -31
  17. package/lib/cjs/client/addon/readyForCapture.js +12 -0
  18. package/lib/cjs/client/addon/register.js +46 -70
  19. package/lib/cjs/client/addon/utils.js +6 -2
  20. package/lib/cjs/client/addon/withCreevey.js +221 -155
  21. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +26 -24
  22. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +22 -18
  23. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +44 -66
  24. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +38 -50
  25. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +26 -45
  26. package/lib/cjs/client/shared/components/ImagesView/index.js +9 -9
  27. package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +12 -8
  28. package/lib/cjs/client/shared/components/PageFooter/Paging.js +14 -18
  29. package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +22 -18
  30. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +42 -67
  31. package/lib/cjs/client/shared/components/ResultsPage.js +39 -69
  32. package/lib/cjs/client/shared/creeveyClientApi.js +55 -82
  33. package/lib/cjs/client/shared/helpers.js +140 -211
  34. package/lib/cjs/client/shared/viewMode.js +5 -5
  35. package/lib/cjs/client/web/142.js +2 -0
  36. package/lib/cjs/client/web/142.js.LICENSE.txt +12 -0
  37. package/lib/cjs/client/web/32.js +1 -0
  38. package/lib/cjs/client/web/551.js +1 -0
  39. package/lib/cjs/client/web/566.js +2 -0
  40. package/lib/cjs/client/web/566.js.LICENSE.txt +31 -0
  41. package/lib/cjs/client/web/691.js +2 -0
  42. package/lib/cjs/client/web/691.js.LICENSE.txt +8 -0
  43. package/lib/cjs/client/web/725.js +1 -0
  44. package/lib/cjs/client/web/main.js +2 -38
  45. package/lib/cjs/client/web/main.js.LICENSE.txt +49 -0
  46. package/lib/cjs/creevey.js +3 -5
  47. package/lib/cjs/index.js +10 -15
  48. package/lib/cjs/server/config.js +5 -4
  49. package/lib/cjs/server/docker.js +3 -7
  50. package/lib/cjs/server/extract.js +7 -4
  51. package/lib/cjs/server/index.js +3 -5
  52. package/lib/cjs/server/loaders/babel/creevey-plugin.js +1 -3
  53. package/lib/cjs/server/loaders/babel/helpers.js +13 -23
  54. package/lib/cjs/server/loaders/babel/register.js +2 -4
  55. package/lib/cjs/server/loaders/webpack/compile.js +34 -51
  56. package/lib/cjs/server/loaders/webpack/creevey-loader.js +20 -22
  57. package/lib/cjs/server/loaders/webpack/dummy-hmr.js +2 -7
  58. package/lib/cjs/server/loaders/webpack/mdx-loader.js +2 -2
  59. package/lib/cjs/server/loaders/webpack/start.js +1 -1
  60. package/lib/cjs/server/logger.js +2 -1
  61. package/lib/cjs/server/master/index.js +4 -4
  62. package/lib/cjs/server/master/master.js +1 -0
  63. package/lib/cjs/server/master/pool.js +38 -47
  64. package/lib/cjs/server/master/runner.js +53 -66
  65. package/lib/cjs/server/master/server.js +78 -4
  66. package/lib/cjs/server/messages.js +128 -18
  67. package/lib/cjs/server/selenium/browser.js +129 -55
  68. package/lib/cjs/server/selenium/selenoid.js +5 -7
  69. package/lib/cjs/server/stories.js +58 -72
  70. package/lib/cjs/server/storybook/entry.js +7 -22
  71. package/lib/cjs/server/storybook/helpers.js +20 -27
  72. package/lib/cjs/server/storybook/providers/browser.js +74 -0
  73. package/lib/cjs/server/storybook/{nodejs-provider.js → providers/nodejs.js} +37 -20
  74. package/lib/cjs/server/update.js +1 -5
  75. package/lib/cjs/server/utils.js +26 -35
  76. package/lib/cjs/server/worker/helpers.js +2 -6
  77. package/lib/cjs/server/worker/reporter.js +8 -20
  78. package/lib/cjs/server/worker/worker.js +21 -19
  79. package/lib/cjs/shared/index.js +101 -0
  80. package/lib/cjs/shared/serializeRegExp.js +42 -0
  81. package/lib/cjs/types.js +11 -6
  82. package/lib/esm/client/addon/Manager.js +122 -271
  83. package/lib/esm/client/addon/components/Addon.js +15 -34
  84. package/lib/esm/client/addon/components/Icons.js +10 -6
  85. package/lib/esm/client/addon/components/Panel.js +17 -13
  86. package/lib/esm/client/addon/components/TestSelect.js +11 -9
  87. package/lib/esm/client/addon/components/Tools.js +19 -36
  88. package/lib/esm/client/addon/decorator.js +1 -1
  89. package/lib/esm/client/addon/index.js +2 -0
  90. package/lib/esm/client/addon/preset.ie11.js +59 -0
  91. package/lib/esm/client/addon/preset.js +12 -26
  92. package/lib/esm/client/addon/readyForCapture.js +5 -0
  93. package/lib/esm/client/addon/register.js +42 -66
  94. package/lib/esm/client/addon/utils.js +3 -2
  95. package/lib/esm/client/addon/withCreevey.js +209 -156
  96. package/lib/esm/client/shared/components/ImagesView/BlendView.js +23 -20
  97. package/lib/esm/client/shared/components/ImagesView/ImagesView.js +21 -17
  98. package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +42 -63
  99. package/lib/esm/client/shared/components/ImagesView/SlideView.js +36 -47
  100. package/lib/esm/client/shared/components/ImagesView/SwapView.js +24 -42
  101. package/lib/esm/client/shared/components/PageFooter/PageFooter.js +12 -8
  102. package/lib/esm/client/shared/components/PageFooter/Paging.js +14 -18
  103. package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +22 -18
  104. package/lib/esm/client/shared/components/PageHeader/PageHeader.js +37 -60
  105. package/lib/esm/client/shared/components/ResultsPage.js +36 -64
  106. package/lib/esm/client/shared/creeveyClientApi.js +57 -84
  107. package/lib/esm/client/shared/helpers.js +124 -195
  108. package/lib/esm/client/shared/viewMode.js +4 -4
  109. package/lib/esm/creevey.js +3 -5
  110. package/lib/esm/index.js +2 -3
  111. package/lib/esm/server/config.js +4 -5
  112. package/lib/esm/server/docker.js +2 -2
  113. package/lib/esm/server/extract.js +6 -4
  114. package/lib/esm/server/index.js +3 -4
  115. package/lib/esm/server/loaders/babel/creevey-plugin.js +1 -3
  116. package/lib/esm/server/loaders/babel/helpers.js +12 -22
  117. package/lib/esm/server/loaders/babel/register.js +3 -5
  118. package/lib/esm/server/loaders/webpack/compile.js +35 -52
  119. package/lib/esm/server/loaders/webpack/creevey-loader.js +9 -10
  120. package/lib/esm/server/loaders/webpack/dummy-hmr.js +2 -6
  121. package/lib/esm/server/loaders/webpack/mdx-loader.js +2 -2
  122. package/lib/esm/server/loaders/webpack/start.js +1 -1
  123. package/lib/esm/server/master/index.js +4 -4
  124. package/lib/esm/server/master/master.js +1 -0
  125. package/lib/esm/server/master/pool.js +38 -49
  126. package/lib/esm/server/master/runner.js +53 -66
  127. package/lib/esm/server/master/server.js +76 -6
  128. package/lib/esm/server/messages.js +118 -14
  129. package/lib/esm/server/selenium/browser.js +126 -57
  130. package/lib/esm/server/selenium/selenoid.js +4 -6
  131. package/lib/esm/server/stories.js +58 -70
  132. package/lib/esm/server/storybook/entry.js +5 -22
  133. package/lib/esm/server/storybook/helpers.js +11 -20
  134. package/lib/esm/server/storybook/providers/browser.js +60 -0
  135. package/lib/esm/server/storybook/{nodejs-provider.js → providers/nodejs.js} +35 -19
  136. package/lib/esm/server/update.js +1 -5
  137. package/lib/esm/server/utils.js +18 -31
  138. package/lib/esm/server/worker/helpers.js +2 -6
  139. package/lib/esm/server/worker/reporter.js +8 -20
  140. package/lib/esm/server/worker/worker.js +22 -20
  141. package/lib/esm/shared/index.js +78 -0
  142. package/lib/esm/shared/serializeRegExp.js +24 -0
  143. package/lib/esm/types.js +3 -0
  144. package/lib/types/client/addon/Manager.d.ts +2 -2
  145. package/lib/types/client/addon/components/TestSelect.d.ts +0 -1
  146. package/lib/types/client/addon/index.d.ts +2 -0
  147. package/lib/types/client/addon/preset.d.ts +2 -1
  148. package/lib/types/client/addon/preset.ie11.d.ts +10 -0
  149. package/lib/types/client/addon/readyForCapture.d.ts +6 -0
  150. package/lib/types/client/addon/utils.d.ts +1 -0
  151. package/lib/types/client/addon/withCreevey.d.ts +13 -2
  152. package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +1 -1
  153. package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +0 -1
  154. package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +1 -1
  155. package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +1 -1
  156. package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +1 -1
  157. package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +0 -1
  158. package/lib/types/client/shared/components/PageFooter/Paging.d.ts +0 -1
  159. package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +1 -1
  160. package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +0 -1
  161. package/lib/types/client/shared/components/ResultsPage.d.ts +1 -1
  162. package/lib/types/client/web/CreeveyApp.d.ts +0 -1
  163. package/lib/types/client/web/CreeveyLoader.d.ts +1 -2
  164. package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +1 -1
  165. package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +0 -1
  166. package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +6 -6
  167. package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +0 -1
  168. package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +1 -1
  169. package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +1 -1
  170. package/lib/types/index.d.ts +0 -1
  171. package/lib/types/server/loaders/babel/register.d.ts +1 -1
  172. package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -2
  173. package/lib/types/server/logger.d.ts +6 -2
  174. package/lib/types/server/master/master.d.ts +1 -0
  175. package/lib/types/server/master/pool.d.ts +1 -0
  176. package/lib/types/server/master/server.d.ts +1 -1
  177. package/lib/types/server/messages.d.ts +17 -6
  178. package/lib/types/server/selenium/browser.d.ts +5 -2
  179. package/lib/types/server/stories.d.ts +2 -2
  180. package/lib/types/server/storybook/entry.d.ts +2 -3
  181. package/lib/types/server/storybook/helpers.d.ts +1 -1
  182. package/lib/types/server/storybook/providers/browser.d.ts +4 -0
  183. package/lib/types/server/storybook/providers/nodejs.d.ts +9 -0
  184. package/lib/types/server/utils.d.ts +5 -1
  185. package/lib/types/server/worker/helpers.d.ts +2 -1
  186. package/lib/types/shared/index.d.ts +7 -0
  187. package/lib/types/shared/serializeRegExp.d.ts +9 -0
  188. package/lib/types/types.d.ts +32 -5
  189. package/package.json +120 -103
  190. package/preset/ie11.js +5 -0
  191. package/{preset.js → preset/index.js} +2 -2
  192. package/types/mdx.d.ts +3 -2
  193. package/types/mocha.d.ts +1 -0
  194. package/lib/cjs/client/web/1.js +0 -13
  195. package/lib/cjs/client/web/2.js +0 -1
  196. package/lib/cjs/shared.js +0 -35
  197. package/lib/esm/shared.js +0 -22
  198. package/lib/types/server/storybook/nodejs-provider.d.ts +0 -5
  199. package/lib/types/shared.d.ts +0 -4
@@ -0,0 +1,49 @@
1
+ /*
2
+ object-assign
3
+ (c) Sindre Sorhus
4
+ @license MIT
5
+ */
6
+
7
+ /*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation.
9
+
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
+ ***************************************************************************** */
21
+
22
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
23
+
24
+ /** @license React v0.20.2
25
+ * scheduler.production.min.js
26
+ *
27
+ * Copyright (c) Facebook, Inc. and its affiliates.
28
+ *
29
+ * This source code is licensed under the MIT license found in the
30
+ * LICENSE file in the root directory of this source tree.
31
+ */
32
+
33
+ /** @license React v17.0.2
34
+ * react-dom.production.min.js
35
+ *
36
+ * Copyright (c) Facebook, Inc. and its affiliates.
37
+ *
38
+ * This source code is licensed under the MIT license found in the
39
+ * LICENSE file in the root directory of this source tree.
40
+ */
41
+
42
+ /** @license React v17.0.2
43
+ * react.production.min.js
44
+ *
45
+ * Copyright (c) Facebook, Inc. and its affiliates.
46
+ *
47
+ * This source code is licensed under the MIT license found in the
48
+ * LICENSE file in the root directory of this source tree.
49
+ */
@@ -19,10 +19,8 @@ var _logger = require("./server/logger");
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
20
 
21
21
  function shutdownOnException(reason) {
22
- var _reason$stack;
23
-
24
22
  if (_utils.isShuttingDown.current) return;
25
- const error = reason instanceof Error ? (_reason$stack = reason.stack) !== null && _reason$stack !== void 0 ? _reason$stack : reason.message : reason;
23
+ const error = reason instanceof Error ? reason.stack ?? reason.message : reason;
26
24
 
27
25
  _logger.logger.error(error);
28
26
 
@@ -33,13 +31,13 @@ function shutdownOnException(reason) {
33
31
  error
34
32
  }
35
33
  });
36
- if (_cluster.default.isMaster && !_utils.isShuttingDown.current) void (0, _utils.shutdownWorkers)();
34
+ if (_cluster.default.isPrimary && !_utils.isShuttingDown.current) void (0, _utils.shutdownWorkers)();
37
35
  }
38
36
 
39
37
  process.on('uncaughtException', shutdownOnException);
40
38
  process.on('unhandledRejection', shutdownOnException);
41
39
  if (_cluster.default.isWorker) process.on('SIGINT', _types.noop);
42
- if (_cluster.default.isMaster) process.on('SIGINT', _utils.shutdown);
40
+ if (_cluster.default.isPrimary) process.on('SIGINT', _utils.shutdown);
43
41
  const argv = (0, _minimist.default)(process.argv.slice(2), {
44
42
  string: ['browser', 'config', 'reporter', 'reportDir', 'screenDir'],
45
43
  boolean: ['debug', 'ui', 'saveReport', 'webpack', 'tests'],
package/lib/cjs/index.js CHANGED
@@ -4,12 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
+ browserStoriesProvider: true,
7
8
  nodejsStoriesProvider: true
8
9
  };
10
+ Object.defineProperty(exports, "browserStoriesProvider", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _browser.loadStories;
14
+ }
15
+ });
9
16
  Object.defineProperty(exports, "nodejsStoriesProvider", {
10
17
  enumerable: true,
11
18
  get: function () {
12
- return _nodejsProvider.loadStories;
19
+ return _nodejs.loadStories;
13
20
  }
14
21
  });
15
22
 
@@ -27,18 +34,6 @@ Object.keys(_types).forEach(function (key) {
27
34
  });
28
35
  });
29
36
 
30
- var _withCreevey = require("./client/addon/withCreevey");
31
-
32
- Object.keys(_withCreevey).forEach(function (key) {
33
- if (key === "default" || key === "__esModule") return;
34
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
35
- if (key in exports && exports[key] === _withCreevey[key]) return;
36
- Object.defineProperty(exports, key, {
37
- enumerable: true,
38
- get: function () {
39
- return _withCreevey[key];
40
- }
41
- });
42
- });
37
+ var _browser = require("./server/storybook/providers/browser");
43
38
 
44
- var _nodejsProvider = require("./server/storybook/nodejs-provider");
39
+ var _nodejs = require("./server/storybook/providers/nodejs");
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.readConfig = readConfig;
7
6
  exports.defaultConfig = exports.defaultBrowser = void 0;
7
+ exports.readConfig = readConfig;
8
8
 
9
9
  var _fs = _interopRequireDefault(require("fs"));
10
10
 
@@ -12,7 +12,9 @@ var _path = _interopRequireDefault(require("path"));
12
12
 
13
13
  var _helpers = require("./storybook/helpers");
14
14
 
15
- var _nodejsProvider = require("./storybook/nodejs-provider");
15
+ var _nodejs = require("./storybook/providers/nodejs");
16
+
17
+ var _browser = require("./storybook/providers/browser");
16
18
 
17
19
  var _types = require("../types");
18
20
 
@@ -80,8 +82,7 @@ async function readConfig(options) {
80
82
  };
81
83
  if ((0, _types.isDefined)(configPath)) Object.assign(userConfig, (await Promise.resolve(`${configPath}`).then(s => _interopRequireWildcard(require(s)))).default);
82
84
  _helpers.storybookDirRef.current = userConfig.storybookDir;
83
- if ((0, _helpers.isStorybookVersionLessThan)(6, 2)) userConfig.useWebpackToExtractTests = true;
84
- if (!userConfig.storiesProvider) userConfig.storiesProvider = (await (0, _helpers.isCSFv3Enabled)()) ? _nodejsProvider.loadStories : _nodejsProvider.loadStories;
85
+ if (!userConfig.storiesProvider) userConfig.storiesProvider = (await (0, _helpers.isCSFv3Enabled)()) ? _browser.loadStories : _nodejs.loadStories;
85
86
  if (options.failFast != undefined) userConfig.failFast = Boolean(options.failFast);
86
87
  if (options.reportDir) userConfig.reportDir = _path.default.resolve(options.reportDir);
87
88
  if (options.screenDir) userConfig.screenDir = _path.default.resolve(options.screenDir); // NOTE: Hack to pass typescript checking
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = _default;
6
7
  exports.pullImages = pullImages;
7
8
  exports.runImage = runImage;
8
- exports.default = _default;
9
9
 
10
- var _cluster = _interopRequireWildcard(require("cluster"));
10
+ var _cluster = _interopRequireDefault(require("cluster"));
11
11
 
12
12
  var _types = require("../types");
13
13
 
@@ -25,10 +25,6 @@ var _logger = require("./logger");
25
25
 
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
 
28
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
-
30
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
-
32
28
  const docker = new _dockerode.default();
33
29
 
34
30
  class DevNull extends _stream.Writable {
@@ -117,7 +113,7 @@ async function runImage(image, args, options, debug) {
117
113
  }
118
114
 
119
115
  async function _default(config, browser, startContainer) {
120
- if (_cluster.isMaster) {
116
+ if (_cluster.default.isPrimary) {
121
117
  const host = await startContainer();
122
118
  let gridUrl = 'http://localhost:4444/wd/hub';
123
119
  gridUrl = _utils.isInsideDocker ? gridUrl.replace(_utils.LOCALHOST_REGEXP, host) : gridUrl;
@@ -9,6 +9,8 @@ var _messages = require("./messages");
9
9
 
10
10
  var _stories = require("./stories");
11
11
 
12
+ var _nodejs = require("./storybook/providers/nodejs");
13
+
12
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
15
 
14
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -29,12 +31,13 @@ async function extract(config, options) {
29
31
  });
30
32
  }
31
33
 
32
- const tests = await (0, _stories.loadTestsFromStories)(Object.keys(config.browsers), async listener => {
33
- const stories = await config.storiesProvider(config, {
34
+ const tests = await (0, _stories.loadTestsFromStories)(Object.keys(config.browsers), async () => {
35
+ const data = await (0, _nodejs.extractStoriesData)(config, {
34
36
  watch: false,
35
37
  debug: options.debug
36
- }, listener);
37
- if (options.extract) (0, _stories.saveStoriesJson)(stories, options.extract);
38
+ });
39
+ const stories = data.stories;
40
+ if (options.extract) (0, _stories.saveStoriesJson)(data, options.extract);
38
41
  return stories;
39
42
  });
40
43
  if (options.tests) (0, _stories.saveTestsJson)(tests); // eslint-disable-next-line no-process-exit
@@ -9,8 +9,6 @@ var _cluster = _interopRequireDefault(require("cluster"));
9
9
 
10
10
  var _config = require("./config");
11
11
 
12
- var _types = require("../types");
13
-
14
12
  var _logger = require("./logger");
15
13
 
16
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -39,8 +37,7 @@ async function _default(options) {
39
37
  ui,
40
38
  port
41
39
  } = options;
42
- if (!config) return;
43
- const resolveApi = ui && _cluster.default.isMaster ? (await Promise.resolve().then(() => _interopRequireWildcard(require('./master/server')))).default(config.reportDir, port) : _types.noop; // NOTE: We don't need docker nor selenoid for webpack or update options
40
+ if (!config) return; // NOTE: We don't need docker nor selenoid for webpack or update options
44
41
 
45
42
  if (!(config.gridUrl || Object.values(config.browsers).every(({
46
43
  gridUrl
@@ -66,10 +63,11 @@ async function _default(options) {
66
63
  return (await Promise.resolve().then(() => _interopRequireWildcard(require('./loaders/webpack/compile')))).default(config, options);
67
64
  }
68
65
 
69
- case _cluster.default.isMaster:
66
+ case _cluster.default.isPrimary:
70
67
  {
71
68
  _logger.logger.info('Starting Master Process');
72
69
 
70
+ const resolveApi = (await Promise.resolve().then(() => _interopRequireWildcard(require('./master/server')))).default(config.reportDir, port, ui);
73
71
  return (await Promise.resolve().then(() => _interopRequireWildcard(require('./master')))).default(config, options, resolveApi);
74
72
  }
75
73
 
@@ -20,9 +20,7 @@ const reexportedStories = new Map();
20
20
  function _default() {
21
21
  return {
22
22
  pre() {
23
- var _this$opts$parents;
24
-
25
- const parents = (_this$opts$parents = this.opts.parents()) !== null && _this$opts$parents !== void 0 ? _this$opts$parents : [];
23
+ const parents = this.opts.parents() ?? [];
26
24
  const story = this.opts.story();
27
25
  this.resourcePath = this.filename;
28
26
  this.fileType = _helpers.FileType.Invalid; // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.storyVisitor = exports.mdxVisitor = exports.previewVisitor = exports.commonVisitor = exports.FileType = void 0;
6
+ exports.storyVisitor = exports.previewVisitor = exports.mdxVisitor = exports.commonVisitor = exports.FileType = void 0;
7
7
 
8
8
  var t = _interopRequireWildcard(require("@babel/types"));
9
9
 
@@ -69,11 +69,9 @@ function getPropertyPath(path, name) {
69
69
 
70
70
  function getDeclaratorPath(path) {
71
71
  if (path !== null && path !== void 0 && path.isIdentifier()) {
72
- var _path$scope$getBindin;
73
-
74
72
  const {
75
73
  path: bindingPath
76
- } = (_path$scope$getBindin = path.scope.getBinding(path.node.name)) !== null && _path$scope$getBindin !== void 0 ? _path$scope$getBindin : {};
74
+ } = path.scope.getBinding(path.node.name) ?? {};
77
75
  if (bindingPath !== null && bindingPath !== void 0 && bindingPath.isVariableDeclarator() || bindingPath !== null && bindingPath !== void 0 && bindingPath.isFunctionDeclaration() || bindingPath !== null && bindingPath !== void 0 && bindingPath.isImportSpecifier()) return bindingPath;
78
76
  }
79
77
  }
@@ -112,7 +110,7 @@ function removeAllPropsExcept(path, propNames) {
112
110
  }
113
111
 
114
112
  function removeAllPropAssignsExcept(propAssigns, propNames) {
115
- for (const [assignPath, props] of propAssigns !== null && propAssigns !== void 0 ? propAssigns : []) {
113
+ for (const [assignPath, props] of propAssigns ?? []) {
116
114
  const restNames = props.reduce((subPropNames, prop) => {
117
115
  const propName = subPropNames.find(names => {
118
116
  const name = Array.isArray(names) ? names[0] : names;
@@ -150,13 +148,11 @@ function getAssignmentPathWithProps(refPath) {
150
148
  function getPropertyAssignmentPaths(idPaths) {
151
149
  const assignPaths = new Map();
152
150
  idPaths.forEach(idPath => {
153
- var _idPath$scope$getBind, _idPath$scope$getBind2;
151
+ var _idPath$scope$getBind;
154
152
 
155
- const referencePaths = (_idPath$scope$getBind = (_idPath$scope$getBind2 = idPath.scope.getBinding(idPath.node.name)) === null || _idPath$scope$getBind2 === void 0 ? void 0 : _idPath$scope$getBind2.referencePaths) !== null && _idPath$scope$getBind !== void 0 ? _idPath$scope$getBind : [];
153
+ const referencePaths = ((_idPath$scope$getBind = idPath.scope.getBinding(idPath.node.name)) === null || _idPath$scope$getBind === void 0 ? void 0 : _idPath$scope$getBind.referencePaths) ?? [];
156
154
  referencePaths.forEach(refPath => {
157
- var _getAssignmentPathWit;
158
-
159
- const [assignmentPath, props] = (_getAssignmentPathWit = getAssignmentPathWithProps(refPath)) !== null && _getAssignmentPathWit !== void 0 ? _getAssignmentPathWit : [];
155
+ const [assignmentPath, props] = getAssignmentPathWithProps(refPath) ?? [];
160
156
  if (assignmentPath && props) assignPaths.set(assignmentPath, props);
161
157
  });
162
158
  });
@@ -346,12 +342,12 @@ const previewVisitor = {
346
342
  exports.previewVisitor = previewVisitor;
347
343
  const mdxVisitor = {
348
344
  FunctionDeclaration(functionPath) {
349
- var _functionPath$get$nod, _rootPath$scope$getBi, _rootPath$scope$getBi2;
345
+ var _functionPath$get$nod, _rootPath$scope$getBi;
350
346
 
351
347
  const functionName = (_functionPath$get$nod = functionPath.get('id').node) === null || _functionPath$get$nod === void 0 ? void 0 : _functionPath$get$nod.name;
352
348
  if (functionName != 'MDXContent') return;
353
349
  const rootPath = findRootPath(functionPath);
354
- const refs = (_rootPath$scope$getBi = rootPath === null || rootPath === void 0 ? void 0 : (_rootPath$scope$getBi2 = rootPath.scope.getBinding(functionName)) === null || _rootPath$scope$getBi2 === void 0 ? void 0 : _rootPath$scope$getBi2.referencePaths) !== null && _rootPath$scope$getBi !== void 0 ? _rootPath$scope$getBi : [];
350
+ const refs = (rootPath === null || rootPath === void 0 ? void 0 : (_rootPath$scope$getBi = rootPath.scope.getBinding(functionName)) === null || _rootPath$scope$getBi === void 0 ? void 0 : _rootPath$scope$getBi.referencePaths) ?? [];
355
351
  refs.forEach(refPath => {
356
352
  var _findRootPath;
357
353
 
@@ -377,10 +373,8 @@ const storyVisitor = {
377
373
  },
378
374
 
379
375
  ExportAllDeclaration(allPath) {
380
- var _this$reexportedStori;
381
-
382
376
  const request = allPath.get('source').node.value;
383
- this.reexportedStories.set(this.resourcePath, ((_this$reexportedStori = this.reexportedStories.get(this.resourcePath)) !== null && _this$reexportedStori !== void 0 ? _this$reexportedStori : new Set()).add(request));
377
+ this.reexportedStories.set(this.resourcePath, (this.reexportedStories.get(this.resourcePath) ?? new Set()).add(request));
384
378
  this.visitedTopPaths.add(allPath);
385
379
  },
386
380
 
@@ -414,9 +408,9 @@ const storyVisitor = {
414
408
  const storiesIdPath = (_rootPath$get$find = rootPath.get('declarations').find(decl => decl.get('init') == rootCallPath)) === null || _rootPath$get$find === void 0 ? void 0 : _rootPath$get$find.get('id');
415
409
 
416
410
  if (storiesIdPath !== null && storiesIdPath !== void 0 && storiesIdPath.isIdentifier()) {
417
- var _storiesIdPath$scope$, _storiesIdPath$scope$2;
411
+ var _storiesIdPath$scope$;
418
412
 
419
- ((_storiesIdPath$scope$ = (_storiesIdPath$scope$2 = storiesIdPath.scope.getBinding(storiesIdPath.node.name)) === null || _storiesIdPath$scope$2 === void 0 ? void 0 : _storiesIdPath$scope$2.referencePaths) !== null && _storiesIdPath$scope$ !== void 0 ? _storiesIdPath$scope$ : []).forEach(cleanUpStoriesOfCallChain);
413
+ (((_storiesIdPath$scope$ = storiesIdPath.scope.getBinding(storiesIdPath.node.name)) === null || _storiesIdPath$scope$ === void 0 ? void 0 : _storiesIdPath$scope$.referencePaths) ?? []).forEach(cleanUpStoriesOfCallChain);
420
414
  }
421
415
  }
422
416
 
@@ -425,11 +419,9 @@ const storyVisitor = {
425
419
 
426
420
  Identifier(identifierPath) {
427
421
  if (isExports(identifierPath)) {
428
- var _getAssignmentPathWit2;
429
-
430
422
  const rootPath = findRootPath(identifierPath);
431
423
  if (rootPath) this.visitedTopPaths.add(rootPath);
432
- const [assignmentPath, props] = (_getAssignmentPathWit2 = getAssignmentPathWithProps(identifierPath)) !== null && _getAssignmentPathWit2 !== void 0 ? _getAssignmentPathWit2 : [];
424
+ const [assignmentPath, props] = getAssignmentPathWithProps(identifierPath) ?? [];
433
425
 
434
426
  if (assignmentPath && props) {
435
427
  if (props.length == 1 && props[0] != 'default') {
@@ -449,11 +441,9 @@ const storyVisitor = {
449
441
  }
450
442
 
451
443
  if (isModuleExports(identifierPath)) {
452
- var _getAssignmentPathWit3;
453
-
454
444
  const rootPath = findRootPath(identifierPath);
455
445
  if (rootPath) this.visitedTopPaths.add(rootPath);
456
- const [assignmentPath, props] = (_getAssignmentPathWit3 = getAssignmentPathWithProps(identifierPath)) !== null && _getAssignmentPathWit3 !== void 0 ? _getAssignmentPathWit3 : [];
446
+ const [assignmentPath, props] = getAssignmentPathWithProps(identifierPath) ?? [];
457
447
 
458
448
  if (assignmentPath && props) {
459
449
  if (props.length == 1 && props[0] == 'exports') {
@@ -59,12 +59,10 @@ function getRequireContext(rootDir) {
59
59
  _fs.default.readdirSync(dirPath, {
60
60
  withFileTypes: true
61
61
  }).forEach(dirent => {
62
- var _filter$test;
63
-
64
62
  const filename = dirent.name;
65
63
  const filePath = (0, _path.join)(dirPath, filename);
66
64
  if (dirent.isDirectory() && deep) return traverse(filePath);
67
- if (dirent.isFile() && ((_filter$test = filter === null || filter === void 0 ? void 0 : filter.test(`./${(0, _path.relative)(contextPath, filePath)}`)) !== null && _filter$test !== void 0 ? _filter$test : true)) return ids.push(filePath);
65
+ if (dirent.isFile() && ((filter === null || filter === void 0 ? void 0 : filter.test(`./${(0, _path.relative)(contextPath, filePath)}`)) ?? true)) return ids.push(filePath);
68
66
  });
69
67
  };
70
68
 
@@ -90,7 +88,7 @@ function getRequireContext(rootDir) {
90
88
  }
91
89
 
92
90
  async function register(config, debug = false) {
93
- const rootDir = (0, _helpers.isStorybookVersionLessThan)(6, 4) ? config.storybookDir : process.cwd();
91
+ const rootDir = process.cwd();
94
92
  const requireContext = getRequireContext(rootDir);
95
93
  const preview = (0, _path.resolve)(config.storybookDir, 'preview');
96
94
  if ((0, _helpers.hasDocsAddon)()) await (await Promise.resolve().then(() => _interopRequireWildcard(require('../hooks/mdx')))).addMDXHook(() => story);
@@ -33,6 +33,8 @@ let isInitiated = false;
33
33
  let dumpStats = _types.noop;
34
34
 
35
35
  function handleWebpackBuild(error, stats) {
36
+ var _stats$toJson$warning;
37
+
36
38
  dumpStats(stats);
37
39
 
38
40
  if (error || !stats || stats.hasErrors()) {
@@ -43,17 +45,16 @@ function handleWebpackBuild(error, stats) {
43
45
  if (error) return console.error(error.message);
44
46
 
45
47
  if (stats && (stats.hasErrors() || stats.hasWarnings())) {
46
- const {
47
- warnings,
48
- errors
49
- } = stats.toJson();
50
- errors.forEach(e => console.error(e));
51
- warnings.forEach(e => console.error(e));
48
+ var _statsJson$errors, _statsJson$warnings;
49
+
50
+ const statsJson = stats.toJson();
51
+ (_statsJson$errors = statsJson.errors) === null || _statsJson$errors === void 0 ? void 0 : _statsJson$errors.forEach(e => console.error(e));
52
+ (_statsJson$warnings = statsJson.warnings) === null || _statsJson$warnings === void 0 ? void 0 : _statsJson$warnings.forEach(e => console.error(e));
52
53
  return;
53
54
  }
54
55
  }
55
56
 
56
- stats.toJson().warnings.forEach(e => console.warn(e));
57
+ stats === null || stats === void 0 ? void 0 : (_stats$toJson$warning = stats.toJson().warnings) === null || _stats$toJson$warning === void 0 ? void 0 : _stats$toJson$warning.forEach(e => console.warn(e));
57
58
 
58
59
  if (!isInitiated) {
59
60
  isInitiated = true;
@@ -74,72 +75,48 @@ async function applyMdxLoader(config, areAddonsRemoved, loader) {
74
75
  mdxLoaders
75
76
  } = await Promise.resolve().then(() => _interopRequireWildcard(require('./mdx-loader')));
76
77
  mdxLoaders.splice(1, 0, loader);
77
- const mdxRegexps = (0, _helpers.isStorybookVersionLessThan)(6, 2) ? [/\.(stories|story).mdx$/, /\.(stories|story)\.mdx$/] : [/(stories|story)\.mdx$/]; // NOTE replace md/mdx to null loader
78
+ const mdxRegexps = [/(stories|story)\.mdx$/]; // NOTE replace md/mdx to null loader
78
79
 
79
80
  const mdRegexps = [/\.md$/, /\.mdx$/];
80
81
 
81
82
  if (areAddonsRemoved) {
82
- var _config$module2;
83
+ var _config$module2, _config$module2$rules;
83
84
 
84
85
  mdRegexps.forEach(test => {
85
- var _config$module;
86
+ var _config$module, _config$module$rules;
86
87
 
87
- return (_config$module = config.module) === null || _config$module === void 0 ? void 0 : _config$module.rules.unshift({
88
+ return (_config$module = config.module) === null || _config$module === void 0 ? void 0 : (_config$module$rules = _config$module.rules) === null || _config$module$rules === void 0 ? void 0 : _config$module$rules.unshift({
88
89
  test,
89
90
  exclude: /(stories|story)\.mdx$/,
90
91
  use: require.resolve('null-loader')
91
92
  });
92
93
  });
93
- (_config$module2 = config.module) === null || _config$module2 === void 0 ? void 0 : _config$module2.rules.unshift({
94
+ (_config$module2 = config.module) === null || _config$module2 === void 0 ? void 0 : (_config$module2$rules = _config$module2.rules) === null || _config$module2$rules === void 0 ? void 0 : _config$module2$rules.unshift({
94
95
  test: /(stories|story)\.mdx$/,
95
96
  use: mdxLoaders
96
97
  });
97
98
  } else {
98
- var _config$module3, _config$module4, _config$module$rules$, _config$module5;
99
+ var _config$module3, _config$module3$rules, _config$module4, _config$module4$rules, _config$module5, _config$module5$rules;
99
100
 
100
101
  // NOTE Exclude addons' entry points
101
102
  config.entry = Array.isArray(config.entry) ? config.entry.filter(entry => !/@storybook(\/|\\)addon/.test(entry)) : config.entry;
102
- (_config$module3 = config.module) === null || _config$module3 === void 0 ? void 0 : _config$module3.rules.filter(rule => mdRegexps.some(test => {
103
+ (_config$module3 = config.module) === null || _config$module3 === void 0 ? void 0 : (_config$module3$rules = _config$module3.rules) === null || _config$module3$rules === void 0 ? void 0 : _config$module3$rules.flatMap(rule => typeof rule == 'object' && 'test' in rule ? rule : []).filter(rule => mdRegexps.some(test => {
103
104
  var _rule$test;
104
105
 
105
106
  return ((_rule$test = rule.test) === null || _rule$test === void 0 ? void 0 : _rule$test.toString()) == test.toString();
106
107
  })).forEach(rule => rule.use = require.resolve('null-loader'));
107
- (_config$module4 = config.module) === null || _config$module4 === void 0 ? void 0 : _config$module4.rules.filter(rule => mdxRegexps.some(test => {
108
+ (_config$module4 = config.module) === null || _config$module4 === void 0 ? void 0 : (_config$module4$rules = _config$module4.rules) === null || _config$module4$rules === void 0 ? void 0 : _config$module4$rules.flatMap(rule => typeof rule == 'object' && 'test' in rule ? rule : []).filter(rule => mdxRegexps.some(test => {
108
109
  var _rule$test2;
109
110
 
110
111
  return ((_rule$test2 = rule.test) === null || _rule$test2 === void 0 ? void 0 : _rule$test2.toString()) == test.toString();
111
112
  })).forEach(rule => rule.use = mdxLoaders); // NOTE Exclude source-loader
112
113
 
113
114
  config.module = { ...config.module,
114
- rules: (_config$module$rules$ = (_config$module5 = config.module) === null || _config$module5 === void 0 ? void 0 : _config$module5.rules.filter(rule => !(typeof rule.loader == 'string' && /@storybook(\/|\\)source-loader/.test(rule.loader)))) !== null && _config$module$rules$ !== void 0 ? _config$module$rules$ : []
115
+ rules: ((_config$module5 = config.module) === null || _config$module5 === void 0 ? void 0 : (_config$module5$rules = _config$module5.rules) === null || _config$module5$rules === void 0 ? void 0 : _config$module5$rules.flatMap(rule => typeof rule == 'object' && 'test' in rule ? rule : []).filter(rule => !(typeof rule.loader == 'string' && /@storybook(\/|\\)source-loader/.test(rule.loader)))) ?? []
115
116
  };
116
117
  }
117
118
  }
118
119
 
119
- async function getWebpackConfigForStorybook_pre6_2(framework, configDir, outputDir) {
120
- const {
121
- default: storybookFrameworkOptions
122
- } = await Promise.resolve(`${(0, _helpers.resolveFromStorybook)(`@storybook/${framework}/dist/server/options`)}`).then(s => _interopRequireWildcard(require(s))); // eslint-disable-next-line node/no-missing-import, @typescript-eslint/no-unsafe-assignment, import/no-unresolved
123
-
124
- const {
125
- default: getConfig
126
- } = await Promise.resolve(`${(0, _helpers.resolveFromStorybook)('@storybook/core/dist/server/config')}`).then(s => _interopRequireWildcard(require(s))); // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
127
-
128
- return getConfig({
129
- // NOTE: 6.1 storybook don't support quite any more. But we still have older versions
130
- quiet: true,
131
- configType: 'PRODUCTION',
132
- outputDir,
133
- cache: {},
134
- // eslint-disable-next-line node/no-missing-require
135
- corePresets: [(0, _helpers.resolveFromStorybook)('@storybook/core/dist/server/preview/preview-preset')],
136
- overridePresets: [...((0, _helpers.hasDocsAddon)() ? [require.resolve('./mdx-loader')] : []), // eslint-disable-next-line node/no-missing-require
137
- (0, _helpers.resolveFromStorybook)('@storybook/core/dist/server/preview/custom-webpack-preset')],
138
- ...storybookFrameworkOptions,
139
- configDir
140
- });
141
- }
142
-
143
120
  async function getWebpackConfigForStorybook_6_2(framework, configDir, outputDir) {
144
121
  const {
145
122
  default: storybookFrameworkOptions
@@ -204,7 +181,7 @@ async function compile(config, {
204
181
  debug,
205
182
  ui
206
183
  }) {
207
- var _storybookWebpackConf, _storybookWebpackConf2, _storybookWebpackConf3, _extensions$map, _storybookWebpackConf4, _storybookWebpackConf5, _storybookWebpackConf6;
184
+ var _storybookWebpackConf, _storybookWebpackConf2, _storybookWebpackConf3, _extensions$map, _storybookWebpackConf4, _storybookWebpackConf5;
208
185
 
209
186
  const storybookFramework = (0, _helpers.getStorybookFramework)();
210
187
 
@@ -228,9 +205,9 @@ async function compile(config, {
228
205
  process.env.NODE_ENV = 'production'; // NOTE Remove addons by monkey patching, only for new config file (main.js)
229
206
 
230
207
  const areAddonsRemoved = await removeAddons();
231
- const getWebpackConfig = (0, _helpers.isStorybookVersionLessThan)(6, 2) ? getWebpackConfigForStorybook_pre6_2 : getWebpackConfigForStorybook_6_2;
208
+ const getWebpackConfig = getWebpackConfigForStorybook_6_2;
232
209
  const storybookWebpackConfig = await getWebpackConfig(storybookFramework, config.storybookDir, outputDir);
233
- const extensions = (_storybookWebpackConf = (_storybookWebpackConf2 = storybookWebpackConfig.resolve) === null || _storybookWebpackConf2 === void 0 ? void 0 : _storybookWebpackConf2.extensions) !== null && _storybookWebpackConf !== void 0 ? _storybookWebpackConf : _utils.extensions;
210
+ const extensions = ((_storybookWebpackConf = storybookWebpackConfig.resolve) === null || _storybookWebpackConf === void 0 ? void 0 : _storybookWebpackConf.extensions) ?? _utils.extensions;
234
211
  delete storybookWebpackConfig.optimization;
235
212
  storybookWebpackConfig.devtool = false;
236
213
  storybookWebpackConfig.performance = false;
@@ -245,18 +222,21 @@ async function compile(config, {
245
222
 
246
223
  if ((0, _helpers.hasDocsAddon)()) await applyMdxLoader(storybookWebpackConfig, areAddonsRemoved, creeveyLoader); // NOTE Add creevey-loader to cut off all unnecessary code except stories meta and tests
247
224
 
248
- (_storybookWebpackConf3 = storybookWebpackConfig.module) === null || _storybookWebpackConf3 === void 0 ? void 0 : _storybookWebpackConf3.rules.unshift({
225
+ (_storybookWebpackConf2 = storybookWebpackConfig.module) === null || _storybookWebpackConf2 === void 0 ? void 0 : (_storybookWebpackConf3 = _storybookWebpackConf2.rules) === null || _storybookWebpackConf3 === void 0 ? void 0 : _storybookWebpackConf3.unshift({
249
226
  enforce: 'pre',
250
227
  test: new RegExp(`\\.(${(_extensions$map = extensions.map(x => x.slice(1))) === null || _extensions$map === void 0 ? void 0 : _extensions$map.join('|')})$`),
251
228
  exclude: /node_modules/,
252
229
  use: creeveyLoader
253
230
  });
254
- const aliases = (_storybookWebpackConf4 = (_storybookWebpackConf5 = storybookWebpackConfig.resolve) === null || _storybookWebpackConf5 === void 0 ? void 0 : _storybookWebpackConf5.alias) !== null && _storybookWebpackConf4 !== void 0 ? _storybookWebpackConf4 : {};
231
+ const aliases = ((_storybookWebpackConf4 = storybookWebpackConfig.resolve) === null || _storybookWebpackConf4 === void 0 ? void 0 : _storybookWebpackConf4.alias) ?? {};
255
232
  const excluded = ['@storybook/addons', '@storybook/api', '@storybook/channel-postmessage', '@storybook/channels', '@storybook/client-api', '@storybook/client-logger', '@storybook/components', '@storybook/core-events', '@storybook/router', '@storybook/semver', '@storybook/theming']; // NOTE Exclude from bundle all modules from node_modules
256
233
 
257
- storybookWebpackConfig.externals = [...Object.entries(aliases).filter(([alias]) => excluded.includes(alias)).map(([, aliasPath]) => ({
258
- [aliasPath]: `commonjs ${aliasPath}`
259
- })), // NOTE Replace `@storybook/${framework}` to ../../storybook.ts
234
+ storybookWebpackConfig.externals = [...(Array.isArray(aliases) ? aliases.map(({
235
+ name,
236
+ alias
237
+ }) => [name, alias]) : Object.entries(aliases)).filter(([alias]) => excluded.includes(alias)).flatMap(([, aliasPath]) => aliasPath == false ? [] : (Array.isArray(aliasPath) ? aliasPath : [aliasPath]).map(x => ({
238
+ [x]: `commonjs ${x}`
239
+ }))), // NOTE Replace `@storybook/${framework}` to ../../storybook.ts
260
240
  {
261
241
  [`@storybook/${storybookFramework}`]: `commonjs ${require.resolve('../../storybook/entry')}`
262
242
  }, (0, _webpackNodeExternals.default)({
@@ -264,17 +244,20 @@ async function compile(config, {
264
244
  allowlist: /(webpack|dummy-hmr|generated-stories-entry|generated-config-entry|generated-other-entry)/
265
245
  }), // TODO Don't work well with monorepos
266
246
  (0, _webpackNodeExternals.default)({
267
- modulesDir: (0, _helpers.resolveFromStorybook)('@storybook/core').split('@storybook')[0],
247
+ modulesDir: (0, _helpers.resolveFromStorybook)('@storybook/core-client').split('@storybook')[0],
268
248
  includeAbsolutePaths: true,
269
249
  allowlist: /(webpack|dummy-hmr|generated-stories-entry|generated-config-entry|generated-other-entry)/
270
250
  })]; // NOTE Exclude some plugins
271
251
 
272
252
  const excludedPlugins = ['DocgenPlugin', 'ForkTsCheckerWebpackPlugin'];
273
- storybookWebpackConfig.plugins = (_storybookWebpackConf6 = storybookWebpackConfig.plugins) === null || _storybookWebpackConf6 === void 0 ? void 0 : _storybookWebpackConf6.filter(plugin => !excludedPlugins.includes(plugin.constructor.name));
253
+ storybookWebpackConfig.plugins = (_storybookWebpackConf5 = storybookWebpackConfig.plugins) === null || _storybookWebpackConf5 === void 0 ? void 0 : _storybookWebpackConf5.filter(plugin => !excludedPlugins.includes(plugin.constructor.name));
274
254
  const storybookWebpackCompiler = (0, _webpack.default)(storybookWebpackConfig);
275
255
 
276
256
  if (debug) {
277
- dumpStats = stats => (0, _fs.writeFile)(_path.default.join(config.reportDir, 'stats.json'), JSON.stringify(stats.toJson(), null, 2), _types.noop);
257
+ dumpStats = stats => {
258
+ if (!stats) return;
259
+ (0, _fs.writeFile)(_path.default.join(config.reportDir, 'stats.json'), JSON.stringify(stats.toJson(), null, 2), _types.noop);
260
+ };
278
261
  }
279
262
 
280
263
  if (ui) {