@servicetitan/startup 22.17.0 → 22.19.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 (321) hide show
  1. package/dist/cli/commands/build.d.ts +3 -2
  2. package/dist/cli/commands/build.d.ts.map +1 -1
  3. package/dist/cli/commands/build.js +1 -0
  4. package/dist/cli/commands/build.js.map +1 -1
  5. package/dist/cli/commands/bundle-package.d.ts +2 -1
  6. package/dist/cli/commands/bundle-package.d.ts.map +1 -1
  7. package/dist/cli/commands/bundle-package.js +4 -3
  8. package/dist/cli/commands/bundle-package.js.map +1 -1
  9. package/dist/cli/commands/mfe-publish.d.ts +1 -0
  10. package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
  11. package/dist/cli/commands/mfe-publish.js +3 -2
  12. package/dist/cli/commands/mfe-publish.js.map +1 -1
  13. package/dist/cli/commands/start.d.ts +3 -2
  14. package/dist/cli/commands/start.d.ts.map +1 -1
  15. package/dist/cli/commands/start.js +3 -2
  16. package/dist/cli/commands/start.js.map +1 -1
  17. package/dist/cli/utils/bundle.d.ts +7 -2
  18. package/dist/cli/utils/bundle.d.ts.map +1 -1
  19. package/dist/cli/utils/bundle.js +28 -58
  20. package/dist/cli/utils/bundle.js.map +1 -1
  21. package/dist/cli/utils/set-node-options.d.ts.map +1 -1
  22. package/dist/cli/utils/set-node-options.js +1 -1
  23. package/dist/cli/utils/set-node-options.js.map +1 -1
  24. package/dist/utils/debug.d.ts +5 -0
  25. package/dist/utils/debug.d.ts.map +1 -0
  26. package/dist/utils/debug.js +19 -0
  27. package/dist/utils/debug.js.map +1 -0
  28. package/dist/utils/get-configuration.d.ts +1 -0
  29. package/dist/utils/get-configuration.d.ts.map +1 -1
  30. package/dist/utils/get-configuration.js +6 -1
  31. package/dist/utils/get-configuration.js.map +1 -1
  32. package/dist/utils/log.d.ts +6 -0
  33. package/dist/utils/log.d.ts.map +1 -1
  34. package/dist/utils/log.js +22 -0
  35. package/dist/utils/log.js.map +1 -1
  36. package/dist/webpack/__mocks__/file-rules.d.ts +3 -0
  37. package/dist/webpack/__mocks__/file-rules.d.ts.map +1 -0
  38. package/dist/webpack/__mocks__/file-rules.js +31 -0
  39. package/dist/webpack/__mocks__/file-rules.js.map +1 -0
  40. package/dist/webpack/__mocks__/index.d.ts +3 -0
  41. package/dist/webpack/__mocks__/index.d.ts.map +1 -0
  42. package/dist/webpack/__mocks__/index.js +19 -0
  43. package/dist/webpack/__mocks__/index.js.map +1 -0
  44. package/dist/webpack/__mocks__/style-rules.d.ts +8 -0
  45. package/dist/webpack/__mocks__/style-rules.d.ts.map +1 -0
  46. package/dist/webpack/__mocks__/style-rules.js +124 -0
  47. package/dist/webpack/__mocks__/style-rules.js.map +1 -0
  48. package/dist/webpack/configs/cache-config.d.ts +6 -0
  49. package/dist/webpack/configs/cache-config.d.ts.map +1 -0
  50. package/dist/webpack/configs/cache-config.js +24 -0
  51. package/dist/webpack/configs/cache-config.js.map +1 -0
  52. package/dist/webpack/configs/dev-server-config.d.ts +6 -0
  53. package/dist/webpack/configs/dev-server-config.d.ts.map +1 -0
  54. package/dist/webpack/configs/dev-server-config.js +27 -0
  55. package/dist/webpack/configs/dev-server-config.js.map +1 -0
  56. package/dist/webpack/configs/devtool-config.d.ts +6 -0
  57. package/dist/webpack/configs/devtool-config.d.ts.map +1 -0
  58. package/dist/webpack/configs/devtool-config.js +16 -0
  59. package/dist/webpack/configs/devtool-config.js.map +1 -0
  60. package/dist/webpack/configs/entry.config.d.ts +6 -0
  61. package/dist/webpack/configs/entry.config.d.ts.map +1 -0
  62. package/dist/webpack/configs/entry.config.js +14 -0
  63. package/dist/webpack/configs/entry.config.js.map +1 -0
  64. package/dist/webpack/configs/externals-config.d.ts +6 -0
  65. package/dist/webpack/configs/externals-config.d.ts.map +1 -0
  66. package/dist/webpack/configs/externals-config.js +16 -0
  67. package/dist/webpack/configs/externals-config.js.map +1 -0
  68. package/dist/webpack/configs/index.d.ts +13 -0
  69. package/dist/webpack/configs/index.d.ts.map +1 -0
  70. package/dist/webpack/configs/index.js +29 -0
  71. package/dist/webpack/configs/index.js.map +1 -0
  72. package/dist/webpack/configs/loaders/css-loader.d.ts +14 -0
  73. package/dist/webpack/configs/loaders/css-loader.d.ts.map +1 -0
  74. package/dist/webpack/configs/loaders/css-loader.js +17 -0
  75. package/dist/webpack/configs/loaders/css-loader.js.map +1 -0
  76. package/dist/webpack/configs/loaders/index.d.ts +5 -0
  77. package/dist/webpack/configs/loaders/index.d.ts.map +1 -0
  78. package/dist/webpack/configs/loaders/index.js +21 -0
  79. package/dist/webpack/configs/loaders/index.js.map +1 -0
  80. package/dist/webpack/configs/loaders/less-loader.d.ts +9 -0
  81. package/dist/webpack/configs/loaders/less-loader.d.ts.map +1 -0
  82. package/dist/webpack/configs/loaders/less-loader.js +8 -0
  83. package/dist/webpack/configs/loaders/less-loader.js.map +1 -0
  84. package/dist/webpack/configs/loaders/style-loader.d.ts +9 -0
  85. package/dist/webpack/configs/loaders/style-loader.d.ts.map +1 -0
  86. package/dist/webpack/configs/loaders/style-loader.js +13 -0
  87. package/dist/webpack/configs/loaders/style-loader.js.map +1 -0
  88. package/dist/webpack/configs/loaders/types.d.ts +4 -0
  89. package/dist/webpack/configs/loaders/types.d.ts.map +1 -0
  90. package/dist/webpack/configs/loaders/types.js +3 -0
  91. package/dist/webpack/configs/loaders/types.js.map +1 -0
  92. package/dist/webpack/configs/module-config.d.ts +6 -0
  93. package/dist/webpack/configs/module-config.d.ts.map +1 -0
  94. package/dist/webpack/configs/module-config.js +10 -0
  95. package/dist/webpack/configs/module-config.js.map +1 -0
  96. package/dist/webpack/configs/optimization-config.d.ts +6 -0
  97. package/dist/webpack/configs/optimization-config.d.ts.map +1 -0
  98. package/dist/webpack/configs/optimization-config.js +57 -0
  99. package/dist/webpack/configs/optimization-config.js.map +1 -0
  100. package/dist/webpack/configs/output-config.d.ts +6 -0
  101. package/dist/webpack/configs/output-config.d.ts.map +1 -0
  102. package/dist/webpack/configs/output-config.js +23 -0
  103. package/dist/webpack/configs/output-config.js.map +1 -0
  104. package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts +4 -0
  105. package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -0
  106. package/dist/webpack/configs/plugins/assets-manifest-plugin.js +34 -0
  107. package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -0
  108. package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts +3 -0
  109. package/dist/webpack/configs/plugins/bundle-analyser-plugin.d.ts.map +1 -0
  110. package/dist/webpack/configs/plugins/bundle-analyser-plugin.js +20 -0
  111. package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -0
  112. package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts +4 -0
  113. package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.d.ts.map +1 -0
  114. package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js +25 -0
  115. package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js.map +1 -0
  116. package/dist/webpack/configs/plugins/define-web-component-name-plugin.d.ts +4 -0
  117. package/dist/webpack/configs/plugins/define-web-component-name-plugin.d.ts.map +1 -0
  118. package/dist/webpack/configs/plugins/define-web-component-name-plugin.js +16 -0
  119. package/dist/webpack/configs/plugins/define-web-component-name-plugin.js.map +1 -0
  120. package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts +3 -0
  121. package/dist/webpack/configs/plugins/filter-warnings-plugin.d.ts.map +1 -0
  122. package/dist/webpack/configs/plugins/filter-warnings-plugin.js +14 -0
  123. package/dist/webpack/configs/plugins/filter-warnings-plugin.js.map +1 -0
  124. package/dist/webpack/configs/plugins/html-plugin.d.ts +4 -0
  125. package/dist/webpack/configs/plugins/html-plugin.d.ts.map +1 -0
  126. package/dist/webpack/configs/plugins/html-plugin.js +42 -0
  127. package/dist/webpack/configs/plugins/html-plugin.js.map +1 -0
  128. package/dist/webpack/configs/plugins/index.d.ts +12 -0
  129. package/dist/webpack/configs/plugins/index.d.ts.map +1 -0
  130. package/dist/webpack/configs/plugins/index.js +28 -0
  131. package/dist/webpack/configs/plugins/index.js.map +1 -0
  132. package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts +4 -0
  133. package/dist/webpack/configs/plugins/mini-css-extract-plugin.d.ts.map +1 -0
  134. package/dist/webpack/configs/plugins/mini-css-extract-plugin.js +23 -0
  135. package/dist/webpack/configs/plugins/mini-css-extract-plugin.js.map +1 -0
  136. package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts +4 -0
  137. package/dist/webpack/configs/plugins/moment-locales-plugin.d.ts.map +1 -0
  138. package/dist/webpack/configs/plugins/moment-locales-plugin.js +14 -0
  139. package/dist/webpack/configs/plugins/moment-locales-plugin.js.map +1 -0
  140. package/dist/webpack/configs/plugins/provide-react-plugin.d.ts +4 -0
  141. package/dist/webpack/configs/plugins/provide-react-plugin.d.ts.map +1 -0
  142. package/dist/webpack/configs/plugins/provide-react-plugin.js +14 -0
  143. package/dist/webpack/configs/plugins/provide-react-plugin.js.map +1 -0
  144. package/dist/webpack/configs/plugins/ts-checker-plugin.d.ts +4 -0
  145. package/dist/webpack/configs/plugins/ts-checker-plugin.d.ts.map +1 -0
  146. package/dist/webpack/configs/plugins/ts-checker-plugin.js +31 -0
  147. package/dist/webpack/configs/plugins/ts-checker-plugin.js.map +1 -0
  148. package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts +4 -0
  149. package/dist/webpack/configs/plugins/virtual-modules-plugin.d.ts.map +1 -0
  150. package/dist/webpack/configs/plugins/virtual-modules-plugin.js +42 -0
  151. package/dist/webpack/configs/plugins/virtual-modules-plugin.js.map +1 -0
  152. package/dist/webpack/configs/plugins-config.d.ts +6 -0
  153. package/dist/webpack/configs/plugins-config.d.ts.map +1 -0
  154. package/dist/webpack/configs/plugins-config.js +24 -0
  155. package/dist/webpack/configs/plugins-config.js.map +1 -0
  156. package/dist/webpack/configs/resolve-config.d.ts +6 -0
  157. package/dist/webpack/configs/resolve-config.d.ts.map +1 -0
  158. package/dist/webpack/configs/resolve-config.js +11 -0
  159. package/dist/webpack/configs/resolve-config.js.map +1 -0
  160. package/dist/webpack/configs/rules/css-rules.d.ts +4 -0
  161. package/dist/webpack/configs/rules/css-rules.d.ts.map +1 -0
  162. package/dist/webpack/configs/rules/css-rules.js +35 -0
  163. package/dist/webpack/configs/rules/css-rules.js.map +1 -0
  164. package/dist/webpack/configs/rules/font-rules.d.ts +4 -0
  165. package/dist/webpack/configs/rules/font-rules.d.ts.map +1 -0
  166. package/dist/webpack/configs/rules/font-rules.js +16 -0
  167. package/dist/webpack/configs/rules/font-rules.js.map +1 -0
  168. package/dist/webpack/configs/rules/image-rules.d.ts +4 -0
  169. package/dist/webpack/configs/rules/image-rules.d.ts.map +1 -0
  170. package/dist/webpack/configs/rules/image-rules.js +16 -0
  171. package/dist/webpack/configs/rules/image-rules.js.map +1 -0
  172. package/dist/webpack/configs/rules/index.d.ts +8 -0
  173. package/dist/webpack/configs/rules/index.d.ts.map +1 -0
  174. package/dist/webpack/configs/rules/index.js +24 -0
  175. package/dist/webpack/configs/rules/index.js.map +1 -0
  176. package/dist/webpack/configs/rules/js-rules.d.ts +4 -0
  177. package/dist/webpack/configs/rules/js-rules.d.ts.map +1 -0
  178. package/dist/webpack/configs/rules/js-rules.js +19 -0
  179. package/dist/webpack/configs/rules/js-rules.js.map +1 -0
  180. package/dist/webpack/configs/rules/less-rules.d.ts +4 -0
  181. package/dist/webpack/configs/rules/less-rules.d.ts.map +1 -0
  182. package/dist/webpack/configs/rules/less-rules.js +23 -0
  183. package/dist/webpack/configs/rules/less-rules.js.map +1 -0
  184. package/dist/webpack/configs/rules/scss-rules.d.ts +4 -0
  185. package/dist/webpack/configs/rules/scss-rules.d.ts.map +1 -0
  186. package/dist/webpack/configs/rules/scss-rules.js +23 -0
  187. package/dist/webpack/configs/rules/scss-rules.js.map +1 -0
  188. package/dist/webpack/configs/rules/tsx-rules.d.ts +4 -0
  189. package/dist/webpack/configs/rules/tsx-rules.d.ts.map +1 -0
  190. package/dist/webpack/configs/rules/tsx-rules.js +23 -0
  191. package/dist/webpack/configs/rules/tsx-rules.js.map +1 -0
  192. package/dist/webpack/configs/rules-config.d.ts +9 -0
  193. package/dist/webpack/configs/rules-config.d.ts.map +1 -0
  194. package/dist/webpack/configs/rules-config.js +31 -0
  195. package/dist/webpack/configs/rules-config.js.map +1 -0
  196. package/dist/webpack/configs/stats-config.d.ts +6 -0
  197. package/dist/webpack/configs/stats-config.d.ts.map +1 -0
  198. package/dist/webpack/configs/stats-config.js +16 -0
  199. package/dist/webpack/configs/stats-config.js.map +1 -0
  200. package/dist/webpack/configs/types.d.ts +15 -0
  201. package/dist/webpack/configs/types.d.ts.map +1 -0
  202. package/dist/webpack/configs/types.js +3 -0
  203. package/dist/webpack/configs/types.js.map +1 -0
  204. package/dist/webpack/configs/utils/generate-metadata.d.ts +3 -0
  205. package/dist/webpack/configs/utils/generate-metadata.d.ts.map +1 -0
  206. package/dist/webpack/configs/utils/generate-metadata.js +31 -0
  207. package/dist/webpack/configs/utils/generate-metadata.js.map +1 -0
  208. package/dist/webpack/configs/utils/get-startup-version.d.ts +2 -0
  209. package/dist/webpack/configs/utils/get-startup-version.d.ts.map +1 -0
  210. package/dist/webpack/configs/utils/get-startup-version.js +13 -0
  211. package/dist/webpack/configs/utils/get-startup-version.js.map +1 -0
  212. package/dist/webpack/configs/utils/index.d.ts +2 -0
  213. package/dist/webpack/configs/utils/index.d.ts.map +1 -0
  214. package/dist/webpack/configs/utils/index.js +18 -0
  215. package/dist/webpack/configs/utils/index.js.map +1 -0
  216. package/dist/webpack/create-webpack-config.d.ts +4 -0
  217. package/dist/webpack/create-webpack-config.d.ts.map +1 -0
  218. package/dist/webpack/create-webpack-config.js +67 -0
  219. package/dist/webpack/create-webpack-config.js.map +1 -0
  220. package/dist/webpack/index.d.ts +2 -10
  221. package/dist/webpack/index.d.ts.map +1 -1
  222. package/dist/webpack/index.js +16 -21
  223. package/dist/webpack/index.js.map +1 -1
  224. package/dist/webpack/types.d.ts +18 -0
  225. package/dist/webpack/types.d.ts.map +1 -0
  226. package/dist/webpack/types.js +3 -0
  227. package/dist/webpack/types.js.map +1 -0
  228. package/dist/webpack/utils/index.d.ts +5 -0
  229. package/dist/webpack/utils/index.d.ts.map +1 -0
  230. package/dist/webpack/utils/index.js +21 -0
  231. package/dist/webpack/utils/index.js.map +1 -0
  232. package/package.json +5 -4
  233. package/src/cli/commands/__tests__/build.test.ts +13 -0
  234. package/src/cli/commands/__tests__/bundle-package.test.ts +27 -4
  235. package/src/cli/commands/__tests__/mfe-package-publish.test.ts +10 -0
  236. package/src/cli/commands/__tests__/mfe-publish.test.ts +1 -0
  237. package/src/cli/commands/__tests__/start.test.ts +15 -0
  238. package/src/cli/commands/build.ts +4 -2
  239. package/src/cli/commands/bundle-package.ts +7 -4
  240. package/src/cli/commands/mfe-publish.ts +3 -1
  241. package/src/cli/commands/start.ts +6 -4
  242. package/src/cli/utils/__tests__/bundle.test.ts +142 -111
  243. package/src/cli/utils/__tests__/set-node-options.test.ts +4 -4
  244. package/src/cli/utils/bundle.ts +37 -118
  245. package/src/cli/utils/set-node-options.ts +2 -2
  246. package/src/utils/__tests__/get-configuration.test.ts +46 -0
  247. package/src/utils/__tests__/log.test.ts +43 -1
  248. package/src/utils/debug.ts +13 -0
  249. package/src/utils/get-configuration.ts +5 -1
  250. package/src/utils/log.ts +22 -0
  251. package/src/webpack/__mocks__/file-rules.ts +29 -0
  252. package/src/webpack/__mocks__/index.ts +2 -0
  253. package/src/webpack/__mocks__/style-rules.ts +126 -0
  254. package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +162 -0
  255. package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +331 -0
  256. package/src/webpack/__tests__/create-webpack-config.test.ts +400 -42
  257. package/src/webpack/configs/cache-config.ts +25 -0
  258. package/src/webpack/configs/dev-server-config.ts +43 -0
  259. package/src/webpack/configs/devtool-config.ts +18 -0
  260. package/src/webpack/configs/entry.config.ts +18 -0
  261. package/src/webpack/configs/externals-config.ts +21 -0
  262. package/src/webpack/configs/index.ts +12 -0
  263. package/src/webpack/configs/loaders/css-loader.ts +19 -0
  264. package/src/webpack/configs/loaders/index.ts +4 -0
  265. package/src/webpack/configs/loaders/less-loader.ts +3 -0
  266. package/src/webpack/configs/loaders/style-loader.ts +11 -0
  267. package/src/webpack/configs/loaders/types.ts +3 -0
  268. package/src/webpack/configs/module-config.ts +12 -0
  269. package/src/webpack/configs/optimization-config.ts +63 -0
  270. package/src/webpack/configs/output-config.ts +28 -0
  271. package/src/webpack/configs/plugins/assets-manifest-plugin.ts +34 -0
  272. package/src/webpack/configs/plugins/bundle-analyser-plugin.ts +18 -0
  273. package/src/webpack/configs/plugins/define-exposed-dependencies-plugin.ts +29 -0
  274. package/src/webpack/configs/plugins/define-web-component-name-plugin.ts +14 -0
  275. package/src/webpack/configs/plugins/filter-warnings-plugin.ts +12 -0
  276. package/src/webpack/configs/plugins/html-plugin.ts +53 -0
  277. package/src/webpack/configs/plugins/index.ts +11 -0
  278. package/src/webpack/configs/plugins/mini-css-extract-plugin.ts +19 -0
  279. package/src/webpack/configs/plugins/moment-locales-plugin.ts +8 -0
  280. package/src/webpack/configs/plugins/provide-react-plugin.ts +12 -0
  281. package/src/webpack/configs/plugins/ts-checker-plugin.ts +33 -0
  282. package/src/webpack/configs/plugins/virtual-modules-plugin.ts +42 -0
  283. package/src/webpack/configs/plugins-config.ts +38 -0
  284. package/src/webpack/configs/resolve-config.ts +13 -0
  285. package/src/webpack/configs/rules/css-rules.ts +36 -0
  286. package/src/webpack/configs/rules/font-rules.ts +14 -0
  287. package/src/webpack/configs/rules/image-rules.ts +14 -0
  288. package/src/webpack/configs/rules/index.ts +7 -0
  289. package/src/webpack/configs/rules/js-rules.ts +17 -0
  290. package/src/webpack/configs/rules/less-rules.ts +21 -0
  291. package/src/webpack/configs/rules/scss-rules.ts +21 -0
  292. package/src/webpack/configs/rules/tsx-rules.ts +22 -0
  293. package/src/webpack/configs/rules-config.ts +38 -0
  294. package/src/webpack/configs/stats-config.ts +18 -0
  295. package/src/webpack/configs/types.ts +15 -0
  296. package/src/webpack/configs/utils/__tests__/generate-metadata.test.ts +77 -0
  297. package/src/webpack/configs/utils/__tests__/get-startup-version.test.ts +27 -0
  298. package/src/webpack/configs/utils/generate-metadata.ts +30 -0
  299. package/src/webpack/configs/utils/get-startup-version.ts +8 -0
  300. package/src/webpack/configs/utils/index.ts +1 -0
  301. package/src/webpack/create-webpack-config.ts +110 -0
  302. package/src/webpack/index.ts +2 -52
  303. package/{dist/webpack/shared.config.d.ts → src/webpack/types.ts} +10 -4
  304. package/src/webpack/utils/index.ts +4 -0
  305. package/dist/webpack/development.config.d.ts +0 -11
  306. package/dist/webpack/development.config.d.ts.map +0 -1
  307. package/dist/webpack/development.config.js +0 -191
  308. package/dist/webpack/development.config.js.map +0 -1
  309. package/dist/webpack/production.config.d.ts +0 -14
  310. package/dist/webpack/production.config.d.ts.map +0 -1
  311. package/dist/webpack/production.config.js +0 -172
  312. package/dist/webpack/production.config.js.map +0 -1
  313. package/dist/webpack/shared.config.d.ts.map +0 -1
  314. package/dist/webpack/shared.config.js +0 -268
  315. package/dist/webpack/shared.config.js.map +0 -1
  316. package/src/webpack/__tests__/create-development-config.test.ts +0 -306
  317. package/src/webpack/__tests__/create-production-config.test.ts +0 -231
  318. package/src/webpack/__tests__/create-shared-config.test.ts +0 -508
  319. package/src/webpack/development.config.ts +0 -237
  320. package/src/webpack/production.config.ts +0 -197
  321. package/src/webpack/shared.config.ts +0 -360
@@ -0,0 +1,12 @@
1
+ import { Configuration } from 'webpack';
2
+ import { rulesConfig } from './rules-config';
3
+ import { Context, Overrides } from './types';
4
+
5
+ type Config = Configuration['module'];
6
+ type Result = Pick<Configuration, 'module'>;
7
+
8
+ export function moduleConfig(context: Context, overrides: Overrides): Result {
9
+ const module: Config = { ...rulesConfig(context, overrides) };
10
+
11
+ return { module };
12
+ }
@@ -0,0 +1,63 @@
1
+ import { Configuration } from 'webpack';
2
+ import { Context, Overrides } from './types';
3
+
4
+ type Config = Configuration['optimization'];
5
+ type Result = Pick<Configuration, 'optimization'>;
6
+
7
+ export function optimizationConfig(context: Context, _: Overrides): Result {
8
+ const { isExposeSharedDependencies, isProduction, isWebComponent } = context;
9
+
10
+ const optimization: Config & { splitChunks: { cacheGroups: Record<string, any> } } = {
11
+ chunkIds: 'size',
12
+ moduleIds: 'size',
13
+ mangleExports: 'size',
14
+ splitChunks: { cacheGroups: {} },
15
+ };
16
+
17
+ if (isExposeSharedDependencies) {
18
+ Object.assign(optimization.splitChunks.cacheGroups, {
19
+ 'design-system': {
20
+ test: /[\\/]node_modules[\\/]@servicetitan[\\/](tokens|anvil-fonts|design-system)[\\/].*\.css$/,
21
+ name: 'design-system',
22
+ chunks: 'all',
23
+ enforce: true,
24
+ },
25
+ });
26
+ }
27
+
28
+ if (isWebComponent) {
29
+ Object.assign(optimization.splitChunks.cacheGroups, {
30
+ styles: {
31
+ name: 'main',
32
+ type: 'css/mini-extract',
33
+ chunks: 'all',
34
+ enforce: true,
35
+ },
36
+ });
37
+ }
38
+
39
+ if (isProduction) {
40
+ optimization.runtimeChunk = 'single';
41
+ if (isWebComponent) {
42
+ Object.assign(optimization.splitChunks.cacheGroups, {
43
+ common: {
44
+ name: 'common',
45
+ test: /[\\/]node_modules[\\/](axios|classnames|formstate|mobx|mobx-react|mobx-utils|react|react-dom|react-router|react-router-dom)[\\/]/,
46
+ chunks: 'all',
47
+ },
48
+ kendo: {
49
+ name: 'kendo',
50
+ test: /[\\/]node_modules[\\/](@progress|@telerik)[\\/]/,
51
+ chunks: 'all',
52
+ },
53
+ servicetitan: {
54
+ name: 'servicetitan',
55
+ test: /[\\/]node_modules[\\/]@servicetitan[\\/]/,
56
+ chunks: 'all',
57
+ },
58
+ });
59
+ }
60
+ }
61
+
62
+ return { optimization };
63
+ }
@@ -0,0 +1,28 @@
1
+ import path from 'path';
2
+ import { Configuration } from 'webpack';
3
+ import { Context, Overrides } from './types';
4
+
5
+ type Config = Configuration['output'];
6
+ type Result = Pick<Configuration, 'output'>;
7
+
8
+ export function outputConfig(context: Context, _: Overrides): Result {
9
+ const { destination, embed, isProduction, isWebComponent } = context;
10
+
11
+ const output: Config = {
12
+ filename: '[name].bundle.js',
13
+ path: isWebComponent
14
+ ? path.join(process.cwd(), `${destination}/bundle/${embed ? 'light' : 'full'}`)
15
+ : path.join(process.cwd(), `${destination}/bundle`),
16
+ };
17
+
18
+ if (isProduction) {
19
+ const cdnPath = process.env.CLIENT_CDN_PATH;
20
+ Object.assign(output, {
21
+ filename: '[name].[contenthash:8].bundle.js',
22
+ clean: true,
23
+ ...(cdnPath ? { publicPath: cdnPath } : {}),
24
+ });
25
+ }
26
+
27
+ return { output };
28
+ }
@@ -0,0 +1,34 @@
1
+ import WebpackAssetsManifest from 'webpack-assets-manifest';
2
+ import { Context, Overrides } from '../types';
3
+ import { generateMetadata } from '../utils';
4
+
5
+ export function assetsManifestPlugin(context: Context, _: Overrides) {
6
+ if (!context.isWebComponent) {
7
+ return;
8
+ }
9
+
10
+ return new WebpackAssetsManifest({
11
+ entrypoints: true,
12
+ output: 'entrypoints.json',
13
+ transform(assets) {
14
+ const entrypoints = assets.entrypoints as Record<
15
+ string,
16
+ { assets: Record<string, string[]> }
17
+ >;
18
+
19
+ const getAssetsByType = (type: string) => {
20
+ return Object.values(entrypoints)
21
+ .map(({ assets }) => assets[type] ?? [])
22
+ .flat();
23
+ };
24
+
25
+ return {
26
+ css: getAssetsByType('css'),
27
+ js: getAssetsByType('js'),
28
+ };
29
+ },
30
+ done(_manifest) {
31
+ generateMetadata(context);
32
+ },
33
+ });
34
+ }
@@ -0,0 +1,18 @@
1
+ import path from 'path';
2
+ import os from 'os';
3
+ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
4
+ import { Context, Overrides } from '../types';
5
+
6
+ export function bundleAnalyzerPlugin({ buildStat, embed }: Context, _: Overrides) {
7
+ if (!buildStat) {
8
+ return;
9
+ }
10
+
11
+ return new BundleAnalyzerPlugin({
12
+ analyzerMode: 'static',
13
+ reportFilename: path.join(
14
+ os.tmpdir(),
15
+ `report-${embed ? 'light' : 'full'}-bundle-${Date.now()}.html`
16
+ ),
17
+ });
18
+ }
@@ -0,0 +1,29 @@
1
+ import { DefinePlugin } from 'webpack';
2
+ import { getPackageDependencyVersion } from '../../../utils';
3
+ import { Context, Overrides } from '../types';
4
+
5
+ export function defineExposedDependenciesPlugin(context: Context, _: Overrides) {
6
+ const { isExposeSharedDependencies, packageData, sharedDependencies } = context;
7
+ if (!isExposeSharedDependencies) {
8
+ return;
9
+ }
10
+
11
+ return new DefinePlugin({
12
+ // eslint-disable-next-line @typescript-eslint/naming-convention
13
+ EXPOSED_DEPENDENCIES: JSON.stringify(
14
+ Object.entries(sharedDependencies).reduce(
15
+ (result, [dependency, variable]) =>
16
+ Object.assign(result, {
17
+ [dependency]: {
18
+ version: getPackageDependencyVersion(
19
+ dependency,
20
+ packageData.dependencies?.[dependency]
21
+ ),
22
+ variable,
23
+ },
24
+ }),
25
+ {}
26
+ )
27
+ ),
28
+ });
29
+ }
@@ -0,0 +1,14 @@
1
+ import { DefinePlugin } from 'webpack';
2
+ import { Context, Overrides } from '../types';
3
+
4
+ export function defineWebComponentNamePlugin(context: Context, _: Overrides) {
5
+ const { isWebComponent, name } = context;
6
+ if (!isWebComponent) {
7
+ return;
8
+ }
9
+
10
+ return new DefinePlugin({
11
+ // eslint-disable-next-line @typescript-eslint/naming-convention
12
+ WEB_COMPONENT_NAME: JSON.stringify(name),
13
+ });
14
+ }
@@ -0,0 +1,12 @@
1
+ const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
2
+ import { Context, Overrides } from '../types';
3
+
4
+ export function filterWarningsPlugin({ embed }: Context, _: Overrides) {
5
+ if (embed) {
6
+ return;
7
+ }
8
+
9
+ return new FilterWarningsPlugin({
10
+ exclude: /export .* was not found in/,
11
+ });
12
+ }
@@ -0,0 +1,53 @@
1
+ import deepmerge from 'deepmerge';
2
+ import HtmlWebpackPlugin, { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
3
+ import { splitByEntry } from '../../utils';
4
+ import { Context, Overrides } from '../types';
5
+
6
+ export function htmlPlugin({ embed, isWebComponent, name }: Context, { plugins }: Overrides) {
7
+ const { HtmlWebpackPlugin: htmlWebpackPluginOptions = {} } = plugins ?? {};
8
+
9
+ if (embed) {
10
+ return;
11
+ }
12
+
13
+ return new HtmlWebpackPlugin(
14
+ deepmerge<HtmlWebpackPluginOptions>(
15
+ {
16
+ title: 'ServiceTitan',
17
+ hash: true,
18
+ ...(isWebComponent
19
+ ? {
20
+ inject: false,
21
+ publicPath: '/',
22
+ templateContent: ({
23
+ htmlWebpackPlugin: {
24
+ tags: { headTags, bodyTags },
25
+ files,
26
+ },
27
+ }) => {
28
+ const styleUrls = encodeURIComponent(JSON.stringify(files.css));
29
+ return `
30
+ <!DOCTYPE html>
31
+ <html>
32
+ <head>
33
+ <meta name="viewport" content="width=device-width,initial-scale=1">
34
+ ${headTags}
35
+ </head>
36
+ <body>
37
+ <${name} style-urls="${styleUrls}" />
38
+
39
+ ${bodyTags}
40
+ </body>
41
+ </html>
42
+ `;
43
+ },
44
+ }
45
+ : {}),
46
+ templateParameters: {
47
+ splitByEntry,
48
+ },
49
+ },
50
+ htmlWebpackPluginOptions
51
+ )
52
+ );
53
+ }
@@ -0,0 +1,11 @@
1
+ export * from './assets-manifest-plugin';
2
+ export * from './bundle-analyser-plugin';
3
+ export * from './define-exposed-dependencies-plugin';
4
+ export * from './define-web-component-name-plugin';
5
+ export * from './filter-warnings-plugin';
6
+ export * from './html-plugin';
7
+ export * from './mini-css-extract-plugin';
8
+ export * from './moment-locales-plugin';
9
+ export * from './provide-react-plugin';
10
+ export * from './ts-checker-plugin';
11
+ export * from './virtual-modules-plugin';
@@ -0,0 +1,19 @@
1
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
2
+ import { Context, Overrides } from '../types';
3
+
4
+ export function miniCssExtractPlugin(context: Context, overrides: Overrides) {
5
+ const { isCustomStyleRules, isExposeSharedDependencies, isProduction, isWebComponent } =
6
+ context;
7
+ if (isProduction) {
8
+ if (!isCustomStyleRules) {
9
+ return new MiniCssExtractPlugin({
10
+ filename: '[name].[contenthash:8].bundle.css',
11
+ ...(overrides.plugins as any)?.MiniCssExtractPlugin,
12
+ });
13
+ }
14
+ } else {
15
+ if (isWebComponent || (isExposeSharedDependencies && !isCustomStyleRules)) {
16
+ return new MiniCssExtractPlugin({ filename: '[name].bundle.css' });
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,8 @@
1
+ import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
2
+ import { Context, Overrides } from '../types';
3
+
4
+ export function momentLocalesPlugin(_: Context, _overrides: Overrides) {
5
+ return new MomentLocalesPlugin({
6
+ localesToKeep: ['en-au', 'en-ca', 'en-gb'],
7
+ });
8
+ }
@@ -0,0 +1,12 @@
1
+ import { ProvidePlugin } from 'webpack';
2
+ import { Context, Overrides } from '../types';
3
+
4
+ export function provideReactPlugin({ esbuild }: Context, _: Overrides) {
5
+ if (!esbuild) {
6
+ return;
7
+ }
8
+
9
+ return new ProvidePlugin({
10
+ React: 'react',
11
+ });
12
+ }
@@ -0,0 +1,33 @@
1
+ import deepmerge from 'deepmerge';
2
+ import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
3
+ import { ForkTsCheckerWebpackPluginOptions } from 'fork-ts-checker-webpack-plugin/lib/plugin-options';
4
+ import { getTsConfig } from '../../../utils';
5
+ import { Context, Overrides } from '../types';
6
+
7
+ export function tsCheckerPlugin({ embed }: Context, { plugins }: Overrides) {
8
+ const { ForkTsCheckerWebpackPlugin: forkTsCheckerWebpackPluginOptions = {} } = plugins ?? {};
9
+
10
+ if (embed) {
11
+ return;
12
+ }
13
+
14
+ return new ForkTsCheckerWebpackPlugin(
15
+ deepmerge<ForkTsCheckerWebpackPluginOptions>(
16
+ {
17
+ typescript: {
18
+ configFile: getTsConfig(),
19
+ configOverwrite: {
20
+ exclude: [
21
+ '**/__tests__/**/*',
22
+ '**/__mocks__/**/*',
23
+ '**/*.test.*',
24
+ '**/*.stories.tsx',
25
+ ],
26
+ references: [],
27
+ },
28
+ },
29
+ },
30
+ forkTsCheckerWebpackPluginOptions
31
+ )
32
+ );
33
+ }
@@ -0,0 +1,42 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import VirtualModulesPlugin from 'webpack-virtual-modules';
4
+ import { Context, Overrides } from '../types';
5
+
6
+ export function virtualModulesPlugin(context: Context, _: Overrides) {
7
+ if (!context.isWebComponent) {
8
+ return;
9
+ }
10
+
11
+ const { source } = context;
12
+
13
+ const indexPath = path.join(process.cwd(), `${source}/index.ts`);
14
+ const modules: ConstructorParameters<typeof VirtualModulesPlugin>[0] = {
15
+ [indexPath]: indexCode(context),
16
+ };
17
+
18
+ const designSystemPath = path.join(process.cwd(), `${source}/design-system.css`);
19
+ if (!fs.existsSync(designSystemPath)) {
20
+ modules[designSystemPath] = designSystemCode();
21
+ }
22
+
23
+ return new VirtualModulesPlugin(modules);
24
+ }
25
+
26
+ function designSystemCode() {
27
+ return [
28
+ `@import '~@servicetitan/tokens/core/tokens.css';`,
29
+ `@import '~@servicetitan/anvil-fonts/dist/css/anvil-fonts.css';`,
30
+ `@import '~@servicetitan/design-system/dist/system.min.css';`,
31
+ ].join('\n');
32
+ }
33
+
34
+ function indexCode({ embed }: Context) {
35
+ return [
36
+ `import { register } from '@servicetitan/web-components';`,
37
+ `import { App } from './app';`,
38
+ ...(embed
39
+ ? [`register(App, true);`]
40
+ : [`require('./design-system.css');`, `register(App, false);`]),
41
+ ].join('\n');
42
+ }
@@ -0,0 +1,38 @@
1
+ import { Configuration } from 'webpack';
2
+ import {
3
+ assetsManifestPlugin,
4
+ bundleAnalyzerPlugin,
5
+ defineExposedDependenciesPlugin,
6
+ defineWebComponentNamePlugin,
7
+ filterWarningsPlugin,
8
+ htmlPlugin,
9
+ miniCssExtractPlugin,
10
+ momentLocalesPlugin,
11
+ provideReactPlugin,
12
+ tsCheckerPlugin,
13
+ virtualModulesPlugin,
14
+ } from './plugins';
15
+ import { Context, Overrides } from './types';
16
+
17
+ type Config = Configuration['plugins'];
18
+ type Result = Pick<Configuration, 'plugins'>;
19
+
20
+ export function pluginsConfig(context: Context, overrides: Overrides): Result {
21
+ const plugins: Config = [
22
+ assetsManifestPlugin,
23
+ bundleAnalyzerPlugin,
24
+ defineExposedDependenciesPlugin,
25
+ defineWebComponentNamePlugin,
26
+ filterWarningsPlugin,
27
+ htmlPlugin,
28
+ miniCssExtractPlugin,
29
+ momentLocalesPlugin,
30
+ tsCheckerPlugin,
31
+ provideReactPlugin,
32
+ virtualModulesPlugin,
33
+ ]
34
+ .map(fn => fn(context, overrides))
35
+ .filter(plugin => !!plugin);
36
+
37
+ return { plugins };
38
+ }
@@ -0,0 +1,13 @@
1
+ import { Configuration } from 'webpack';
2
+ import { Context, Overrides } from './types';
3
+
4
+ type Config = Configuration['resolve'];
5
+ type Result = Pick<Configuration, 'resolve'>;
6
+
7
+ export function resolveConfig(_context: Context, _: Overrides): Result {
8
+ const resolve: Config = {
9
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
10
+ };
11
+
12
+ return { resolve };
13
+ }
@@ -0,0 +1,36 @@
1
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
2
+ import { RuleSetRule } from 'webpack';
3
+ import { cssLoader, styleLoader } from '../loaders';
4
+ import { Context } from '../types';
5
+
6
+ export function cssRules(context: Context): RuleSetRule[] {
7
+ const { isExposeSharedDependencies, isProduction } = context;
8
+
9
+ const excludeCallback = (path: string) => {
10
+ return (
11
+ path.endsWith('.module.css') ||
12
+ (isExposeSharedDependencies && path.endsWith('design-system.css'))
13
+ );
14
+ };
15
+
16
+ const result: RuleSetRule[] = [
17
+ {
18
+ test: /\.module.css$/,
19
+ use: [styleLoader(context, { esModule: true }), cssLoader(context, { esModule: true })],
20
+ },
21
+ {
22
+ test: /(\.css)$/,
23
+ exclude: isProduction ? /\.module.css$/ : excludeCallback,
24
+ use: [styleLoader(context), cssLoader(context)],
25
+ },
26
+ ];
27
+
28
+ if (isExposeSharedDependencies && !isProduction) {
29
+ result.push({
30
+ test: /design-system.css$/,
31
+ use: [MiniCssExtractPlugin.loader, cssLoader(context)],
32
+ });
33
+ }
34
+
35
+ return result;
36
+ }
@@ -0,0 +1,14 @@
1
+ import { RuleSetRule } from 'webpack';
2
+ import { Context } from '../types';
3
+
4
+ export function fontRules(_: Context): RuleSetRule[] {
5
+ return [
6
+ {
7
+ test: /\.(woff|woff2|eot|ttf|otf)$/i,
8
+ type: 'asset/resource',
9
+ generator: {
10
+ filename: 'fonts/[contenthash][ext][query]',
11
+ },
12
+ },
13
+ ];
14
+ }
@@ -0,0 +1,14 @@
1
+ import { RuleSetRule } from 'webpack';
2
+ import { Context } from '../types';
3
+
4
+ export function imageRules(_: Context): RuleSetRule[] {
5
+ return [
6
+ {
7
+ test: /\.(png|svg|jpg|jpeg|gif)$/i,
8
+ type: 'asset',
9
+ generator: {
10
+ filename: 'images/[contenthash][ext][query]',
11
+ },
12
+ },
13
+ ];
14
+ }
@@ -0,0 +1,7 @@
1
+ export * from './css-rules';
2
+ export * from './font-rules';
3
+ export * from './image-rules';
4
+ export * from './js-rules';
5
+ export * from './less-rules';
6
+ export * from './scss-rules';
7
+ export * from './tsx-rules';
@@ -0,0 +1,17 @@
1
+ import { RuleSetRule } from 'webpack';
2
+ import { Context } from '../types';
3
+
4
+ export function jsRules(_: Context): RuleSetRule[] {
5
+ return [
6
+ {
7
+ enforce: 'pre',
8
+ test: /\.js$/,
9
+ exclude: /node_modules/,
10
+ loader: 'source-map-loader',
11
+ },
12
+ {
13
+ test: /\.worker\.js$/,
14
+ use: { loader: 'worker-loader' },
15
+ },
16
+ ];
17
+ }
@@ -0,0 +1,21 @@
1
+ import { RuleSetRule } from 'webpack';
2
+ import { cssLoader, lessLoader, styleLoader } from '../loaders';
3
+ import { Context } from '../types';
4
+
5
+ export function lessRules(context: Context): RuleSetRule[] {
6
+ return [
7
+ {
8
+ test: /\.module.less$/,
9
+ use: [
10
+ styleLoader(context, { esModule: true }),
11
+ cssLoader(context, { esModule: true }),
12
+ lessLoader(),
13
+ ],
14
+ },
15
+ {
16
+ test: /(\.less)$/,
17
+ exclude: /\.module.less$/,
18
+ use: [styleLoader(context), cssLoader(context), lessLoader()],
19
+ },
20
+ ];
21
+ }
@@ -0,0 +1,21 @@
1
+ import { RuleSetRule } from 'webpack';
2
+ import { cssLoader, styleLoader } from '../loaders';
3
+ import { Context } from '../types';
4
+
5
+ export function scssRules(context: Context): RuleSetRule[] {
6
+ return [
7
+ {
8
+ test: /\.module.scss$/,
9
+ use: [
10
+ styleLoader(context, { esModule: true }),
11
+ cssLoader(context, { esModule: true }),
12
+ 'sass-loader',
13
+ ],
14
+ },
15
+ {
16
+ test: /(\.scss)$/,
17
+ exclude: /\.module.scss$/,
18
+ use: [styleLoader(context), cssLoader(context), 'sass-loader'],
19
+ },
20
+ ];
21
+ }
@@ -0,0 +1,22 @@
1
+ import { RuleSetRule } from 'webpack';
2
+ import { Context } from '../types';
3
+
4
+ export function tsxRules({ esbuild }: Context): RuleSetRule[] {
5
+ const loader = esbuild
6
+ ? {
7
+ loader: 'esbuild-loader',
8
+ options: { loader: 'tsx', target: 'es2018' },
9
+ }
10
+ : {
11
+ loader: 'ts-loader',
12
+ options: { transpileOnly: true },
13
+ };
14
+
15
+ return [
16
+ {
17
+ test: /\.tsx?$/,
18
+ exclude: /node_modules/,
19
+ use: [loader],
20
+ },
21
+ ];
22
+ }
@@ -0,0 +1,38 @@
1
+ import { Configuration, RuleSetRule } from 'webpack';
2
+ import { getModuleEntryPath } from '../utils';
3
+ import { cssRules, fontRules, imageRules, jsRules, lessRules, scssRules, tsxRules } from './rules';
4
+ import { Context, Overrides } from './types';
5
+
6
+ type Config = NonNullable<Configuration['module']>['rules'];
7
+ interface Result {
8
+ rules: Config;
9
+ }
10
+
11
+ export function rulesConfig(context: Context, _: Overrides): Result {
12
+ const rules: Config = [
13
+ jsRules,
14
+ imageRules,
15
+ fontRules,
16
+ tsxRules,
17
+ sharedDependenciesRules,
18
+ ].flatMap(fn => fn(context));
19
+
20
+ if (!context.isCustomStyleRules) {
21
+ rules.push(...[scssRules, lessRules, cssRules].flatMap(fn => fn(context)));
22
+ }
23
+
24
+ return { rules };
25
+ }
26
+
27
+ function sharedDependenciesRules(context: Context): RuleSetRule[] {
28
+ const { isExposeSharedDependencies, sharedDependencies } = context;
29
+ if (!isExposeSharedDependencies) {
30
+ return [];
31
+ }
32
+
33
+ return Object.entries(sharedDependencies).map(([dependency, variable]) => ({
34
+ test: getModuleEntryPath(dependency),
35
+ loader: require.resolve('../loaders/expose-loader'),
36
+ options: { exposes: variable },
37
+ }));
38
+ }