@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
@@ -22,14 +22,15 @@ function _interop_require_default(obj) {
22
22
  // Suffix for the CJS entry files emitted by `entryFileNames` below.
23
23
  const ENTRY_FILE_SUFFIX = '.cjs.js';
24
24
  function sharedDependenciesPlugin({ dependencies, css, metadataDir }) {
25
- const CSS_VIRTUAL_PREFIX = '\0SHARED_DEPENDENCY_CSS';
25
+ const CSS_VIRTUAL_PREFIX = '\0shared-dependencies:css:';
26
+ const CSS_VIRTUAL_ID_PATTERN = new RegExp(`^${CSS_VIRTUAL_PREFIX}`);
26
27
  const dependencyNames = Object.keys(dependencies);
27
28
  const dependencySet = new Set(dependencyNames);
28
29
  const cssEntries = css !== null && css !== void 0 ? css : {};
29
30
  const cssInputNames = Object.keys(cssEntries);
30
31
  let isProduction = false;
31
32
  return {
32
- name: 'shared-dependencies',
33
+ name: 'st:shared-dependencies',
33
34
  enforce: 'pre',
34
35
  config (_, env) {
35
36
  isProduction = env.mode === _core.bundleConstants.mode.production;
@@ -93,16 +94,18 @@ function sharedDependenciesPlugin({ dependencies, css, metadataDir }) {
93
94
  };
94
95
  }
95
96
  },
96
- load (id) {
97
- if (!id.startsWith(CSS_VIRTUAL_PREFIX)) {
98
- return;
99
- }
100
- const name = id.slice(CSS_VIRTUAL_PREFIX.length);
101
- const imports = cssEntries[name];
102
- if (!imports) {
103
- return;
97
+ load: {
98
+ filter: {
99
+ id: CSS_VIRTUAL_ID_PATTERN
100
+ },
101
+ handler (id) {
102
+ const name = id.slice(CSS_VIRTUAL_PREFIX.length);
103
+ const imports = cssEntries[name];
104
+ if (!imports) {
105
+ return;
106
+ }
107
+ return imports.map((p)=>`import '${p}';`).join('\n');
104
108
  }
105
- return imports.map((p)=>`import '${p}';`).join('\n');
106
109
  },
107
110
  generateBundle (_options, bundle) {
108
111
  (0, _assertnodynamiccss.assertNoDynamicCss)(bundle);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts"],"sourcesContent":["import crypto from 'crypto';\nimport path from 'path';\nimport { Plugin } from 'vite';\nimport { bundleConstants, generateExposedDependenciesMetadata, sortSharedCss } from '../../../core';\nimport { assembleIife, Expose, ModuleFactory } from './assemble-iife';\nimport { assertNoDynamicCss } from './assert-no-dynamic-css';\nimport { flatten } from './flatten';\n\nexport interface SharedDependenciesPluginOptions {\n dependencies: Record<string, string>;\n css?: Record<string, string[]>;\n metadataDir?: string;\n}\n\n// Suffix for the CJS entry files emitted by `entryFileNames` below.\nconst ENTRY_FILE_SUFFIX = '.cjs.js';\n\nexport function sharedDependenciesPlugin({\n dependencies,\n css,\n metadataDir,\n}: SharedDependenciesPluginOptions): Plugin {\n const CSS_VIRTUAL_PREFIX = '\\0SHARED_DEPENDENCY_CSS';\n\n const dependencyNames = Object.keys(dependencies);\n const dependencySet = new Set(dependencyNames);\n const cssEntries = css ?? {};\n const cssInputNames = Object.keys(cssEntries);\n let isProduction = false;\n\n return {\n name: 'shared-dependencies',\n enforce: 'pre',\n\n config(_, env) {\n isProduction = env.mode === bundleConstants.mode.production;\n\n const input: Record<string, string> = {};\n for (const dependency of dependencyNames) {\n input[flatten(dependency)] = dependency;\n }\n for (const name of cssInputNames) {\n input[name] = CSS_VIRTUAL_PREFIX + name;\n }\n\n return {\n // Relative base so CSS font URLs resolve from the CSS file's directory, not site root\n base: './',\n // Must match host build mode; mismatch causes react-dom/client usingClientEntryPoint errors\n define: {\n 'process.env.NODE_ENV': JSON.stringify(env.mode),\n },\n build: {\n rolldownOptions: {\n // Vite defaults to false which strips all CJS exports from entry chunks\n preserveEntrySignatures: 'exports-only',\n input,\n output: {\n /*\n * CJS format + named exports: the factory system wraps each entry's\n * code in function(module, exports, require) { ... }\n */\n format: 'cjs',\n exports: 'named',\n entryFileNames: `[name]${ENTRY_FILE_SUFFIX}`,\n chunkFileNames: '_[name]-[hash].js',\n assetFileNames: assetInfo => {\n const rawName = assetInfo.names?.[0] ?? '';\n const ext = rawName.split('.').pop() ?? '';\n // Strip scope prefix added by flatten (e.g. @servicetitan-anvil2 to anvil2)\n const name = rawName\n .replace(/^@[^-]+-/, '')\n .replace(/\\.[^.]+$/, '');\n if (ext === 'css') {\n return isProduction\n ? `${name}.[hash].bundle[extname]`\n : `${name}.bundle[extname]`;\n }\n return isProduction\n ? `${name}.[hash][extname]`\n : `${name}[extname]`;\n },\n },\n // Disabled: we don't know which exports MFEs will use at runtime\n treeshake: false,\n },\n },\n };\n },\n\n resolveId(source: string, importer: string | undefined) {\n if (source.startsWith(CSS_VIRTUAL_PREFIX)) {\n return source;\n }\n if (!importer) {\n return;\n }\n if (dependencySet.has(source)) {\n return { id: source, external: true };\n }\n },\n\n load(id: string) {\n if (!id.startsWith(CSS_VIRTUAL_PREFIX)) {\n return;\n }\n const name = id.slice(CSS_VIRTUAL_PREFIX.length);\n const imports = cssEntries[name];\n if (!imports) {\n return;\n }\n return imports.map(p => `import '${p}';`).join('\\n');\n },\n\n generateBundle(_options, bundle) {\n assertNoDynamicCss(bundle);\n\n const modules: ModuleFactory[] = [];\n const exposes: Expose[] = [];\n\n for (const [fileName, chunk] of Object.entries(bundle)) {\n if (chunk.type !== 'chunk') {\n continue;\n }\n if (!chunk.isEntry) {\n modules.push({ id: `./${fileName}`, code: chunk.code });\n delete bundle[fileName];\n }\n }\n\n for (const [dependency, variable] of Object.entries(dependencies)) {\n const entryFileName = `${flatten(dependency)}${ENTRY_FILE_SUFFIX}`;\n const chunk = bundle[entryFileName];\n if (chunk?.type !== 'chunk') {\n throw new Error(\n `Expected entry chunk for ${dependency}, got type: ${chunk?.type ?? 'undefined'}`\n );\n }\n modules.push({ id: dependency, code: chunk.code });\n exposes.push({ variable, dependency });\n delete bundle[entryFileName];\n }\n\n for (const name of cssInputNames) {\n delete bundle[`${name}${ENTRY_FILE_SUFFIX}`];\n }\n\n const code = assembleIife(modules, exposes);\n const hash = crypto.createHash('md5').update(code).digest('hex').slice(0, 20);\n const sharedFileName = isProduction ? `shared.${hash}.bundle.js` : 'shared.bundle.js';\n\n this.emitFile({\n type: 'asset',\n fileName: sharedFileName,\n source: code,\n });\n\n const cssFiles = sortSharedCss(\n Object.keys(bundle).filter(f => f.endsWith('.bundle.css'))\n );\n const entrypoints = { css: cssFiles, js: [sharedFileName] };\n this.emitFile({\n type: 'asset',\n fileName: 'entrypoints.json',\n source: JSON.stringify(entrypoints, null, 2),\n });\n },\n\n writeBundle: metadataDir\n ? options => {\n /*\n * dir is always set when build.outDir is configured (our case).\n * Rolldown types it as optional, but falling back to '' would\n * silently resolve to cwd; better to crash than write wrong metadata.\n */\n generateExposedDependenciesMetadata(metadataDir, () =>\n path.resolve(options.dir!, 'entrypoints.json')\n );\n }\n : undefined,\n };\n}\n"],"names":["sharedDependenciesPlugin","ENTRY_FILE_SUFFIX","dependencies","css","metadataDir","CSS_VIRTUAL_PREFIX","dependencyNames","Object","keys","dependencySet","Set","cssEntries","cssInputNames","isProduction","name","enforce","config","_","env","mode","bundleConstants","production","input","dependency","flatten","base","define","JSON","stringify","build","rolldownOptions","preserveEntrySignatures","output","format","exports","entryFileNames","chunkFileNames","assetFileNames","assetInfo","rawName","names","ext","split","pop","replace","treeshake","resolveId","source","importer","startsWith","has","id","external","load","slice","length","imports","map","p","join","generateBundle","_options","bundle","assertNoDynamicCss","modules","exposes","fileName","chunk","entries","type","isEntry","push","code","variable","entryFileName","Error","assembleIife","hash","crypto","createHash","update","digest","sharedFileName","emitFile","cssFiles","sortSharedCss","filter","f","endsWith","entrypoints","js","writeBundle","options","generateExposedDependenciesMetadata","path","resolve","dir","undefined"],"mappings":";;;;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,CAAC;YAE/C,MAAMC,cAAc;gBAAEtF,KAAKiF;gBAAUM,IAAI;oBAACR;iBAAe;YAAC;YAC1D,IAAI,CAACC,QAAQ,CAAC;gBACVd,MAAM;gBACNH,UAAU;gBACVnB,QAAQpB,KAAKC,SAAS,CAAC6D,aAAa,MAAM;YAC9C;QACJ;QAEAE,aAAavF,cACPwF,CAAAA;YACI;;;;mBAIC,GACDC,IAAAA,yCAAmC,EAACzF,aAAa,IAC7C0F,aAAI,CAACC,OAAO,CAACH,QAAQI,GAAG,EAAG;QAEnC,IACAC;IACV;AACJ"}
1
+ {"version":3,"sources":["../../../../src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts"],"sourcesContent":["import crypto from 'crypto';\nimport path from 'path';\nimport { Plugin } from 'vite';\nimport { bundleConstants, generateExposedDependenciesMetadata, sortSharedCss } from '../../../core';\nimport { assembleIife, Expose, ModuleFactory } from './assemble-iife';\nimport { assertNoDynamicCss } from './assert-no-dynamic-css';\nimport { flatten } from './flatten';\n\nexport interface SharedDependenciesPluginOptions {\n dependencies: Record<string, string>;\n css?: Record<string, string[]>;\n metadataDir?: string;\n}\n\n// Suffix for the CJS entry files emitted by `entryFileNames` below.\nconst ENTRY_FILE_SUFFIX = '.cjs.js';\n\nexport function sharedDependenciesPlugin({\n dependencies,\n css,\n metadataDir,\n}: SharedDependenciesPluginOptions): Plugin {\n const CSS_VIRTUAL_PREFIX = '\\0shared-dependencies:css:';\n const CSS_VIRTUAL_ID_PATTERN = new RegExp(`^${CSS_VIRTUAL_PREFIX}`);\n\n const dependencyNames = Object.keys(dependencies);\n const dependencySet = new Set(dependencyNames);\n const cssEntries = css ?? {};\n const cssInputNames = Object.keys(cssEntries);\n let isProduction = false;\n\n return {\n name: 'st:shared-dependencies',\n enforce: 'pre',\n\n config(_, env) {\n isProduction = env.mode === bundleConstants.mode.production;\n\n const input: Record<string, string> = {};\n for (const dependency of dependencyNames) {\n input[flatten(dependency)] = dependency;\n }\n for (const name of cssInputNames) {\n input[name] = CSS_VIRTUAL_PREFIX + name;\n }\n\n return {\n // Relative base so CSS font URLs resolve from the CSS file's directory, not site root\n base: './',\n // Must match host build mode; mismatch causes react-dom/client usingClientEntryPoint errors\n define: {\n 'process.env.NODE_ENV': JSON.stringify(env.mode),\n },\n build: {\n rolldownOptions: {\n // Vite defaults to false which strips all CJS exports from entry chunks\n preserveEntrySignatures: 'exports-only',\n input,\n output: {\n /*\n * CJS format + named exports: the factory system wraps each entry's\n * code in function(module, exports, require) { ... }\n */\n format: 'cjs',\n exports: 'named',\n entryFileNames: `[name]${ENTRY_FILE_SUFFIX}`,\n chunkFileNames: '_[name]-[hash].js',\n assetFileNames: assetInfo => {\n const rawName = assetInfo.names?.[0] ?? '';\n const ext = rawName.split('.').pop() ?? '';\n // Strip scope prefix added by flatten (e.g. @servicetitan-anvil2 to anvil2)\n const name = rawName\n .replace(/^@[^-]+-/, '')\n .replace(/\\.[^.]+$/, '');\n if (ext === 'css') {\n return isProduction\n ? `${name}.[hash].bundle[extname]`\n : `${name}.bundle[extname]`;\n }\n return isProduction\n ? `${name}.[hash][extname]`\n : `${name}[extname]`;\n },\n },\n // Disabled: we don't know which exports MFEs will use at runtime\n treeshake: false,\n },\n },\n };\n },\n\n resolveId(source: string, importer: string | undefined) {\n if (source.startsWith(CSS_VIRTUAL_PREFIX)) {\n return source;\n }\n if (!importer) {\n return;\n }\n if (dependencySet.has(source)) {\n return { id: source, external: true };\n }\n },\n\n load: {\n filter: { id: CSS_VIRTUAL_ID_PATTERN },\n handler(id: string) {\n const name = id.slice(CSS_VIRTUAL_PREFIX.length);\n const imports = cssEntries[name];\n if (!imports) {\n return;\n }\n return imports.map(p => `import '${p}';`).join('\\n');\n },\n },\n\n generateBundle(_options, bundle) {\n assertNoDynamicCss(bundle);\n\n const modules: ModuleFactory[] = [];\n const exposes: Expose[] = [];\n\n for (const [fileName, chunk] of Object.entries(bundle)) {\n if (chunk.type !== 'chunk') {\n continue;\n }\n if (!chunk.isEntry) {\n modules.push({ id: `./${fileName}`, code: chunk.code });\n delete bundle[fileName];\n }\n }\n\n for (const [dependency, variable] of Object.entries(dependencies)) {\n const entryFileName = `${flatten(dependency)}${ENTRY_FILE_SUFFIX}`;\n const chunk = bundle[entryFileName];\n if (chunk?.type !== 'chunk') {\n throw new Error(\n `Expected entry chunk for ${dependency}, got type: ${chunk?.type ?? 'undefined'}`\n );\n }\n modules.push({ id: dependency, code: chunk.code });\n exposes.push({ variable, dependency });\n delete bundle[entryFileName];\n }\n\n for (const name of cssInputNames) {\n delete bundle[`${name}${ENTRY_FILE_SUFFIX}`];\n }\n\n const code = assembleIife(modules, exposes);\n const hash = crypto.createHash('md5').update(code).digest('hex').slice(0, 20);\n const sharedFileName = isProduction ? `shared.${hash}.bundle.js` : 'shared.bundle.js';\n\n this.emitFile({\n type: 'asset',\n fileName: sharedFileName,\n source: code,\n });\n\n const cssFiles = sortSharedCss(\n Object.keys(bundle).filter(f => f.endsWith('.bundle.css'))\n );\n const entrypoints = { css: cssFiles, js: [sharedFileName] };\n this.emitFile({\n type: 'asset',\n fileName: 'entrypoints.json',\n source: JSON.stringify(entrypoints, null, 2),\n });\n },\n\n writeBundle: metadataDir\n ? options => {\n /*\n * dir is always set when build.outDir is configured (our case).\n * Rolldown types it as optional, but falling back to '' would\n * silently resolve to cwd; better to crash than write wrong metadata.\n */\n generateExposedDependenciesMetadata(metadataDir, () =>\n path.resolve(options.dir!, 'entrypoints.json')\n );\n }\n : undefined,\n };\n}\n"],"names":["sharedDependenciesPlugin","ENTRY_FILE_SUFFIX","dependencies","css","metadataDir","CSS_VIRTUAL_PREFIX","CSS_VIRTUAL_ID_PATTERN","RegExp","dependencyNames","Object","keys","dependencySet","Set","cssEntries","cssInputNames","isProduction","name","enforce","config","_","env","mode","bundleConstants","production","input","dependency","flatten","base","define","JSON","stringify","build","rolldownOptions","preserveEntrySignatures","output","format","exports","entryFileNames","chunkFileNames","assetFileNames","assetInfo","rawName","names","ext","split","pop","replace","treeshake","resolveId","source","importer","startsWith","has","id","external","load","filter","handler","slice","length","imports","map","p","join","generateBundle","_options","bundle","assertNoDynamicCss","modules","exposes","fileName","chunk","entries","type","isEntry","push","code","variable","entryFileName","Error","assembleIife","hash","crypto","createHash","update","digest","sharedFileName","emitFile","cssFiles","sortSharedCss","f","endsWith","entrypoints","js","writeBundle","options","generateExposedDependenciesMetadata","path","resolve","dir","undefined"],"mappings":";;;;+BAiBgBA;;;eAAAA;;;+DAjBG;6DACF;sBAEmE;8BAChC;oCACjB;yBACX;;;;;;AAQxB,oEAAoE;AACpE,MAAMC,oBAAoB;AAEnB,SAASD,yBAAyB,EACrCE,YAAY,EACZC,GAAG,EACHC,WAAW,EACmB;IAC9B,MAAMC,qBAAqB;IAC3B,MAAMC,yBAAyB,IAAIC,OAAO,CAAC,CAAC,EAAEF,oBAAoB;IAElE,MAAMG,kBAAkBC,OAAOC,IAAI,CAACR;IACpC,MAAMS,gBAAgB,IAAIC,IAAIJ;IAC9B,MAAMK,aAAaV,gBAAAA,iBAAAA,MAAO,CAAC;IAC3B,MAAMW,gBAAgBL,OAAOC,IAAI,CAACG;IAClC,IAAIE,eAAe;IAEnB,OAAO;QACHC,MAAM;QACNC,SAAS;QAETC,QAAOC,CAAC,EAAEC,GAAG;YACTL,eAAeK,IAAIC,IAAI,KAAKC,qBAAe,CAACD,IAAI,CAACE,UAAU;YAE3D,MAAMC,QAAgC,CAAC;YACvC,KAAK,MAAMC,cAAcjB,gBAAiB;gBACtCgB,KAAK,CAACE,IAAAA,gBAAO,EAACD,YAAY,GAAGA;YACjC;YACA,KAAK,MAAMT,QAAQF,cAAe;gBAC9BU,KAAK,CAACR,KAAK,GAAGX,qBAAqBW;YACvC;YAEA,OAAO;gBACH,sFAAsF;gBACtFW,MAAM;gBACN,4FAA4F;gBAC5FC,QAAQ;oBACJ,wBAAwBC,KAAKC,SAAS,CAACV,IAAIC,IAAI;gBACnD;gBACAU,OAAO;oBACHC,iBAAiB;wBACb,wEAAw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,OAAOC,MAAM,CAACR,MAAMS,MAAM,CAAC,OAAO3B,KAAK,CAAC,GAAG;YAC1E,MAAM4B,iBAAiBvE,eAAe,CAAC,OAAO,EAAEkE,KAAK,UAAU,CAAC,GAAG;YAEnE,IAAI,CAACM,QAAQ,CAAC;gBACVd,MAAM;gBACNH,UAAUgB;gBACVrC,QAAQ2B;YACZ;YAEA,MAAMY,WAAWC,IAAAA,mBAAa,EAC1BhF,OAAOC,IAAI,CAACwD,QAAQV,MAAM,CAACkC,CAAAA,IAAKA,EAAEC,QAAQ,CAAC;YAE/C,MAAMC,cAAc;gBAAEzF,KAAKqF;gBAAUK,IAAI;oBAACP;iBAAe;YAAC;YAC1D,IAAI,CAACC,QAAQ,CAAC;gBACVd,MAAM;gBACNH,UAAU;gBACVrB,QAAQpB,KAAKC,SAAS,CAAC8D,aAAa,MAAM;YAC9C;QACJ;QAEAE,aAAa1F,cACP2F,CAAAA;YACI;;;;mBAIC,GACDC,IAAAA,yCAAmC,EAAC5F,aAAa,IAC7C6F,aAAI,CAACC,OAAO,CAACH,QAAQI,GAAG,EAAG;QAEnC,IACAC;IACV;AACJ"}
@@ -14,7 +14,7 @@ function styleUrlsPlugin(context) {
14
14
  const { isWebComponent } = context.package;
15
15
  if (isWebComponent && isProduction) {
16
16
  return {
17
- name: 'style-urls',
17
+ name: 'st:style-urls',
18
18
  transformIndexHtml: {
19
19
  order: 'post',
20
20
  handler (html, ctx) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/vite/plugins/style-urls-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport type { BuildContext } from '../../core';\nimport { getCssFileNames } from './utils/get-css-file-names';\n\nexport function styleUrlsPlugin(context: BuildContext): Plugin | undefined {\n const { name, isProduction } = context.build;\n const { isWebComponent } = context.package;\n if (isWebComponent && isProduction) {\n return {\n name: 'style-urls',\n transformIndexHtml: {\n order: 'post',\n handler(html, ctx) {\n const css = getCssFileNames(ctx.bundle ?? {});\n const styleUrls = `style-urls=\"${encodeURIComponent(JSON.stringify(css))}\"`;\n return html.replace(`<${name} />`, `<${name} ${styleUrls} />`);\n },\n },\n };\n }\n}\n"],"names":["styleUrlsPlugin","context","name","isProduction","build","isWebComponent","package","transformIndexHtml","order","handler","html","ctx","css","getCssFileNames","bundle","styleUrls","encodeURIComponent","JSON","stringify","replace"],"mappings":";;;;+BAIgBA;;;eAAAA;;;iCAFgB;AAEzB,SAASA,gBAAgBC,OAAqB;IACjD,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAE,GAAGF,QAAQG,KAAK;IAC5C,MAAM,EAAEC,cAAc,EAAE,GAAGJ,QAAQK,OAAO;IAC1C,IAAID,kBAAkBF,cAAc;QAChC,OAAO;YACHD,MAAM;YACNK,oBAAoB;gBAChBC,OAAO;gBACPC,SAAQC,IAAI,EAAEC,GAAG;wBACeA;oBAA5B,MAAMC,MAAMC,IAAAA,gCAAe,GAACF,cAAAA,IAAIG,MAAM,cAAVH,yBAAAA,cAAc,CAAC;oBAC3C,MAAMI,YAAY,CAAC,YAAY,EAAEC,mBAAmBC,KAAKC,SAAS,CAACN,MAAM,CAAC,CAAC;oBAC3E,OAAOF,KAAKS,OAAO,CAAC,CAAC,CAAC,EAAEjB,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,EAAEA,KAAK,CAAC,EAAEa,UAAU,GAAG,CAAC;gBACjE;YACJ;QACJ;IACJ;AACJ"}
1
+ {"version":3,"sources":["../../../src/vite/plugins/style-urls-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport type { BuildContext } from '../../core';\nimport { getCssFileNames } from './utils/get-css-file-names';\n\nexport function styleUrlsPlugin(context: BuildContext): Plugin | undefined {\n const { name, isProduction } = context.build;\n const { isWebComponent } = context.package;\n if (isWebComponent && isProduction) {\n return {\n name: 'st:style-urls',\n transformIndexHtml: {\n order: 'post',\n handler(html, ctx) {\n const css = getCssFileNames(ctx.bundle ?? {});\n const styleUrls = `style-urls=\"${encodeURIComponent(JSON.stringify(css))}\"`;\n return html.replace(`<${name} />`, `<${name} ${styleUrls} />`);\n },\n },\n };\n }\n}\n"],"names":["styleUrlsPlugin","context","name","isProduction","build","isWebComponent","package","transformIndexHtml","order","handler","html","ctx","css","getCssFileNames","bundle","styleUrls","encodeURIComponent","JSON","stringify","replace"],"mappings":";;;;+BAIgBA;;;eAAAA;;;iCAFgB;AAEzB,SAASA,gBAAgBC,OAAqB;IACjD,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAE,GAAGF,QAAQG,KAAK;IAC5C,MAAM,EAAEC,cAAc,EAAE,GAAGJ,QAAQK,OAAO;IAC1C,IAAID,kBAAkBF,cAAc;QAChC,OAAO;YACHD,MAAM;YACNK,oBAAoB;gBAChBC,OAAO;gBACPC,SAAQC,IAAI,EAAEC,GAAG;wBACeA;oBAA5B,MAAMC,MAAMC,IAAAA,gCAAe,GAACF,cAAAA,IAAIG,MAAM,cAAVH,yBAAAA,cAAc,CAAC;oBAC3C,MAAMI,YAAY,CAAC,YAAY,EAAEC,mBAAmBC,KAAKC,SAAS,CAACN,MAAM,CAAC,CAAC;oBAC3E,OAAOF,KAAKS,OAAO,CAAC,CAAC,CAAC,EAAEjB,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,EAAEA,KAAK,CAAC,EAAEa,UAAU,GAAG,CAAC;gBACjE;YACJ;QACJ;IACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-modules-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/virtual-modules-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAC;AAE1D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAyC9E"}
1
+ {"version":3,"file":"virtual-modules-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/virtual-modules-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAC;AAE1D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CA0C9E"}
@@ -16,7 +16,8 @@ function _interop_require_default(obj) {
16
16
  };
17
17
  }
18
18
  function virtualModulesPlugin(context) {
19
- const VIRTUAL_PREFIX = '\0VIRTUAL';
19
+ const VIRTUAL_PREFIX = '\0virtual-modules:';
20
+ const VIRTUAL_ID_PATTERN = new RegExp(`^${VIRTUAL_PREFIX}`);
20
21
  const { destination } = context.package;
21
22
  const modules = (0, _core.virtualModules)(context);
22
23
  const pluginModules = {};
@@ -30,7 +31,7 @@ function virtualModulesPlugin(context) {
30
31
  return;
31
32
  }
32
33
  return {
33
- name: 'virtual-modules',
34
+ name: 'st:virtual-modules',
34
35
  resolveId (source, importer) {
35
36
  if (pluginModules[source]) {
36
37
  return VIRTUAL_PREFIX + source;
@@ -42,10 +43,12 @@ function virtualModulesPlugin(context) {
42
43
  }
43
44
  }
44
45
  },
45
- load (id) {
46
- if (id.startsWith(VIRTUAL_PREFIX)) {
47
- const idNoPrefix = id.slice(VIRTUAL_PREFIX.length);
48
- return pluginModules[idNoPrefix];
46
+ load: {
47
+ filter: {
48
+ id: VIRTUAL_ID_PATTERN
49
+ },
50
+ handler (id) {
51
+ return pluginModules[id.slice(VIRTUAL_PREFIX.length)];
49
52
  }
50
53
  }
51
54
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/vite/plugins/virtual-modules-plugin.ts"],"sourcesContent":["import path from 'path';\nimport type { Plugin } from 'vite';\nimport { BuildContext, virtualModules } from '../../core';\n\nexport function virtualModulesPlugin(context: BuildContext): Plugin | undefined {\n const VIRTUAL_PREFIX = '\\0VIRTUAL';\n\n const { destination } = context.package;\n\n const modules = virtualModules(context);\n\n const pluginModules: Record<string, string> = {};\n\n if (modules.index) {\n pluginModules['./index'] = modules.index;\n }\n\n if (modules.designSystem) {\n pluginModules['./design-system.css'] = modules.designSystem;\n }\n\n if (Object.keys(pluginModules).length === 0) {\n return;\n }\n\n return {\n name: 'virtual-modules',\n resolveId(source, importer) {\n if (pluginModules[source]) {\n return VIRTUAL_PREFIX + source;\n }\n if (importer?.startsWith(VIRTUAL_PREFIX) && source.startsWith('.')) {\n const importerNoPrefix = importer.slice(VIRTUAL_PREFIX.length);\n if (pluginModules[importerNoPrefix]) {\n return path.resolve(destination, source + '.js');\n }\n }\n },\n load(id) {\n if (id.startsWith(VIRTUAL_PREFIX)) {\n const idNoPrefix = id.slice(VIRTUAL_PREFIX.length);\n return pluginModules[idNoPrefix];\n }\n },\n };\n}\n"],"names":["virtualModulesPlugin","context","VIRTUAL_PREFIX","destination","package","modules","virtualModules","pluginModules","index","designSystem","Object","keys","length","name","resolveId","source","importer","startsWith","importerNoPrefix","slice","path","resolve","load","id","idNoPrefix"],"mappings":";;;;+BAIgBA;;;eAAAA;;;6DAJC;sBAE4B;;;;;;AAEtC,SAASA,qBAAqBC,OAAqB;IACtD,MAAMC,iBAAiB;IAEvB,MAAM,EAAEC,WAAW,EAAE,GAAGF,QAAQG,OAAO;IAEvC,MAAMC,UAAUC,IAAAA,oBAAc,EAACL;IAE/B,MAAMM,gBAAwC,CAAC;IAE/C,IAAIF,QAAQG,KAAK,EAAE;QACfD,aAAa,CAAC,UAAU,GAAGF,QAAQG,KAAK;IAC5C;IAEA,IAAIH,QAAQI,YAAY,EAAE;QACtBF,aAAa,CAAC,sBAAsB,GAAGF,QAAQI,YAAY;IAC/D;IAEA,IAAIC,OAAOC,IAAI,CAACJ,eAAeK,MAAM,KAAK,GAAG;QACzC;IACJ;IAEA,OAAO;QACHC,MAAM;QACNC,WAAUC,MAAM,EAAEC,QAAQ;YACtB,IAAIT,aAAa,CAACQ,OAAO,EAAE;gBACvB,OAAOb,iBAAiBa;YAC5B;YACA,IAAIC,CAAAA,qBAAAA,+BAAAA,SAAUC,UAAU,CAACf,oBAAmBa,OAAOE,UAAU,CAAC,MAAM;gBAChE,MAAMC,mBAAmBF,SAASG,KAAK,CAACjB,eAAeU,MAAM;gBAC7D,IAAIL,aAAa,CAACW,iBAAiB,EAAE;oBACjC,OAAOE,aAAI,CAACC,OAAO,CAAClB,aAAaY,SAAS;gBAC9C;YACJ;QACJ;QACAO,MAAKC,EAAE;YACH,IAAIA,GAAGN,UAAU,CAACf,iBAAiB;gBAC/B,MAAMsB,aAAaD,GAAGJ,KAAK,CAACjB,eAAeU,MAAM;gBACjD,OAAOL,aAAa,CAACiB,WAAW;YACpC;QACJ;IACJ;AACJ"}
1
+ {"version":3,"sources":["../../../src/vite/plugins/virtual-modules-plugin.ts"],"sourcesContent":["import path from 'path';\nimport type { Plugin } from 'vite';\nimport { BuildContext, virtualModules } from '../../core';\n\nexport function virtualModulesPlugin(context: BuildContext): Plugin | undefined {\n const VIRTUAL_PREFIX = '\\0virtual-modules:';\n const VIRTUAL_ID_PATTERN = new RegExp(`^${VIRTUAL_PREFIX}`);\n\n const { destination } = context.package;\n\n const modules = virtualModules(context);\n\n const pluginModules: Record<string, string> = {};\n\n if (modules.index) {\n pluginModules['./index'] = modules.index;\n }\n\n if (modules.designSystem) {\n pluginModules['./design-system.css'] = modules.designSystem;\n }\n\n if (Object.keys(pluginModules).length === 0) {\n return;\n }\n\n return {\n name: 'st:virtual-modules',\n resolveId(source, importer) {\n if (pluginModules[source]) {\n return VIRTUAL_PREFIX + source;\n }\n if (importer?.startsWith(VIRTUAL_PREFIX) && source.startsWith('.')) {\n const importerNoPrefix = importer.slice(VIRTUAL_PREFIX.length);\n if (pluginModules[importerNoPrefix]) {\n return path.resolve(destination, source + '.js');\n }\n }\n },\n load: {\n filter: { id: VIRTUAL_ID_PATTERN },\n handler(id) {\n return pluginModules[id.slice(VIRTUAL_PREFIX.length)];\n },\n },\n };\n}\n"],"names":["virtualModulesPlugin","context","VIRTUAL_PREFIX","VIRTUAL_ID_PATTERN","RegExp","destination","package","modules","virtualModules","pluginModules","index","designSystem","Object","keys","length","name","resolveId","source","importer","startsWith","importerNoPrefix","slice","path","resolve","load","filter","id","handler"],"mappings":";;;;+BAIgBA;;;eAAAA;;;6DAJC;sBAE4B;;;;;;AAEtC,SAASA,qBAAqBC,OAAqB;IACtD,MAAMC,iBAAiB;IACvB,MAAMC,qBAAqB,IAAIC,OAAO,CAAC,CAAC,EAAEF,gBAAgB;IAE1D,MAAM,EAAEG,WAAW,EAAE,GAAGJ,QAAQK,OAAO;IAEvC,MAAMC,UAAUC,IAAAA,oBAAc,EAACP;IAE/B,MAAMQ,gBAAwC,CAAC;IAE/C,IAAIF,QAAQG,KAAK,EAAE;QACfD,aAAa,CAAC,UAAU,GAAGF,QAAQG,KAAK;IAC5C;IAEA,IAAIH,QAAQI,YAAY,EAAE;QACtBF,aAAa,CAAC,sBAAsB,GAAGF,QAAQI,YAAY;IAC/D;IAEA,IAAIC,OAAOC,IAAI,CAACJ,eAAeK,MAAM,KAAK,GAAG;QACzC;IACJ;IAEA,OAAO;QACHC,MAAM;QACNC,WAAUC,MAAM,EAAEC,QAAQ;YACtB,IAAIT,aAAa,CAACQ,OAAO,EAAE;gBACvB,OAAOf,iBAAiBe;YAC5B;YACA,IAAIC,CAAAA,qBAAAA,+BAAAA,SAAUC,UAAU,CAACjB,oBAAmBe,OAAOE,UAAU,CAAC,MAAM;gBAChE,MAAMC,mBAAmBF,SAASG,KAAK,CAACnB,eAAeY,MAAM;gBAC7D,IAAIL,aAAa,CAACW,iBAAiB,EAAE;oBACjC,OAAOE,aAAI,CAACC,OAAO,CAAClB,aAAaY,SAAS;gBAC9C;YACJ;QACJ;QACAO,MAAM;YACFC,QAAQ;gBAAEC,IAAIvB;YAAmB;YACjCwB,SAAQD,EAAE;gBACN,OAAOjB,aAAa,CAACiB,GAAGL,KAAK,CAACnB,eAAeY,MAAM,EAAE;YACzD;QACJ;IACJ;AACJ"}
@@ -0,0 +1,22 @@
1
+ import type { Plugin } from 'vite';
2
+ /**
3
+ * Maps each `window` global to the import(s) that resolve to it. The key is the `window` global
4
+ * (`jQuery` names `window.jQuery`). Every value matches specifiers with a regex:
5
+ *
6
+ * - `RegExp` resolves matching imports to `window.<global>` (`/^jquery$/`, or
7
+ * `/^(moment|moment-timezone)$/` to cover several specifiers)
8
+ * - `{ match, exports }` resolves imports to `window.<global>.<export>`, for
9
+ * packages that have named imports (e.g., (`import { formatMoney } from 'accounting'`))
10
+ * - `{ match, member }` resolves imports to `window.<global>[member(specifier)]`, deriving the key from
11
+ * the function result. For example `{ match: /^@arcgis\/core\//, member: s => s.split('/').pop() }`
12
+ * maps `@arcgis/core/views/MapView` to `window.arcgis["MapView"]`.
13
+ */
14
+ export type WindowExternals = Record<string, RegExp | {
15
+ match: RegExp;
16
+ exports?: string[];
17
+ } | {
18
+ match: RegExp;
19
+ member?: (specifier: string) => string | false | null | undefined;
20
+ }>;
21
+ export declare function windowExternalsPlugin(externals: WindowExternals): Plugin;
22
+ //# sourceMappingURL=window-externals-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window-externals-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugins/window-externals-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAChC,MAAM,EACJ,MAAM,GACN;IACI,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,GACD;IACI,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;CACrE,CACN,CAAC;AAqBF,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CA+CxE"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "windowExternalsPlugin", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return windowExternalsPlugin;
9
+ }
10
+ });
11
+ const VIRTUAL_PREFIX = '\0window-externals:';
12
+ const VIRTUAL_ID_PATTERN = new RegExp(`^${VIRTUAL_PREFIX}`);
13
+ function windowExternalsPlugin(externals) {
14
+ const entries = Object.entries(externals).map(([global, value])=>{
15
+ if (value instanceof RegExp) {
16
+ return {
17
+ match: value,
18
+ bind: ()=>({
19
+ expression: `window.${global}`
20
+ })
21
+ };
22
+ }
23
+ const { match } = value;
24
+ const exports1 = 'exports' in value ? value.exports : undefined;
25
+ const member = 'member' in value ? value.member : undefined;
26
+ return {
27
+ match,
28
+ bind: (specifier)=>{
29
+ const key = member === null || member === void 0 ? void 0 : member(specifier);
30
+ const expression = key ? `window.${global}[${JSON.stringify(key)}]` : `window.${global}`;
31
+ return {
32
+ expression,
33
+ exports: exports1
34
+ };
35
+ }
36
+ };
37
+ });
38
+ const bind = (specifier)=>{
39
+ var _ref;
40
+ var _entries_find;
41
+ return (_ref = (_entries_find = entries.find((entry)=>entry.match.test(specifier))) === null || _entries_find === void 0 ? void 0 : _entries_find.bind(specifier)) !== null && _ref !== void 0 ? _ref : null;
42
+ };
43
+ return {
44
+ name: 'st:window-externals',
45
+ enforce: 'pre',
46
+ resolveId: {
47
+ filter: {
48
+ id: entries.map((entry)=>entry.match)
49
+ },
50
+ handler (source) {
51
+ return VIRTUAL_PREFIX + source;
52
+ }
53
+ },
54
+ load: {
55
+ filter: {
56
+ id: VIRTUAL_ID_PATTERN
57
+ },
58
+ handler (id) {
59
+ var _binding_exports;
60
+ const binding = bind(id.slice(VIRTUAL_PREFIX.length));
61
+ if (!((_binding_exports = binding.exports) === null || _binding_exports === void 0 ? void 0 : _binding_exports.length)) {
62
+ return `export default ${binding.expression};`;
63
+ }
64
+ return [
65
+ `const _m = ${binding.expression};`,
66
+ 'export default _m;',
67
+ ...binding.exports.map((name)=>`export const ${name} = _m.${name};`)
68
+ ].join('\n');
69
+ }
70
+ }
71
+ };
72
+ }
73
+
74
+ //# sourceMappingURL=window-externals-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/vite/plugins/window-externals-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\n/**\n * Maps each `window` global to the import(s) that resolve to it. The key is the `window` global\n * (`jQuery` names `window.jQuery`). Every value matches specifiers with a regex:\n *\n * - `RegExp` resolves matching imports to `window.<global>` (`/^jquery$/`, or\n * `/^(moment|moment-timezone)$/` to cover several specifiers)\n * - `{ match, exports }` resolves imports to `window.<global>.<export>`, for\n * packages that have named imports (e.g., (`import { formatMoney } from 'accounting'`))\n * - `{ match, member }` resolves imports to `window.<global>[member(specifier)]`, deriving the key from\n * the function result. For example `{ match: /^@arcgis\\/core\\//, member: s => s.split('/').pop() }`\n * maps `@arcgis/core/views/MapView` to `window.arcgis[\"MapView\"]`.\n */\nexport type WindowExternals = Record<\n string,\n | RegExp\n | {\n match: RegExp;\n exports?: string[];\n }\n | {\n match: RegExp;\n member?: (specifier: string) => string | false | null | undefined;\n }\n>;\n\ninterface Binding {\n expression: string;\n exports?: string[];\n}\n\ninterface Entry {\n match: RegExp;\n bind: (specifier: string) => Binding;\n}\n\nconst VIRTUAL_PREFIX = '\\0window-externals:';\nconst VIRTUAL_ID_PATTERN = new RegExp(`^${VIRTUAL_PREFIX}`);\n\n/*\n * Uses a global the host already puts on `window` instead of bundling the library, like webpack's\n * `externals` with externalsType `var`/`window`. Vite/Rolldown offers no built-in way to do this\n * for ES module builds (its `output.globals` maps externals to globals only for umd/iife output).\n * This plugin replaces matched imports with a module that reads the global.\n */\nexport function windowExternalsPlugin(externals: WindowExternals): Plugin {\n const entries: Entry[] = Object.entries(externals).map(([global, value]) => {\n if (value instanceof RegExp) {\n return { match: value, bind: () => ({ expression: `window.${global}` }) };\n }\n const { match } = value;\n const exports = 'exports' in value ? value.exports : undefined;\n const member = 'member' in value ? value.member : undefined;\n return {\n match,\n bind: specifier => {\n const key = member?.(specifier);\n const expression = key\n ? `window.${global}[${JSON.stringify(key)}]`\n : `window.${global}`;\n return { expression, exports };\n },\n };\n });\n\n const bind = (specifier: string): Binding | null =>\n entries.find(entry => entry.match.test(specifier))?.bind(specifier) ?? null;\n\n return {\n name: 'st:window-externals',\n enforce: 'pre',\n resolveId: {\n filter: { id: entries.map(entry => entry.match) },\n handler(source) {\n return VIRTUAL_PREFIX + source;\n },\n },\n load: {\n filter: { id: VIRTUAL_ID_PATTERN },\n handler(id) {\n const binding = bind(id.slice(VIRTUAL_PREFIX.length))!;\n if (!binding.exports?.length) {\n return `export default ${binding.expression};`;\n }\n return [\n `const _m = ${binding.expression};`,\n 'export default _m;',\n ...binding.exports.map(name => `export const ${name} = _m.${name};`),\n ].join('\\n');\n },\n },\n };\n}\n"],"names":["windowExternalsPlugin","VIRTUAL_PREFIX","VIRTUAL_ID_PATTERN","RegExp","externals","entries","Object","map","global","value","match","bind","expression","exports","undefined","member","specifier","key","JSON","stringify","find","entry","test","name","enforce","resolveId","filter","id","handler","source","load","binding","slice","length","join"],"mappings":";;;;+BA8CgBA;;;eAAAA;;;AAThB,MAAMC,iBAAiB;AACvB,MAAMC,qBAAqB,IAAIC,OAAO,CAAC,CAAC,EAAEF,gBAAgB;AAQnD,SAASD,sBAAsBI,SAA0B;IAC5D,MAAMC,UAAmBC,OAAOD,OAAO,CAACD,WAAWG,GAAG,CAAC,CAAC,CAACC,QAAQC,MAAM;QACnE,IAAIA,iBAAiBN,QAAQ;YACzB,OAAO;gBAAEO,OAAOD;gBAAOE,MAAM,IAAO,CAAA;wBAAEC,YAAY,CAAC,OAAO,EAAEJ,QAAQ;oBAAC,CAAA;YAAG;QAC5E;QACA,MAAM,EAAEE,KAAK,EAAE,GAAGD;QAClB,MAAMI,WAAU,aAAaJ,QAAQA,MAAMI,OAAO,GAAGC;QAC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4 +1,7 @@
1
1
  import { BuildContext } from '../core';
2
2
  import { ViteBundlerConfig } from '../utils';
3
- export type ViteBuildContext = BuildContext<Required<Omit<ViteBundlerConfig, 'port'>> & Pick<ViteBundlerConfig, 'port'>>;
3
+ export type ViteBuildContext = BuildContext<(Required<Omit<ViteBundlerConfig, 'port'>> & Pick<ViteBundlerConfig, 'port'>) & {
4
+ /** The resolved `build.outDir` override, if the package configures one. */
5
+ outDir?: string;
6
+ }>;
4
7
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vite/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,YAAY,CACvC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAC9E,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vite/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,YAAY,CACvC,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,GAAG;IAC5E,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bundle-webpack.d.ts","sourceRoot":"","sources":["../../src/webpack/bundle-webpack.ts"],"names":[],"mappings":"AAMA,UAAU,OAAO;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,aAAa,CAAC,OAAO,GAAE,OAAY,8DA8BxD"}
1
+ {"version":3,"file":"bundle-webpack.d.ts","sourceRoot":"","sources":["../../src/webpack/bundle-webpack.ts"],"names":[],"mappings":"AAOA,UAAU,OAAO;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,aAAa,CAAC,OAAO,GAAE,OAAY,8DA8BxD"}
@@ -13,6 +13,7 @@ const _webpack = /*#__PURE__*/ _interop_require_default(require("webpack"));
13
13
  const _webpackdevserver = /*#__PURE__*/ _interop_require_default(require("webpack-dev-server"));
14
14
  const _utils = require("../utils");
15
15
  const _createwebpackconfigs = require("./create-webpack-configs");
16
+ const _utils1 = require("./utils");
16
17
  function _interop_require_default(obj) {
17
18
  return obj && obj.__esModule ? obj : {
18
19
  default: obj
@@ -73,11 +74,15 @@ async function runServe({ devServer = {}, ...config }) {
73
74
  port: Number(process.env.PORT) || Number(devServer.port) || 8080,
74
75
  host
75
76
  });
77
+ const proxy = devServer.proxy && (0, _utils1.normalizeProxyConfig)(devServer.proxy);
76
78
  return new Promise((_0, reject)=>{
77
79
  const server = new _webpackdevserver.default({
78
80
  ...devServer,
79
81
  host,
80
- port
82
+ port,
83
+ ...proxy && {
84
+ proxy
85
+ }
81
86
  }, compiler);
82
87
  server.startCallback((e)=>{
83
88
  if (e) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/webpack/bundle-webpack.ts"],"sourcesContent":["import { getPortPromise } from 'portfinder';\nimport webpack, { Configuration } from 'webpack';\nimport WebpackDevServer from 'webpack-dev-server';\nimport { isDevServerDisabled, isExposeSharedDependencies, isWebComponent, log } from '../utils';\nimport { createWebpackConfigs } from './create-webpack-configs';\n\ninterface Options {\n buildStat?: boolean;\n codeCoverage?: boolean;\n config?: string;\n emitExposedDependencies?: boolean;\n useWatchConfig?: boolean;\n watch?: boolean;\n}\n\nexport async function bundleWebpack(options: Options = {}) {\n const { emitExposedDependencies, watch } = options;\n\n if (emitExposedDependencies) {\n if (watch) {\n throw new Error('cannot bundle exposed dependencies in watch mode');\n }\n if (!isExposeSharedDependencies()) {\n return;\n }\n }\n\n log.info(`Bundling ${emitExposedDependencies ? 'exposed dependencies' : 'package'}...`);\n\n const { full, light, headless } = createWebpackConfigs(options);\n\n // Standalone app — only the full config is needed\n if (!isWebComponent()) {\n return watch ? runDevServer(full) : run(full);\n }\n\n if (watch) {\n return Promise.all([\n runDevServer(full),\n light && runWatch(light),\n headless && runWatch(headless),\n ]);\n }\n\n return Promise.all([run(full), light && run(light), headless && run(headless)]);\n}\n\nasync function runDevServer(config: Configuration) {\n return isDevServerDisabled() ? runWatch(config) : runServe(config);\n}\n\nasync function run(config: Configuration) {\n const compiler = createWebpackCompiler(config);\n\n const stats = await new Promise<webpack.Stats>((resolve, reject) => {\n compiler.run((error, stats) => {\n if (!stats || error) {\n return reject(error ?? new Error('Something went wrong.'));\n }\n\n if (stats.hasErrors()) {\n return reject(new Error(stats.toString('errors-only')));\n }\n\n compiler.close(() => resolve(stats));\n });\n });\n\n process.stdout.write(stats.toString(config.stats) + '\\n');\n}\n\nasync function runServe({ devServer = {}, ...config }: Configuration) {\n const compiler = createWebpackCompiler(config);\n const host = devServer.host ?? 'localhost';\n const port = await getPortPromise({\n port: Number(process.env.PORT) || Number(devServer.port) || 8080,\n host,\n });\n\n return new Promise<void>((_0, reject) => {\n const server = new WebpackDevServer({ ...devServer, host, port }, compiler);\n server.startCallback(e => {\n if (e) {\n server.stopCallback(() => {\n reject(e);\n });\n }\n });\n });\n}\n\nasync function runWatch(config: Configuration) {\n const compiler = createWebpackCompiler(config);\n return new Promise<void>((_0, reject) => {\n const watching = compiler.watch({}, e => {\n if (e) {\n watching?.close(() => {\n reject(e);\n });\n }\n });\n });\n}\n\nfunction createWebpackCompiler(config: Configuration) {\n return webpack(config);\n}\n"],"names":["bundleWebpack","options","emitExposedDependencies","watch","Error","isExposeSharedDependencies","log","info","full","light","headless","createWebpackConfigs","isWebComponent","runDevServer","run","Promise","all","runWatch","config","isDevServerDisabled","runServe","compiler","createWebpackCompiler","stats","resolve","reject","error","hasErrors","toString","close","process","stdout","write","devServer","host","port","getPortPromise","Number","env","PORT","_0","server","WebpackDevServer","startCallback","e","stopCallback","watching","webpack"],"mappings":";;;;+BAesBA;;;eAAAA;;;4BAfS;gEACQ;yEACV;uBACwD;sCAChD;;;;;;AAW9B,eAAeA,cAAcC,UAAmB,CAAC,CAAC;IACrD,MAAM,EAAEC,uBAAuB,EAAEC,KAAK,EAAE,GAAGF;IAE3C,IAAIC,yBAAyB;QACzB,IAAIC,OAAO;YACP,MAAM,IAAIC,MAAM;QACpB;QACA,IAAI,CAACC,IAAAA,iCAA0B,KAAI;YAC/B;QACJ;IACJ;IAEAC,UAAG,CAACC,IAAI,CAAC,CAAC,SAAS,EAAEL,0BAA0B,yBAAyB,UAAU,GAAG,CAAC;IAEtF,MAAM,EAAEM,IAAI,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGC,IAAAA,0CAAoB,EAACV;IAEvD,kDAAkD;IAClD,IAAI,CAACW,IAAAA,qBAAc,KAAI;QACnB,OAAOT,QAAQU,aAAaL,QAAQM,IAAIN;IAC5C;IAEA,IAAIL,OAAO;QACP,OAAOY,QAAQC,GAAG,CAAC;YACfH,aAAaL;YACbC,SAASQ,SAASR;YAClBC,YAAYO,SAASP;SACxB;IACL;IAEA,OAAOK,QAA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AEA,eAAe3B,SAASC,MAAqB;IACzC,MAAMG,WAAWC,sBAAsBJ;IACvC,OAAO,IAAIH,QAAc,CAACyB,IAAIf;QAC1B,MAAMqB,WAAWzB,SAASlB,KAAK,CAAC,CAAC,GAAGyC,CAAAA;YAChC,IAAIA,GAAG;gBACHE,qBAAAA,+BAAAA,SAAUjB,KAAK,CAAC;oBACZJ,OAAOmB;gBACX;YACJ;QACJ;IACJ;AACJ;AAEA,SAAStB,sBAAsBJ,MAAqB;IAChD,OAAO6B,IAAAA,gBAAO,EAAC7B;AACnB"}
1
+ {"version":3,"sources":["../../src/webpack/bundle-webpack.ts"],"sourcesContent":["import { getPortPromise } from 'portfinder';\nimport webpack, { Configuration } from 'webpack';\nimport WebpackDevServer from 'webpack-dev-server';\nimport { isDevServerDisabled, isExposeSharedDependencies, isWebComponent, log } from '../utils';\nimport { createWebpackConfigs } from './create-webpack-configs';\nimport { normalizeProxyConfig } from './utils';\n\ninterface Options {\n buildStat?: boolean;\n codeCoverage?: boolean;\n config?: string;\n emitExposedDependencies?: boolean;\n useWatchConfig?: boolean;\n watch?: boolean;\n}\n\nexport async function bundleWebpack(options: Options = {}) {\n const { emitExposedDependencies, watch } = options;\n\n if (emitExposedDependencies) {\n if (watch) {\n throw new Error('cannot bundle exposed dependencies in watch mode');\n }\n if (!isExposeSharedDependencies()) {\n return;\n }\n }\n\n log.info(`Bundling ${emitExposedDependencies ? 'exposed dependencies' : 'package'}...`);\n\n const { full, light, headless } = createWebpackConfigs(options);\n\n // Standalone app — only the full config is needed\n if (!isWebComponent()) {\n return watch ? runDevServer(full) : run(full);\n }\n\n if (watch) {\n return Promise.all([\n runDevServer(full),\n light && runWatch(light),\n headless && runWatch(headless),\n ]);\n }\n\n return Promise.all([run(full), light && run(light), headless && run(headless)]);\n}\n\nasync function runDevServer(config: Configuration) {\n return isDevServerDisabled() ? runWatch(config) : runServe(config);\n}\n\nasync function run(config: Configuration) {\n const compiler = createWebpackCompiler(config);\n\n const stats = await new Promise<webpack.Stats>((resolve, reject) => {\n compiler.run((error, stats) => {\n if (!stats || error) {\n return reject(error ?? new Error('Something went wrong.'));\n }\n\n if (stats.hasErrors()) {\n return reject(new Error(stats.toString('errors-only')));\n }\n\n compiler.close(() => resolve(stats));\n });\n });\n\n process.stdout.write(stats.toString(config.stats) + '\\n');\n}\n\nasync function runServe({ devServer = {}, ...config }: Configuration) {\n const compiler = createWebpackCompiler(config);\n const host = devServer.host ?? 'localhost';\n const port = await getPortPromise({\n port: Number(process.env.PORT) || Number(devServer.port) || 8080,\n host,\n });\n\n const proxy = devServer.proxy && normalizeProxyConfig(devServer.proxy);\n\n return new Promise<void>((_0, reject) => {\n const server = new WebpackDevServer(\n { ...devServer, host, port, ...(proxy && { proxy }) },\n compiler\n );\n server.startCallback(e => {\n if (e) {\n server.stopCallback(() => {\n reject(e);\n });\n }\n });\n });\n}\n\nasync function runWatch(config: Configuration) {\n const compiler = createWebpackCompiler(config);\n return new Promise<void>((_0, reject) => {\n const watching = compiler.watch({}, e => {\n if (e) {\n watching?.close(() => {\n reject(e);\n });\n }\n });\n });\n}\n\nfunction createWebpackCompiler(config: Configuration) {\n return webpack(config);\n}\n"],"names":["bundleWebpack","options","emitExposedDependencies","watch","Error","isExposeSharedDependencies","log","info","full","light","headless","createWebpackConfigs","isWebComponent","runDevServer","run","Promise","all","runWatch","config","isDevServerDisabled","runServe","compiler","createWebpackCompiler","stats","resolve","reject","error","hasErrors","toString","close","process","stdout","write","devServer","host","port","getPortPromise","Number","env","PORT","proxy","normalizeProxyConfig","_0","server","WebpackDevServer","startCallback","e","stopCallback","watching","webpack"],"mappings":";;;;+BAgBsBA;;;eAAAA;;;4BAhBS;gEACQ;yEACV;uBACwD;sCAChD;wBACA;;;;;;AAW9B,eAAeA,cAAcC,UAAmB,CAAC,CAAC;IACrD,MAAM,EAAEC,uBAAuB,EAAEC,KAAK,EAAE,GAAGF;IAE3C,IAAIC,yBAAyB;QACzB,IAAIC,OAAO;YACP,MAAM,I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C,sBAAsBJ;IACvC,MAAMgB,QAAOD,kBAAAA,UAAUC,IAAI,cAAdD,6BAAAA,kBAAkB;IAC/B,MAAME,OAAO,MAAMC,IAAAA,0BAAc,EAAC;QAC9BD,MAAME,OAAOP,QAAQQ,GAAG,CAACC,IAAI,KAAKF,OAAOJ,UAAUE,IAAI,KAAK;QAC5DD;IACJ;IAEA,MAAMM,QAAQP,UAAUO,KAAK,IAAIC,IAAAA,4BAAoB,EAACR,UAAUO,KAAK;IAErE,OAAO,IAAIzB,QAAc,CAAC2B,IAAIjB;QAC1B,MAAMkB,SAAS,IAAIC,yBAAgB,CAC/B;YAAE,GAAGX,SAAS;YAAEC;YAAMC;YAAM,GAAIK,SAAS;gBAAEA;YAAM,CAAC;QAAE,GACpDnB;QAEJsB,OAAOE,aAAa,CAACC,CAAAA;YACjB,IAAIA,GAAG;gBACHH,OAAOI,YAAY,CAAC;oBAChBtB,OAAOqB;gBACX;YACJ;QACJ;IACJ;AACJ;AAEA,eAAe7B,SAASC,MAAqB;IACzC,MAAMG,WAAWC,sBAAsBJ;IACvC,OAAO,IAAIH,QAAc,CAAC2B,IAAIjB;QAC1B,MAAMuB,WAAW3B,SAASlB,KAAK,CAAC,CAAC,GAAG2C,CAAAA;YAChC,IAAIA,GAAG;gBACHE,qBAAAA,+BAAAA,SAAUnB,KAAK,CAAC;oBACZJ,OAAOqB;gBACX;YACJ;QACJ;IACJ;AACJ;AAEA,SAASxB,sBAAsBJ,MAAqB;IAChD,OAAO+B,IAAAA,gBAAO,EAAC/B;AACnB"}
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "optimizationConfig", {
9
9
  }
10
10
  });
11
11
  const _cssminimizerwebpackplugin = /*#__PURE__*/ _interop_require_default(require("css-minimizer-webpack-plugin"));
12
- const _terserwebpackplugin = /*#__PURE__*/ _interop_require_default(require("terser-webpack-plugin"));
12
+ const _minimizerwebpackplugin = /*#__PURE__*/ _interop_require_default(require("minimizer-webpack-plugin"));
13
13
  const _core = require("../../core");
14
14
  function _interop_require_default(obj) {
15
15
  return obj && obj.__esModule ? obj : {
@@ -67,7 +67,7 @@ function minimizeConfig(optimization, context) {
67
67
  /*
68
68
  * MFE source maps are available to Datadog, so compress and mangle are OK.
69
69
  * Disable for hosts until their source maps are uploaded too.
70
- */ const terserOptions = {
70
+ */ const minimizerOptions = {
71
71
  compress: !!isWebComponent,
72
72
  mangle: !!isWebComponent,
73
73
  ...typeof minifyJs === 'object' ? minifyJs : {}
@@ -77,8 +77,8 @@ function minimizeConfig(optimization, context) {
77
77
  };
78
78
  optimization.minimizer = [
79
79
  ...minifyJs ? [
80
- new _terserwebpackplugin.default({
81
- terserOptions
80
+ new _minimizerwebpackplugin.default({
81
+ minimizerOptions
82
82
  })
83
83
  ] : [],
84
84
  ...minifyCss ? [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/webpack/configs/optimization-config.ts"],"sourcesContent":["import CssMinimizerWebpackPlugin from 'css-minimizer-webpack-plugin';\nimport TerserPlugin from 'terser-webpack-plugin';\nimport { Configuration } from 'webpack';\nimport { CHUNK_PATTERNS } from '../../core';\nimport { Overrides, WebpackBuildContext } from '../types';\n\ntype Config = Configuration['optimization'];\ntype ConfigWithCacheGroups = Config & { splitChunks: { cacheGroups: Record<string, any> } };\ntype Result = Pick<Configuration, 'optimization'>;\n\nexport function optimizationConfig(context: WebpackBuildContext, _: Overrides): Result {\n const { headless, isProduction, emitExposedDependencies } = context.build;\n\n const optimization: ConfigWithCacheGroups = {\n chunkIds: isProduction ? 'deterministic' : 'named',\n moduleIds: 'size',\n mangleExports: 'size',\n splitChunks: { cacheGroups: {} },\n };\n\n if (emitExposedDependencies) {\n optimization.runtimeChunk = false;\n } else if (!headless && isProduction) {\n optimization.runtimeChunk = 'single';\n }\n\n [hostConfig, minimizeConfig, sharedDependenciesConfig, webComponentConfig].forEach(handler =>\n handler(optimization, context)\n );\n\n return { optimization };\n}\n\nfunction hostConfig(optimization: ConfigWithCacheGroups, context: WebpackBuildContext) {\n const { isProduction } = context.build;\n const { isWebComponent } = context.package;\n if (isWebComponent || !isProduction) {\n return;\n }\n\n Object.assign(optimization.splitChunks.cacheGroups, vendorGroups());\n}\n\nfunction minimizeConfig(optimization: ConfigWithCacheGroups, context: WebpackBuildContext) {\n const { isProduction } = context.build;\n const { isWebComponent } = context.package;\n const { codeCoverage } = context.options;\n const { minify } = context.bundlerConfig;\n if (!isProduction) {\n return;\n }\n\n const minifyJs = minify?.js ?? true;\n const minifyCss = minify?.css ?? true;\n optimization.minimize = !codeCoverage && (!!minifyJs || !!minifyCss);\n if (!optimization.minimize) {\n return;\n }\n\n /*\n * MFE source maps are available to Datadog, so compress and mangle are OK.\n * Disable for hosts until their source maps are uploaded too.\n */\n const terserOptions = {\n compress: !!isWebComponent,\n mangle: !!isWebComponent,\n ...(typeof minifyJs === 'object' ? minifyJs : {}),\n };\n\n const cssMinimizerPluginOptions = {\n ...(typeof minifyCss === 'object' ? minifyCss : {}),\n };\n\n optimization.minimizer = [\n ...(minifyJs ? [new TerserPlugin({ terserOptions })] : []),\n ...(minifyCss ? [new CssMinimizerWebpackPlugin(cssMinimizerPluginOptions)] : []),\n ];\n}\n\nfunction sharedDependenciesConfig(\n optimization: ConfigWithCacheGroups,\n context: WebpackBuildContext\n) {\n const { emitExposedDependencies } = context.build;\n if (!emitExposedDependencies) {\n return;\n }\n\n Object.assign(optimization.splitChunks.cacheGroups, {\n anvil2: {\n test: /@servicetitan[\\\\/]anvil2[\\\\/].*\\.css$/,\n name: 'anvil2',\n chunks: 'all',\n enforce: true,\n // Must outrank vendor groups so anvil2 CSS lands in separate chunk\n priority: 10,\n },\n });\n}\n\nfunction webComponentConfig(optimization: ConfigWithCacheGroups, context: WebpackBuildContext) {\n const { headless, isProduction } = context.build;\n const { isWebComponent } = context.package;\n if (!isWebComponent) {\n return;\n }\n\n const groups = vendorGroups();\n const styles = { name: 'main', type: 'css/mini-extract', chunks: 'all', enforce: true };\n\n Object.assign(optimization.splitChunks.cacheGroups, {\n ...(headless ? {} : { styles }),\n // assets-manifest-plugin requires servicetitan to order CSS correctly (headless has no CSS)\n ...(isProduction ? groups : headless ? {} : { servicetitan: groups.servicetitan }),\n });\n}\n\nfunction vendorGroups() {\n return {\n 'servicetitan': {\n name: 'servicetitan',\n test: CHUNK_PATTERNS.servicetitan,\n chunks: 'all',\n },\n 'vendor-core': {\n name: 'vendor-core',\n test: CHUNK_PATTERNS['vendor-core'],\n chunks: 'all',\n },\n 'kendo': {\n name: 'kendo',\n test: CHUNK_PATTERNS.kendo,\n chunks: 'all',\n },\n 'vendor': {\n name: 'vendor',\n test: CHUNK_PATTERNS.vendor,\n chunks: 'all',\n priority: -5,\n },\n };\n}\n"],"names":["optimizationConfig","context","_","headless","isProduction","emitExposedDependencies","build","optimization","chunkIds","moduleIds","mangleExports","splitChunks","cacheGroups","runtimeChunk","hostConfig","minimizeConfig","sharedDependenciesConfig","webComponentConfig","forEach","handler","isWebComponent","package","Object","assign","vendorGroups","codeCoverage","options","minify","bundlerConfig","minifyJs","js","minifyCss","css","minimize","terserOptions","compress","mangle","cssMinimizerPluginOptions","minimizer","TerserPlugin","CssMinimizerWebpackPlugin","anvil2","test","name","chunks","enforce","priority","groups","styles","type","servicetitan","CHUNK_PATTERNS","kendo","vendor"],"mappings":";;;;+BAUgBA;;;eAAAA;;;kFAVsB;4EACb;sBAEM;;;;;;AAOxB,SAASA,mBAAmBC,OAA4B,EAAEC,CAAY;IACzE,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,uBAAuB,EAAE,GAAGJ,QAAQK,KAAK;IAEzE,MAAMC,eAAsC;QACxCC,UAAUJ,eAAe,kBAAkB;QAC3CK,WAAW;QACXC,eAAe;QACfC,aAAa;YAAEC,aAAa,CAAC;QAAE;IACnC;IAEA,IAAIP,yBAAyB;QACzBE,aAAaM,YAAY,GAAG;IAChC,OAAO,IAAI,CAACV,YAAYC,cAAc;QAClCG,aAAaM,YAAY,GAAG;IAChC;IAEA;QAACC;QAAY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CAACE,MAAM;YAC3BT,QAAQ;YACRE,UAAU,CAAC;QACf;IACJ;AACJ"}
1
+ {"version":3,"sources":["../../../src/webpack/configs/optimization-config.ts"],"sourcesContent":["import CssMinimizerWebpackPlugin from 'css-minimizer-webpack-plugin';\nimport MinimizerPlugin from 'minimizer-webpack-plugin';\nimport { Configuration } from 'webpack';\nimport { CHUNK_PATTERNS } from '../../core';\nimport { Overrides, WebpackBuildContext } from '../types';\n\ntype Config = Configuration['optimization'];\ntype ConfigWithCacheGroups = Config & { splitChunks: { cacheGroups: Record<string, any> } };\ntype Result = Pick<Configuration, 'optimization'>;\n\nexport function optimizationConfig(context: WebpackBuildContext, _: Overrides): Result {\n const { headless, isProduction, emitExposedDependencies } = context.build;\n\n const optimization: ConfigWithCacheGroups = {\n chunkIds: isProduction ? 'deterministic' : 'named',\n moduleIds: 'size',\n mangleExports: 'size',\n splitChunks: { cacheGroups: {} },\n };\n\n if (emitExposedDependencies) {\n optimization.runtimeChunk = false;\n } else if (!headless && isProduction) {\n optimization.runtimeChunk = 'single';\n }\n\n [hostConfig, minimizeConfig, sharedDependenciesConfig, webComponentConfig].forEach(handler =>\n handler(optimization, context)\n );\n\n return { optimization };\n}\n\nfunction hostConfig(optimization: ConfigWithCacheGroups, context: WebpackBuildContext) {\n const { isProduction } = context.build;\n const { isWebComponent } = context.package;\n if (isWebComponent || !isProduction) {\n return;\n }\n\n Object.assign(optimization.splitChunks.cacheGroups, vendorGroups());\n}\n\nfunction minimizeConfig(optimization: ConfigWithCacheGroups, context: WebpackBuildContext) {\n const { isProduction } = context.build;\n const { isWebComponent } = context.package;\n const { codeCoverage } = context.options;\n const { minify } = context.bundlerConfig;\n if (!isProduction) {\n return;\n }\n\n const minifyJs = minify?.js ?? true;\n const minifyCss = minify?.css ?? true;\n optimization.minimize = !codeCoverage && (!!minifyJs || !!minifyCss);\n if (!optimization.minimize) {\n return;\n }\n\n /*\n * MFE source maps are available to Datadog, so compress and mangle are OK.\n * Disable for hosts until their source maps are uploaded too.\n */\n const minimizerOptions = {\n compress: !!isWebComponent,\n mangle: !!isWebComponent,\n ...(typeof minifyJs === 'object' ? minifyJs : {}),\n };\n\n const cssMinimizerPluginOptions = {\n ...(typeof minifyCss === 'object' ? minifyCss : {}),\n };\n\n optimization.minimizer = [\n ...(minifyJs ? [new MinimizerPlugin({ minimizerOptions })] : []),\n ...(minifyCss ? [new CssMinimizerWebpackPlugin(cssMinimizerPluginOptions)] : []),\n ];\n}\n\nfunction sharedDependenciesConfig(\n optimization: ConfigWithCacheGroups,\n context: WebpackBuildContext\n) {\n const { emitExposedDependencies } = context.build;\n if (!emitExposedDependencies) {\n return;\n }\n\n Object.assign(optimization.splitChunks.cacheGroups, {\n anvil2: {\n test: /@servicetitan[\\\\/]anvil2[\\\\/].*\\.css$/,\n name: 'anvil2',\n chunks: 'all',\n enforce: true,\n // Must outrank vendor groups so anvil2 CSS lands in separate chunk\n priority: 10,\n },\n });\n}\n\nfunction webComponentConfig(optimization: ConfigWithCacheGroups, context: WebpackBuildContext) {\n const { headless, isProduction } = context.build;\n const { isWebComponent } = context.package;\n if (!isWebComponent) {\n return;\n }\n\n const groups = vendorGroups();\n const styles = { name: 'main', type: 'css/mini-extract', chunks: 'all', enforce: true };\n\n Object.assign(optimization.splitChunks.cacheGroups, {\n ...(headless ? {} : { styles }),\n // assets-manifest-plugin requires servicetitan to order CSS correctly (headless has no CSS)\n ...(isProduction ? groups : headless ? {} : { servicetitan: groups.servicetitan }),\n });\n}\n\nfunction vendorGroups() {\n return {\n 'servicetitan': {\n name: 'servicetitan',\n test: CHUNK_PATTERNS.servicetitan,\n chunks: 'all',\n },\n 'vendor-core': {\n name: 'vendor-core',\n test: CHUNK_PATTERNS['vendor-core'],\n chunks: 'all',\n },\n 'kendo': {\n name: 'kendo',\n test: CHUNK_PATTERNS.kendo,\n chunks: 'all',\n },\n 'vendor': {\n name: 'vendor',\n test: CHUNK_PATTERNS.vendor,\n chunks: 'all',\n priority: -5,\n },\n };\n}\n"],"names":["optimizationConfig","context","_","headless","isProduction","emitExposedDependencies","build","optimization","chunkIds","moduleIds","mangleExports","splitChunks","cacheGroups","runtimeChunk","hostConfig","minimizeConfig","sharedDependenciesConfig","webComponentConfig","forEach","handler","isWebComponent","package","Object","assign","vendorGroups","codeCoverage","options","minify","bundlerConfig","minifyJs","js","minifyCss","css","minimize","minimizerOptions","compress","mangle","cssMinimizerPluginOptions","minimizer","MinimizerPlugin","CssMinimizerWebpackPlugin","anvil2","test","name","chunks","enforce","priority","groups","styles","type","servicetitan","CHUNK_PATTERNS","kendo","vendor"],"mappings":";;;;+BAUgBA;;;eAAAA;;;kFAVsB;+EACV;sBAEG;;;;;;AAOxB,SAASA,mBAAmBC,OAA4B,EAAEC,CAAY;IACzE,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,uBAAuB,EAAE,GAAGJ,QAAQK,KAAK;IAEzE,MAAMC,eAAsC;QACxCC,UAAUJ,eAAe,kBAAkB;QAC3CK,WAAW;QACXC,eAAe;QACfC,aAAa;YAAEC,aAAa,CAAC;QAAE;IACnC;IAEA,IAAIP,yBAAyB;QACzBE,aAAaM,YAAY,GAAG;IAChC,OAAO,IAAI,CAACV,YAAYC,cAAc;QAClCG,aAAaM,YAAY,GAAG;IAChC;IAEA;QAACC;QAAYC;QAAgBC;QAA0BC;KAAmB,CAACC,OAAO,CAACC,CAAAA,UAC/EA,QAAQZ,cAAcN;IAG1B,OAAO;QAAEM;IAAa;AAC1B;AAEA,SAASO,WAAWP,YAAmC,EAAEN,OAA4B;IACjF,MAAM,EAAEG,YAAY,EAAE,GAAGH,QAAQK,KAAK;IACtC,MAAM,EAAEc,cAAc,EAAE,GAAGnB,QAAQoB,OAAO;IAC1C,IAAID,kBAAkB,CAAChB,cAAc;QACjC;IACJ;IAEAkB,OAAOC,MAAM,CAAChB,aAAaI,WAAW,CAACC,WAAW,EAAEY;AACxD;AAEA,SAAST,eAAeR,YAAmC,EAAEN,OAA4B;;IACrF,MAAM,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AAmC,EAAEN,OAA4B;IACzF,MAAM,EAAEE,QAAQ,EAAEC,YAAY,EAAE,GAAGH,QAAQK,KAAK;IAChD,MAAM,EAAEc,cAAc,EAAE,GAAGnB,QAAQoB,OAAO;IAC1C,IAAI,CAACD,gBAAgB;QACjB;IACJ;IAEA,MAAM2B,SAASvB;IACf,MAAMwB,SAAS;QAAEL,MAAM;QAAQM,MAAM;QAAoBL,QAAQ;QAAOC,SAAS;IAAK;IAEtFvB,OAAOC,MAAM,CAAChB,aAAaI,WAAW,CAACC,WAAW,EAAE;QAChD,GAAIT,WAAW,CAAC,IAAI;YAAE6C;QAAO,CAAC;QAC9B,4FAA4F;QAC5F,GAAI5C,eAAe2C,SAAS5C,WAAW,CAAC,IAAI;YAAE+C,cAAcH,OAAOG,YAAY;QAAC,CAAC;IACrF;AACJ;AAEA,SAAS1B;IACL,OAAO;QACH,gBAAgB;YACZmB,MAAM;YACND,MAAMS,oBAAc,CAACD,YAAY;YACjCN,QAAQ;QACZ;QACA,eAAe;YACXD,MAAM;YACND,MAAMS,oBAAc,CAAC,cAAc;YACnCP,QAAQ;QACZ;QACA,SAAS;YACLD,MAAM;YACND,MAAMS,oBAAc,CAACC,KAAK;YAC1BR,QAAQ;QACZ;QACA,UAAU;YACND,MAAM;YACND,MAAMS,oBAAc,CAACE,MAAM;YAC3BT,QAAQ;YACRE,UAAU,CAAC;QACf;IACJ;AACJ"}
@@ -24,7 +24,7 @@ function outputConfig(context, _) {
24
24
  Object.assign(output, {
25
25
  filename: '[name].[contenthash].bundle.js',
26
26
  ...isWebComponent ? {
27
- uniqueName: name
27
+ uniqueName: `${name}-${(0, _core.getBundleType)(context)}`
28
28
  } : {},
29
29
  ...cdnPath ? {
30
30
  publicPath: cdnPath
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/webpack/configs/output-config.ts"],"sourcesContent":["import { Configuration } from 'webpack';\nimport { BuildContext, getBundleType, getCdnPath } from '../../core';\nimport { Overrides } from '../types';\n\ntype Config = Configuration['output'];\ntype Result = Pick<Configuration, 'output'>;\n\nexport function outputConfig(context: BuildContext, _: Overrides): Result {\n const { name, isProduction, emitExposedDependencies } = context.build;\n const { isWebComponent } = context.package;\n\n const output: Config = {\n filename: '[name].bundle.js',\n clean: getClean(context),\n ...(emitExposedDependencies ? { chunkLoadingGlobal: `sharedChunk${name}` } : {}),\n };\n\n if (isProduction) {\n const cdnPath = getCdnPath(context);\n Object.assign(output, {\n filename: '[name].[contenthash].bundle.js',\n ...(isWebComponent ? { uniqueName: name } : {}),\n ...(cdnPath ? { publicPath: cdnPath } : {}),\n });\n }\n\n return { output };\n}\n\nfunction getClean(context: BuildContext): NonNullable<Config>['clean'] {\n const { emitExposedDependencies } = context.build;\n if (emitExposedDependencies) {\n return true;\n }\n const exposedDependenciesDir = getBundleType({\n ...context,\n build: { ...context.build, emitExposedDependencies: true },\n });\n return exposedDependenciesDir ? { keep: new RegExp(exposedDependenciesDir) } : true;\n}\n"],"names":["outputConfig","context","_","name","isProduction","emitExposedDependencies","build","isWebComponent","package","output","filename","clean","getClean","chunkLoadingGlobal","cdnPath","getCdnPath","Object","assign","uniqueName","publicPath","exposedDependenciesDir","getBundleType","keep","RegExp"],"mappings":";;;;+BAOgBA;;;eAAAA;;;sBANwC;AAMjD,SAASA,aAAaC,OAAqB,EAAEC,CAAY;IAC5D,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAEC,uBAAuB,EAAE,GAAGJ,QAAQK,KAAK;IACrE,MAAM,EAAEC,cAAc,EAAE,GAAGN,QAAQO,OAAO;IAE1C,MAAMC,SAAiB;QACnBC,UAAU;QACVC,OAAOC,SAASX;QAChB,GAAII,0BAA0B;YAAEQ,oBAAoB,CAAC,WAAW,EAAEV,MAAM;QAAC,IAAI,CAAC,CAAC;IACnF;IAEA,IAAIC,cAAc;QACd,MAAMU,UAAUC,IAAAA,gBAAU,EAACd;QAC3Be,OAAOC,MAAM,CAACR,QAAQ;YAClBC,UAAU;YACV,GAAIH,iBAAiB;gBAAEW,YAAYf;YAAK,IAAI,CAAC,CAAC;YAC9C,GAAIW,UAAU;gBAAEK,YAAYL;YAAQ,IAAI,CAAC,CAAC;QAC9C;IACJ;IAEA,OAAO;QAAEL;IAAO;AACpB;AAEA,SAASG,SAASX,OAAqB;IACnC,MAAM,EAAEI,uBAAuB,EAAE,GAAGJ,QAAQK,KAAK;IACjD,IAAID,yBAAyB;QACzB,OAAO;IACX;IACA,MAAMe,yBAAyBC,IAAAA,mBAAa,EAAC;QACzC,GAAGpB,OAAO;QACVK,OAAO;YAAE,GAAGL,QAAQK,KAAK;YAAED,yBAAyB;QAAK;IAC7D;IACA,OAAOe,yBAAyB;QAAEE,MAAM,IAAIC,OAAOH;IAAwB,IAAI;AACnF"}
1
+ {"version":3,"sources":["../../../src/webpack/configs/output-config.ts"],"sourcesContent":["import { Configuration } from 'webpack';\nimport { BuildContext, getBundleType, getCdnPath } from '../../core';\nimport { Overrides } from '../types';\n\ntype Config = Configuration['output'];\ntype Result = Pick<Configuration, 'output'>;\n\nexport function outputConfig(context: BuildContext, _: Overrides): Result {\n const { name, isProduction, emitExposedDependencies } = context.build;\n const { isWebComponent } = context.package;\n\n const output: Config = {\n filename: '[name].bundle.js',\n clean: getClean(context),\n ...(emitExposedDependencies ? { chunkLoadingGlobal: `sharedChunk${name}` } : {}),\n };\n\n if (isProduction) {\n const cdnPath = getCdnPath(context);\n Object.assign(output, {\n filename: '[name].[contenthash].bundle.js',\n ...(isWebComponent ? { uniqueName: `${name}-${getBundleType(context)}` } : {}),\n ...(cdnPath ? { publicPath: cdnPath } : {}),\n });\n }\n\n return { output };\n}\n\nfunction getClean(context: BuildContext): NonNullable<Config>['clean'] {\n const { emitExposedDependencies } = context.build;\n if (emitExposedDependencies) {\n return true;\n }\n const exposedDependenciesDir = getBundleType({\n ...context,\n build: { ...context.build, emitExposedDependencies: true },\n });\n return exposedDependenciesDir ? { keep: new RegExp(exposedDependenciesDir) } : true;\n}\n"],"names":["outputConfig","context","_","name","isProduction","emitExposedDependencies","build","isWebComponent","package","output","filename","clean","getClean","chunkLoadingGlobal","cdnPath","getCdnPath","Object","assign","uniqueName","getBundleType","publicPath","exposedDependenciesDir","keep","RegExp"],"mappings":";;;;+BAOgBA;;;eAAAA;;;sBANwC;AAMjD,SAASA,aAAaC,OAAqB,EAAEC,CAAY;IAC5D,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAEC,uBAAuB,EAAE,GAAGJ,QAAQK,KAAK;IACrE,MAAM,EAAEC,cAAc,EAAE,GAAGN,QAAQO,OAAO;IAE1C,MAAMC,SAAiB;QACnBC,UAAU;QACVC,OAAOC,SAASX;QAChB,GAAII,0BAA0B;YAAEQ,oBAAoB,CAAC,WAAW,EAAEV,MAAM;QAAC,IAAI,CAAC,CAAC;IACnF;IAEA,IAAIC,cAAc;QACd,MAAMU,UAAUC,IAAAA,gBAAU,EAACd;QAC3Be,OAAOC,MAAM,CAACR,QAAQ;YAClBC,UAAU;YACV,GAAIH,iBAAiB;gBAAEW,YAAY,GAAGf,KAAK,CAAC,EAAEgB,IAAAA,mBAAa,EAAClB,UAAU;YAAC,IAAI,CAAC,CAAC;YAC7E,GAAIa,UAAU;gBAAEM,YAAYN;YAAQ,IAAI,CAAC,CAAC;QAC9C;IACJ;IAEA,OAAO;QAAEL;IAAO;AACpB;AAEA,SAASG,SAASX,OAAqB;IACnC,MAAM,EAAEI,uBAAuB,EAAE,GAAGJ,QAAQK,KAAK;IACjD,IAAID,yBAAyB;QACzB,OAAO;IACX;IACA,MAAMgB,yBAAyBF,IAAAA,mBAAa,EAAC;QACzC,GAAGlB,OAAO;QACVK,OAAO;YAAE,GAAGL,QAAQK,KAAK;YAAED,yBAAyB;QAAK;IAC7D;IACA,OAAOgB,yBAAyB;QAAEC,MAAM,IAAIC,OAAOF;IAAwB,IAAI;AACnF"}
@@ -17,9 +17,7 @@ function _define_property(obj, key, value) {
17
17
  configurable: true,
18
18
  writable: true
19
19
  });
20
- } else {
21
- obj[key] = value;
22
- }
20
+ } else obj[key] = value;
23
21
  return obj;
24
22
  }
25
23
  class IgnoreOptionalDependenciesPlugin {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/webpack/configs/plugins/ignore-plugin/ignore-plugin.ts"],"sourcesContent":["import { Compiler } from 'webpack';\nimport { BuildContext, type CheckerArgs, checkResource, type IgnoreMode } from '../../../../core';\nimport { Overrides } from '../../../types';\n\n/**\n * Handles optional peer dependencies that are not installed.\n *\n * @see {@link file://./../../../../vite/plugins/ignore-modules-plugin.ts} for the vite counterpart.\n *\n * 'throw' mode: returns false from beforeResolve, mirroring webpack's built-in IgnorePlugin.\n * Webpack emits a `webpackMissingModule()` IIFE that throws \"Cannot find module\" at runtime.\n * Top-level static imports of the resource crash module evaluation, and `try { require(...) }\n * catch {}` patterns work as expected. This is the default for matched optional peers.\n *\n * 'empty' mode: rewrites the request to point at an empty physical module so the import\n * resolves successfully with no exports. Required for top-level `import * as X from 'optional'`\n * followed by `X.foo === undefined` detection. Opt in via\n * `cli.peerDependenciesMeta[\"pkg\"].fallback = \"empty\"` in the importer's package.json.\n */\ntype Checker = (args: CheckerArgs) => IgnoreMode | false;\n\nclass IgnoreOptionalDependenciesPlugin {\n private readonly checker: Checker;\n private readonly emptyModulePath: string;\n\n constructor(checker: Checker) {\n this.checker = checker;\n this.emptyModulePath = require.resolve('./empty-module');\n }\n\n apply(compiler: Compiler) {\n compiler.hooks.normalModuleFactory.tap(\n 'IgnoreOptionalDependenciesPlugin',\n normalModuleFactory => {\n normalModuleFactory.hooks.beforeResolve.tap(\n 'IgnoreOptionalDependenciesPlugin',\n resolveData => {\n if (!resolveData) {\n return;\n }\n\n const mode = this.checker({\n resource: resolveData.request,\n importer: resolveData.context,\n });\n\n if (mode === 'throw') {\n return false;\n }\n\n if (mode === 'empty') {\n resolveData.request = this.emptyModulePath; // must be a physical file\n }\n }\n );\n }\n );\n }\n}\n\nexport function ignorePlugin(context: BuildContext, _: Overrides) {\n return new IgnoreOptionalDependenciesPlugin(checkResource(context));\n}\n"],"names":["ignorePlugin","IgnoreOptionalDependenciesPlugin","apply","compiler","hooks","normalModuleFactory","tap","beforeResolve","resolveData","mode","checker","resource","request","importer","context","emptyModulePath","require","resolve","_","checkResource"],"mappings":";;;;+BA4DgBA;;;eAAAA;;;sBA3D+D;;;;;;;;;;;;;;AAoB/E,MAAMC;IASFC,MAAMC,QAAkB,EAAE;QACtBA,SAASC,KAAK,CAACC,mBAAmB,CAACC,GAAG,CAClC,oCACAD,CAAAA;YACIA,oBAAoBD,KAAK,CAACG,aAAa,CAACD,GAAG,CACvC,oCACAE,CAAAA;gBACI,IAAI,CAACA,aAAa;oBACd;gBACJ;gBAEA,MAAMC,OAAO,IAAI,CAACC,OAAO,CAAC;oBACtBC,UAAUH,YAAYI,OAAO;oBAC7BC,UAAUL,YAAYM,OAAO;gBACjC;gBAEA,IAAIL,SAAS,SAAS;oBAClB,OAAO;gBACX;gBAEA,IAAIA,SAAS,SAAS;oBAClBD,YAAYI,OAAO,GAAG,IAAI,CAACG,eAAe,EAAE,0BAA0B;gBAC1E;YACJ;QAER;IAER;IAhCA,YAAYL,OAAgB,CAAE;QAH9B,uBAAiBA,WAAjB,KAAA;QACA,uBAAiBK,mBAAjB,KAAA;QAGI,IAAI,CAACL,OAAO,GAAGA;QACf,IAAI,CAACK,eAAe,GAAGC,QAAQC,OAAO,CAAC;IAC3C;AA8BJ;AAEO,SAASjB,aAAac,OAAqB,EAAEI,CAAY;IAC5D,OAAO,IAAIjB,iCAAiCkB,IAAAA,mBAAa,EAACL;AAC9D"}
1
+ {"version":3,"sources":["../../../../../src/webpack/configs/plugins/ignore-plugin/ignore-plugin.ts"],"sourcesContent":["import { Compiler } from 'webpack';\nimport { BuildContext, type CheckerArgs, checkResource, type IgnoreMode } from '../../../../core';\nimport { Overrides } from '../../../types';\n\n/**\n * Handles optional peer dependencies that are not installed.\n *\n * @see {@link file://./../../../../vite/plugins/ignore-modules-plugin.ts} for the vite counterpart.\n *\n * 'throw' mode: returns false from beforeResolve, mirroring webpack's built-in IgnorePlugin.\n * Webpack emits a `webpackMissingModule()` IIFE that throws \"Cannot find module\" at runtime.\n * Top-level static imports of the resource crash module evaluation, and `try { require(...) }\n * catch {}` patterns work as expected. This is the default for matched optional peers.\n *\n * 'empty' mode: rewrites the request to point at an empty physical module so the import\n * resolves successfully with no exports. Required for top-level `import * as X from 'optional'`\n * followed by `X.foo === undefined` detection. Opt in via\n * `cli.peerDependenciesMeta[\"pkg\"].fallback = \"empty\"` in the importer's package.json.\n */\ntype Checker = (args: CheckerArgs) => IgnoreMode | false;\n\nclass IgnoreOptionalDependenciesPlugin {\n private readonly checker: Checker;\n private readonly emptyModulePath: string;\n\n constructor(checker: Checker) {\n this.checker = checker;\n this.emptyModulePath = require.resolve('./empty-module');\n }\n\n apply(compiler: Compiler) {\n compiler.hooks.normalModuleFactory.tap(\n 'IgnoreOptionalDependenciesPlugin',\n normalModuleFactory => {\n normalModuleFactory.hooks.beforeResolve.tap(\n 'IgnoreOptionalDependenciesPlugin',\n resolveData => {\n if (!resolveData) {\n return;\n }\n\n const mode = this.checker({\n resource: resolveData.request,\n importer: resolveData.context,\n });\n\n if (mode === 'throw') {\n return false;\n }\n\n if (mode === 'empty') {\n resolveData.request = this.emptyModulePath; // must be a physical file\n }\n }\n );\n }\n );\n }\n}\n\nexport function ignorePlugin(context: BuildContext, _: Overrides) {\n return new IgnoreOptionalDependenciesPlugin(checkResource(context));\n}\n"],"names":["ignorePlugin","IgnoreOptionalDependenciesPlugin","apply","compiler","hooks","normalModuleFactory","tap","beforeResolve","resolveData","mode","checker","resource","request","importer","context","emptyModulePath","require","resolve","_","checkResource"],"mappings":";;;;+BA4DgBA;;;eAAAA;;;sBA3D+D;;;;;;;;;;;;AAoB/E,MAAMC;IASFC,MAAMC,QAAkB,EAAE;QACtBA,SAASC,KAAK,CAACC,mBAAmB,CAACC,GAAG,CAClC,oCACAD,CAAAA;YACIA,oBAAoBD,KAAK,CAACG,aAAa,CAACD,GAAG,CACvC,oCACAE,CAAAA;gBACI,IAAI,CAACA,aAAa;oBACd;gBACJ;gBAEA,MAAMC,OAAO,IAAI,CAACC,OAAO,CAAC;oBACtBC,UAAUH,YAAYI,OAAO;oBAC7BC,UAAUL,YAAYM,OAAO;gBACjC;gBAEA,IAAIL,SAAS,SAAS;oBAClB,OAAO;gBACX;gBAEA,IAAIA,SAAS,SAAS;oBAClBD,YAAYI,OAAO,GAAG,IAAI,CAACG,eAAe,EAAE,0BAA0B;gBAC1E;YACJ;QAER;IAER;IAhCA,YAAYL,OAAgB,CAAE;QAH9B,uBAAiBA,WAAjB,KAAA;QACA,uBAAiBK,mBAAjB,KAAA;QAGI,IAAI,CAACL,OAAO,GAAGA;QACf,IAAI,CAACK,eAAe,GAAGC,QAAQC,OAAO,CAAC;IAC3C;AA8BJ;AAEO,SAASjB,aAAac,OAAqB,EAAEI,CAAY;IAC5D,OAAO,IAAIjB,iCAAiCkB,IAAAA,mBAAa,EAACL;AAC9D"}
@@ -0,0 +1,13 @@
1
+ const version = '1.0.0';
2
+
3
+ const configuration = { foo: 'bar' };
4
+
5
+ function get() {
6
+ return configuration;
7
+ }
8
+
9
+ function set(changes) {
10
+ Object.assign(configuration, changes);
11
+ }
12
+
13
+ module.exports = { version, get, set };
@@ -0,0 +1 @@
1
+ module.exports = require('./configuration.expose-loader');
@@ -1,5 +1,6 @@
1
1
  export * from './create-webpack-build-context';
2
2
  export * from './get-caller-filename';
3
3
  export * from './get-module-entry-path';
4
+ export * from './normalize-proxy-config';
4
5
  export * from './split-by-entry';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/webpack/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/webpack/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  _export_star(require("./create-webpack-build-context"), exports);
6
6
  _export_star(require("./get-caller-filename"), exports);
7
7
  _export_star(require("./get-module-entry-path"), exports);
8
+ _export_star(require("./normalize-proxy-config"), exports);
8
9
  _export_star(require("./split-by-entry"), exports);
9
10
  function _export_star(from, to) {
10
11
  Object.keys(from).forEach(function(k) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/webpack/utils/index.ts"],"sourcesContent":["export * from './create-webpack-build-context';\nexport * from './get-caller-filename';\nexport * from './get-module-entry-path';\nexport * from './split-by-entry';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA"}
1
+ {"version":3,"sources":["../../../src/webpack/utils/index.ts"],"sourcesContent":["export * from './create-webpack-build-context';\nexport * from './get-caller-filename';\nexport * from './get-module-entry-path';\nexport * from './normalize-proxy-config';\nexport * from './split-by-entry';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA"}
@@ -0,0 +1,6 @@
1
+ import { Configuration } from 'webpack';
2
+ type DevServerConfig = NonNullable<Configuration['devServer']>;
3
+ type ProxyConfig = NonNullable<DevServerConfig['proxy']>;
4
+ export declare function normalizeProxyConfig(proxy: ProxyConfig): ProxyConfig;
5
+ export {};
6
+ //# sourceMappingURL=normalize-proxy-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-proxy-config.d.ts","sourceRoot":"","sources":["../../../src/webpack/utils/normalize-proxy-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,KAAK,eAAe,GAAG,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;AAC/D,KAAK,WAAW,GAAG,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;AAYzD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAOpE"}