creevey 0.9.0-beta.1 → 0.9.0-non-webpack.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 (267) hide show
  1. package/AUTHORS +15 -15
  2. package/CHANGELOG.md +1275 -1275
  3. package/LICENSE +21 -21
  4. package/README.md +7 -0
  5. package/addon/README.md +3 -0
  6. package/addon/package.json +4 -0
  7. package/docs/config.md +212 -212
  8. package/docs/grid.md +10 -10
  9. package/docs/tests.md +63 -63
  10. package/jest.config.js +6 -0
  11. package/lib/cjs/cli.js +5 -0
  12. package/lib/cjs/client/addon/Manager.js +418 -0
  13. package/lib/cjs/client/addon/components/Addon.js +76 -0
  14. package/lib/cjs/client/addon/components/Icons.js +42 -0
  15. package/lib/cjs/client/addon/components/Panel.js +68 -0
  16. package/lib/cjs/client/addon/components/TestSelect.js +63 -0
  17. package/lib/cjs/client/addon/components/Tools.js +114 -0
  18. package/lib/cjs/client/addon/decorator.js +11 -0
  19. package/lib/cjs/client/addon/index.js +31 -0
  20. package/lib/cjs/client/addon/preset.js +81 -0
  21. package/lib/cjs/client/addon/readyForCapture.js +12 -0
  22. package/lib/cjs/client/addon/register.js +100 -0
  23. package/lib/cjs/client/addon/utils.js +38 -0
  24. package/lib/cjs/client/addon/withCreevey.js +558 -0
  25. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +85 -0
  26. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +88 -0
  27. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +176 -0
  28. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +179 -0
  29. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +110 -0
  30. package/lib/cjs/client/shared/components/ImagesView/index.js +45 -0
  31. package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +46 -0
  32. package/lib/cjs/client/shared/components/PageFooter/Paging.js +98 -0
  33. package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +78 -0
  34. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +144 -0
  35. package/lib/cjs/client/shared/components/ResultsPage.js +173 -0
  36. package/lib/cjs/client/shared/creeveyClientApi.js +107 -0
  37. package/lib/cjs/client/shared/helpers.js +482 -0
  38. package/lib/cjs/client/shared/viewMode.js +17 -0
  39. package/lib/cjs/client/web/142.js +2 -0
  40. package/lib/cjs/client/web/142.js.LICENSE.txt +12 -0
  41. package/lib/cjs/client/web/32.js +1 -0
  42. package/lib/cjs/client/web/551.js +1 -0
  43. package/lib/cjs/client/web/566.js +2 -0
  44. package/lib/cjs/client/web/566.js.LICENSE.txt +31 -0
  45. package/lib/cjs/client/web/691.js +2 -0
  46. package/lib/cjs/client/web/691.js.LICENSE.txt +8 -0
  47. package/lib/cjs/client/web/725.js +1 -0
  48. package/lib/cjs/client/web/index.html +19 -0
  49. package/lib/cjs/client/web/main.js +2 -38
  50. package/lib/cjs/client/web/main.js.LICENSE.txt +49 -0
  51. package/lib/cjs/creevey.js +69 -0
  52. package/lib/cjs/index.js +62 -0
  53. package/lib/cjs/server/config.js +96 -0
  54. package/lib/cjs/server/docker.js +146 -0
  55. package/lib/cjs/server/extract.js +50 -0
  56. package/lib/cjs/server/index.js +83 -0
  57. package/lib/cjs/server/loaders/babel/creevey-plugin.js +86 -0
  58. package/lib/cjs/server/loaders/babel/helpers.js +469 -0
  59. package/lib/cjs/server/loaders/babel/register.js +124 -0
  60. package/lib/cjs/server/loaders/hooks/mdx.js +30 -0
  61. package/lib/cjs/server/loaders/hooks/svelte.js +65 -0
  62. package/lib/cjs/server/loaders/webpack/compile.js +293 -0
  63. package/lib/cjs/server/loaders/webpack/creevey-loader.js +179 -0
  64. package/lib/cjs/server/loaders/webpack/dummy-hmr.js +39 -0
  65. package/lib/cjs/server/loaders/webpack/mdx-loader.js +72 -0
  66. package/lib/cjs/server/loaders/webpack/start.js +41 -0
  67. package/lib/cjs/server/logger.js +48 -0
  68. package/lib/cjs/server/master/api.js +71 -0
  69. package/lib/cjs/server/master/index.js +146 -0
  70. package/lib/cjs/server/master/master.js +57 -0
  71. package/lib/cjs/server/master/pool.js +197 -0
  72. package/lib/cjs/server/master/runner.js +281 -0
  73. package/lib/cjs/server/master/server.js +129 -0
  74. package/lib/cjs/server/messages.js +264 -0
  75. package/lib/cjs/server/selenium/browser.js +672 -0
  76. package/lib/cjs/server/selenium/index.js +31 -0
  77. package/lib/cjs/server/selenium/selenoid.js +172 -0
  78. package/lib/cjs/server/stories.js +159 -0
  79. package/lib/cjs/server/storybook/entry.js +70 -0
  80. package/lib/cjs/server/storybook/helpers.js +159 -0
  81. package/lib/cjs/server/storybook/providers/browser.js +74 -0
  82. package/lib/cjs/server/storybook/providers/hybrid.js +84 -0
  83. package/lib/cjs/server/storybook/providers/nodejs.js +239 -0
  84. package/lib/cjs/server/testsFiles/parser.js +72 -0
  85. package/lib/cjs/server/testsFiles/register.js +48 -0
  86. package/lib/cjs/server/update.js +79 -0
  87. package/lib/cjs/server/utils.js +183 -0
  88. package/lib/cjs/server/worker/chai-image.js +142 -0
  89. package/lib/cjs/server/worker/helpers.js +69 -0
  90. package/lib/cjs/server/worker/index.js +15 -0
  91. package/lib/cjs/server/worker/reporter.js +108 -0
  92. package/lib/cjs/server/worker/worker.js +268 -0
  93. package/lib/cjs/shared/index.js +89 -0
  94. package/lib/cjs/shared/serializeRegExp.js +41 -0
  95. package/lib/cjs/types.js +74 -0
  96. package/lib/esm/cli.js +4 -0
  97. package/lib/esm/client/addon/Manager.js +402 -0
  98. package/lib/esm/client/addon/components/Addon.js +58 -0
  99. package/lib/esm/client/addon/components/Icons.js +27 -0
  100. package/lib/esm/client/addon/components/Panel.js +49 -0
  101. package/lib/esm/client/addon/components/TestSelect.js +49 -0
  102. package/lib/esm/client/addon/components/Tools.js +91 -0
  103. package/lib/esm/client/addon/decorator.js +2 -0
  104. package/lib/esm/client/addon/index.js +2 -0
  105. package/lib/esm/client/addon/preset.js +56 -0
  106. package/lib/esm/client/addon/readyForCapture.js +5 -0
  107. package/lib/esm/client/addon/register.js +79 -0
  108. package/lib/esm/client/addon/utils.js +31 -0
  109. package/lib/esm/client/addon/withCreevey.js +534 -0
  110. package/lib/esm/client/shared/components/ImagesView/BlendView.js +63 -0
  111. package/lib/esm/client/shared/components/ImagesView/ImagesView.js +65 -0
  112. package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +151 -0
  113. package/lib/esm/client/shared/components/ImagesView/SlideView.js +154 -0
  114. package/lib/esm/client/shared/components/ImagesView/SwapView.js +88 -0
  115. package/lib/esm/client/shared/components/ImagesView/index.js +5 -0
  116. package/lib/esm/client/shared/components/PageFooter/PageFooter.js +32 -0
  117. package/lib/esm/client/shared/components/PageFooter/Paging.js +84 -0
  118. package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +64 -0
  119. package/lib/esm/client/shared/components/PageHeader/PageHeader.js +120 -0
  120. package/lib/esm/client/shared/components/ResultsPage.js +143 -0
  121. package/lib/esm/client/shared/creeveyClientApi.js +98 -0
  122. package/lib/esm/client/shared/helpers.js +424 -0
  123. package/lib/esm/client/shared/viewMode.js +6 -0
  124. package/lib/esm/creevey.js +54 -0
  125. package/lib/esm/index.js +5 -0
  126. package/lib/esm/server/config.js +73 -0
  127. package/lib/esm/server/docker.js +123 -0
  128. package/lib/esm/server/extract.js +34 -0
  129. package/lib/esm/server/index.js +64 -0
  130. package/lib/esm/server/loaders/babel/creevey-plugin.js +72 -0
  131. package/lib/esm/server/loaders/babel/helpers.js +452 -0
  132. package/lib/esm/server/loaders/babel/register.js +103 -0
  133. package/lib/esm/server/loaders/hooks/mdx.js +15 -0
  134. package/lib/esm/server/loaders/hooks/svelte.js +49 -0
  135. package/lib/esm/server/loaders/webpack/compile.js +270 -0
  136. package/lib/esm/server/loaders/webpack/creevey-loader.js +158 -0
  137. package/lib/esm/server/loaders/webpack/dummy-hmr.js +32 -0
  138. package/lib/esm/server/loaders/webpack/mdx-loader.js +58 -0
  139. package/lib/esm/server/loaders/webpack/start.js +27 -0
  140. package/lib/esm/server/logger.js +20 -0
  141. package/lib/esm/server/master/api.js +60 -0
  142. package/lib/esm/server/master/index.js +125 -0
  143. package/lib/esm/server/master/master.js +38 -0
  144. package/lib/esm/server/master/pool.js +176 -0
  145. package/lib/esm/server/master/runner.js +259 -0
  146. package/lib/esm/server/master/server.js +105 -0
  147. package/lib/esm/server/messages.js +232 -0
  148. package/lib/esm/server/selenium/browser.js +639 -0
  149. package/lib/esm/server/selenium/index.js +2 -0
  150. package/lib/esm/server/selenium/selenoid.js +149 -0
  151. package/lib/esm/server/stories.js +140 -0
  152. package/lib/esm/server/storybook/entry.js +46 -0
  153. package/lib/esm/server/storybook/helpers.js +98 -0
  154. package/lib/esm/server/storybook/providers/browser.js +60 -0
  155. package/lib/esm/server/storybook/providers/hybrid.js +64 -0
  156. package/lib/esm/server/storybook/providers/nodejs.js +217 -0
  157. package/lib/esm/server/testsFiles/parser.js +50 -0
  158. package/lib/esm/server/testsFiles/register.js +35 -0
  159. package/lib/esm/server/update.js +61 -0
  160. package/lib/esm/server/utils.js +142 -0
  161. package/lib/esm/server/worker/chai-image.js +130 -0
  162. package/lib/esm/server/worker/helpers.js +60 -0
  163. package/lib/esm/server/worker/index.js +1 -0
  164. package/lib/esm/server/worker/reporter.js +86 -0
  165. package/lib/esm/server/worker/worker.js +238 -0
  166. package/lib/esm/shared/index.js +66 -0
  167. package/lib/esm/shared/serializeRegExp.js +23 -0
  168. package/lib/esm/types.js +43 -0
  169. package/lib/types/cli.d.ts +1 -1
  170. package/lib/types/client/addon/Manager.d.ts +37 -37
  171. package/lib/types/client/addon/components/Addon.d.ts +8 -8
  172. package/lib/types/client/addon/components/Icons.d.ts +7 -7
  173. package/lib/types/client/addon/components/Panel.d.ts +9 -9
  174. package/lib/types/client/addon/components/TestSelect.d.ts +8 -9
  175. package/lib/types/client/addon/components/Tools.d.ts +6 -6
  176. package/lib/types/client/addon/decorator.d.ts +1 -1
  177. package/lib/types/client/addon/index.d.ts +2 -0
  178. package/lib/types/client/addon/preset.d.ts +23 -24
  179. package/lib/types/client/addon/readyForCapture.d.ts +6 -6
  180. package/lib/types/client/addon/register.d.ts +3 -3
  181. package/lib/types/client/addon/utils.d.ts +2 -2
  182. package/lib/types/client/addon/withCreevey.d.ts +24 -24
  183. package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +3 -3
  184. package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +24 -25
  185. package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +3 -3
  186. package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +3 -3
  187. package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +3 -3
  188. package/lib/types/client/shared/components/ImagesView/index.d.ts +5 -5
  189. package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +8 -9
  190. package/lib/types/client/shared/components/PageFooter/Paging.d.ts +7 -8
  191. package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +12 -12
  192. package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +16 -17
  193. package/lib/types/client/shared/components/ResultsPage.d.ts +18 -18
  194. package/lib/types/client/shared/creeveyClientApi.d.ts +9 -9
  195. package/lib/types/client/shared/helpers.d.ts +46 -46
  196. package/lib/types/client/shared/viewMode.d.ts +4 -4
  197. package/lib/types/client/web/CreeveyApp.d.ts +11 -12
  198. package/lib/types/client/web/CreeveyContext.d.ts +11 -11
  199. package/lib/types/client/web/CreeveyLoader.d.ts +2 -3
  200. package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +19 -19
  201. package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +6 -6
  202. package/lib/types/client/web/CreeveyView/SideBar/SideBar.d.ts +14 -14
  203. package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +12 -13
  204. package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +33 -33
  205. package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +7 -8
  206. package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +10 -10
  207. package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +9 -9
  208. package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +6 -6
  209. package/lib/types/client/web/CreeveyView/SideBar/index.d.ts +1 -1
  210. package/lib/types/client/web/KeyboardEventsContext.d.ts +13 -13
  211. package/lib/types/client/web/index.d.ts +4 -4
  212. package/lib/types/creevey.d.ts +1 -1
  213. package/lib/types/index.d.ts +1 -4
  214. package/lib/types/server/config.d.ts +4 -4
  215. package/lib/types/server/docker.d.ts +7 -7
  216. package/lib/types/server/extract.d.ts +2 -2
  217. package/lib/types/server/index.d.ts +2 -2
  218. package/lib/types/server/loaders/babel/creevey-plugin.d.ts +1 -1
  219. package/lib/types/server/loaders/babel/helpers.d.ts +19 -19
  220. package/lib/types/server/loaders/babel/register.d.ts +5 -5
  221. package/lib/types/server/loaders/hooks/mdx.d.ts +1 -1
  222. package/lib/types/server/loaders/hooks/svelte.d.ts +1 -1
  223. package/lib/types/server/loaders/webpack/compile.d.ts +2 -2
  224. package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -2
  225. package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +10 -10
  226. package/lib/types/server/loaders/webpack/mdx-loader.d.ts +6 -6
  227. package/lib/types/server/loaders/webpack/start.d.ts +1 -1
  228. package/lib/types/server/logger.d.ts +10 -6
  229. package/lib/types/server/master/api.d.ts +7 -7
  230. package/lib/types/server/master/index.d.ts +3 -3
  231. package/lib/types/server/master/master.d.ts +7 -7
  232. package/lib/types/server/master/pool.d.ts +31 -31
  233. package/lib/types/server/master/runner.d.ts +26 -26
  234. package/lib/types/server/master/server.d.ts +2 -2
  235. package/lib/types/server/messages.d.ts +27 -27
  236. package/lib/types/server/selenium/browser.d.ts +17 -17
  237. package/lib/types/server/selenium/index.d.ts +2 -2
  238. package/lib/types/server/selenium/selenoid.d.ts +3 -3
  239. package/lib/types/server/stories.d.ts +8 -8
  240. package/lib/types/server/storybook/entry.d.ts +18 -18
  241. package/lib/types/server/storybook/helpers.d.ts +24 -24
  242. package/lib/types/server/storybook/providers/browser.d.ts +4 -4
  243. package/lib/types/server/storybook/providers/hybrid.d.ts +4 -4
  244. package/lib/types/server/storybook/providers/nodejs.d.ts +9 -9
  245. package/lib/types/server/testsFiles/parser.d.ts +12 -12
  246. package/lib/types/server/testsFiles/register.d.ts +2 -2
  247. package/lib/types/server/update.d.ts +2 -2
  248. package/lib/types/server/utils.d.ts +20 -20
  249. package/lib/types/server/worker/chai-image.d.ts +6 -6
  250. package/lib/types/server/worker/helpers.d.ts +8 -8
  251. package/lib/types/server/worker/index.d.ts +1 -1
  252. package/lib/types/server/worker/reporter.d.ts +8 -8
  253. package/lib/types/server/worker/worker.d.ts +4 -4
  254. package/lib/types/{shared.d.ts → shared/index.d.ts} +7 -16
  255. package/lib/types/shared/serializeRegExp.d.ts +9 -0
  256. package/lib/types/types.d.ts +490 -489
  257. package/package.json +115 -102
  258. package/preset.js +9 -9
  259. package/types/babel__register.d.ts +1 -1
  260. package/types/chai.d.ts +12 -12
  261. package/types/event-source-polyfill.d.ts +6 -6
  262. package/types/mdx.d.ts +3 -2
  263. package/types/mocha.d.ts +20 -20
  264. package/types/png.d.ts +4 -4
  265. package/lib/cjs/client/web/1.js +0 -13
  266. package/lib/cjs/client/web/2.js +0 -1
  267. package/storybook-static/stories.json +0 -21
@@ -0,0 +1,34 @@
1
+ import { denormalizeStoryParameters } from '../shared';
2
+ import { subscribeOn } from './messages';
3
+ import { loadTestsFromStories, saveStoriesJson, saveTestsJson } from './stories';
4
+ import { isStorybookVersionGreaterThan, isStorybookVersionLessThan } from './storybook/helpers';
5
+ import { extractStoriesData } from './storybook/providers/nodejs';
6
+ export default async function extract(config, options) {
7
+ if (config.useWebpackToExtractTests && process.env.__CREEVEY_ENV__ != 'test') {
8
+ await new Promise((resolve, reject) => {
9
+ subscribeOn('webpack', message => {
10
+ switch (message.type) {
11
+ case 'success':
12
+ return resolve();
13
+
14
+ case 'fail':
15
+ return reject();
16
+ }
17
+ });
18
+ void (async () => (await import('./loaders/webpack/compile')).default(config, options))();
19
+ });
20
+ }
21
+
22
+ const tests = await loadTestsFromStories(Object.keys(config.browsers), async () => {
23
+ const data = await extractStoriesData(config, {
24
+ watch: false,
25
+ debug: options.debug
26
+ });
27
+ const stories = isStorybookVersionLessThan(6) || isStorybookVersionGreaterThan(6, 3) ? data.stories : denormalizeStoryParameters(data);
28
+ if (options.extract) saveStoriesJson(data, options.extract);
29
+ return stories;
30
+ });
31
+ if (options.tests) saveTestsJson(tests); // eslint-disable-next-line no-process-exit
32
+
33
+ process.exit(0);
34
+ }
@@ -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
+ };