@servicetitan/startup 37.0.2 → 38.1.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 (433) hide show
  1. package/bin/js-yaml.js +2 -2
  2. package/dist/cli/commands/build.d.ts.map +1 -1
  3. package/dist/cli/commands/build.js +22 -9
  4. package/dist/cli/commands/build.js.map +1 -1
  5. package/dist/cli/commands/bundle-package.d.ts +6 -0
  6. package/dist/cli/commands/bundle-package.d.ts.map +1 -0
  7. package/dist/cli/commands/bundle-package.js +59 -0
  8. package/dist/cli/commands/bundle-package.js.map +1 -0
  9. package/dist/cli/commands/bundle-vite.js +13 -4
  10. package/dist/cli/commands/bundle-vite.js.map +1 -1
  11. package/dist/cli/commands/bundle-webpack.js +13 -4
  12. package/dist/cli/commands/bundle-webpack.js.map +1 -1
  13. package/dist/cli/commands/clean.js +13 -4
  14. package/dist/cli/commands/clean.js.map +1 -1
  15. package/dist/cli/commands/command.d.ts +9 -0
  16. package/dist/cli/commands/command.d.ts.map +1 -0
  17. package/dist/cli/commands/command.js +35 -0
  18. package/dist/cli/commands/command.js.map +1 -0
  19. package/dist/cli/commands/convert-eslint-config.js +14 -7
  20. package/dist/cli/commands/convert-eslint-config.js.map +1 -1
  21. package/dist/cli/commands/eslint.js +13 -4
  22. package/dist/cli/commands/eslint.js.map +1 -1
  23. package/dist/cli/commands/init.js +13 -4
  24. package/dist/cli/commands/init.js.map +1 -1
  25. package/dist/cli/commands/install.js +13 -4
  26. package/dist/cli/commands/install.js.map +1 -1
  27. package/dist/cli/commands/kendo-ui-license.js +13 -4
  28. package/dist/cli/commands/kendo-ui-license.js.map +1 -1
  29. package/dist/cli/commands/lint.js +13 -4
  30. package/dist/cli/commands/lint.js.map +1 -1
  31. package/dist/cli/commands/mfe-check.d.ts.map +1 -1
  32. package/dist/cli/commands/mfe-check.js +15 -7
  33. package/dist/cli/commands/mfe-check.js.map +1 -1
  34. package/dist/cli/commands/mfe-generate-metadata.js +13 -4
  35. package/dist/cli/commands/mfe-generate-metadata.js.map +1 -1
  36. package/dist/cli/commands/mfe-list.js +13 -4
  37. package/dist/cli/commands/mfe-list.js.map +1 -1
  38. package/dist/cli/commands/mfe-package-clean.js +13 -4
  39. package/dist/cli/commands/mfe-package-clean.js.map +1 -1
  40. package/dist/cli/commands/mfe-package-publish.js +13 -4
  41. package/dist/cli/commands/mfe-package-publish.js.map +1 -1
  42. package/dist/cli/commands/mfe-package-rollback.js +13 -4
  43. package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
  44. package/dist/cli/commands/mfe-publish.js +13 -4
  45. package/dist/cli/commands/mfe-publish.js.map +1 -1
  46. package/dist/cli/commands/mfe-purge-cache.js +13 -4
  47. package/dist/cli/commands/mfe-purge-cache.js.map +1 -1
  48. package/dist/cli/commands/prepare-package.js +13 -4
  49. package/dist/cli/commands/prepare-package.js.map +1 -1
  50. package/dist/cli/commands/registry/build.d.ts +1 -1
  51. package/dist/cli/commands/registry/build.d.ts.map +1 -1
  52. package/dist/cli/commands/registry/build.js +3 -5
  53. package/dist/cli/commands/registry/build.js.map +1 -1
  54. package/dist/cli/commands/registry/bundle-package.d.ts +41 -0
  55. package/dist/cli/commands/registry/bundle-package.d.ts.map +1 -0
  56. package/dist/cli/commands/registry/bundle-package.js +54 -0
  57. package/dist/cli/commands/registry/bundle-package.js.map +1 -0
  58. package/dist/cli/commands/registry/command-registry.d.ts +42 -2
  59. package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
  60. package/dist/cli/commands/registry/command-registry.js +10 -19
  61. package/dist/cli/commands/registry/command-registry.js.map +1 -1
  62. package/dist/cli/commands/registry/start.d.ts +1 -1
  63. package/dist/cli/commands/registry/start.d.ts.map +1 -1
  64. package/dist/cli/commands/registry/start.js +3 -5
  65. package/dist/cli/commands/registry/start.js.map +1 -1
  66. package/dist/cli/commands/review/review.js +14 -7
  67. package/dist/cli/commands/review/review.js.map +1 -1
  68. package/dist/cli/commands/review/rules/no-deprecated-content-base.js +1 -3
  69. package/dist/cli/commands/review/rules/no-deprecated-content-base.js.map +1 -1
  70. package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js +1 -3
  71. package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js.map +1 -1
  72. package/dist/cli/commands/review/rules/no-typescript-entry-point.js +1 -3
  73. package/dist/cli/commands/review/rules/no-typescript-entry-point.js.map +1 -1
  74. package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js +5 -12
  75. package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js.map +1 -1
  76. package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js +5 -12
  77. package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js.map +1 -1
  78. package/dist/cli/commands/review/rules/require-explicit-side-effects.js +1 -3
  79. package/dist/cli/commands/review/rules/require-explicit-side-effects.js.map +1 -1
  80. package/dist/cli/commands/review/rules/require-one-collection-version.js +1 -3
  81. package/dist/cli/commands/review/rules/require-one-collection-version.js.map +1 -1
  82. package/dist/cli/commands/review/rules/require-servicetitan-scope.js +1 -3
  83. package/dist/cli/commands/review/rules/require-servicetitan-scope.js.map +1 -1
  84. package/dist/cli/commands/review/rules/require-tsconfig-references.js +1 -3
  85. package/dist/cli/commands/review/rules/require-tsconfig-references.js.map +1 -1
  86. package/dist/cli/commands/review/types.d.ts.map +1 -1
  87. package/dist/cli/commands/review/types.js.map +1 -1
  88. package/dist/cli/commands/review/utils/compare-version.js +8 -19
  89. package/dist/cli/commands/review/utils/compare-version.js.map +1 -1
  90. package/dist/cli/commands/run-task.d.ts +1 -0
  91. package/dist/cli/commands/run-task.d.ts.map +1 -1
  92. package/dist/cli/commands/run-task.js +20 -6
  93. package/dist/cli/commands/run-task.js.map +1 -1
  94. package/dist/cli/commands/start.d.ts.map +1 -1
  95. package/dist/cli/commands/start.js +28 -13
  96. package/dist/cli/commands/start.js.map +1 -1
  97. package/dist/cli/commands/stylelint.js +13 -4
  98. package/dist/cli/commands/stylelint.js.map +1 -1
  99. package/dist/cli/commands/styles-check.js +13 -4
  100. package/dist/cli/commands/styles-check.js.map +1 -1
  101. package/dist/cli/commands/test/runners/jest.js +1 -3
  102. package/dist/cli/commands/test/runners/jest.js.map +1 -1
  103. package/dist/cli/commands/test/tests.js +13 -4
  104. package/dist/cli/commands/test/tests.js.map +1 -1
  105. package/dist/cli/commands/types.d.ts +1 -6
  106. package/dist/cli/commands/types.d.ts.map +1 -1
  107. package/dist/cli/commands/types.js +2 -20
  108. package/dist/cli/commands/types.js.map +1 -1
  109. package/dist/cli/commands/upload-sourcemaps.js +17 -13
  110. package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
  111. package/dist/cli/index.js +1 -0
  112. package/dist/cli/index.js.map +1 -1
  113. package/dist/cli/tasks/cli-task.d.ts +3 -0
  114. package/dist/cli/tasks/cli-task.d.ts.map +1 -1
  115. package/dist/cli/tasks/cli-task.js +41 -9
  116. package/dist/cli/tasks/cli-task.js.map +1 -1
  117. package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts +9 -1
  118. package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts.map +1 -1
  119. package/dist/cli/tasks/swc-compile-package/get-swc-options.js +18 -2
  120. package/dist/cli/tasks/swc-compile-package/get-swc-options.js.map +1 -1
  121. package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts +3 -1
  122. package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts.map +1 -1
  123. package/dist/cli/tasks/swc-compile-package/swc-compile-package.js +17 -3
  124. package/dist/cli/tasks/swc-compile-package/swc-compile-package.js.map +1 -1
  125. package/dist/cli/tasks/task.d.ts +2 -1
  126. package/dist/cli/tasks/task.d.ts.map +1 -1
  127. package/dist/cli/tasks/task.js +6 -3
  128. package/dist/cli/tasks/task.js.map +1 -1
  129. package/dist/cli/tasks/tsc-compile/tsc-compile.js +1 -3
  130. package/dist/cli/tasks/tsc-compile/tsc-compile.js.map +1 -1
  131. package/dist/cli/utils/cli-npm.d.ts.map +1 -1
  132. package/dist/cli/utils/cli-npm.js +8 -1
  133. package/dist/cli/utils/cli-npm.js.map +1 -1
  134. package/dist/cli/utils/cli-os.d.ts +1 -0
  135. package/dist/cli/utils/cli-os.d.ts.map +1 -1
  136. package/dist/cli/utils/cli-os.js +20 -0
  137. package/dist/cli/utils/cli-os.js.map +1 -1
  138. package/dist/cli/utils/compile.d.ts.map +1 -1
  139. package/dist/cli/utils/compile.js +7 -4
  140. package/dist/cli/utils/compile.js.map +1 -1
  141. package/dist/cli/utils/copy-files.js +1 -0
  142. package/dist/cli/utils/copy-files.js.map +1 -1
  143. package/dist/cli/utils/index.d.ts +1 -1
  144. package/dist/cli/utils/index.d.ts.map +1 -1
  145. package/dist/cli/utils/index.js +1 -1
  146. package/dist/cli/utils/index.js.map +1 -1
  147. package/dist/cli/utils/process-tree.js +2 -6
  148. package/dist/cli/utils/process-tree.js.map +1 -1
  149. package/dist/cli/utils/resolve-bundler.d.ts.map +1 -1
  150. package/dist/cli/utils/resolve-bundler.js +2 -1
  151. package/dist/cli/utils/resolve-bundler.js.map +1 -1
  152. package/dist/cli/utils/ts-config.d.ts +1 -1
  153. package/dist/cli/utils/ts-config.d.ts.map +1 -1
  154. package/dist/cli/utils/ts-config.js +1 -3
  155. package/dist/cli/utils/ts-config.js.map +1 -1
  156. package/dist/cli/utils/with-exponential-backoff.d.ts +7 -0
  157. package/dist/cli/utils/with-exponential-backoff.d.ts.map +1 -0
  158. package/dist/cli/utils/with-exponential-backoff.js +28 -0
  159. package/dist/cli/utils/with-exponential-backoff.js.map +1 -0
  160. package/dist/core/constants.d.ts +2 -0
  161. package/dist/core/constants.d.ts.map +1 -1
  162. package/dist/core/constants.js +6 -1
  163. package/dist/core/constants.js.map +1 -1
  164. package/dist/cypress/config/vite-config.d.ts.map +1 -1
  165. package/dist/cypress/config/vite-config.js +23 -3
  166. package/dist/cypress/config/vite-config.js.map +1 -1
  167. package/dist/cypress/config/webpack-config.d.ts.map +1 -1
  168. package/dist/cypress/config/webpack-config.js +5 -0
  169. package/dist/cypress/config/webpack-config.js.map +1 -1
  170. package/dist/postinstall.js +118 -0
  171. package/dist/scripts/generate-bin-wrappers.js +203 -0
  172. package/dist/storybook-config/swc.d.ts +6 -0
  173. package/dist/storybook-config/swc.d.ts.map +1 -1
  174. package/dist/storybook-config/vite-final.d.ts.map +1 -1
  175. package/dist/storybook-config/vite-final.js +32 -6
  176. package/dist/storybook-config/vite-final.js.map +1 -1
  177. package/dist/storybook-config/webpack-final.d.ts.map +1 -1
  178. package/dist/storybook-config/webpack-final.js +3 -1
  179. package/dist/storybook-config/webpack-final.js.map +1 -1
  180. package/dist/utils/exit-when-parent-exits.d.ts +6 -0
  181. package/dist/utils/exit-when-parent-exits.d.ts.map +1 -0
  182. package/dist/utils/exit-when-parent-exits.js +37 -0
  183. package/dist/utils/exit-when-parent-exits.js.map +1 -0
  184. package/dist/utils/find-up.d.ts +1 -1
  185. package/dist/utils/find-up.d.ts.map +1 -1
  186. package/dist/utils/find-up.js +2 -2
  187. package/dist/utils/find-up.js.map +1 -1
  188. package/dist/utils/get-configuration.d.ts +6 -3
  189. package/dist/utils/get-configuration.d.ts.map +1 -1
  190. package/dist/utils/get-configuration.js +10 -2
  191. package/dist/utils/get-configuration.js.map +1 -1
  192. package/dist/utils/index.d.ts +1 -0
  193. package/dist/utils/index.d.ts.map +1 -1
  194. package/dist/utils/index.js +1 -0
  195. package/dist/utils/index.js.map +1 -1
  196. package/dist/utils/log.js +1 -3
  197. package/dist/utils/log.js.map +1 -1
  198. package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
  199. package/dist/vite/build-shared-dependencies.js +2 -0
  200. package/dist/vite/build-shared-dependencies.js.map +1 -1
  201. package/dist/vite/config/base-config.d.ts.map +1 -1
  202. package/dist/vite/config/base-config.js +14 -1
  203. package/dist/vite/config/base-config.js.map +1 -1
  204. package/dist/vite/config/create-filtering-logger.d.ts.map +1 -1
  205. package/dist/vite/config/create-filtering-logger.js +12 -1
  206. package/dist/vite/config/create-filtering-logger.js.map +1 -1
  207. package/dist/vite/config/create-vite-build-context.d.ts.map +1 -1
  208. package/dist/vite/config/create-vite-build-context.js +4 -1
  209. package/dist/vite/config/create-vite-build-context.js.map +1 -1
  210. package/dist/vite/config/create-vite-config.js +7 -2
  211. package/dist/vite/config/create-vite-config.js.map +1 -1
  212. package/dist/vite/config/load-config-file.js +8 -19
  213. package/dist/vite/config/load-config-file.js.map +1 -1
  214. package/dist/vite/index.d.ts +2 -0
  215. package/dist/vite/index.d.ts.map +1 -1
  216. package/dist/vite/index.html +2 -2
  217. package/dist/vite/index.js +16 -0
  218. package/dist/vite/index.js.map +1 -1
  219. package/dist/vite/plugins/chain-source-maps-plugin.js +1 -1
  220. package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -1
  221. package/dist/vite/plugins/clean-plugin.js +1 -1
  222. package/dist/vite/plugins/clean-plugin.js.map +1 -1
  223. package/dist/vite/plugins/css-injector-plugin.js +1 -1
  224. package/dist/vite/plugins/css-injector-plugin.js.map +1 -1
  225. package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -1
  226. package/dist/vite/plugins/design-system-guard-plugin.js +10 -5
  227. package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -1
  228. package/dist/vite/plugins/dev-server-routing-plugin.d.ts +1 -1
  229. package/dist/vite/plugins/dev-server-routing-plugin.d.ts.map +1 -1
  230. package/dist/vite/plugins/dev-server-routing-plugin.js +4 -3
  231. package/dist/vite/plugins/dev-server-routing-plugin.js.map +1 -1
  232. package/dist/vite/plugins/externals-plugin.d.ts.map +1 -1
  233. package/dist/vite/plugins/externals-plugin.js +11 -5
  234. package/dist/vite/plugins/externals-plugin.js.map +1 -1
  235. package/dist/vite/plugins/html-plugin.d.ts.map +1 -1
  236. package/dist/vite/plugins/html-plugin.js +5 -3
  237. package/dist/vite/plugins/html-plugin.js.map +1 -1
  238. package/dist/vite/plugins/ignore-modules-plugin.d.ts +2 -2
  239. package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
  240. package/dist/vite/plugins/ignore-modules-plugin.js +36 -24
  241. package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
  242. package/dist/vite/plugins/index.d.ts +3 -0
  243. package/dist/vite/plugins/index.d.ts.map +1 -1
  244. package/dist/vite/plugins/index.js +3 -0
  245. package/dist/vite/plugins/index.js.map +1 -1
  246. package/dist/vite/plugins/istanbul-plugin.d.ts.map +1 -1
  247. package/dist/vite/plugins/istanbul-plugin.js +33 -1
  248. package/dist/vite/plugins/istanbul-plugin.js.map +1 -1
  249. package/dist/vite/plugins/less-tilde-plugin.d.ts +8 -0
  250. package/dist/vite/plugins/less-tilde-plugin.d.ts.map +1 -0
  251. package/dist/vite/plugins/less-tilde-plugin.js +53 -0
  252. package/dist/vite/plugins/less-tilde-plugin.js.map +1 -0
  253. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +1 -1
  254. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -1
  255. package/dist/vite/plugins/metadata-plugin.js +1 -1
  256. package/dist/vite/plugins/metadata-plugin.js.map +1 -1
  257. package/dist/vite/plugins/moment-locales-plugin.d.ts +1 -1
  258. package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -1
  259. package/dist/vite/plugins/moment-locales-plugin.js +30 -14
  260. package/dist/vite/plugins/moment-locales-plugin.js.map +1 -1
  261. package/dist/vite/plugins/react-refresh-plugin/index.d.ts +2 -0
  262. package/dist/vite/plugins/react-refresh-plugin/index.d.ts.map +1 -0
  263. package/dist/vite/plugins/react-refresh-plugin/index.js +20 -0
  264. package/dist/vite/plugins/react-refresh-plugin/index.js.map +1 -0
  265. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts +4 -0
  266. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts.map +1 -0
  267. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js +143 -0
  268. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js.map +1 -0
  269. package/dist/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
  270. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -1
  271. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js +14 -11
  272. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -1
  273. package/dist/vite/plugins/style-urls-plugin.js +1 -1
  274. package/dist/vite/plugins/style-urls-plugin.js.map +1 -1
  275. package/dist/vite/plugins/virtual-modules-plugin.d.ts.map +1 -1
  276. package/dist/vite/plugins/virtual-modules-plugin.js +9 -6
  277. package/dist/vite/plugins/virtual-modules-plugin.js.map +1 -1
  278. package/dist/vite/plugins/window-externals-plugin.d.ts +22 -0
  279. package/dist/vite/plugins/window-externals-plugin.d.ts.map +1 -0
  280. package/dist/vite/plugins/window-externals-plugin.js +74 -0
  281. package/dist/vite/plugins/window-externals-plugin.js.map +1 -0
  282. package/dist/vite/types.d.ts +4 -1
  283. package/dist/vite/types.d.ts.map +1 -1
  284. package/dist/webpack/bundle-webpack.d.ts.map +1 -1
  285. package/dist/webpack/bundle-webpack.js +6 -1
  286. package/dist/webpack/bundle-webpack.js.map +1 -1
  287. package/dist/webpack/configs/optimization-config.js +4 -4
  288. package/dist/webpack/configs/optimization-config.js.map +1 -1
  289. package/dist/webpack/configs/output-config.js +1 -1
  290. package/dist/webpack/configs/output-config.js.map +1 -1
  291. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +1 -3
  292. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
  293. package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/configuration.expose-loader.js +13 -0
  294. package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/index.js +1 -0
  295. package/dist/webpack/utils/index.d.ts +1 -0
  296. package/dist/webpack/utils/index.d.ts.map +1 -1
  297. package/dist/webpack/utils/index.js +1 -0
  298. package/dist/webpack/utils/index.js.map +1 -1
  299. package/dist/webpack/utils/normalize-proxy-config.d.ts +6 -0
  300. package/dist/webpack/utils/normalize-proxy-config.d.ts.map +1 -0
  301. package/dist/webpack/utils/normalize-proxy-config.js +52 -0
  302. package/dist/webpack/utils/normalize-proxy-config.js.map +1 -0
  303. package/package.json +25 -22
  304. package/src/cli/commands/__tests__/build.test.ts +33 -19
  305. package/src/cli/commands/__tests__/bundle-package.test.ts +65 -0
  306. package/src/cli/commands/__tests__/bundle-vite.test.ts +1 -0
  307. package/src/cli/commands/__tests__/command.test.ts +42 -0
  308. package/src/cli/commands/__tests__/mfe-check.test.ts +26 -5
  309. package/src/cli/commands/__tests__/run-task.test.ts +20 -1
  310. package/src/cli/commands/__tests__/start.test.ts +35 -15
  311. package/src/cli/commands/build.ts +6 -5
  312. package/src/cli/commands/bundle-package.ts +20 -0
  313. package/src/cli/commands/command.ts +14 -0
  314. package/src/cli/commands/mfe-check.ts +6 -10
  315. package/src/cli/commands/registry/build.ts +3 -2
  316. package/src/cli/commands/registry/bundle-package.ts +22 -0
  317. package/src/cli/commands/registry/command-registry.ts +2 -0
  318. package/src/cli/commands/registry/start.ts +3 -2
  319. package/src/cli/commands/review/types.ts +1 -3
  320. package/src/cli/commands/run-task.ts +8 -2
  321. package/src/cli/commands/start.ts +9 -5
  322. package/src/cli/commands/types.ts +2 -6
  323. package/src/cli/index.ts +3 -0
  324. package/src/cli/tasks/__tests__/cli-task.test.ts +181 -69
  325. package/src/cli/tasks/__tests__/task.test.ts +40 -45
  326. package/src/cli/tasks/cli-task.ts +43 -2
  327. package/src/cli/tasks/swc-compile-package/__tests__/get-swc-options.test.ts +46 -4
  328. package/src/cli/tasks/swc-compile-package/__tests__/swc-compile-package.test.ts +25 -4
  329. package/src/cli/tasks/swc-compile-package/get-swc-options.ts +14 -1
  330. package/src/cli/tasks/swc-compile-package/swc-compile-package.ts +6 -2
  331. package/src/cli/tasks/task.ts +8 -2
  332. package/src/cli/tasks/tsc-compile/__tests__/tsc-compile.test.ts +8 -32
  333. package/src/cli/tasks/tsc-compile-package/__tests__/tsc-compile-package.test.ts +10 -19
  334. package/src/cli/utils/__tests__/cli-npm.test.ts +33 -0
  335. package/src/cli/utils/__tests__/cli-os.test.ts +86 -3
  336. package/src/cli/utils/__tests__/compile.test.ts +37 -2
  337. package/src/cli/utils/__tests__/copy-files.test.ts +1 -1
  338. package/src/cli/utils/__tests__/with-exponential-backoff.test.ts +119 -0
  339. package/src/cli/utils/cli-npm.ts +19 -4
  340. package/src/cli/utils/cli-os.ts +14 -0
  341. package/src/cli/utils/compile.ts +8 -1
  342. package/src/cli/utils/copy-files.ts +1 -1
  343. package/src/cli/utils/index.ts +1 -1
  344. package/src/cli/utils/resolve-bundler.ts +2 -1
  345. package/src/cli/utils/ts-config.ts +1 -1
  346. package/src/cli/utils/with-exponential-backoff.ts +28 -0
  347. package/src/core/constants.ts +2 -0
  348. package/src/cypress/config/__tests__/vite-config.test.ts +21 -11
  349. package/src/cypress/config/__tests__/webpack-config.test.ts +17 -0
  350. package/src/cypress/config/vite-config.ts +18 -3
  351. package/src/cypress/config/webpack-config.ts +2 -0
  352. package/src/storybook-config/__tests__/vite-final.test.ts +71 -11
  353. package/src/storybook-config/__tests__/webpack-final.test.ts +30 -6
  354. package/src/storybook-config/vite-final.ts +23 -2
  355. package/src/storybook-config/webpack-final.ts +10 -2
  356. package/src/utils/__tests__/exit-when-parent-exits.test.ts +87 -0
  357. package/src/utils/__tests__/find-up.test.ts +49 -0
  358. package/src/utils/__tests__/get-configuration.test.ts +62 -0
  359. package/src/utils/exit-when-parent-exits.ts +33 -0
  360. package/src/utils/find-up.ts +2 -2
  361. package/src/utils/get-configuration.ts +14 -5
  362. package/src/utils/index.ts +1 -0
  363. package/src/vite/__tests__/build-shared-dependencies.test.ts +39 -5
  364. package/src/vite/build-shared-dependencies.ts +2 -1
  365. package/src/vite/config/__tests__/base-config.test.ts +16 -4
  366. package/src/vite/config/__tests__/create-css-config.test.ts +2 -6
  367. package/src/vite/config/__tests__/create-filtering-logger.test.ts +9 -0
  368. package/src/vite/config/__tests__/create-vite-build-context.test.ts +25 -0
  369. package/src/vite/config/__tests__/create-vite-config.test.ts +6 -3
  370. package/src/vite/config/base-config.ts +18 -2
  371. package/src/vite/config/create-filtering-logger.ts +13 -2
  372. package/src/vite/config/create-vite-build-context.ts +1 -0
  373. package/src/vite/config/create-vite-config.ts +6 -3
  374. package/src/vite/index.html +2 -2
  375. package/src/vite/index.ts +2 -0
  376. package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +1 -1
  377. package/src/vite/plugins/__tests__/clean-plugin.test.ts +1 -1
  378. package/src/vite/plugins/__tests__/css-injector-plugin.test.ts +1 -1
  379. package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +15 -3
  380. package/src/vite/plugins/__tests__/dev-server-routing-plugin.test.ts +121 -99
  381. package/src/vite/plugins/__tests__/externals-plugin.test.ts +24 -3
  382. package/src/vite/plugins/__tests__/html-plugin.test.ts +10 -3
  383. package/src/vite/plugins/__tests__/html-template.test.ts +10 -2
  384. package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +30 -6
  385. package/src/vite/plugins/__tests__/istanbul-plugin.test.ts +42 -1
  386. package/src/vite/plugins/__tests__/less-tilde-plugin.test.ts +91 -0
  387. package/src/vite/plugins/__tests__/metadata-plugin.test.ts +1 -1
  388. package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +35 -25
  389. package/src/vite/plugins/__tests__/style-urls-plugin.test.ts +1 -1
  390. package/src/vite/plugins/__tests__/virtual-modules-plugin.test.ts +20 -9
  391. package/src/vite/plugins/__tests__/window-externals-plugin.test.ts +128 -0
  392. package/src/vite/plugins/chain-source-maps-plugin.ts +1 -1
  393. package/src/vite/plugins/clean-plugin.ts +1 -1
  394. package/src/vite/plugins/css-injector-plugin.ts +1 -1
  395. package/src/vite/plugins/design-system-guard-plugin.ts +11 -8
  396. package/src/vite/plugins/dev-server-routing-plugin.ts +4 -4
  397. package/src/vite/plugins/externals-plugin.ts +15 -6
  398. package/src/vite/plugins/html-plugin.ts +4 -2
  399. package/src/vite/plugins/ignore-modules-plugin.ts +32 -23
  400. package/src/vite/plugins/index.ts +3 -0
  401. package/src/vite/plugins/istanbul-plugin.ts +28 -1
  402. package/src/vite/plugins/less-tilde-plugin.ts +64 -0
  403. package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +1 -1
  404. package/src/vite/plugins/metadata-plugin.ts +1 -1
  405. package/src/vite/plugins/moment-locales-plugin.ts +24 -14
  406. package/src/vite/plugins/react-refresh-plugin/README.md +165 -0
  407. package/src/vite/plugins/react-refresh-plugin/__tests__/react-refresh-plugin.test.ts +366 -0
  408. package/src/vite/plugins/react-refresh-plugin/__tests__/refresh-runtime.test.ts +193 -0
  409. package/src/vite/plugins/react-refresh-plugin/index.ts +1 -0
  410. package/src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts +144 -0
  411. package/src/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
  412. package/src/vite/plugins/shared-dependencies-plugin/__tests__/shared-dependencies-plugin.test.ts +21 -16
  413. package/src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts +13 -12
  414. package/src/vite/plugins/style-urls-plugin.ts +1 -1
  415. package/src/vite/plugins/virtual-modules-plugin.ts +8 -7
  416. package/src/vite/plugins/window-externals-plugin.ts +94 -0
  417. package/src/vite/types.ts +4 -1
  418. package/src/webpack/__tests__/bundle-webpack.test.ts +32 -0
  419. package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +17 -5
  420. package/src/webpack/__tests__/create-webpack-config.test.ts +10 -6
  421. package/src/webpack/bundle-webpack.ts +7 -1
  422. package/src/webpack/configs/optimization-config.ts +3 -3
  423. package/src/webpack/configs/output-config.ts +1 -1
  424. package/src/webpack/utils/__tests__/normalize-proxy-config.test.ts +121 -0
  425. package/src/webpack/utils/index.ts +1 -0
  426. package/src/webpack/utils/normalize-proxy-config.ts +59 -0
  427. package/tsconfig/types.d.ts +10 -0
  428. package/dist/cli/utils/get-bundle-command.d.ts +0 -3
  429. package/dist/cli/utils/get-bundle-command.d.ts.map +0 -1
  430. package/dist/cli/utils/get-bundle-command.js +0 -16
  431. package/dist/cli/utils/get-bundle-command.js.map +0 -1
  432. package/src/cli/utils/__tests__/get-bundle-command.test.ts +0 -23
  433. package/src/cli/utils/get-bundle-command.ts +0 -5
@@ -1,10 +1,12 @@
1
1
  import { fs, vol } from 'memfs';
2
2
  import path from 'path';
3
+ import { normalizePath } from 'vite';
3
4
  import { type BuildContext, getBundleType } from '../../../core';
4
5
  import { log } from '../../../utils';
5
6
  import { devServerRoutingPlugin } from '../dev-server-routing-plugin';
6
7
 
7
8
  jest.mock('fs', () => fs);
9
+ jest.mock('vite', () => ({ normalizePath: jest.fn() }));
8
10
  jest.mock('../../../core', () => ({
9
11
  getBundleType: jest.fn(),
10
12
  }));
@@ -16,8 +18,6 @@ describe(devServerRoutingPlugin.name, () => {
16
18
  const SHARED_DEPS_DIR = 'shared';
17
19
  const destination = 'dist/bundle/full';
18
20
  const destDir = path.resolve(destination);
19
- const outDir = path.resolve('dist/bundle/full');
20
- const outDirRelative = path.relative(process.cwd(), outDir);
21
21
 
22
22
  let context: BuildContext;
23
23
 
@@ -25,6 +25,7 @@ describe(devServerRoutingPlugin.name, () => {
25
25
  jest.clearAllMocks();
26
26
  vol.fromJSON({});
27
27
  jest.mocked(getBundleType).mockReturnValue(SHARED_DEPS_DIR);
28
+ jest.mocked(normalizePath).mockImplementation(id => id.split('\\').join('/'));
28
29
  context = {
29
30
  build: { name: 'test-app' },
30
31
  package: { destination },
@@ -39,92 +40,94 @@ describe(devServerRoutingPlugin.name, () => {
39
40
  const subject = () => devServerRoutingPlugin(context);
40
41
 
41
42
  test('returns plugin with correct name', () => {
42
- expect(subject().name).toBe('dev-server-routing');
43
+ expect(subject().name).toBe('st:dev-server-routing');
43
44
  });
44
45
 
45
- const setupMiddleware = (resolvedOutDir: string) => {
46
- const plugin = subject();
47
- (plugin.configResolved as Function).call(plugin, {
48
- build: { outDir: resolvedOutDir },
49
- });
50
-
51
- let middleware!: Function;
52
- const server: any = {
53
- middlewares: {
54
- use: (handler: Function) => (middleware = handler),
55
- },
56
- };
57
- (plugin.configureServer as Function).call(plugin, server);
58
- return middleware;
59
- };
46
+ describe('configureServer', () => {
47
+ let req: any;
48
+ let next: jest.Mock;
49
+ let middleware: Function;
60
50
 
61
- describe('configResolved', () => {
62
- test('captures outDir for use by configureServer', () => {
63
- const middleware = setupMiddleware(outDir);
64
- const req: any = { url: `/${SHARED_DEPS_DIR}/dep.js` };
65
- const originalUrl = req.url;
51
+ const setupMiddleware = () => {
52
+ const plugin = devServerRoutingPlugin(context);
53
+ (plugin.configResolved as Function).call(plugin, { build: { outDir: destDir } });
66
54
 
67
- middleware(req, {}, jest.fn());
55
+ const server: any = {
56
+ middlewares: { use: (handler: Function) => (middleware = handler) },
57
+ };
58
+ (plugin.configureServer as Function).call(plugin, server);
59
+ };
68
60
 
69
- expect(req.url).toBe(`/${outDirRelative}/${originalUrl.slice(1)}`);
61
+ beforeEach(() => {
62
+ req = { method: 'GET', url: '/anything' };
63
+ next = jest.fn();
64
+ setupMiddleware();
70
65
  });
71
- });
72
-
73
- describe('configureServer', () => {
74
- const itPreservesUnmatchedUrls = () => {
75
- test('preserves unmatched URL', () => {
76
- const middleware = setupMiddleware(outDir);
77
- const req: any = { url: '/other/path' };
78
- const originalUrl = req.url;
79
-
80
- middleware(req, {}, jest.fn());
81
66
 
82
- expect(req.url).toBe(originalUrl);
83
- });
84
- };
67
+ const subject = () => middleware(req, {}, next);
85
68
 
86
69
  test('logs request', () => {
87
- const middleware = setupMiddleware(outDir);
88
-
89
- middleware({ method: 'GET', url: '/anything' }, {}, jest.fn());
70
+ subject();
90
71
 
91
72
  expect(log.info).toHaveBeenCalled();
92
73
  });
93
74
 
94
75
  test('calls next middleware', () => {
95
- const middleware = setupMiddleware(outDir);
96
- const next = jest.fn();
97
-
98
- middleware({ url: '/anything' }, {}, next);
76
+ subject();
99
77
 
100
78
  expect(next).toHaveBeenCalled();
101
79
  });
102
80
 
81
+ const itPreservesUnmatchedUrls = () => {
82
+ describe('with an unmatched URL', () => {
83
+ let originalUrl: string;
84
+
85
+ beforeEach(() => {
86
+ req.url = '/other/path';
87
+ originalUrl = req.url;
88
+ });
89
+
90
+ test('preserves the URL', () => {
91
+ subject();
92
+
93
+ expect(req.url).toBe(originalUrl);
94
+ });
95
+ });
96
+ };
97
+
103
98
  describe('when package is a web component', () => {
104
- beforeEach(() => (context.package.isWebComponent = true));
99
+ beforeEach(() => {
100
+ context.package.isWebComponent = true;
101
+ setupMiddleware();
102
+ });
105
103
 
106
- test('strips outDir prefix from URL', () => {
107
- const middleware = setupMiddleware(outDir);
108
- const req: any = { url: `/${outDirRelative}/index.js` };
104
+ describe('with a URL under outDir', () => {
105
+ beforeEach(() => (req.url = `/${destination}/index.js`));
109
106
 
110
- middleware(req, {}, jest.fn());
107
+ test('strips outDir prefix from URL', () => {
108
+ subject();
111
109
 
112
- expect(req.url).toBe('/index.js');
110
+ expect(req.url).toBe('/index.js');
111
+ });
113
112
  });
114
113
 
115
114
  itPreservesUnmatchedUrls();
116
115
  });
117
116
 
118
117
  describe('when package is not a web component', () => {
119
- beforeEach(() => (context.package.isWebComponent = false));
118
+ beforeEach(() => {
119
+ context.package.isWebComponent = false;
120
+ setupMiddleware();
121
+ });
120
122
 
121
- test('rewrites shared dependencies URL to outDir', () => {
122
- const middleware = setupMiddleware(outDir);
123
- const req: any = { url: `/${SHARED_DEPS_DIR}/dep.js` };
123
+ describe('with a shared dependency URL', () => {
124
+ beforeEach(() => (req.url = `/${SHARED_DEPS_DIR}/dep.js`));
124
125
 
125
- middleware(req, {}, jest.fn());
126
+ test('rewrites URL to outDir', () => {
127
+ subject();
126
128
 
127
- expect(req.url).toBe(`/${outDirRelative}/${SHARED_DEPS_DIR}/dep.js`);
129
+ expect(req.url).toBe(`/${destination}/${SHARED_DEPS_DIR}/dep.js`);
130
+ });
128
131
  });
129
132
 
130
133
  itPreservesUnmatchedUrls();
@@ -132,8 +135,8 @@ describe(devServerRoutingPlugin.name, () => {
132
135
  });
133
136
 
134
137
  describe('configurePreviewServer', () => {
135
- const setupPreviewServer = () => {
136
- const plugin = subject();
138
+ const registerPreviewServer = () => {
139
+ const plugin = devServerRoutingPlugin(context);
137
140
  const uses: { path?: string; handler: Function }[] = [];
138
141
  const server: any = {
139
142
  middlewares: {
@@ -153,39 +156,66 @@ describe(devServerRoutingPlugin.name, () => {
153
156
  };
154
157
  };
155
158
 
156
- test('logs request and calls next middleware', () => {
157
- const { logger } = setupPreviewServer();
158
- const req = { method: 'GET', url: '/index.html' };
159
- const next = jest.fn();
159
+ describe('logging middleware', () => {
160
+ let req: any;
161
+ let next: jest.Mock;
162
+ let logger: Function;
160
163
 
161
- logger(req, {}, next);
164
+ beforeEach(() => {
165
+ ({ logger } = registerPreviewServer());
166
+ req = { method: 'GET', url: '/index.html' };
167
+ next = jest.fn();
168
+ });
162
169
 
163
- expect(log.info).toHaveBeenCalled();
164
- expect(next).toHaveBeenCalled();
170
+ const subject = () => logger(req, {}, next);
171
+
172
+ test('logs request', () => {
173
+ subject();
174
+
175
+ expect(log.info).toHaveBeenCalled();
176
+ });
177
+
178
+ test('calls next middleware', () => {
179
+ subject();
180
+
181
+ expect(next).toHaveBeenCalled();
182
+ });
165
183
  });
166
184
 
167
185
  describe('when package is not a web component', () => {
168
- beforeEach(() => (context.package.isWebComponent = false));
186
+ let staticFiles: Function | undefined;
169
187
 
170
- test('only registers logging middleware', () => {
171
- const { logger, staticFiles } = setupPreviewServer();
188
+ beforeEach(() => {
189
+ context.package.isWebComponent = false;
190
+ ({ staticFiles } = registerPreviewServer());
191
+ });
172
192
 
173
- expect(logger).toBeDefined();
193
+ test('does not register a static file middleware', () => {
174
194
  expect(staticFiles).toBeUndefined();
175
195
  });
176
196
  });
177
197
 
178
198
  describe('when package is a web component', () => {
179
- beforeEach(() => (context.package.isWebComponent = true));
180
-
181
- const serveStaticFile = (fileName: string) => {
182
- const mockStream = { pipe: jest.fn() };
183
- jest.spyOn(fs, 'createReadStream').mockReturnValue(mockStream as any);
184
- const { staticFiles } = setupPreviewServer();
185
- const res = { setHeader: jest.fn() };
186
- staticFiles!({ url: `/${fileName}` }, res, jest.fn());
187
- return { res, mockStream };
188
- };
199
+ let req: any;
200
+ let res: any;
201
+ let next: jest.Mock;
202
+ let mockStream: { pipe: jest.Mock };
203
+ let createReadStreamSpy: jest.SpyInstance;
204
+ let staticFiles: Function | undefined;
205
+
206
+ beforeEach(() => {
207
+ context.package.isWebComponent = true;
208
+ mockStream = { pipe: jest.fn() };
209
+ createReadStreamSpy = jest
210
+ .spyOn(fs, 'createReadStream')
211
+ .mockReturnValue(mockStream as any);
212
+ ({ staticFiles } = registerPreviewServer());
213
+ req = { url: '/file.js' };
214
+ res = { setHeader: jest.fn() };
215
+ next = jest.fn();
216
+ });
217
+
218
+ const subject = () => staticFiles!(req, res, next);
189
219
 
190
220
  describe.each([
191
221
  ['file.js', 'application/javascript'],
@@ -193,11 +223,12 @@ describe(devServerRoutingPlugin.name, () => {
193
223
  ['file.json', 'application/json'],
194
224
  ])('when requested file is %s', (fileName, contentType) => {
195
225
  beforeEach(() => {
226
+ req.url = `/${fileName}`;
196
227
  vol.fromJSON({ [path.join(destDir, fileName)]: 'content' });
197
228
  });
198
229
 
199
230
  test(`serves file as ${contentType}`, () => {
200
- const { res, mockStream } = serveStaticFile(fileName);
231
+ subject();
201
232
 
202
233
  expect(res.setHeader).toHaveBeenCalledWith('Content-Type', contentType);
203
234
  expect(mockStream.pipe).toHaveBeenCalledWith(res);
@@ -205,14 +236,13 @@ describe(devServerRoutingPlugin.name, () => {
205
236
  });
206
237
 
207
238
  describe('when requested file has unrecognized extension', () => {
208
- const fileName = 'file.txt';
209
-
210
239
  beforeEach(() => {
211
- vol.fromJSON({ [path.join(destDir, fileName)]: 'content' });
240
+ req.url = '/file.txt';
241
+ vol.fromJSON({ [path.join(destDir, 'file.txt')]: 'content' });
212
242
  });
213
243
 
214
244
  test('serves file without content type', () => {
215
- const { res, mockStream } = serveStaticFile(fileName);
245
+ subject();
216
246
 
217
247
  expect(res.setHeader).not.toHaveBeenCalled();
218
248
  expect(mockStream.pipe).toHaveBeenCalledWith(res);
@@ -220,13 +250,10 @@ describe(devServerRoutingPlugin.name, () => {
220
250
  });
221
251
 
222
252
  describe('when requested file does not exist', () => {
223
- beforeEach(() => vol.reset());
253
+ beforeEach(() => (req.url = '/missing.js'));
224
254
 
225
255
  test('calls next middleware', () => {
226
- const { staticFiles } = setupPreviewServer();
227
- const next = jest.fn();
228
-
229
- staticFiles!({ url: '/missing.js' }, {}, next);
256
+ subject();
230
257
 
231
258
  expect(next).toHaveBeenCalled();
232
259
  });
@@ -234,20 +261,15 @@ describe(devServerRoutingPlugin.name, () => {
234
261
 
235
262
  describe('when requested URL traverses outside the mounted directory', () => {
236
263
  beforeEach(() => {
237
- vol.fromJSON({
238
- [path.resolve(destDir, '../outside.js')]: 'content',
239
- });
264
+ req.url = '/../outside.js';
265
+ vol.fromJSON({ [path.resolve(destDir, '../outside.js')]: 'content' });
240
266
  });
241
267
 
242
268
  test('does not serve the file', () => {
243
- const createReadStream = jest.spyOn(fs, 'createReadStream');
244
- const { staticFiles } = setupPreviewServer();
245
- const next = jest.fn();
246
-
247
- staticFiles!({ url: '/../outside.js' }, {}, next);
269
+ subject();
248
270
 
249
271
  expect(next).toHaveBeenCalled();
250
- expect(createReadStream).not.toHaveBeenCalled();
272
+ expect(createReadStreamSpy).not.toHaveBeenCalled();
251
273
  });
252
274
  });
253
275
  });
@@ -31,7 +31,7 @@ describe(externalsPlugin.name, () => {
31
31
  const subject = () => externalsPlugin(context);
32
32
 
33
33
  test('returns plugin with correct name', () => {
34
- expect(subject()!.name).toBe('externals');
34
+ expect(subject()!.name).toBe('st:externals');
35
35
  });
36
36
 
37
37
  test('enforces pre', () => {
@@ -70,12 +70,33 @@ describe(externalsPlugin.name, () => {
70
70
  describe('when build is production', () => {
71
71
  beforeEach(() => (context.build.isProduction = true));
72
72
 
73
+ describe('resolveId filter', () => {
74
+ const subject = () =>
75
+ (externalsPlugin(context) as { resolveId: { filter: unknown } }).resolveId.filter;
76
+
77
+ test('matches each dependency exactly', () => {
78
+ expect(subject()).toEqual({ id: [/^react$/, /^@scope\/lib$/] });
79
+ });
80
+
81
+ describe('when a dependency name contains regex characters', () => {
82
+ beforeEach(() =>
83
+ jest.mocked(getExternals).mockReturnValue({ 'lodash.throttle': 'x' })
84
+ );
85
+
86
+ test('escapes them', () => {
87
+ expect(subject()).toEqual({ id: [/^lodash\.throttle$/] });
88
+ });
89
+ });
90
+ });
91
+
73
92
  describe('resolveId', () => {
74
93
  let source: string;
75
94
 
76
95
  const subject = () => {
77
- const plugin = externalsPlugin(context)!;
78
- return (plugin.resolveId as Function).call(plugin, source);
96
+ const { resolveId } = externalsPlugin(context) as {
97
+ resolveId: { handler: Function };
98
+ };
99
+ return resolveId.handler.call({}, source);
79
100
  };
80
101
 
81
102
  describe('with known dependency', () => {
@@ -28,7 +28,7 @@ describe(htmlPlugin.name, () => {
28
28
  jest.mocked(getSharedEntryPoints).mockReturnValue({ css: [], js: [] });
29
29
  context = {
30
30
  build: { name: 'my-app', isProduction: false },
31
- package: { isWebComponent: false, source: 'src' },
31
+ package: { isWebComponent: false, source: 'src', destination: 'dist' },
32
32
  bundlerConfig: { pluginOverrides: {} },
33
33
  } as ViteBuildContext;
34
34
  });
@@ -38,7 +38,7 @@ describe(htmlPlugin.name, () => {
38
38
  const subject = () => htmlPlugin(context);
39
39
 
40
40
  test('returns plugin with correct name', () => {
41
- expect(subject().name).toBe('html');
41
+ expect(subject().name).toBe('st:html');
42
42
  });
43
43
 
44
44
  test('constructs Eta with default template directory', () => {
@@ -170,6 +170,7 @@ describe(htmlPlugin.name, () => {
170
170
  isProduction: context.build.isProduction,
171
171
  isWebComponent: context.package.isWebComponent,
172
172
  name: context.build.name,
173
+ tsOutDir: context.package.destination,
173
174
  });
174
175
  });
175
176
 
@@ -310,7 +311,7 @@ describe(htmlPlugin.name, () => {
310
311
 
311
312
  beforeEach(() => {
312
313
  req = { url: '/other' };
313
- res = { end: jest.fn() };
314
+ res = { end: jest.fn(), setHeader: jest.fn() };
314
315
  next = jest.fn();
315
316
 
316
317
  const plugin = htmlPlugin(context);
@@ -350,6 +351,12 @@ describe(htmlPlugin.name, () => {
350
351
  expect(res.end).toHaveBeenCalledWith(TRANSFORMED_HTML);
351
352
  });
352
353
 
354
+ test('sets HTML content type', async () => {
355
+ await subject();
356
+
357
+ expect(res.setHeader).toHaveBeenCalledWith('Content-Type', 'text/html');
358
+ });
359
+
353
360
  test('does not call next middleware', async () => {
354
361
  await subject();
355
362
 
@@ -19,7 +19,7 @@ describe('Vite host HTML template', () => {
19
19
  jest.mocked(getSharedEntryPoints).mockReturnValue({ css, js });
20
20
  context = {
21
21
  build: { name: 'my-mfe', isProduction: true },
22
- package: { isWebComponent: false, source: __dirname },
22
+ package: { isWebComponent: false, source: __dirname, destination: 'dist' },
23
23
  bundlerConfig: { pluginOverrides: {} },
24
24
  } as ViteBuildContext;
25
25
  });
@@ -70,13 +70,21 @@ describe('Vite host HTML template', () => {
70
70
  test('renders each shared JS script', () => {
71
71
  const html = subject();
72
72
 
73
- js.forEach(item => expect(html).toContain(`<script src="./${item}"></script>`));
73
+ js.forEach(item => expect(html).toContain(`<script defer src="./${item}"></script>`));
74
74
  });
75
75
 
76
76
  test('imports the host entry module', () => {
77
77
  expect(subject()).toContain("import './dist/index'");
78
78
  });
79
79
 
80
+ describe('with a non-default tsconfig outDir', () => {
81
+ beforeEach(() => (context.package.destination = 'lib'));
82
+
83
+ test('imports the entry from that directory', () => {
84
+ expect(subject()).toContain(`import './${context.package.destination}/index'`);
85
+ });
86
+ });
87
+
80
88
  describe('when web component', () => {
81
89
  beforeEach(() => {
82
90
  context.package.isWebComponent = true;
@@ -5,7 +5,7 @@ jest.mock('../../../core', () => ({
5
5
  checkResource: jest.fn(),
6
6
  }));
7
7
 
8
- describe(ignoreModulesPlugin.name, () => {
8
+ describe(`[startup] ${ignoreModulesPlugin.name}`, () => {
9
9
  const moduleName = 'some-module';
10
10
  const context = {} as BuildContext;
11
11
  const checker = jest.fn();
@@ -18,21 +18,32 @@ describe(ignoreModulesPlugin.name, () => {
18
18
  const subject = () => ignoreModulesPlugin(context);
19
19
 
20
20
  test('creates plugin with correct name', () => {
21
- expect(subject().name).toBe('ignore-modules');
21
+ expect(subject().name).toBe('st:ignore-modules');
22
22
  });
23
23
 
24
24
  test('enforces pre order so it runs before built-in resolvers', () => {
25
25
  expect(subject().enforce).toBe('pre');
26
26
  });
27
27
 
28
+ describe('resolveId filter', () => {
29
+ const subject = () =>
30
+ (ignoreModulesPlugin(context) as { resolveId: { filter: unknown } }).resolveId.filter;
31
+
32
+ test('runs the hook only for bare specifiers', () => {
33
+ expect(subject()).toEqual({ id: /^[@a-z]/ });
34
+ });
35
+ });
36
+
28
37
  describe('resolveId', () => {
29
38
  let importer: string | undefined;
30
39
 
31
40
  beforeEach(() => (importer = '/importer.ts'));
32
41
 
33
42
  const subject = () => {
34
- const plugin = ignoreModulesPlugin(context);
35
- return (plugin.resolveId as Function).call(plugin, moduleName, importer);
43
+ const { resolveId } = ignoreModulesPlugin(context) as {
44
+ resolveId: { handler: Function };
45
+ };
46
+ return resolveId.handler.call({}, moduleName, importer);
36
47
  };
37
48
 
38
49
  const itReturnsUndefined = () => {
@@ -72,14 +83,27 @@ describe(ignoreModulesPlugin.name, () => {
72
83
  });
73
84
  });
74
85
 
86
+ describe('load filter', () => {
87
+ const subject = () =>
88
+ (ignoreModulesPlugin(context) as { load: { filter: { id: RegExp } } }).load.filter.id;
89
+
90
+ test('matches the plugin virtual module ids', () => {
91
+ expect(subject().test(`${THROW_PREFIX}${moduleName}`)).toBe(true);
92
+ });
93
+
94
+ test('ignores ordinary module ids', () => {
95
+ expect(subject().test('/src/app.tsx')).toBe(false);
96
+ });
97
+ });
98
+
75
99
  describe('load', () => {
76
100
  let id: string;
77
101
 
78
102
  beforeEach(() => (id = moduleName));
79
103
 
80
104
  const subject = () => {
81
- const plugin = ignoreModulesPlugin(context);
82
- return (plugin.load as Function).call(plugin, id);
105
+ const { load } = ignoreModulesPlugin(context) as { load: { handler: Function } };
106
+ return load.handler.call({}, id);
83
107
  };
84
108
 
85
109
  test('returns undefined', () => {
@@ -11,7 +11,12 @@ describe(istanbulPlugin.name, () => {
11
11
  beforeEach(() => {
12
12
  jest.clearAllMocks();
13
13
  jest.mocked(importEsm).mockResolvedValue({ default: mockIstanbul });
14
- context = { options: {} } as ViteBuildContext;
14
+ context = {
15
+ options: {},
16
+ build: {},
17
+ package: { destination: 'dist' },
18
+ bundlerConfig: {},
19
+ } as ViteBuildContext;
15
20
  });
16
21
 
17
22
  const subject = () => istanbulPlugin(context);
@@ -58,5 +63,41 @@ describe(istanbulPlugin.name, () => {
58
63
  expect.objectContaining({ exclude: ['**/node_modules/**', '**/.yalc/**'] })
59
64
  );
60
65
  });
66
+
67
+ describe('when the package exposes shared dependencies', () => {
68
+ beforeEach(() => {
69
+ context.package.isExposeSharedDependencies = true;
70
+ });
71
+
72
+ test('also excludes the shared dependencies', async () => {
73
+ await subject();
74
+
75
+ expect(mockIstanbul).toHaveBeenCalledWith(
76
+ expect.objectContaining({
77
+ exclude: [
78
+ '**/node_modules/**',
79
+ '**/.yalc/**',
80
+ `${context.package.destination}/bundle/shared/**`,
81
+ ],
82
+ })
83
+ );
84
+ });
85
+
86
+ describe('when package has custom outDir', () => {
87
+ const outDir = 'foo';
88
+
89
+ beforeEach(() => (context.bundlerConfig.outDir = outDir));
90
+
91
+ test('excludes custom shared dependencies location', async () => {
92
+ await subject();
93
+
94
+ expect(mockIstanbul).toHaveBeenCalledWith(
95
+ expect.objectContaining({
96
+ exclude: ['**/node_modules/**', '**/.yalc/**', `${outDir}/shared/**`],
97
+ })
98
+ );
99
+ });
100
+ });
101
+ });
61
102
  });
62
103
  });