@servicetitan/startup 36.4.0 → 37.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/bin/analyze.js +3 -0
  2. package/dist/cli/commands/build.d.ts.map +1 -1
  3. package/dist/cli/commands/build.js +4 -5
  4. package/dist/cli/commands/build.js.map +1 -1
  5. package/dist/cli/commands/bundle-vite.d.ts.map +1 -1
  6. package/dist/cli/commands/bundle-vite.js +18 -1
  7. package/dist/cli/commands/bundle-vite.js.map +1 -1
  8. package/dist/cli/commands/registry/build.d.ts +6 -0
  9. package/dist/cli/commands/registry/build.d.ts.map +1 -1
  10. package/dist/cli/commands/registry/build.js +10 -1
  11. package/dist/cli/commands/registry/build.js.map +1 -1
  12. package/dist/cli/commands/registry/command-registry.d.ts +12 -28
  13. package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
  14. package/dist/cli/commands/registry/command-registry.js +0 -3
  15. package/dist/cli/commands/registry/command-registry.js.map +1 -1
  16. package/dist/cli/commands/registry/start.d.ts +6 -0
  17. package/dist/cli/commands/registry/start.d.ts.map +1 -1
  18. package/dist/cli/commands/registry/start.js +10 -1
  19. package/dist/cli/commands/registry/start.js.map +1 -1
  20. package/dist/cli/commands/review/rules/index.d.ts.map +1 -1
  21. package/dist/cli/commands/review/rules/index.js +2 -0
  22. package/dist/cli/commands/review/rules/index.js.map +1 -1
  23. package/dist/cli/commands/review/rules/require-compatible-typescript.d.ts +13 -0
  24. package/dist/cli/commands/review/rules/require-compatible-typescript.d.ts.map +1 -0
  25. package/dist/cli/commands/review/rules/require-compatible-typescript.js +72 -0
  26. package/dist/cli/commands/review/rules/require-compatible-typescript.js.map +1 -0
  27. package/dist/cli/commands/start.d.ts.map +1 -1
  28. package/dist/cli/commands/start.js +3 -4
  29. package/dist/cli/commands/start.js.map +1 -1
  30. package/dist/cli/commands/test/runners/vitest.d.ts.map +1 -1
  31. package/dist/cli/commands/test/runners/vitest.js +7 -1
  32. package/dist/cli/commands/test/runners/vitest.js.map +1 -1
  33. package/dist/cli/index.js +1 -1
  34. package/dist/cli/index.js.map +1 -1
  35. package/dist/cli/utils/get-bundle-command.d.ts +3 -0
  36. package/dist/cli/utils/get-bundle-command.d.ts.map +1 -0
  37. package/dist/cli/utils/get-bundle-command.js +16 -0
  38. package/dist/cli/utils/get-bundle-command.js.map +1 -0
  39. package/dist/cli/utils/get-exit-code.d.ts +12 -0
  40. package/dist/cli/utils/get-exit-code.d.ts.map +1 -0
  41. package/dist/cli/utils/get-exit-code.js +26 -0
  42. package/dist/cli/utils/get-exit-code.js.map +1 -0
  43. package/dist/cli/utils/index.d.ts +3 -0
  44. package/dist/cli/utils/index.d.ts.map +1 -1
  45. package/dist/cli/utils/index.js +3 -0
  46. package/dist/cli/utils/index.js.map +1 -1
  47. package/dist/cli/utils/resolve-bundler.d.ts +8 -0
  48. package/dist/cli/utils/resolve-bundler.d.ts.map +1 -0
  49. package/dist/cli/utils/resolve-bundler.js +24 -0
  50. package/dist/cli/utils/resolve-bundler.js.map +1 -0
  51. package/dist/core/bundle-report.d.ts +4 -0
  52. package/dist/core/bundle-report.d.ts.map +1 -0
  53. package/dist/core/bundle-report.js +43 -0
  54. package/dist/core/bundle-report.js.map +1 -0
  55. package/dist/core/check-resource/check-resource.d.ts +5 -3
  56. package/dist/core/check-resource/check-resource.d.ts.map +1 -1
  57. package/dist/core/check-resource/check-resource.js +20 -13
  58. package/dist/core/check-resource/check-resource.js.map +1 -1
  59. package/dist/core/check-resource/get-peer-dependency-meta.d.ts +11 -1
  60. package/dist/core/check-resource/get-peer-dependency-meta.d.ts.map +1 -1
  61. package/dist/core/check-resource/get-peer-dependency-meta.js +58 -2
  62. package/dist/core/check-resource/get-peer-dependency-meta.js.map +1 -1
  63. package/dist/core/check-resource/index.d.ts +1 -1
  64. package/dist/core/check-resource/index.d.ts.map +1 -1
  65. package/dist/core/check-resource/index.js.map +1 -1
  66. package/dist/core/check-resource/is-resolvable.d.ts +7 -0
  67. package/dist/core/check-resource/is-resolvable.d.ts.map +1 -0
  68. package/dist/core/check-resource/is-resolvable.js +31 -0
  69. package/dist/core/check-resource/is-resolvable.js.map +1 -0
  70. package/dist/core/check-resource/types.d.ts +1 -0
  71. package/dist/core/check-resource/types.d.ts.map +1 -1
  72. package/dist/core/chunk-patterns.d.ts +7 -0
  73. package/dist/core/chunk-patterns.d.ts.map +1 -0
  74. package/dist/core/chunk-patterns.js +37 -0
  75. package/dist/core/chunk-patterns.js.map +1 -0
  76. package/dist/core/create-build-context.d.ts +0 -1
  77. package/dist/core/create-build-context.d.ts.map +1 -1
  78. package/dist/core/create-build-context.js +2 -2
  79. package/dist/core/create-build-context.js.map +1 -1
  80. package/dist/core/create-extension-regexp.d.ts +5 -0
  81. package/dist/core/create-extension-regexp.d.ts.map +1 -0
  82. package/dist/core/create-extension-regexp.js +45 -0
  83. package/dist/core/create-extension-regexp.js.map +1 -0
  84. package/dist/core/get-process-env.d.ts +3 -0
  85. package/dist/core/get-process-env.d.ts.map +1 -0
  86. package/dist/core/get-process-env.js +25 -0
  87. package/dist/core/get-process-env.js.map +1 -0
  88. package/dist/core/index.d.ts +8 -1
  89. package/dist/core/index.d.ts.map +1 -1
  90. package/dist/core/index.js +8 -1
  91. package/dist/core/index.js.map +1 -1
  92. package/dist/core/moment-locales.d.ts +2 -0
  93. package/dist/core/moment-locales.d.ts.map +1 -0
  94. package/dist/core/moment-locales.js +21 -0
  95. package/dist/core/moment-locales.js.map +1 -0
  96. package/dist/core/resolve-output-path.d.ts +3 -0
  97. package/dist/core/resolve-output-path.d.ts.map +1 -0
  98. package/dist/core/resolve-output-path.js +25 -0
  99. package/dist/core/resolve-output-path.js.map +1 -0
  100. package/dist/core/resolve-output-root.d.ts +3 -0
  101. package/dist/core/resolve-output-root.d.ts.map +1 -0
  102. package/dist/core/resolve-output-root.js +23 -0
  103. package/dist/core/resolve-output-root.js.map +1 -0
  104. package/dist/core/sort-shared-css.d.ts +2 -0
  105. package/dist/core/sort-shared-css.d.ts.map +1 -0
  106. package/dist/core/sort-shared-css.js +20 -0
  107. package/dist/core/sort-shared-css.js.map +1 -0
  108. package/dist/core/types.d.ts +1 -1
  109. package/dist/core/types.d.ts.map +1 -1
  110. package/dist/cypress/config/index.d.ts +1 -0
  111. package/dist/cypress/config/index.d.ts.map +1 -1
  112. package/dist/cypress/config/index.js +1 -0
  113. package/dist/cypress/config/index.js.map +1 -1
  114. package/dist/cypress/config/vite-config.d.ts +3 -0
  115. package/dist/cypress/config/vite-config.d.ts.map +1 -0
  116. package/dist/cypress/config/vite-config.js +58 -0
  117. package/dist/cypress/config/vite-config.js.map +1 -0
  118. package/dist/jest/resolver.d.ts.map +1 -1
  119. package/dist/jest/resolver.js +20 -1
  120. package/dist/jest/resolver.js.map +1 -1
  121. package/dist/storybook-config/index.d.ts +1 -0
  122. package/dist/storybook-config/index.d.ts.map +1 -1
  123. package/dist/storybook-config/index.js +1 -0
  124. package/dist/storybook-config/index.js.map +1 -1
  125. package/dist/storybook-config/vite-final.d.ts +7 -0
  126. package/dist/storybook-config/vite-final.d.ts.map +1 -0
  127. package/dist/storybook-config/vite-final.js +86 -0
  128. package/dist/storybook-config/vite-final.js.map +1 -0
  129. package/dist/utils/get-configuration.d.ts +15 -10
  130. package/dist/utils/get-configuration.d.ts.map +1 -1
  131. package/dist/utils/get-configuration.js +32 -2
  132. package/dist/utils/get-configuration.js.map +1 -1
  133. package/dist/utils/get-package-name.d.ts +2 -1
  134. package/dist/utils/get-package-name.d.ts.map +1 -1
  135. package/dist/utils/get-package-name.js +4 -2
  136. package/dist/utils/get-package-name.js.map +1 -1
  137. package/dist/utils/index.d.ts +1 -0
  138. package/dist/utils/index.d.ts.map +1 -1
  139. package/dist/utils/index.js.map +1 -1
  140. package/dist/utils/types.d.ts +2 -0
  141. package/dist/utils/types.d.ts.map +1 -0
  142. package/dist/utils/types.js +6 -0
  143. package/dist/utils/types.js.map +1 -0
  144. package/dist/utils/validate-shared-dependencies.d.ts.map +1 -1
  145. package/dist/utils/validate-shared-dependencies.js +4 -0
  146. package/dist/utils/validate-shared-dependencies.js.map +1 -1
  147. package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
  148. package/dist/vite/build-shared-dependencies.js +1 -2
  149. package/dist/vite/build-shared-dependencies.js.map +1 -1
  150. package/dist/vite/config/asset-file-names.d.ts +4 -0
  151. package/dist/vite/config/asset-file-names.d.ts.map +1 -0
  152. package/dist/vite/config/asset-file-names.js +29 -0
  153. package/dist/vite/config/asset-file-names.js.map +1 -0
  154. package/dist/vite/config/base-config.d.ts.map +1 -1
  155. package/dist/vite/config/base-config.js +67 -40
  156. package/dist/vite/config/base-config.js.map +1 -1
  157. package/dist/vite/config/code-splitting.d.ts +4 -0
  158. package/dist/vite/config/code-splitting.d.ts.map +1 -0
  159. package/dist/vite/config/code-splitting.js +48 -0
  160. package/dist/vite/config/code-splitting.js.map +1 -0
  161. package/dist/vite/config/create-css-config.d.ts +3 -0
  162. package/dist/vite/config/create-css-config.d.ts.map +1 -0
  163. package/dist/vite/config/create-css-config.js +26 -0
  164. package/dist/vite/config/create-css-config.js.map +1 -0
  165. package/dist/vite/config/create-filtering-logger.d.ts +3 -0
  166. package/dist/vite/config/create-filtering-logger.d.ts.map +1 -0
  167. package/dist/vite/config/create-filtering-logger.js +37 -0
  168. package/dist/vite/config/create-filtering-logger.js.map +1 -0
  169. package/dist/vite/config/create-vite-build-context.d.ts +2 -1
  170. package/dist/vite/config/create-vite-build-context.d.ts.map +1 -1
  171. package/dist/vite/config/create-vite-build-context.js.map +1 -1
  172. package/dist/vite/config/create-vite-config.d.ts.map +1 -1
  173. package/dist/vite/config/create-vite-config.js +30 -13
  174. package/dist/vite/config/create-vite-config.js.map +1 -1
  175. package/dist/vite/config/get-warmup-client-files.d.ts +3 -0
  176. package/dist/vite/config/get-warmup-client-files.d.ts.map +1 -0
  177. package/dist/vite/config/get-warmup-client-files.js +26 -0
  178. package/dist/vite/config/get-warmup-client-files.js.map +1 -0
  179. package/dist/vite/index.html +1 -0
  180. package/dist/vite/plugins/bundle-stat-plugin.d.ts +4 -0
  181. package/dist/vite/plugins/bundle-stat-plugin.d.ts.map +1 -0
  182. package/dist/vite/plugins/bundle-stat-plugin.js +32 -0
  183. package/dist/vite/plugins/bundle-stat-plugin.js.map +1 -0
  184. package/dist/vite/plugins/chain-source-maps-plugin.d.ts +3 -0
  185. package/dist/vite/plugins/chain-source-maps-plugin.d.ts.map +1 -0
  186. package/dist/vite/plugins/chain-source-maps-plugin.js +37 -0
  187. package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -0
  188. package/dist/vite/plugins/clean-plugin.d.ts +4 -0
  189. package/dist/vite/plugins/clean-plugin.d.ts.map +1 -0
  190. package/dist/vite/plugins/clean-plugin.js +63 -0
  191. package/dist/vite/plugins/clean-plugin.js.map +1 -0
  192. package/dist/vite/plugins/design-system-guard-plugin.d.ts +4 -0
  193. package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -0
  194. package/dist/vite/plugins/design-system-guard-plugin.js +35 -0
  195. package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -0
  196. package/dist/vite/plugins/ignore-modules-plugin.d.ts +21 -3
  197. package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
  198. package/dist/vite/plugins/ignore-modules-plugin.js +22 -8
  199. package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
  200. package/dist/vite/plugins/index.d.ts +7 -0
  201. package/dist/vite/plugins/index.d.ts.map +1 -1
  202. package/dist/vite/plugins/index.js +7 -0
  203. package/dist/vite/plugins/index.js.map +1 -1
  204. package/dist/vite/plugins/istanbul-plugin.d.ts +4 -0
  205. package/dist/vite/plugins/istanbul-plugin.d.ts.map +1 -0
  206. package/dist/vite/plugins/istanbul-plugin.js +27 -0
  207. package/dist/vite/plugins/istanbul-plugin.js.map +1 -0
  208. package/dist/vite/plugins/magic-comments-plugin/index.d.ts +2 -0
  209. package/dist/vite/plugins/magic-comments-plugin/index.d.ts.map +1 -0
  210. package/dist/vite/plugins/magic-comments-plugin/index.js +20 -0
  211. package/dist/vite/plugins/magic-comments-plugin/index.js.map +1 -0
  212. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.d.ts +4 -0
  213. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.d.ts.map +1 -0
  214. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +63 -0
  215. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -0
  216. package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.d.ts +6 -0
  217. package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.d.ts.map +1 -0
  218. package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.js +40 -0
  219. package/dist/vite/plugins/magic-comments-plugin/parse-magic-comments.js.map +1 -0
  220. package/dist/vite/plugins/metadata-plugin.js +2 -2
  221. package/dist/vite/plugins/metadata-plugin.js.map +1 -1
  222. package/dist/vite/plugins/moment-locales-plugin.d.ts +5 -0
  223. package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -0
  224. package/dist/vite/plugins/moment-locales-plugin.js +50 -0
  225. package/dist/vite/plugins/moment-locales-plugin.js.map +1 -0
  226. package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.d.ts +14 -0
  227. package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.d.ts.map +1 -0
  228. package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.js +100 -0
  229. package/dist/vite/plugins/shared-dependencies-plugin/assemble-iife.js.map +1 -0
  230. package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.d.ts +3 -0
  231. package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.d.ts.map +1 -0
  232. package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.js +56 -0
  233. package/dist/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.js.map +1 -0
  234. package/dist/vite/plugins/shared-dependencies-plugin/flatten.d.ts +2 -0
  235. package/dist/vite/plugins/shared-dependencies-plugin/flatten.d.ts.map +1 -0
  236. package/dist/vite/plugins/shared-dependencies-plugin/flatten.js +19 -0
  237. package/dist/vite/plugins/shared-dependencies-plugin/flatten.js.map +1 -0
  238. package/dist/vite/plugins/shared-dependencies-plugin/index.d.ts +2 -0
  239. package/dist/vite/plugins/shared-dependencies-plugin/index.d.ts.map +1 -0
  240. package/dist/vite/plugins/shared-dependencies-plugin/index.js +20 -0
  241. package/dist/vite/plugins/shared-dependencies-plugin/index.js.map +1 -0
  242. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -0
  243. package/dist/vite/plugins/{shared-dependencies-plugin.js → shared-dependencies-plugin/shared-dependencies-plugin.js} +29 -107
  244. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -0
  245. package/dist/vite/plugins/utils/import-esm.d.ts +2 -0
  246. package/dist/vite/plugins/utils/import-esm.d.ts.map +1 -0
  247. package/dist/vite/plugins/utils/import-esm.js +22 -0
  248. package/dist/vite/plugins/utils/import-esm.js.map +1 -0
  249. package/dist/vite/plugins/utils/index.d.ts +3 -0
  250. package/dist/vite/plugins/utils/index.d.ts.map +1 -0
  251. package/dist/vite/plugins/utils/index.js +21 -0
  252. package/dist/vite/plugins/utils/index.js.map +1 -0
  253. package/dist/webpack/configs/optimization-config.d.ts.map +1 -1
  254. package/dist/webpack/configs/optimization-config.js +53 -24
  255. package/dist/webpack/configs/optimization-config.js.map +1 -1
  256. package/dist/webpack/configs/output-config.d.ts.map +1 -1
  257. package/dist/webpack/configs/output-config.js +0 -1
  258. package/dist/webpack/configs/output-config.js.map +1 -1
  259. package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -1
  260. package/dist/webpack/configs/plugins/assets-manifest-plugin.js +11 -3
  261. package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -1
  262. package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -1
  263. package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +2 -21
  264. package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -1
  265. package/dist/webpack/configs/plugins/define-process-env-plugin.d.ts +5 -0
  266. package/dist/webpack/configs/plugins/define-process-env-plugin.d.ts.map +1 -0
  267. package/dist/webpack/configs/plugins/define-process-env-plugin.js +20 -0
  268. package/dist/webpack/configs/plugins/define-process-env-plugin.js.map +1 -0
  269. package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts +1 -1
  270. package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts.map +1 -1
  271. package/dist/webpack/configs/plugins/filter-warnings-plugin.js +1 -4
  272. package/dist/webpack/configs/plugins/filter-warnings-plugin.js.map +1 -1
  273. package/dist/webpack/configs/plugins/ignore-plugin/empty-module.d.ts +2 -0
  274. package/dist/webpack/configs/plugins/ignore-plugin/empty-module.d.ts.map +1 -0
  275. package/dist/webpack/configs/plugins/ignore-plugin/empty-module.js +11 -0
  276. package/dist/webpack/configs/plugins/ignore-plugin/empty-module.js.map +1 -0
  277. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.d.ts +26 -3
  278. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.d.ts.map +1 -1
  279. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +41 -10
  280. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
  281. package/dist/webpack/configs/plugins/index.d.ts +1 -0
  282. package/dist/webpack/configs/plugins/index.d.ts.map +1 -1
  283. package/dist/webpack/configs/plugins/index.js +1 -0
  284. package/dist/webpack/configs/plugins/index.js.map +1 -1
  285. package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts.map +1 -1
  286. package/dist/webpack/configs/plugins/moment-locales-plugin.js +2 -5
  287. package/dist/webpack/configs/plugins/moment-locales-plugin.js.map +1 -1
  288. package/dist/webpack/configs/plugins-config.d.ts.map +1 -1
  289. package/dist/webpack/configs/plugins-config.js +1 -0
  290. package/dist/webpack/configs/plugins-config.js.map +1 -1
  291. package/dist/webpack/configs/rules/font-rules.d.ts.map +1 -1
  292. package/dist/webpack/configs/rules/font-rules.js +2 -1
  293. package/dist/webpack/configs/rules/font-rules.js.map +1 -1
  294. package/dist/webpack/configs/rules/image-rules.d.ts.map +1 -1
  295. package/dist/webpack/configs/rules/image-rules.js +2 -1
  296. package/dist/webpack/configs/rules/image-rules.js.map +1 -1
  297. package/dist/webpack/create-webpack-config.d.ts.map +1 -1
  298. package/dist/webpack/create-webpack-config.js +8 -3
  299. package/dist/webpack/create-webpack-config.js.map +1 -1
  300. package/dist/webpack/create-webpack-configs.d.ts.map +1 -1
  301. package/dist/webpack/create-webpack-configs.js +4 -12
  302. package/dist/webpack/create-webpack-configs.js.map +1 -1
  303. package/dist/webpack/types.d.ts +1 -1
  304. package/dist/webpack/types.d.ts.map +1 -1
  305. package/dist/webpack/utils/create-webpack-build-context.d.ts.map +1 -1
  306. package/dist/webpack/utils/create-webpack-build-context.js +1 -2
  307. package/dist/webpack/utils/create-webpack-build-context.js.map +1 -1
  308. package/package.json +22 -18
  309. package/src/cli/commands/__tests__/build.test.ts +33 -5
  310. package/src/cli/commands/__tests__/bundle-vite.test.ts +50 -1
  311. package/src/cli/commands/__tests__/start.test.ts +17 -4
  312. package/src/cli/commands/build.ts +5 -6
  313. package/src/cli/commands/bundle-vite.ts +13 -0
  314. package/src/cli/commands/registry/build.ts +6 -1
  315. package/src/cli/commands/registry/command-registry.ts +0 -1
  316. package/src/cli/commands/registry/start.ts +6 -1
  317. package/src/cli/commands/review/rules/__tests__/require-compatible-typescript.test.ts +127 -0
  318. package/src/cli/commands/review/rules/index.ts +2 -0
  319. package/src/cli/commands/review/rules/require-compatible-typescript.ts +64 -0
  320. package/src/cli/commands/start.ts +4 -4
  321. package/src/cli/commands/test/runners/__tests__/vitest.test.ts +8 -1
  322. package/src/cli/commands/test/runners/vitest.ts +5 -3
  323. package/src/cli/index.ts +2 -2
  324. package/src/cli/utils/__tests__/get-bundle-command.test.ts +23 -0
  325. package/src/cli/utils/__tests__/get-exit-code.test.ts +41 -0
  326. package/src/cli/utils/__tests__/resolve-bundler.test.ts +64 -0
  327. package/src/cli/utils/get-bundle-command.ts +5 -0
  328. package/src/cli/utils/get-exit-code.ts +17 -0
  329. package/src/cli/utils/index.ts +3 -0
  330. package/src/cli/utils/resolve-bundler.ts +23 -0
  331. package/src/core/__tests__/bundle-report.test.ts +60 -0
  332. package/src/core/__tests__/create-extension-regexp.test.ts +32 -0
  333. package/src/core/__tests__/resolve-output-path.test.ts +45 -0
  334. package/src/core/__tests__/resolve-output-root.test.ts +37 -0
  335. package/src/core/__tests__/sort-shared-css.test.ts +39 -0
  336. package/src/core/bundle-report.ts +33 -0
  337. package/src/core/check-resource/__tests__/check-resource.test.ts +21 -7
  338. package/src/core/check-resource/__tests__/get-peer-dependency-meta.test.ts +70 -13
  339. package/src/core/check-resource/__tests__/is-resolvable.test.ts +20 -0
  340. package/src/core/check-resource/check-resource.ts +17 -16
  341. package/src/core/check-resource/get-peer-dependency-meta.ts +67 -4
  342. package/src/core/check-resource/index.ts +1 -1
  343. package/src/core/check-resource/is-resolvable.ts +19 -0
  344. package/src/core/check-resource/types.ts +2 -0
  345. package/src/core/chunk-patterns.ts +30 -0
  346. package/src/core/create-build-context.ts +2 -2
  347. package/src/core/create-extension-regexp.ts +7 -0
  348. package/src/core/get-process-env.ts +17 -0
  349. package/src/core/index.ts +8 -1
  350. package/src/core/moment-locales.ts +6 -0
  351. package/src/core/resolve-output-path.ts +10 -0
  352. package/src/core/resolve-output-root.ts +8 -0
  353. package/src/core/sort-shared-css.ts +7 -0
  354. package/src/core/types.ts +1 -1
  355. package/src/cypress/config/__tests__/vite-config.test.ts +72 -0
  356. package/src/cypress/config/index.ts +1 -0
  357. package/src/cypress/config/vite-config.ts +37 -0
  358. package/src/jest/__tests__/resolver.test.ts +42 -1
  359. package/src/jest/resolver.ts +17 -1
  360. package/src/storybook-config/__tests__/vite-final.test.ts +122 -0
  361. package/src/storybook-config/index.ts +1 -0
  362. package/src/storybook-config/vite-final.ts +65 -0
  363. package/src/utils/__tests__/get-configuration.test.ts +82 -5
  364. package/src/utils/__tests__/get-package-name.test.ts +57 -0
  365. package/src/utils/__tests__/validate-shared-dependencies.test.ts +50 -35
  366. package/src/utils/get-configuration.ts +50 -15
  367. package/src/utils/get-package-name.ts +8 -2
  368. package/src/utils/index.ts +1 -0
  369. package/src/utils/types.ts +1 -0
  370. package/src/utils/validate-shared-dependencies.ts +15 -1
  371. package/src/vite/__tests__/build-shared-dependencies.test.ts +13 -26
  372. package/src/vite/__tests__/validate-shared-dependencies.test.ts +30 -19
  373. package/src/vite/build-shared-dependencies.ts +3 -7
  374. package/src/vite/config/__tests__/asset-file-names.test.ts +40 -0
  375. package/src/vite/config/__tests__/base-config.test.ts +99 -31
  376. package/src/vite/config/__tests__/code-splitting.test.ts +34 -0
  377. package/src/vite/config/__tests__/create-css-config.test.ts +58 -0
  378. package/src/vite/config/__tests__/create-filtering-logger.test.ts +51 -0
  379. package/src/vite/config/__tests__/create-vite-build-context.test.ts +5 -2
  380. package/src/vite/config/__tests__/create-vite-config.test.ts +91 -13
  381. package/src/vite/config/__tests__/get-warmup-client-files.test.ts +20 -0
  382. package/src/vite/config/asset-file-names.ts +20 -0
  383. package/src/vite/config/base-config.ts +45 -37
  384. package/src/vite/config/code-splitting.ts +23 -0
  385. package/src/vite/config/create-css-config.ts +16 -0
  386. package/src/vite/config/create-filtering-logger.ts +34 -0
  387. package/src/vite/config/create-vite-build-context.ts +3 -5
  388. package/src/vite/config/create-vite-config.ts +45 -12
  389. package/src/vite/config/get-warmup-client-files.ts +13 -0
  390. package/src/vite/index.html +1 -0
  391. package/src/vite/plugins/__tests__/bundle-stat-plugin.test.ts +70 -0
  392. package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +58 -0
  393. package/src/vite/plugins/__tests__/clean-plugin.test.ts +121 -0
  394. package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +83 -0
  395. package/src/vite/plugins/__tests__/html-template.test.ts +6 -0
  396. package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +29 -7
  397. package/src/vite/plugins/__tests__/istanbul-plugin.test.ts +62 -0
  398. package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +104 -0
  399. package/src/vite/plugins/bundle-stat-plugin.ts +24 -0
  400. package/src/vite/plugins/chain-source-maps-plugin.ts +26 -0
  401. package/src/vite/plugins/clean-plugin.ts +46 -0
  402. package/src/vite/plugins/design-system-guard-plugin.ts +34 -0
  403. package/src/vite/plugins/ignore-modules-plugin.ts +36 -7
  404. package/src/vite/plugins/index.ts +7 -0
  405. package/src/vite/plugins/istanbul-plugin.ts +19 -0
  406. package/src/vite/plugins/magic-comments-plugin/__tests__/magic-comments-plugin.test.ts +105 -0
  407. package/src/vite/plugins/magic-comments-plugin/__tests__/parse-magic-comments.test.ts +40 -0
  408. package/src/vite/plugins/magic-comments-plugin/index.ts +1 -0
  409. package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +63 -0
  410. package/src/vite/plugins/magic-comments-plugin/parse-magic-comments.ts +39 -0
  411. package/src/vite/plugins/metadata-plugin.ts +1 -1
  412. package/src/vite/plugins/moment-locales-plugin.ts +41 -0
  413. package/src/vite/plugins/shared-dependencies-plugin/__tests__/assemble-iife.test.ts +29 -0
  414. package/src/vite/plugins/shared-dependencies-plugin/__tests__/assert-no-dynamic-css.test.ts +113 -0
  415. package/src/vite/plugins/shared-dependencies-plugin/__tests__/flatten.test.ts +23 -0
  416. package/src/vite/plugins/{__tests__ → shared-dependencies-plugin/__tests__}/shared-dependencies-plugin.test.ts +38 -4
  417. package/src/vite/plugins/shared-dependencies-plugin/assemble-iife.ts +114 -0
  418. package/src/vite/plugins/shared-dependencies-plugin/assert-no-dynamic-css.ts +58 -0
  419. package/src/vite/plugins/shared-dependencies-plugin/flatten.ts +8 -0
  420. package/src/vite/plugins/shared-dependencies-plugin/index.ts +1 -0
  421. package/src/vite/plugins/{shared-dependencies-plugin.ts → shared-dependencies-plugin/shared-dependencies-plugin.ts} +24 -115
  422. package/src/vite/plugins/utils/import-esm.ts +15 -0
  423. package/src/vite/plugins/utils/index.ts +2 -0
  424. package/src/vite/rolldown-oxc.d.ts +20 -0
  425. package/src/webpack/__tests__/bundle-webpack.test.ts +8 -8
  426. package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +54 -5
  427. package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +81 -12
  428. package/src/webpack/__tests__/create-webpack-config.test.ts +92 -9
  429. package/src/webpack/configs/optimization-config.ts +47 -25
  430. package/src/webpack/configs/output-config.ts +1 -2
  431. package/src/webpack/configs/plugins/assets-manifest-plugin.ts +16 -4
  432. package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +3 -25
  433. package/src/webpack/configs/plugins/define-process-env-plugin.ts +10 -0
  434. package/src/webpack/configs/plugins/filter-warnings-plugin.ts +1 -5
  435. package/src/webpack/configs/plugins/ignore-plugin/__tests__/ignore-plugin.test.ts +76 -24
  436. package/src/webpack/configs/plugins/ignore-plugin/empty-module.ts +7 -0
  437. package/src/webpack/configs/plugins/ignore-plugin/ignore-plugin.ts +59 -9
  438. package/src/webpack/configs/plugins/index.ts +1 -0
  439. package/src/webpack/configs/plugins/moment-locales-plugin.ts +2 -2
  440. package/src/webpack/configs/plugins-config.ts +2 -0
  441. package/src/webpack/configs/rules/font-rules.ts +2 -2
  442. package/src/webpack/configs/rules/image-rules.ts +2 -2
  443. package/src/webpack/create-webpack-config.ts +11 -4
  444. package/src/webpack/create-webpack-configs.ts +2 -8
  445. package/src/webpack/types.ts +1 -4
  446. package/src/webpack/utils/create-webpack-build-context.ts +1 -6
  447. package/tsconfig/base.json +1 -1
  448. package/tsconfig/types.d.ts +10 -0
  449. package/dist/core/get-output-path.d.ts +0 -3
  450. package/dist/core/get-output-path.d.ts.map +0 -1
  451. package/dist/core/get-output-path.js +0 -29
  452. package/dist/core/get-output-path.js.map +0 -1
  453. package/dist/vite/plugins/shared-dependencies-plugin.d.ts.map +0 -1
  454. package/dist/vite/plugins/shared-dependencies-plugin.js.map +0 -1
  455. package/src/core/__tests__/get-output-path.test.ts +0 -64
  456. package/src/core/get-output-path.ts +0 -15
  457. /package/dist/vite/plugins/{shared-dependencies-plugin.d.ts → shared-dependencies-plugin/shared-dependencies-plugin.d.ts} +0 -0
@@ -0,0 +1,13 @@
1
+ import path from 'path';
2
+ import { ViteBuildContext } from '../types';
3
+
4
+ /*
5
+ * Returns the glob patterns the dev server warms at startup: the package's compiled
6
+ * output, minus the production bundle. Warming the bundle makes Vite read sourcemaps
7
+ * that reference sources it cannot resolve, logging "missing source files" warnings.
8
+ */
9
+ export function getWarmupClientFiles(context: ViteBuildContext, outputRoot: string): string[] {
10
+ const { destination } = context.package;
11
+ const bundleDir = path.relative(process.cwd(), outputRoot);
12
+ return [`${destination}/**/*.js`, `!${bundleDir.replace(/\\/g, '/')}/**`];
13
+ }
@@ -2,6 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
5
6
  <title><%= it.title %></title>
6
7
  <% if (it.favicon) { %>
7
8
  <link rel="icon" href="<%= it.favicon %>" />
@@ -0,0 +1,70 @@
1
+ import os from 'os';
2
+ import path from 'path';
3
+ import { analyzer, unstableRolldownAdapter } from 'vite-bundle-analyzer';
4
+ import { bundleReportFileName, bundleReportTitle } from '../../../core';
5
+ import { ViteBuildContext } from '../../types';
6
+ import { bundleStatPlugin } from '../bundle-stat-plugin';
7
+
8
+ jest.mock('vite-bundle-analyzer', () => ({
9
+ analyzer: jest.fn(() => ({ name: 'analyzer-plugin' })),
10
+ unstableRolldownAdapter: jest.fn(() => ({ name: 'bundle-stat' })),
11
+ }));
12
+ jest.mock('../../../core', () => ({
13
+ bundleReportFileName: jest.fn(() => 'report-name'),
14
+ bundleReportTitle: jest.fn(() => 'Report Title'),
15
+ }));
16
+
17
+ describe(bundleStatPlugin.name, () => {
18
+ let context: ViteBuildContext;
19
+
20
+ beforeEach(() => {
21
+ jest.clearAllMocks();
22
+ context = { options: {} } as ViteBuildContext;
23
+ });
24
+
25
+ const subject = () => bundleStatPlugin(context);
26
+
27
+ test('returns undefined', () => {
28
+ expect(subject()).toBeUndefined();
29
+ });
30
+
31
+ describe('when buildStat is true', () => {
32
+ beforeEach(() => (context.options.buildStat = true));
33
+
34
+ test('returns a plugin with correct name', () => {
35
+ expect(subject()).toEqual({ name: 'bundle-stat' });
36
+ });
37
+
38
+ test('configures the analyzer for a static report', () => {
39
+ subject();
40
+
41
+ expect(analyzer).toHaveBeenCalledWith(
42
+ expect.objectContaining({ analyzerMode: 'static', openAnalyzer: true })
43
+ );
44
+ });
45
+
46
+ test('configures report title', () => {
47
+ subject();
48
+
49
+ expect(analyzer).toHaveBeenCalledWith(
50
+ expect.objectContaining({ reportTitle: bundleReportTitle(context) })
51
+ );
52
+ });
53
+
54
+ test('configures report location', () => {
55
+ subject();
56
+
57
+ const { fileName } = jest.mocked(analyzer).mock.calls[0][0] as {
58
+ fileName: () => string;
59
+ };
60
+
61
+ expect(fileName()).toBe(path.join(os.tmpdir(), bundleReportFileName(context)));
62
+ });
63
+
64
+ test('feeds the analyzer plugin through the rolldown adapter', () => {
65
+ subject();
66
+
67
+ expect(unstableRolldownAdapter).toHaveBeenCalledWith({ name: 'analyzer-plugin' });
68
+ });
69
+ });
70
+ });
@@ -0,0 +1,58 @@
1
+ import { fs, vol } from 'memfs';
2
+ import path from 'path';
3
+ import { chainSourceMapsPlugin } from '../chain-source-maps-plugin';
4
+
5
+ jest.mock('fs', () => fs);
6
+
7
+ describe(chainSourceMapsPlugin.name, () => {
8
+ const code = 'compiled code';
9
+ const map = { version: 3, sources: ['../src/foo.ts'], sourcesContent: ['source'] };
10
+
11
+ let id: string;
12
+
13
+ beforeEach(() => {
14
+ id = '/abs/pkg/dist/foo.js';
15
+ vol.fromJSON({ [id]: code, [`${id}.map`]: JSON.stringify(map) });
16
+ });
17
+
18
+ afterEach(() => vol.reset());
19
+
20
+ const subject = () => {
21
+ const plugin = chainSourceMapsPlugin();
22
+ return (plugin.load as Function).call(plugin, id);
23
+ };
24
+
25
+ test('has correct name', () => {
26
+ expect(chainSourceMapsPlugin().name).toBe('chain-source-maps');
27
+ });
28
+
29
+ test('returns code with *.js.map sources as absolute paths', () => {
30
+ expect(subject()).toEqual({
31
+ code,
32
+ map: {
33
+ ...map,
34
+ sources: map.sources.map(source =>
35
+ path.resolve(path.dirname(id), source).replace(/\\/g, '/')
36
+ ),
37
+ },
38
+ });
39
+ });
40
+
41
+ function itReturnsUndefined() {
42
+ test('returns undefined', () => {
43
+ expect(subject()).toBeUndefined();
44
+ });
45
+ }
46
+
47
+ describe('when id is not a .js file', () => {
48
+ beforeEach(() => (id = '/abs/pkg/src/foo.ts'));
49
+
50
+ itReturnsUndefined();
51
+ });
52
+
53
+ describe('when no sibling .map exists', () => {
54
+ beforeEach(() => vol.reset());
55
+
56
+ itReturnsUndefined();
57
+ });
58
+ });
@@ -0,0 +1,121 @@
1
+ import { fs, vol } from 'memfs';
2
+ import path from 'path';
3
+ import type { BuildContext } from '../../../core';
4
+ import { cleanPlugin } from '../clean-plugin';
5
+
6
+ jest.mock('fs', () => fs);
7
+
8
+ describe('[startup] cleanPlugin', () => {
9
+ let context: BuildContext;
10
+
11
+ beforeEach(() => {
12
+ vol.fromJSON({});
13
+ context = {
14
+ package: { isWebComponent: false, isExposeSharedDependencies: true },
15
+ build: { emitExposedDependencies: false },
16
+ } as BuildContext;
17
+ });
18
+
19
+ afterEach(() => vol.reset());
20
+
21
+ const plugin = () => cleanPlugin(context);
22
+
23
+ test('returns a plugin named clean', () => {
24
+ expect(plugin().name).toBe('clean');
25
+ });
26
+
27
+ test('applies only to build', () => {
28
+ expect(plugin().apply).toBe('build');
29
+ });
30
+
31
+ describe('config', () => {
32
+ const subject = () => (plugin().config as Function)();
33
+
34
+ test('sets build.emptyOutDir to false', () => {
35
+ expect(subject().build.emptyOutDir).toBe(false);
36
+ });
37
+
38
+ describe('when package is a web component', () => {
39
+ beforeEach(() => (context.package.isWebComponent = true));
40
+
41
+ test('sets build.emptyOutDir to true', () => {
42
+ expect(subject().build.emptyOutDir).toBe(true);
43
+ });
44
+ });
45
+ });
46
+
47
+ describe('buildStart', () => {
48
+ const outDir = '/dist/bundle';
49
+ const outputFiles = { [`${outDir}/foo.js`]: '', [`${outDir}/bar.css`]: '' };
50
+
51
+ beforeEach(() => vol.fromJSON(outputFiles));
52
+
53
+ const subject = () => {
54
+ const instance = plugin();
55
+ (instance.configResolved as Function).call(instance, { build: { outDir } });
56
+ (instance.buildStart as Function).call(instance);
57
+ };
58
+
59
+ function itRemovesAllOutputFiles() {
60
+ test('removes all output files', () => {
61
+ subject();
62
+
63
+ expect(fs.readdirSync(outDir)).toHaveLength(0);
64
+ });
65
+ }
66
+
67
+ itRemovesAllOutputFiles();
68
+
69
+ describe('when package is a web component', () => {
70
+ beforeEach(() => (context.package.isWebComponent = true));
71
+
72
+ test('removes nothing', () => {
73
+ subject();
74
+
75
+ expect(fs.readdirSync(outDir)).toHaveLength(Object.keys(outputFiles).length);
76
+ });
77
+ });
78
+
79
+ describe('when the output directory does not exist', () => {
80
+ beforeEach(() => vol.reset());
81
+
82
+ test('does not throw', () => {
83
+ expect(subject).not.toThrow();
84
+ });
85
+ });
86
+
87
+ describe('with shared dependencies', () => {
88
+ const sharedDependency = `${outDir}/shared/react.js`;
89
+
90
+ beforeEach(() => vol.fromJSON({ ...outputFiles, [sharedDependency]: '' }));
91
+
92
+ function getAllFilesSync(dirPath: string) {
93
+ const entries = fs.readdirSync(dirPath, {
94
+ recursive: true,
95
+ withFileTypes: true,
96
+ }) as unknown as { parentPath: string; name: string; isFile(): boolean }[];
97
+ return entries
98
+ .filter(entry => entry.isFile())
99
+ .map(entry => path.join(entry.parentPath, entry.name));
100
+ }
101
+
102
+ test('keeps only shared dependencies', () => {
103
+ subject();
104
+
105
+ expect(getAllFilesSync(outDir)).toEqual([path.normalize(sharedDependency)]);
106
+ });
107
+
108
+ describe('when emitting exposed dependencies', () => {
109
+ beforeEach(() => (context.build.emitExposedDependencies = true));
110
+
111
+ itRemovesAllOutputFiles();
112
+ });
113
+
114
+ describe('when not exposing shared dependencies', () => {
115
+ beforeEach(() => (context.package.isExposeSharedDependencies = false));
116
+
117
+ itRemovesAllOutputFiles();
118
+ });
119
+ });
120
+ });
121
+ });
@@ -0,0 +1,83 @@
1
+ import { BuildContext } from '../../../core';
2
+ import { designSystemGuardPlugin } from '../design-system-guard-plugin';
3
+
4
+ describe(designSystemGuardPlugin.name, () => {
5
+ let context: BuildContext;
6
+
7
+ beforeEach(() => {
8
+ context = {
9
+ package: {
10
+ isExposeSharedDependencies: true,
11
+ sharedDependencies: { '@servicetitan/design-system': '1.0.0' },
12
+ },
13
+ build: { emitExposedDependencies: false },
14
+ } as unknown as BuildContext;
15
+ });
16
+
17
+ const subject = () => designSystemGuardPlugin(context);
18
+
19
+ test('creates plugin with correct name', () => {
20
+ expect(subject().name).toBe('design-system-guard');
21
+ });
22
+
23
+ test('enforces pre order so it runs before built-in resolvers', () => {
24
+ expect(subject().enforce).toBe('pre');
25
+ });
26
+
27
+ describe('resolveId', () => {
28
+ let pluginContext: { error: jest.Mock };
29
+ let source: string;
30
+ let importer: string | undefined;
31
+
32
+ beforeEach(() => {
33
+ pluginContext = { error: jest.fn() };
34
+ source = './design-system.css';
35
+ importer = '/src/app.tsx';
36
+ });
37
+
38
+ const subject = () => {
39
+ const plugin = designSystemGuardPlugin(context);
40
+ return (plugin.resolveId as Function).call(pluginContext, source, importer);
41
+ };
42
+
43
+ function itReportsNoError() {
44
+ test('reports no error', () => {
45
+ subject();
46
+
47
+ expect(pluginContext.error).not.toHaveBeenCalled();
48
+ });
49
+ }
50
+
51
+ test('reports error when design-system.css is imported', () => {
52
+ subject();
53
+
54
+ expect(pluginContext.error).toHaveBeenCalledWith(
55
+ 'do not import design-system.css in "app"; it is automatically included as a shared dependency'
56
+ );
57
+ });
58
+
59
+ describe('when other css is imported', () => {
60
+ beforeEach(() => (source = './styles.css'));
61
+
62
+ itReportsNoError();
63
+ });
64
+
65
+ describe('when the package does not expose shared dependencies', () => {
66
+ beforeEach(() => (context.package.isExposeSharedDependencies = false));
67
+
68
+ itReportsNoError();
69
+ });
70
+
71
+ describe('when the design system is not a shared dependency', () => {
72
+ beforeEach(() => (context.package.sharedDependencies = {}));
73
+
74
+ itReportsNoError();
75
+ });
76
+
77
+ describe('when building the shared dependencies bundle', () => {
78
+ beforeEach(() => (context.build.emitExposedDependencies = true));
79
+
80
+ itReportsNoError();
81
+ });
82
+ });
83
+ });
@@ -33,6 +33,12 @@ describe('Vite host HTML template', () => {
33
33
  expect(subject()).toContain('<title>ServiceTitan</title>');
34
34
  });
35
35
 
36
+ test('renders the viewport meta tag', () => {
37
+ expect(subject()).toContain(
38
+ '<meta name="viewport" content="width=device-width,initial-scale=1" />'
39
+ );
40
+ });
41
+
36
42
  describe('with a configured title', () => {
37
43
  beforeEach(() => (context.bundlerConfig.pluginOverrides.html = { title: 'My App' }));
38
44
 
@@ -1,5 +1,5 @@
1
1
  import { BuildContext, checkResource } from '../../../core';
2
- import { ignoreModulesPlugin, VIRTUAL_PREFIX } from '../ignore-modules-plugin';
2
+ import { EMPTY_PREFIX, ignoreModulesPlugin, THROW_PREFIX } from '../ignore-modules-plugin';
3
3
 
4
4
  jest.mock('../../../core', () => ({
5
5
  checkResource: jest.fn(),
@@ -43,11 +43,25 @@ describe(ignoreModulesPlugin.name, () => {
43
43
 
44
44
  itReturnsUndefined();
45
45
 
46
- describe('when checker matches the resource', () => {
47
- beforeEach(() => checker.mockReturnValue(true));
46
+ describe('when checker returns "throw"', () => {
47
+ beforeEach(() => checker.mockReturnValue('throw'));
48
48
 
49
- test('returns virtual id', () => {
50
- expect(subject()).toBe(`${VIRTUAL_PREFIX}${moduleName}`);
49
+ test('returns throw-prefixed virtual id', () => {
50
+ expect(subject()).toBe(`${THROW_PREFIX}${moduleName}`);
51
+ });
52
+
53
+ describe('when importer is not provided', () => {
54
+ beforeEach(() => (importer = undefined));
55
+
56
+ itReturnsUndefined();
57
+ });
58
+ });
59
+
60
+ describe('when checker returns "empty"', () => {
61
+ beforeEach(() => checker.mockReturnValue('empty'));
62
+
63
+ test('returns empty-prefixed virtual id', () => {
64
+ expect(subject()).toBe(`${EMPTY_PREFIX}${moduleName}`);
51
65
  });
52
66
 
53
67
  describe('when importer is not provided', () => {
@@ -72,8 +86,8 @@ describe(ignoreModulesPlugin.name, () => {
72
86
  expect(subject()).toBeUndefined();
73
87
  });
74
88
 
75
- describe('when id has virtual prefix', () => {
76
- beforeEach(() => (id = `${VIRTUAL_PREFIX}${moduleName}`));
89
+ describe('when id has throw prefix', () => {
90
+ beforeEach(() => (id = `${THROW_PREFIX}${moduleName}`));
77
91
 
78
92
  test('returns module that throws MODULE_NOT_FOUND on evaluation', () => {
79
93
  expect(subject()).toBe(
@@ -81,5 +95,13 @@ describe(ignoreModulesPlugin.name, () => {
81
95
  );
82
96
  });
83
97
  });
98
+
99
+ describe('when id has empty prefix', () => {
100
+ beforeEach(() => (id = `${EMPTY_PREFIX}${moduleName}`));
101
+
102
+ test('returns module with no exports', () => {
103
+ expect(subject()).toBe('export {};');
104
+ });
105
+ });
84
106
  });
85
107
  });
@@ -0,0 +1,62 @@
1
+ import type { ViteBuildContext } from '../../types';
2
+ import { istanbulPlugin } from '../istanbul-plugin';
3
+ import { importEsm } from '../utils';
4
+
5
+ jest.mock('../utils/import-esm');
6
+
7
+ describe(istanbulPlugin.name, () => {
8
+ const mockIstanbul = jest.fn(() => ({ name: 'vite-plugin-istanbul' }));
9
+ let context: ViteBuildContext;
10
+
11
+ beforeEach(() => {
12
+ jest.clearAllMocks();
13
+ jest.mocked(importEsm).mockResolvedValue({ default: mockIstanbul });
14
+ context = { options: {} } as ViteBuildContext;
15
+ });
16
+
17
+ const subject = () => istanbulPlugin(context);
18
+
19
+ test('returns undefined', () => {
20
+ expect(subject()).toBeUndefined();
21
+ });
22
+
23
+ describe('when code coverage is enabled', () => {
24
+ beforeEach(() => {
25
+ context.options.codeCoverage = true;
26
+ });
27
+
28
+ test('loads vite-plugin-istanbul', async () => {
29
+ await subject();
30
+
31
+ expect(importEsm).toHaveBeenCalledWith('vite-plugin-istanbul');
32
+ });
33
+
34
+ test('returns the istanbul plugin', async () => {
35
+ expect(await subject()).toEqual({ name: 'vite-plugin-istanbul' });
36
+ });
37
+
38
+ test('instruments production builds', async () => {
39
+ await subject();
40
+
41
+ expect(mockIstanbul).toHaveBeenCalledWith(
42
+ expect.objectContaining({ forceBuildInstrument: true })
43
+ );
44
+ });
45
+
46
+ test('instruments without requiring an env flag', async () => {
47
+ await subject();
48
+
49
+ expect(mockIstanbul).toHaveBeenCalledWith(
50
+ expect.objectContaining({ requireEnv: false })
51
+ );
52
+ });
53
+
54
+ test('excludes node_modules and yalc', async () => {
55
+ await subject();
56
+
57
+ expect(mockIstanbul).toHaveBeenCalledWith(
58
+ expect.objectContaining({ exclude: ['**/node_modules/**', '**/.yalc/**'] })
59
+ );
60
+ });
61
+ });
62
+ });
@@ -0,0 +1,104 @@
1
+ import { BuildContext } from '../../../core';
2
+ import { VIRTUAL_MOMENT, momentLocalesPlugin } from '../moment-locales-plugin';
3
+
4
+ const LOCALES_TO_KEEP = ['en-au', 'en-ca', 'en-gb'];
5
+ const context = {} as BuildContext;
6
+
7
+ describe(momentLocalesPlugin.name, () => {
8
+ const subject = () => momentLocalesPlugin(context);
9
+
10
+ test('creates plugin with correct name', () => {
11
+ expect(subject().name).toBe('moment-locales');
12
+ });
13
+
14
+ test('enforces pre order so it runs before built-in resolvers', () => {
15
+ expect(subject().enforce).toBe('pre');
16
+ });
17
+
18
+ describe('resolveId', () => {
19
+ const importer = 'importer.ts';
20
+ let source: string;
21
+ let resolve: jest.Mock;
22
+
23
+ beforeEach(() => {
24
+ source = 'react';
25
+ resolve = jest.fn(() => `resolved: ${source}`);
26
+ });
27
+
28
+ const subject = () => {
29
+ const plugin = momentLocalesPlugin(context);
30
+ return (plugin.resolveId as Function).call({ resolve }, source, importer, {});
31
+ };
32
+
33
+ const itReturnsUndefined = () => {
34
+ test('returns undefined', () => {
35
+ expect(subject()).toBeUndefined();
36
+ });
37
+ };
38
+
39
+ itReturnsUndefined();
40
+
41
+ describe('when source is "moment"', () => {
42
+ beforeEach(() => (source = 'moment'));
43
+
44
+ test('returns the virtual module', () => {
45
+ expect(subject()).toBe(VIRTUAL_MOMENT);
46
+ });
47
+ });
48
+
49
+ describe('when source is a UMD moment path', () => {
50
+ beforeEach(() => (source = 'moment/locale/fr'));
51
+
52
+ test('resolves the ESM moment path', async () => {
53
+ await subject();
54
+
55
+ expect(resolve).toHaveBeenCalledWith(
56
+ source.replace('/locale/', '/dist/locale/'),
57
+ importer,
58
+ {}
59
+ );
60
+ });
61
+
62
+ test('returns the resolved ESM moment path', async () => {
63
+ expect(await subject()).toEqual(resolve(source));
64
+ });
65
+ });
66
+
67
+ describe('when source is already an ESM moment path', () => {
68
+ beforeEach(() => (source = 'moment/dist/locale/fr'));
69
+
70
+ itReturnsUndefined();
71
+ });
72
+ });
73
+
74
+ describe('load', () => {
75
+ let id: string;
76
+
77
+ beforeEach(() => (id = 'react'));
78
+
79
+ const subject = () => {
80
+ const plugin = momentLocalesPlugin(context);
81
+ return (plugin.load as Function).call(plugin, id) as string | undefined;
82
+ };
83
+
84
+ test('returns undefined', () => {
85
+ expect(subject()).toBeUndefined();
86
+ });
87
+
88
+ describe('when id is the virtual module', () => {
89
+ beforeEach(() => (id = VIRTUAL_MOMENT));
90
+
91
+ test.each(LOCALES_TO_KEEP)('imports the ESM %s locale', locale => {
92
+ expect(subject()).toContain(`import 'moment/dist/locale/${locale}';`);
93
+ });
94
+
95
+ test('imports moment from the ESM build', () => {
96
+ expect(subject()).toContain("import moment from 'moment/dist/moment.js';");
97
+ });
98
+
99
+ test('re-exports moment as the default', () => {
100
+ expect(subject()).toContain('export default moment;');
101
+ });
102
+ });
103
+ });
104
+ });
@@ -0,0 +1,24 @@
1
+ import os from 'os';
2
+ import path from 'path';
3
+ import type { Plugin } from 'vite';
4
+ import { analyzer, unstableRolldownAdapter } from 'vite-bundle-analyzer';
5
+ import { bundleReportFileName, bundleReportTitle } from '../../core';
6
+ import { ViteBuildContext } from '../types';
7
+
8
+ /*
9
+ * Writes a static bundle-size treemap to the temp directory when --stat is passed, parity with the webpack build.
10
+ */
11
+ export function bundleStatPlugin(context: ViteBuildContext): Plugin | undefined {
12
+ if (!context.options.buildStat) {
13
+ return;
14
+ }
15
+
16
+ return unstableRolldownAdapter(
17
+ analyzer({
18
+ analyzerMode: 'static',
19
+ fileName: () => path.join(os.tmpdir(), bundleReportFileName(context)),
20
+ reportTitle: bundleReportTitle(context),
21
+ openAnalyzer: true,
22
+ })
23
+ ) as Plugin;
24
+ }
@@ -0,0 +1,26 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import type { Plugin } from 'rolldown';
4
+
5
+ /*
6
+ * Return each compiled `.js` file's external `.js.map` (emitted by SWC) from the
7
+ * load hook so Rolldown chains it, making source maps resolve to the original
8
+ * `.ts` instead of stopping at the compiled `.js`.
9
+ */
10
+ export function chainSourceMapsPlugin(): Plugin {
11
+ return {
12
+ name: 'chain-source-maps',
13
+ load(id) {
14
+ const mapPath = `${id}.map`;
15
+ if (id.endsWith('.js') && fs.existsSync(mapPath)) {
16
+ const map = JSON.parse(fs.readFileSync(mapPath, 'utf8'));
17
+ const dir = path.dirname(mapPath);
18
+ // Absolute paths let Rolldown resolve the sources; source maps require `/` separators.
19
+ map.sources = map.sources.map((source: string) =>
20
+ path.resolve(dir, source).replace(/\\/g, '/')
21
+ );
22
+ return { code: fs.readFileSync(id, 'utf8'), map };
23
+ }
24
+ },
25
+ };
26
+ }