creevey 0.9.0-beta.1 → 0.9.0-beta.10

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 (221) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +9 -1
  3. package/addon/README.md +3 -0
  4. package/addon/package.json +5 -0
  5. package/docs/config.md +29 -26
  6. package/jest.config.js +6 -0
  7. package/lib/cjs/cli.js +5 -0
  8. package/lib/cjs/client/addon/Manager.js +264 -0
  9. package/lib/cjs/client/addon/components/Addon.js +55 -0
  10. package/lib/cjs/client/addon/components/Icons.js +46 -0
  11. package/lib/cjs/client/addon/components/Panel.js +72 -0
  12. package/lib/cjs/client/addon/components/TestSelect.js +65 -0
  13. package/lib/cjs/client/addon/components/Tools.js +95 -0
  14. package/lib/cjs/client/addon/decorator.js +11 -0
  15. package/lib/cjs/client/addon/index.js +31 -0
  16. package/lib/cjs/client/addon/preset.ie11.js +74 -0
  17. package/lib/cjs/client/addon/preset.js +17 -0
  18. package/lib/cjs/client/addon/preset.sb7.js +19 -0
  19. package/lib/cjs/client/addon/preview.js +14 -0
  20. package/lib/cjs/client/addon/readyForCapture.js +12 -0
  21. package/lib/cjs/client/addon/register.js +72 -0
  22. package/lib/cjs/client/addon/utils.js +42 -0
  23. package/lib/cjs/client/addon/withCreevey.js +351 -0
  24. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +87 -0
  25. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +92 -0
  26. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +154 -0
  27. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +166 -0
  28. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +91 -0
  29. package/lib/cjs/client/shared/components/ImagesView/index.js +45 -0
  30. package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +50 -0
  31. package/lib/cjs/client/shared/components/PageFooter/Paging.js +94 -0
  32. package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +82 -0
  33. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +119 -0
  34. package/lib/cjs/client/shared/components/ResultsPage.js +143 -0
  35. package/lib/cjs/client/shared/creeveyClientApi.js +76 -0
  36. package/lib/cjs/client/shared/helpers.js +411 -0
  37. package/lib/cjs/client/shared/viewMode.js +17 -0
  38. package/lib/cjs/client/web/142.js +2 -0
  39. package/lib/cjs/client/web/142.js.LICENSE.txt +12 -0
  40. package/lib/cjs/client/web/32.js +1 -0
  41. package/lib/cjs/client/web/551.js +1 -0
  42. package/lib/cjs/client/web/566.js +2 -0
  43. package/lib/cjs/client/web/566.js.LICENSE.txt +31 -0
  44. package/lib/cjs/client/web/691.js +2 -0
  45. package/lib/cjs/client/web/691.js.LICENSE.txt +8 -0
  46. package/lib/cjs/client/web/725.js +1 -0
  47. package/lib/cjs/client/web/index.html +19 -0
  48. package/lib/cjs/client/web/main.js +2 -38
  49. package/lib/cjs/client/web/main.js.LICENSE.txt +49 -0
  50. package/lib/cjs/creevey.js +69 -0
  51. package/lib/cjs/index.js +62 -0
  52. package/lib/cjs/server/config.js +94 -0
  53. package/lib/cjs/server/docker.js +146 -0
  54. package/lib/cjs/server/extract.js +46 -0
  55. package/lib/cjs/server/index.js +83 -0
  56. package/lib/cjs/server/loaders/babel/creevey-plugin.js +86 -0
  57. package/lib/cjs/server/loaders/babel/helpers.js +469 -0
  58. package/lib/cjs/server/loaders/babel/register.js +124 -0
  59. package/lib/cjs/server/loaders/hooks/mdx.js +30 -0
  60. package/lib/cjs/server/loaders/hooks/svelte.js +65 -0
  61. package/lib/cjs/server/loaders/webpack/compile.js +269 -0
  62. package/lib/cjs/server/loaders/webpack/creevey-loader.js +172 -0
  63. package/lib/cjs/server/loaders/webpack/dummy-hmr.js +39 -0
  64. package/lib/cjs/server/loaders/webpack/mdx-loader.js +72 -0
  65. package/lib/cjs/server/loaders/webpack/start.js +41 -0
  66. package/lib/cjs/server/logger.js +48 -0
  67. package/lib/cjs/server/master/api.js +71 -0
  68. package/lib/cjs/server/master/index.js +146 -0
  69. package/lib/cjs/server/master/master.js +57 -0
  70. package/lib/cjs/server/master/pool.js +197 -0
  71. package/lib/cjs/server/master/runner.js +281 -0
  72. package/lib/cjs/server/master/server.js +131 -0
  73. package/lib/cjs/server/messages.js +264 -0
  74. package/lib/cjs/server/selenium/browser.js +668 -0
  75. package/lib/cjs/server/selenium/index.js +31 -0
  76. package/lib/cjs/server/selenium/selenoid.js +172 -0
  77. package/lib/cjs/server/stories.js +153 -0
  78. package/lib/cjs/server/storybook/entry.js +53 -0
  79. package/lib/cjs/server/storybook/helpers.js +158 -0
  80. package/lib/cjs/server/storybook/providers/browser.js +74 -0
  81. package/lib/cjs/server/storybook/providers/hybrid.js +82 -0
  82. package/lib/cjs/server/storybook/providers/nodejs.js +239 -0
  83. package/lib/cjs/server/testsFiles/parser.js +72 -0
  84. package/lib/cjs/server/testsFiles/register.js +44 -0
  85. package/lib/cjs/server/update.js +79 -0
  86. package/lib/cjs/server/utils.js +176 -0
  87. package/lib/cjs/server/worker/chai-image.js +142 -0
  88. package/lib/cjs/server/worker/helpers.js +69 -0
  89. package/lib/cjs/server/worker/index.js +15 -0
  90. package/lib/cjs/server/worker/reporter.js +108 -0
  91. package/lib/cjs/server/worker/worker.js +268 -0
  92. package/lib/cjs/shared/index.js +101 -0
  93. package/lib/cjs/shared/serializeRegExp.js +42 -0
  94. package/lib/cjs/types.js +75 -0
  95. package/lib/esm/cli.js +4 -0
  96. package/lib/esm/client/addon/Manager.js +248 -0
  97. package/lib/esm/client/addon/components/Addon.js +39 -0
  98. package/lib/esm/client/addon/components/Icons.js +31 -0
  99. package/lib/esm/client/addon/components/Panel.js +53 -0
  100. package/lib/esm/client/addon/components/TestSelect.js +51 -0
  101. package/lib/esm/client/addon/components/Tools.js +74 -0
  102. package/lib/esm/client/addon/decorator.js +2 -0
  103. package/lib/esm/client/addon/index.js +2 -0
  104. package/lib/esm/client/addon/preset.ie11.js +59 -0
  105. package/lib/esm/client/addon/preset.js +8 -0
  106. package/lib/esm/client/addon/preset.sb7.js +8 -0
  107. package/lib/esm/client/addon/preview.js +5 -0
  108. package/lib/esm/client/addon/readyForCapture.js +5 -0
  109. package/lib/esm/client/addon/register.js +51 -0
  110. package/lib/esm/client/addon/utils.js +32 -0
  111. package/lib/esm/client/addon/withCreevey.js +325 -0
  112. package/lib/esm/client/shared/components/ImagesView/BlendView.js +67 -0
  113. package/lib/esm/client/shared/components/ImagesView/ImagesView.js +69 -0
  114. package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +131 -0
  115. package/lib/esm/client/shared/components/ImagesView/SlideView.js +143 -0
  116. package/lib/esm/client/shared/components/ImagesView/SwapView.js +71 -0
  117. package/lib/esm/client/shared/components/ImagesView/index.js +5 -0
  118. package/lib/esm/client/shared/components/PageFooter/PageFooter.js +36 -0
  119. package/lib/esm/client/shared/components/PageFooter/Paging.js +80 -0
  120. package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +68 -0
  121. package/lib/esm/client/shared/components/PageHeader/PageHeader.js +97 -0
  122. package/lib/esm/client/shared/components/ResultsPage.js +115 -0
  123. package/lib/esm/client/shared/creeveyClientApi.js +67 -0
  124. package/lib/esm/client/shared/helpers.js +353 -0
  125. package/lib/esm/client/shared/viewMode.js +6 -0
  126. package/lib/esm/creevey.js +54 -0
  127. package/lib/esm/index.js +5 -0
  128. package/lib/esm/server/config.js +71 -0
  129. package/lib/esm/server/docker.js +123 -0
  130. package/lib/esm/server/extract.js +32 -0
  131. package/lib/esm/server/index.js +64 -0
  132. package/lib/esm/server/loaders/babel/creevey-plugin.js +72 -0
  133. package/lib/esm/server/loaders/babel/helpers.js +452 -0
  134. package/lib/esm/server/loaders/babel/register.js +103 -0
  135. package/lib/esm/server/loaders/hooks/mdx.js +15 -0
  136. package/lib/esm/server/loaders/hooks/svelte.js +49 -0
  137. package/lib/esm/server/loaders/webpack/compile.js +246 -0
  138. package/lib/esm/server/loaders/webpack/creevey-loader.js +152 -0
  139. package/lib/esm/server/loaders/webpack/dummy-hmr.js +32 -0
  140. package/lib/esm/server/loaders/webpack/mdx-loader.js +58 -0
  141. package/lib/esm/server/loaders/webpack/start.js +27 -0
  142. package/lib/esm/server/logger.js +20 -0
  143. package/lib/esm/server/master/api.js +60 -0
  144. package/lib/esm/server/master/index.js +125 -0
  145. package/lib/esm/server/master/master.js +38 -0
  146. package/lib/esm/server/master/pool.js +176 -0
  147. package/lib/esm/server/master/runner.js +259 -0
  148. package/lib/esm/server/master/server.js +107 -0
  149. package/lib/esm/server/messages.js +232 -0
  150. package/lib/esm/server/selenium/browser.js +635 -0
  151. package/lib/esm/server/selenium/index.js +2 -0
  152. package/lib/esm/server/selenium/selenoid.js +149 -0
  153. package/lib/esm/server/stories.js +135 -0
  154. package/lib/esm/server/storybook/entry.js +27 -0
  155. package/lib/esm/server/storybook/helpers.js +97 -0
  156. package/lib/esm/server/storybook/providers/browser.js +58 -0
  157. package/lib/esm/server/storybook/providers/hybrid.js +60 -0
  158. package/lib/esm/server/storybook/providers/nodejs.js +216 -0
  159. package/lib/esm/server/testsFiles/parser.js +50 -0
  160. package/lib/esm/server/testsFiles/register.js +31 -0
  161. package/lib/esm/server/update.js +61 -0
  162. package/lib/esm/server/utils.js +133 -0
  163. package/lib/esm/server/worker/chai-image.js +130 -0
  164. package/lib/esm/server/worker/helpers.js +60 -0
  165. package/lib/esm/server/worker/index.js +1 -0
  166. package/lib/esm/server/worker/reporter.js +86 -0
  167. package/lib/esm/server/worker/worker.js +238 -0
  168. package/lib/esm/shared/index.js +78 -0
  169. package/lib/esm/shared/serializeRegExp.js +24 -0
  170. package/lib/esm/types.js +44 -0
  171. package/lib/types/client/addon/Manager.d.ts +2 -2
  172. package/lib/types/client/addon/components/TestSelect.d.ts +0 -1
  173. package/lib/types/client/addon/index.d.ts +2 -0
  174. package/lib/types/client/addon/preset.d.ts +0 -22
  175. package/lib/types/client/addon/preset.ie11.d.ts +10 -0
  176. package/lib/types/client/addon/preset.sb7.d.ts +2 -0
  177. package/lib/types/client/addon/preview.d.ts +4 -0
  178. package/lib/types/client/addon/utils.d.ts +1 -0
  179. package/lib/types/client/addon/withCreevey.d.ts +1 -1
  180. package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +1 -1
  181. package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +0 -1
  182. package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +1 -1
  183. package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +1 -1
  184. package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +1 -1
  185. package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +0 -1
  186. package/lib/types/client/shared/components/PageFooter/Paging.d.ts +0 -1
  187. package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +1 -1
  188. package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +0 -1
  189. package/lib/types/client/shared/components/ResultsPage.d.ts +1 -1
  190. package/lib/types/client/web/CreeveyApp.d.ts +0 -1
  191. package/lib/types/client/web/CreeveyLoader.d.ts +1 -2
  192. package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +1 -1
  193. package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +0 -1
  194. package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +4 -4
  195. package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +0 -1
  196. package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +1 -1
  197. package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +1 -1
  198. package/lib/types/index.d.ts +1 -0
  199. package/lib/types/server/loaders/babel/register.d.ts +1 -1
  200. package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -2
  201. package/lib/types/server/logger.d.ts +6 -2
  202. package/lib/types/server/messages.d.ts +14 -12
  203. package/lib/types/server/selenium/browser.d.ts +5 -3
  204. package/lib/types/server/storybook/entry.d.ts +2 -3
  205. package/lib/types/server/storybook/helpers.d.ts +1 -1
  206. package/lib/types/server/storybook/providers/browser.d.ts +2 -4
  207. package/lib/types/server/storybook/providers/hybrid.d.ts +2 -4
  208. package/lib/types/server/storybook/providers/nodejs.d.ts +3 -3
  209. package/lib/types/server/utils.d.ts +5 -1
  210. package/lib/types/{shared.d.ts → shared/index.d.ts} +1 -10
  211. package/lib/types/shared/serializeRegExp.d.ts +9 -0
  212. package/lib/types/types.d.ts +4 -7
  213. package/package.json +117 -103
  214. package/preset/ie11.js +5 -0
  215. package/{preset.js → preset/index.js} +2 -2
  216. package/preset/sb7.js +5 -0
  217. package/types/global.d.ts +5 -0
  218. package/types/mdx.d.ts +3 -2
  219. package/lib/cjs/client/web/1.js +0 -13
  220. package/lib/cjs/client/web/2.js +0 -1
  221. package/storybook-static/stories.json +0 -21
@@ -0,0 +1,64 @@
1
+ import cluster from 'cluster';
2
+ import { readConfig, defaultBrowser } from './config';
3
+ import { logger } from './logger'; // NOTE: Impure function, mutate config by adding gridUrl prop
4
+
5
+ async function startWebdriverServer(config, options) {
6
+ if (config.useDocker) {
7
+ return (await import('./docker')).default(config, options.browser, async () => (await import('./selenium/selenoid')).startSelenoidContainer(config, options.debug));
8
+ } else {
9
+ return (await import('./selenium/selenoid')).startSelenoidStandalone(config, options.debug);
10
+ }
11
+ }
12
+
13
+ export default async function (options) {
14
+ const config = await readConfig(options);
15
+ const {
16
+ browser = defaultBrowser,
17
+ extract,
18
+ tests,
19
+ update,
20
+ webpack,
21
+ ui,
22
+ port
23
+ } = options;
24
+ if (!config) return; // NOTE: We don't need docker nor selenoid for webpack or update options
25
+
26
+ if (!(config.gridUrl || Object.values(config.browsers).every(({
27
+ gridUrl
28
+ }) => gridUrl)) && !extract && !webpack && !tests && !update) {
29
+ await startWebdriverServer(config, options);
30
+ }
31
+
32
+ switch (true) {
33
+ case Boolean(extract) || tests:
34
+ {
35
+ return (await import('./extract')).default(config, options);
36
+ }
37
+
38
+ case Boolean(update):
39
+ {
40
+ return (await import('./update')).default(config, typeof update == 'string' ? update : undefined);
41
+ }
42
+
43
+ case webpack:
44
+ {
45
+ logger.info('Starting Webpack Compiler');
46
+ return (await import('./loaders/webpack/compile')).default(config, options);
47
+ }
48
+
49
+ case cluster.isPrimary:
50
+ {
51
+ logger.info('Starting Master Process');
52
+ const resolveApi = (await import('./master/server')).default(config.reportDir, port, ui);
53
+ return (await import('./master')).default(config, options, resolveApi);
54
+ }
55
+
56
+ default:
57
+ {
58
+ logger.info(`Starting Worker for ${browser}`);
59
+ return (await import('./worker')).default(config, { ...options,
60
+ browser
61
+ });
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,72 @@
1
+ import path from 'path';
2
+ import { commonVisitor, FileType, mdxVisitor, previewVisitor, storyVisitor } from './helpers';
3
+ import { logger } from '../../logger';
4
+ let lastStoryFile = null;
5
+ const stories = new Set();
6
+ const reexportedStories = new Map();
7
+ export default function () {
8
+ return {
9
+ pre() {
10
+ const parents = this.opts.parents() ?? [];
11
+ const story = this.opts.story();
12
+ this.resourcePath = this.filename;
13
+ this.fileType = FileType.Invalid; // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+
15
+ this.visitedTopPaths = new Set();
16
+ this.visitedBindings = new Set();
17
+ this.reexportedStories = reexportedStories;
18
+
19
+ if (story && this.filename.startsWith(story) || parents.find(parent => this.reexportedStories.has(parent))) {
20
+ this.fileType = FileType.Story;
21
+ this.isMDX = path.parse(this.filename).ext == '.mdx';
22
+ lastStoryFile = this.filename;
23
+ stories.add(this.filename);
24
+ } else if (this.filename.startsWith(this.opts.preview)) this.fileType = FileType.Preview;else if (lastStoryFile && this.opts.debug) {
25
+ logger.warn('Trying to transform possible non-story file', this.resourcePath, 'Please check the', lastStoryFile);
26
+ lastStoryFile = null; // TODO Add link to docs, how creevey works and what user should do in this situation
27
+ }
28
+ },
29
+
30
+ visitor: { ...commonVisitor,
31
+
32
+ ExportAllDeclaration(path) {
33
+ if (this.fileType == FileType.Story && typeof storyVisitor.ExportAllDeclaration == 'function') {
34
+ storyVisitor.ExportAllDeclaration.call(this, path, this);
35
+ }
36
+ },
37
+
38
+ ExportDefaultDeclaration(path) {
39
+ if (this.fileType == FileType.Story && typeof storyVisitor.ExportDefaultDeclaration == 'function') {
40
+ storyVisitor.ExportDefaultDeclaration.call(this, path, this);
41
+ }
42
+ },
43
+
44
+ ExportNamedDeclaration(path) {
45
+ if (this.fileType == FileType.Preview && typeof previewVisitor.ExportNamedDeclaration == 'function') {
46
+ previewVisitor.ExportNamedDeclaration.call(this, path, this);
47
+ }
48
+
49
+ if (this.fileType == FileType.Story && typeof storyVisitor.ExportNamedDeclaration == 'function') {
50
+ storyVisitor.ExportNamedDeclaration.call(this, path, this);
51
+ }
52
+ },
53
+
54
+ CallExpression(path) {
55
+ if (this.fileType == FileType.Preview && typeof previewVisitor.CallExpression == 'function') {
56
+ previewVisitor.CallExpression.call(this, path, this);
57
+ }
58
+
59
+ if (this.fileType == FileType.Story && typeof storyVisitor.CallExpression == 'function') {
60
+ storyVisitor.CallExpression.call(this, path, this);
61
+ }
62
+ },
63
+
64
+ FunctionDeclaration(path) {
65
+ if (this.isMDX && typeof mdxVisitor.FunctionDeclaration == 'function') {
66
+ mdxVisitor.FunctionDeclaration.call(this, path, this);
67
+ }
68
+ }
69
+
70
+ }
71
+ };
72
+ }
@@ -0,0 +1,452 @@
1
+ import * as t from '@babel/types';
2
+ import { isDefined } from '../../../types';
3
+
4
+ function isExports(path) {
5
+ const {
6
+ parentPath
7
+ } = path;
8
+ return path.node.name == 'exports' && path.scope.hasGlobal('exports') && !path.scope.hasBinding('exports') && parentPath.isMemberExpression() && parentPath.get('object').isIdentifier({
9
+ name: 'exports'
10
+ });
11
+ }
12
+
13
+ function isModuleExports(path) {
14
+ const {
15
+ parentPath
16
+ } = path;
17
+ return path.node.name == 'module' && path.scope.hasGlobal('module') && !path.scope.hasBinding('module') && parentPath.isMemberExpression() && parentPath.get('object').isIdentifier({
18
+ name: 'module'
19
+ }) && parentPath.get('property').isIdentifier({
20
+ name: 'exports'
21
+ });
22
+ }
23
+
24
+ function isObjectAssign(path) {
25
+ if (!(path !== null && path !== void 0 && path.isCallExpression())) return false;
26
+ const calleePath = path.get('callee');
27
+ return calleePath.isMemberExpression() && calleePath.get('object').isIdentifier({
28
+ name: 'Object'
29
+ }) && calleePath.get('property').isIdentifier({
30
+ name: 'assign'
31
+ });
32
+ }
33
+
34
+ function isTemplateBind(path) {
35
+ if (!(path !== null && path !== void 0 && path.isCallExpression())) return false;
36
+ const calleePath = path.get('callee');
37
+ return calleePath.isMemberExpression() && calleePath.get('object').isIdentifier() && calleePath.get('property').isIdentifier({
38
+ name: 'bind'
39
+ });
40
+ }
41
+
42
+ function findRootPath(path) {
43
+ return path.find(x => {
44
+ var _x$parentPath;
45
+
46
+ return Boolean((_x$parentPath = x.parentPath) === null || _x$parentPath === void 0 ? void 0 : _x$parentPath.isProgram());
47
+ });
48
+ }
49
+
50
+ function getPropertyPath(path, name) {
51
+ const propertyPath = path.get('properties').find(propPath => propPath.isObjectProperty() && t.isIdentifier(propPath.node.key, {
52
+ name
53
+ }));
54
+ return propertyPath !== null && propertyPath !== void 0 && propertyPath.isObjectProperty() ? propertyPath : undefined;
55
+ } // TODO Support import and process them
56
+
57
+
58
+ function getDeclaratorPath(path) {
59
+ if (path !== null && path !== void 0 && path.isIdentifier()) {
60
+ const {
61
+ path: bindingPath
62
+ } = path.scope.getBinding(path.node.name) ?? {};
63
+ if (bindingPath !== null && bindingPath !== void 0 && bindingPath.isVariableDeclarator() || bindingPath !== null && bindingPath !== void 0 && bindingPath.isFunctionDeclaration() || bindingPath !== null && bindingPath !== void 0 && bindingPath.isImportSpecifier()) return bindingPath;
64
+ }
65
+ }
66
+
67
+ function getKindObjectNodePath(path) {
68
+ if (path.isObjectExpression()) {
69
+ return getPropertyPath(path, 'title') ? path : undefined;
70
+ }
71
+ }
72
+
73
+ function getIdentifiers(path) {
74
+ return path.map(x => x.isFunctionDeclaration() ? x.get('id') : x.get('id')).map(idPath => idPath.isIdentifier() ? idPath : null).filter(isDefined);
75
+ }
76
+
77
+ function removeAllPropsExcept(path, propNames) {
78
+ const getPropName = propPath => propNames.find(names => {
79
+ const keyPath = propPath.isObjectProperty() ? propPath.get('key') : propPath.get('key');
80
+ if (!keyPath.isIdentifier()) return;
81
+ const name = Array.isArray(names) ? names[0] : names;
82
+ return typeof name == 'string' ? keyPath.isIdentifier({
83
+ name
84
+ }) : name(keyPath.node.name);
85
+ });
86
+
87
+ path.get('properties').forEach(propPath => {
88
+ if (propPath.isObjectProperty() || propPath.isObjectMethod()) {
89
+ const propName = getPropName(propPath);
90
+ if (!propName) return propPath.remove();
91
+ const restNames = Array.isArray(propName) ? propName.slice(1) : [];
92
+ if (propPath.isObjectProperty() && restNames.length != 0) removeAllExpressionPropsExcept(propPath === null || propPath === void 0 ? void 0 : propPath.get('value'), restNames);
93
+ if (propPath.isObjectMethod() && restNames[0] == 'storyName') replaceStoryFnToNoop(propPath);
94
+ } else if (propPath.isSpreadElement()) {
95
+ removeAllExpressionPropsExcept(propPath.get('argument'), propNames);
96
+ } else propPath.remove();
97
+ });
98
+ }
99
+
100
+ function removeAllPropAssignsExcept(propAssigns, propNames) {
101
+ for (const [assignPath, props] of propAssigns ?? []) {
102
+ const restNames = props.reduce((subPropNames, prop) => {
103
+ const propName = subPropNames.find(names => {
104
+ const name = Array.isArray(names) ? names[0] : names;
105
+ return typeof name == 'string' ? name == prop : name(prop);
106
+ });
107
+ if (Array.isArray(propName)) return propName.slice(1);
108
+ if (!propName) assignPath.remove();
109
+ return [];
110
+ }, propNames);
111
+ if (restNames.length != 0) removeAllExpressionPropsExcept(assignPath.get('right'), restNames);
112
+ }
113
+ }
114
+
115
+ function replaceStoryFnToNoop(path) {
116
+ if (path !== null && path !== void 0 && path.isArrowFunctionExpression()) path.get('body').replaceWith(t.blockStatement([]));else if (path !== null && path !== void 0 && path.isFunctionDeclaration()) path.get('body').replaceWith(t.blockStatement([]));else if (path !== null && path !== void 0 && path.isFunctionExpression()) path.get('body').replaceWith(t.blockStatement([]));else if (path !== null && path !== void 0 && path.isObjectMethod()) path.get('body').replaceWith(t.blockStatement([]));
117
+ }
118
+
119
+ function getAssignmentPathWithProps(refPath) {
120
+ const assignmentPath = refPath.findParent(parentPath => parentPath.isAssignmentExpression());
121
+ if (!(assignmentPath !== null && assignmentPath !== void 0 && assignmentPath.isAssignmentExpression())) return;
122
+ const props = [];
123
+
124
+ for (let propPath = refPath.parentPath; propPath != assignmentPath; propPath = propPath.parentPath) {
125
+ var _propPath;
126
+
127
+ if (!((_propPath = propPath) !== null && _propPath !== void 0 && _propPath.isMemberExpression())) return;
128
+ const propNode = propPath.node.property;
129
+ if (!t.isIdentifier(propNode)) return;
130
+ props.push(propNode.name);
131
+ }
132
+
133
+ if (props.length != 0) return [assignmentPath, props];
134
+ }
135
+
136
+ function getPropertyAssignmentPaths(idPaths) {
137
+ const assignPaths = new Map();
138
+ idPaths.forEach(idPath => {
139
+ var _idPath$scope$getBind;
140
+
141
+ const referencePaths = ((_idPath$scope$getBind = idPath.scope.getBinding(idPath.node.name)) === null || _idPath$scope$getBind === void 0 ? void 0 : _idPath$scope$getBind.referencePaths) ?? [];
142
+ referencePaths.forEach(refPath => {
143
+ const [assignmentPath, props] = getAssignmentPathWithProps(refPath) ?? [];
144
+ if (assignmentPath && props) assignPaths.set(assignmentPath, props);
145
+ });
146
+ });
147
+ return assignPaths;
148
+ }
149
+
150
+ function removeAllExpressionPropsExcept(expressionPath, propNames) {
151
+ const resolvedDeclPath = getDeclaratorPath(expressionPath);
152
+ if (expressionPath !== null && expressionPath !== void 0 && expressionPath.isObjectExpression()) removeAllPropsExcept(expressionPath, propNames);else if (expressionPath !== null && expressionPath !== void 0 && expressionPath.isCallExpression()) {
153
+ if (isObjectAssign(expressionPath)) expressionPath.get('arguments').forEach(argumentPath => removeAllExpressionPropsExcept(argumentPath, storyProps));else if (isTemplateBind(expressionPath)) {
154
+ const calleePath = expressionPath.get('callee');
155
+ if (calleePath.isMemberExpression()) removeAllExpressionPropsExcept(calleePath.get('object'), propNames);
156
+ } else if (propNames[0] == 'storyName') {
157
+ expressionPath === null || expressionPath === void 0 ? void 0 : expressionPath.replaceWith(t.arrowFunctionExpression([], t.blockStatement([])));
158
+ }
159
+ } else if ((expressionPath !== null && expressionPath !== void 0 && expressionPath.isFunctionExpression() || expressionPath !== null && expressionPath !== void 0 && expressionPath.isArrowFunctionExpression()) && propNames[0] == 'storyName') replaceStoryFnToNoop(expressionPath);else if ((!resolvedDeclPath || resolvedDeclPath.isImportSpecifier()) && propNames[0] == 'storyName') expressionPath === null || expressionPath === void 0 ? void 0 : expressionPath.replaceWith(t.arrowFunctionExpression([], t.blockStatement([])));
160
+
161
+ if (resolvedDeclPath) {
162
+ if (!resolvedDeclPath.isImportSpecifier()) removeAllPropAssignsExcept(getPropertyAssignmentPaths(getIdentifiers([resolvedDeclPath])).entries(), propNames);
163
+ if (resolvedDeclPath.isVariableDeclarator()) removeAllExpressionPropsExcept(resolvedDeclPath.get('init'), propNames);
164
+ if (resolvedDeclPath.isFunctionDeclaration() && propNames[0] == 'storyName') replaceStoryFnToNoop(resolvedDeclPath);
165
+ }
166
+ }
167
+
168
+ function cleanUpStoriesOfCallChain(storiesOfPath) {
169
+ let callPath = storiesOfPath;
170
+
171
+ do {
172
+ const childCallPath = callPath;
173
+ const {
174
+ parentPath: memberPath
175
+ } = childCallPath;
176
+ if (!memberPath || !memberPath.isMemberExpression()) return;
177
+ callPath = memberPath.parentPath;
178
+ const propPath = memberPath.get('property');
179
+ if (!callPath.isCallExpression()) return;
180
+
181
+ if (propPath.isIdentifier({
182
+ name: 'add'
183
+ })) {
184
+ const [, storyPath, parametersPath] = callPath.get('arguments');
185
+ storyPath.replaceWith(t.arrowFunctionExpression([], t.blockStatement([])));
186
+ removeAllExpressionPropsExcept(parametersPath, ['creevey']);
187
+ } else if (propPath.isIdentifier({
188
+ name: 'addDecorator'
189
+ })) {
190
+ callPath.replaceWith(childCallPath);
191
+ } else if (propPath.isIdentifier({
192
+ name: 'addParameters'
193
+ })) {
194
+ const [parametersPath] = callPath.get('arguments');
195
+ removeAllExpressionPropsExcept(parametersPath, ['creevey']);
196
+ }
197
+ } while (callPath.parentPath != null);
198
+ }
199
+
200
+ function recursivelyRemoveUnreferencedBindings(path) {
201
+ const getUnreferencedBindings = () => {
202
+ path.scope.crawl();
203
+ return Object.values(path.scope.bindings).filter(binding => !binding.referenced || binding.referencePaths.every(refPath => refPath.find(x => x.node == binding.path.node)));
204
+ };
205
+
206
+ let bindings = getUnreferencedBindings();
207
+
208
+ do {
209
+ bindings.forEach(binding => !binding.path.removed && binding.path.remove());
210
+ } while ((bindings = getUnreferencedBindings()).length > 0);
211
+ }
212
+
213
+ function getUnvisitedRefs(paths, // eslint-disable-next-line @typescript-eslint/no-explicit-any
214
+ state) {
215
+ const rootPaths = [...new Set(paths.map(findRootPath).filter(isDefined))];
216
+ const bindings = new Set();
217
+ rootPaths.forEach(rootPath => {
218
+ state.visitedTopPaths.add(rootPath);
219
+ rootPath.traverse({
220
+ Identifier(identifierPath) {
221
+ const binding = identifierPath.scope.getBinding(identifierPath.node.name);
222
+
223
+ if ((binding === null || binding === void 0 ? void 0 : binding.scope) == rootPath.scope && !state.visitedBindings.has(binding)) {
224
+ bindings.add(binding);
225
+ state.visitedBindings.add(binding);
226
+ }
227
+ }
228
+
229
+ });
230
+ });
231
+ const refs = [].concat(...[...bindings].map(b => [b.path, ...b.referencePaths]));
232
+ return [...new Set(refs)];
233
+ }
234
+
235
+ export let FileType;
236
+
237
+ (function (FileType) {
238
+ FileType[FileType["Invalid"] = -1] = "Invalid";
239
+ FileType[FileType["Entry"] = 0] = "Entry";
240
+ FileType[FileType["Preview"] = 1] = "Preview";
241
+ FileType[FileType["Story"] = 2] = "Story";
242
+ })(FileType || (FileType = {}));
243
+
244
+ export const commonVisitor = {
245
+ Program: {
246
+ enter(path) {
247
+ path.traverse({
248
+ TSDeclareFunction(path) {
249
+ path.remove();
250
+ },
251
+
252
+ TSTypeAliasDeclaration(path) {
253
+ path.remove();
254
+ },
255
+
256
+ TSInterfaceDeclaration(path) {
257
+ path.remove();
258
+ },
259
+
260
+ TSTypeAnnotation(path) {
261
+ path.remove();
262
+ },
263
+
264
+ TSAsExpression(path) {
265
+ path.replaceWith(path.get('expression'));
266
+ }
267
+
268
+ });
269
+ },
270
+
271
+ exit(path) {
272
+ if (this.fileType != FileType.Story && this.fileType != FileType.Preview) return;
273
+ recursivelyRemoveUnreferencedBindings(path);
274
+ path.traverse({
275
+ ImportDeclaration(path) {
276
+ if (path.node.specifiers.length == 0) path.remove();
277
+ }
278
+
279
+ });
280
+ let refs = [...this.visitedTopPaths];
281
+
282
+ while (refs.length > 0) {
283
+ refs = getUnvisitedRefs(refs, this);
284
+ }
285
+
286
+ path.get('body').filter(x => !this.visitedTopPaths.has(x)).forEach(x => x.remove());
287
+ }
288
+
289
+ }
290
+ };
291
+ export const previewVisitor = {
292
+ ExportNamedDeclaration(namedPath) {
293
+ this.visitedTopPaths.add(namedPath);
294
+ const declarationPath = namedPath.get('declaration');
295
+ if (!declarationPath.isVariableDeclaration()) return;
296
+ declarationPath.get('declarations').forEach(declPath => {
297
+ if (!declPath.isVariableDeclarator()) return;
298
+ if (t.isIdentifier(declPath.node.id, {
299
+ name: 'decorators'
300
+ })) return declPath.remove();
301
+
302
+ if (t.isIdentifier(declPath.node.id, {
303
+ name: 'parameters'
304
+ })) {
305
+ removeAllExpressionPropsExcept(declPath.get('init'), ['creevey']);
306
+ }
307
+ });
308
+ },
309
+
310
+ CallExpression(rootCallPath) {
311
+ const rootPath = findRootPath(rootCallPath);
312
+ const calleePath = rootCallPath.get('callee');
313
+ if (calleePath.isIdentifier({
314
+ name: 'configure'
315
+ }) && rootPath) this.visitedTopPaths.add(rootPath);else if (calleePath.isIdentifier({
316
+ name: 'addDecorator'
317
+ })) rootCallPath.remove();else if (calleePath.isIdentifier({
318
+ name: 'addParameters'
319
+ })) {
320
+ const [argPath] = rootCallPath.get('arguments');
321
+ if (!argPath || !argPath.isObjectExpression()) return;
322
+ if (rootPath) this.visitedTopPaths.add(rootPath);
323
+ removeAllPropsExcept(argPath, ['creevey']);
324
+ }
325
+ }
326
+
327
+ };
328
+ export const mdxVisitor = {
329
+ FunctionDeclaration(functionPath) {
330
+ var _functionPath$get$nod, _rootPath$scope$getBi;
331
+
332
+ const functionName = (_functionPath$get$nod = functionPath.get('id').node) === null || _functionPath$get$nod === void 0 ? void 0 : _functionPath$get$nod.name;
333
+ if (functionName != 'MDXContent') return;
334
+ const rootPath = findRootPath(functionPath);
335
+ 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) ?? [];
336
+ refs.forEach(refPath => {
337
+ var _findRootPath;
338
+
339
+ return (_findRootPath = findRootPath(refPath)) === null || _findRootPath === void 0 ? void 0 : _findRootPath.remove();
340
+ });
341
+ rootPath === null || rootPath === void 0 ? void 0 : rootPath.remove();
342
+ }
343
+
344
+ };
345
+ const kindProps = ['title', 'id', ['parameters', 'creevey'], 'includeStories', 'excludeStories'];
346
+ const storyProps = ['storyName', ['story', 'name', ['parameters', 'creevey', 'docsOnly']], ['parameters', 'creevey', 'docsOnly']];
347
+ const exportsProps = [['default', ...kindProps], [name => name != 'default', ...storyProps]];
348
+ export const storyVisitor = {
349
+ ExportDefaultDeclaration(defaultPath) {
350
+ const defaultDeclaration = defaultPath.get('declaration');
351
+ const declaratorPath = getDeclaratorPath(defaultDeclaration);
352
+ const kindPath = declaratorPath !== null && declaratorPath !== void 0 && declaratorPath.isVariableDeclarator() ? getKindObjectNodePath(declaratorPath.get('init')) : getKindObjectNodePath(defaultDeclaration);
353
+ if (!kindPath) return;
354
+ this.visitedTopPaths.add(defaultPath);
355
+ removeAllPropsExcept(kindPath, kindProps);
356
+ if (declaratorPath && !declaratorPath.isImportSpecifier()) removeAllPropAssignsExcept(getPropertyAssignmentPaths(getIdentifiers([declaratorPath])).entries(), kindProps);
357
+ },
358
+
359
+ ExportAllDeclaration(allPath) {
360
+ const request = allPath.get('source').node.value;
361
+ this.reexportedStories.set(this.resourcePath, (this.reexportedStories.get(this.resourcePath) ?? new Set()).add(request));
362
+ this.visitedTopPaths.add(allPath);
363
+ },
364
+
365
+ ExportNamedDeclaration(namedPath) {
366
+ this.visitedTopPaths.add(namedPath);
367
+ const declarationPath = namedPath.get('declaration');
368
+ let storyFnPropAssigns = new Map();
369
+
370
+ if (declarationPath.isVariableDeclaration()) {
371
+ const declarations = declarationPath.get('declarations');
372
+ declarations.map(x => x.get('init')).forEach(initPath => removeAllExpressionPropsExcept(initPath, storyProps));
373
+ storyFnPropAssigns = getPropertyAssignmentPaths(getIdentifiers(declarations));
374
+ } else if (declarationPath.isFunctionDeclaration()) {
375
+ replaceStoryFnToNoop(declarationPath);
376
+ storyFnPropAssigns = getPropertyAssignmentPaths(getIdentifiers([declarationPath]));
377
+ }
378
+
379
+ removeAllPropAssignsExcept(storyFnPropAssigns.entries(), storyProps);
380
+ },
381
+
382
+ CallExpression(rootCallPath) {
383
+ const rootPath = findRootPath(rootCallPath);
384
+ if (!rootCallPath.get('callee').isIdentifier({
385
+ name: 'storiesOf'
386
+ })) return;
387
+ if (rootPath) this.visitedTopPaths.add(rootPath);
388
+
389
+ if (rootPath !== null && rootPath !== void 0 && rootPath.isVariableDeclaration()) {
390
+ var _rootPath$get$find;
391
+
392
+ 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');
393
+
394
+ if (storiesIdPath !== null && storiesIdPath !== void 0 && storiesIdPath.isIdentifier()) {
395
+ var _storiesIdPath$scope$;
396
+
397
+ (((_storiesIdPath$scope$ = storiesIdPath.scope.getBinding(storiesIdPath.node.name)) === null || _storiesIdPath$scope$ === void 0 ? void 0 : _storiesIdPath$scope$.referencePaths) ?? []).forEach(cleanUpStoriesOfCallChain);
398
+ }
399
+ }
400
+
401
+ cleanUpStoriesOfCallChain(rootCallPath);
402
+ },
403
+
404
+ Identifier(identifierPath) {
405
+ if (isExports(identifierPath)) {
406
+ const rootPath = findRootPath(identifierPath);
407
+ if (rootPath) this.visitedTopPaths.add(rootPath);
408
+ const [assignmentPath, props] = getAssignmentPathWithProps(identifierPath) ?? [];
409
+
410
+ if (assignmentPath && props) {
411
+ if (props.length == 1 && props[0] != 'default') {
412
+ const declaratorPath = getDeclaratorPath(assignmentPath.get('right'));
413
+
414
+ if (declaratorPath && !declaratorPath.isImportSpecifier()) {
415
+ removeAllPropAssignsExcept(getPropertyAssignmentPaths(getIdentifiers([declaratorPath])).entries(), storyProps);
416
+ } else {
417
+ const rightPath = assignmentPath.get('right');
418
+
419
+ if (isObjectAssign(rightPath)) {
420
+ rightPath.get('arguments').forEach(argumentPath => removeAllExpressionPropsExcept(argumentPath, storyProps));
421
+ } else rightPath.replaceWith(t.arrowFunctionExpression([], t.blockStatement([])));
422
+ }
423
+ } else removeAllPropAssignsExcept(new Map([[assignmentPath, props]]).entries(), exportsProps);
424
+ }
425
+ }
426
+
427
+ if (isModuleExports(identifierPath)) {
428
+ const rootPath = findRootPath(identifierPath);
429
+ if (rootPath) this.visitedTopPaths.add(rootPath);
430
+ const [assignmentPath, props] = getAssignmentPathWithProps(identifierPath) ?? [];
431
+
432
+ if (assignmentPath && props) {
433
+ if (props.length == 1 && props[0] == 'exports') {
434
+ removeAllExpressionPropsExcept(assignmentPath.get('right'), exportsProps);
435
+ } else if (props.length == 2 && props[0] == 'exports' && props[1] != 'default') {
436
+ const declaratorPath = getDeclaratorPath(assignmentPath.get('right'));
437
+
438
+ if (declaratorPath && !declaratorPath.isImportSpecifier()) {
439
+ removeAllPropAssignsExcept(getPropertyAssignmentPaths(getIdentifiers([declaratorPath])).entries(), storyProps);
440
+ } else {
441
+ const rightPath = assignmentPath.get('right');
442
+
443
+ if (isObjectAssign(rightPath)) {
444
+ rightPath.get('arguments').forEach(argumentPath => removeAllExpressionPropsExcept(argumentPath, storyProps));
445
+ } else rightPath.replaceWith(t.arrowFunctionExpression([], t.blockStatement([])));
446
+ }
447
+ } else removeAllPropAssignsExcept(new Map([[assignmentPath, props]]).entries(), [['exports', ...exportsProps]]);
448
+ }
449
+ }
450
+ }
451
+
452
+ };
@@ -0,0 +1,103 @@
1
+ import Module from 'module';
2
+ import fs from 'fs';
3
+ import { isAbsolute, join, relative, resolve } from 'path';
4
+ import { addHook } from 'pirates';
5
+ import { isDefined } from '../../../types';
6
+ import { extensions } from '../../utils';
7
+ import plugin from './creevey-plugin';
8
+ import { hasDocsAddon, hasSvelteCSFAddon } from '../../storybook/helpers';
9
+ let parents = null;
10
+ let story = null; //@ts-expect-error private field doesn't have types
11
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
12
+
13
+ const jsLoader = Module._extensions['.js']; //@ts-expect-error private field doesn't have types
14
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
15
+
16
+ Module._extensions['.js'] = function (mod, filename) {
17
+ parents = Object.values(require.cache).filter(m => m === null || m === void 0 ? void 0 : m.children.includes(mod)).filter(isDefined).map(m => m.filename); // eslint-disable-next-line @typescript-eslint/no-unsafe-call
18
+
19
+ jsLoader(mod, filename);
20
+ parents = null;
21
+ };
22
+
23
+ addHook(() => '', {
24
+ exts: ['.jpg', '.jpeg', '.png', '.gif', '.eot', '.otf', '.svg', '.ttf', '.woff', '.woff2', '.css', '.less', '.scss', '.styl'],
25
+ ignoreNodeModules: false
26
+ });
27
+
28
+ function getRequireContext(rootDir) {
29
+ return function requireContext(rootPath, deep, filter) {
30
+ const ids = [];
31
+ let contextPath; // Relative path
32
+
33
+ if (rootPath.startsWith('.')) contextPath = resolve(rootDir, rootPath); // Module path
34
+ else if (!isAbsolute(rootPath)) contextPath = require.resolve(rootPath); // Absolute path
35
+ else contextPath = rootPath;
36
+
37
+ const traverse = dirPath => {
38
+ fs.readdirSync(dirPath, {
39
+ withFileTypes: true
40
+ }).forEach(dirent => {
41
+ const filename = dirent.name;
42
+ const filePath = join(dirPath, filename);
43
+ if (dirent.isDirectory() && deep) return traverse(filePath);
44
+ if (dirent.isFile() && ((filter === null || filter === void 0 ? void 0 : filter.test(`./${relative(contextPath, filePath)}`)) ?? true)) return ids.push(filePath);
45
+ });
46
+ };
47
+
48
+ traverse(contextPath);
49
+
50
+ const context = id => {
51
+ story = id; // eslint-disable-next-line @typescript-eslint/no-var-requires
52
+
53
+ const storyModule = require(id);
54
+
55
+ story = null;
56
+ return storyModule;
57
+ };
58
+
59
+ context.id = contextPath;
60
+
61
+ context.keys = () => ids;
62
+
63
+ context.resolve = id => id;
64
+
65
+ return context;
66
+ };
67
+ }
68
+
69
+ export default async function register(config, debug = false) {
70
+ const rootDir = process.cwd();
71
+ const requireContext = getRequireContext(rootDir);
72
+ const preview = resolve(config.storybookDir, 'preview');
73
+ if (hasDocsAddon()) await (await import('../hooks/mdx')).addMDXHook(() => story);
74
+ if (hasSvelteCSFAddon()) await (await import('../hooks/svelte')).addSvelteHook(() => story); // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
75
+
76
+ (await import('@babel/register')).default(config.babelOptions({
77
+ babelrc: false,
78
+ rootMode: 'upward-optional',
79
+ ignore: [/node_modules/],
80
+ extensions: [...extensions, ...(hasDocsAddon() ? ['.mdx'] : []), ...(hasSvelteCSFAddon() ? ['.svelte'] : [])],
81
+ parserOpts: {
82
+ sourceType: 'module',
83
+ plugins: ['classProperties', 'decorators-legacy', 'jsx', 'typescript']
84
+ },
85
+ plugins: [[plugin, {
86
+ debug,
87
+ preview,
88
+ parents: () => parents,
89
+ story: () => story
90
+ }], ['@babel/plugin-transform-runtime', {
91
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
92
+ version: require('@babel/helpers/package.json').version,
93
+ absoluteRuntime: true,
94
+ corejs: 3
95
+ }]],
96
+ presets: [['@babel/preset-env', {
97
+ targets: {
98
+ node: '10'
99
+ }
100
+ }]]
101
+ }));
102
+ return requireContext;
103
+ }