@servicetitan/startup 38.0.0 → 38.2.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 (429) 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 +32 -10
  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 +13 -0
  16. package/dist/cli/commands/command.d.ts.map +1 -0
  17. package/dist/cli/commands/command.js +74 -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.d.ts.map +1 -1
  24. package/dist/cli/commands/init.js +13 -5
  25. package/dist/cli/commands/init.js.map +1 -1
  26. package/dist/cli/commands/install.d.ts.map +1 -1
  27. package/dist/cli/commands/install.js +14 -21
  28. package/dist/cli/commands/install.js.map +1 -1
  29. package/dist/cli/commands/kendo-ui-license.js +13 -4
  30. package/dist/cli/commands/kendo-ui-license.js.map +1 -1
  31. package/dist/cli/commands/lint.js +13 -4
  32. package/dist/cli/commands/lint.js.map +1 -1
  33. package/dist/cli/commands/mfe-check.d.ts.map +1 -1
  34. package/dist/cli/commands/mfe-check.js +15 -7
  35. package/dist/cli/commands/mfe-check.js.map +1 -1
  36. package/dist/cli/commands/mfe-generate-metadata.js +13 -4
  37. package/dist/cli/commands/mfe-generate-metadata.js.map +1 -1
  38. package/dist/cli/commands/mfe-list.js +13 -4
  39. package/dist/cli/commands/mfe-list.js.map +1 -1
  40. package/dist/cli/commands/mfe-package-clean.js +13 -4
  41. package/dist/cli/commands/mfe-package-clean.js.map +1 -1
  42. package/dist/cli/commands/mfe-package-publish.js +13 -4
  43. package/dist/cli/commands/mfe-package-publish.js.map +1 -1
  44. package/dist/cli/commands/mfe-package-rollback.js +13 -4
  45. package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
  46. package/dist/cli/commands/mfe-publish.js +13 -4
  47. package/dist/cli/commands/mfe-publish.js.map +1 -1
  48. package/dist/cli/commands/mfe-purge-cache.js +13 -4
  49. package/dist/cli/commands/mfe-purge-cache.js.map +1 -1
  50. package/dist/cli/commands/prepare-package.js +13 -4
  51. package/dist/cli/commands/prepare-package.js.map +1 -1
  52. package/dist/cli/commands/registry/build.d.ts +1 -1
  53. package/dist/cli/commands/registry/build.d.ts.map +1 -1
  54. package/dist/cli/commands/registry/build.js +3 -5
  55. package/dist/cli/commands/registry/build.js.map +1 -1
  56. package/dist/cli/commands/registry/bundle-package.d.ts +41 -0
  57. package/dist/cli/commands/registry/bundle-package.d.ts.map +1 -0
  58. package/dist/cli/commands/registry/bundle-package.js +54 -0
  59. package/dist/cli/commands/registry/bundle-package.js.map +1 -0
  60. package/dist/cli/commands/registry/command-registry.d.ts +42 -18
  61. package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
  62. package/dist/cli/commands/registry/command-registry.js +10 -19
  63. package/dist/cli/commands/registry/command-registry.js.map +1 -1
  64. package/dist/cli/commands/registry/install.d.ts +0 -16
  65. package/dist/cli/commands/registry/install.d.ts.map +1 -1
  66. package/dist/cli/commands/registry/install.js +1 -17
  67. package/dist/cli/commands/registry/install.js.map +1 -1
  68. package/dist/cli/commands/registry/start.d.ts +1 -1
  69. package/dist/cli/commands/registry/start.d.ts.map +1 -1
  70. package/dist/cli/commands/registry/start.js +3 -5
  71. package/dist/cli/commands/registry/start.js.map +1 -1
  72. package/dist/cli/commands/review/review.js +14 -7
  73. package/dist/cli/commands/review/review.js.map +1 -1
  74. package/dist/cli/commands/review/rules/no-deprecated-content-base.js +1 -3
  75. package/dist/cli/commands/review/rules/no-deprecated-content-base.js.map +1 -1
  76. package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js +1 -3
  77. package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js.map +1 -1
  78. package/dist/cli/commands/review/rules/no-typescript-entry-point.js +1 -3
  79. package/dist/cli/commands/review/rules/no-typescript-entry-point.js.map +1 -1
  80. package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js +5 -12
  81. package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js.map +1 -1
  82. package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js +5 -12
  83. package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js.map +1 -1
  84. package/dist/cli/commands/review/rules/require-explicit-side-effects.js +1 -3
  85. package/dist/cli/commands/review/rules/require-explicit-side-effects.js.map +1 -1
  86. package/dist/cli/commands/review/rules/require-one-collection-version.js +1 -3
  87. package/dist/cli/commands/review/rules/require-one-collection-version.js.map +1 -1
  88. package/dist/cli/commands/review/rules/require-servicetitan-scope.js +1 -3
  89. package/dist/cli/commands/review/rules/require-servicetitan-scope.js.map +1 -1
  90. package/dist/cli/commands/review/rules/require-tsconfig-references.js +1 -3
  91. package/dist/cli/commands/review/rules/require-tsconfig-references.js.map +1 -1
  92. package/dist/cli/commands/review/utils/compare-version.js +8 -19
  93. package/dist/cli/commands/review/utils/compare-version.js.map +1 -1
  94. package/dist/cli/commands/run-task.d.ts +1 -0
  95. package/dist/cli/commands/run-task.d.ts.map +1 -1
  96. package/dist/cli/commands/run-task.js +20 -6
  97. package/dist/cli/commands/run-task.js.map +1 -1
  98. package/dist/cli/commands/start.d.ts.map +1 -1
  99. package/dist/cli/commands/start.js +37 -14
  100. package/dist/cli/commands/start.js.map +1 -1
  101. package/dist/cli/commands/stylelint.js +13 -4
  102. package/dist/cli/commands/stylelint.js.map +1 -1
  103. package/dist/cli/commands/styles-check.js +13 -4
  104. package/dist/cli/commands/styles-check.js.map +1 -1
  105. package/dist/cli/commands/test/runners/jest.js +1 -3
  106. package/dist/cli/commands/test/runners/jest.js.map +1 -1
  107. package/dist/cli/commands/test/tests.js +13 -4
  108. package/dist/cli/commands/test/tests.js.map +1 -1
  109. package/dist/cli/commands/types.d.ts +1 -6
  110. package/dist/cli/commands/types.d.ts.map +1 -1
  111. package/dist/cli/commands/types.js +2 -20
  112. package/dist/cli/commands/types.js.map +1 -1
  113. package/dist/cli/commands/upload-sourcemaps.js +17 -13
  114. package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
  115. package/dist/cli/index.js +1 -0
  116. package/dist/cli/index.js.map +1 -1
  117. package/dist/cli/tasks/cli-task.d.ts +3 -0
  118. package/dist/cli/tasks/cli-task.d.ts.map +1 -1
  119. package/dist/cli/tasks/cli-task.js +41 -9
  120. package/dist/cli/tasks/cli-task.js.map +1 -1
  121. package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts +9 -1
  122. package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts.map +1 -1
  123. package/dist/cli/tasks/swc-compile-package/get-swc-options.js +18 -2
  124. package/dist/cli/tasks/swc-compile-package/get-swc-options.js.map +1 -1
  125. package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts +3 -1
  126. package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts.map +1 -1
  127. package/dist/cli/tasks/swc-compile-package/swc-compile-package.js +17 -3
  128. package/dist/cli/tasks/swc-compile-package/swc-compile-package.js.map +1 -1
  129. package/dist/cli/tasks/task.d.ts +2 -1
  130. package/dist/cli/tasks/task.d.ts.map +1 -1
  131. package/dist/cli/tasks/task.js +6 -3
  132. package/dist/cli/tasks/task.js.map +1 -1
  133. package/dist/cli/tasks/tsc-compile/tsc-compile.js +1 -3
  134. package/dist/cli/tasks/tsc-compile/tsc-compile.js.map +1 -1
  135. package/dist/cli/utils/cli-git.d.ts +7 -0
  136. package/dist/cli/utils/cli-git.d.ts.map +1 -1
  137. package/dist/cli/utils/cli-git.js +30 -0
  138. package/dist/cli/utils/cli-git.js.map +1 -1
  139. package/dist/cli/utils/cli-npm.d.ts.map +1 -1
  140. package/dist/cli/utils/cli-npm.js +8 -1
  141. package/dist/cli/utils/cli-npm.js.map +1 -1
  142. package/dist/cli/utils/cli-os.d.ts +7 -1
  143. package/dist/cli/utils/cli-os.d.ts.map +1 -1
  144. package/dist/cli/utils/cli-os.js +42 -0
  145. package/dist/cli/utils/cli-os.js.map +1 -1
  146. package/dist/cli/utils/compile.d.ts.map +1 -1
  147. package/dist/cli/utils/compile.js +7 -4
  148. package/dist/cli/utils/compile.js.map +1 -1
  149. package/dist/cli/utils/copy-files.js +1 -0
  150. package/dist/cli/utils/copy-files.js.map +1 -1
  151. package/dist/cli/utils/index.d.ts +1 -1
  152. package/dist/cli/utils/index.d.ts.map +1 -1
  153. package/dist/cli/utils/index.js +1 -1
  154. package/dist/cli/utils/index.js.map +1 -1
  155. package/dist/cli/utils/process-tree.js +2 -6
  156. package/dist/cli/utils/process-tree.js.map +1 -1
  157. package/dist/cli/utils/resolve-bundler.d.ts.map +1 -1
  158. package/dist/cli/utils/resolve-bundler.js +2 -1
  159. package/dist/cli/utils/resolve-bundler.js.map +1 -1
  160. package/dist/cli/utils/ts-config.d.ts +1 -1
  161. package/dist/cli/utils/ts-config.d.ts.map +1 -1
  162. package/dist/cli/utils/ts-config.js +1 -3
  163. package/dist/cli/utils/ts-config.js.map +1 -1
  164. package/dist/cli/utils/with-exponential-backoff.d.ts +7 -0
  165. package/dist/cli/utils/with-exponential-backoff.d.ts.map +1 -0
  166. package/dist/cli/utils/with-exponential-backoff.js +28 -0
  167. package/dist/cli/utils/with-exponential-backoff.js.map +1 -0
  168. package/dist/core/constants.d.ts +2 -0
  169. package/dist/core/constants.d.ts.map +1 -1
  170. package/dist/core/constants.js +6 -1
  171. package/dist/core/constants.js.map +1 -1
  172. package/dist/postinstall.js +118 -0
  173. package/dist/scripts/generate-bin-wrappers.js +203 -0
  174. package/dist/storybook-config/swc.d.ts +6 -0
  175. package/dist/storybook-config/swc.d.ts.map +1 -1
  176. package/dist/storybook-config/webpack-final.d.ts.map +1 -1
  177. package/dist/storybook-config/webpack-final.js +2 -1
  178. package/dist/storybook-config/webpack-final.js.map +1 -1
  179. package/dist/telemetry/index.d.ts +3 -0
  180. package/dist/telemetry/index.d.ts.map +1 -0
  181. package/dist/telemetry/index.js +21 -0
  182. package/dist/telemetry/index.js.map +1 -0
  183. package/dist/telemetry/telemetry.d.ts +15 -0
  184. package/dist/telemetry/telemetry.d.ts.map +1 -0
  185. package/dist/telemetry/telemetry.js +176 -0
  186. package/dist/telemetry/telemetry.js.map +1 -0
  187. package/dist/utils/exit-when-parent-exits.d.ts +6 -0
  188. package/dist/utils/exit-when-parent-exits.d.ts.map +1 -0
  189. package/dist/utils/exit-when-parent-exits.js +37 -0
  190. package/dist/utils/exit-when-parent-exits.js.map +1 -0
  191. package/dist/utils/find-up.d.ts +1 -1
  192. package/dist/utils/find-up.d.ts.map +1 -1
  193. package/dist/utils/find-up.js +2 -2
  194. package/dist/utils/find-up.js.map +1 -1
  195. package/dist/utils/get-configuration.d.ts +6 -3
  196. package/dist/utils/get-configuration.d.ts.map +1 -1
  197. package/dist/utils/get-configuration.js +10 -2
  198. package/dist/utils/get-configuration.js.map +1 -1
  199. package/dist/utils/index.d.ts +1 -0
  200. package/dist/utils/index.d.ts.map +1 -1
  201. package/dist/utils/index.js +1 -0
  202. package/dist/utils/index.js.map +1 -1
  203. package/dist/utils/log.js +1 -3
  204. package/dist/utils/log.js.map +1 -1
  205. package/dist/vite/build-shared-dependencies.d.ts.map +1 -1
  206. package/dist/vite/build-shared-dependencies.js +2 -0
  207. package/dist/vite/build-shared-dependencies.js.map +1 -1
  208. package/dist/vite/config/base-config.d.ts.map +1 -1
  209. package/dist/vite/config/base-config.js +12 -1
  210. package/dist/vite/config/base-config.js.map +1 -1
  211. package/dist/vite/config/create-filtering-logger.d.ts.map +1 -1
  212. package/dist/vite/config/create-filtering-logger.js +6 -2
  213. package/dist/vite/config/create-filtering-logger.js.map +1 -1
  214. package/dist/vite/config/create-vite-config.js +7 -2
  215. package/dist/vite/config/create-vite-config.js.map +1 -1
  216. package/dist/vite/config/load-config-file.js +8 -19
  217. package/dist/vite/config/load-config-file.js.map +1 -1
  218. package/dist/vite/index.d.ts +2 -0
  219. package/dist/vite/index.d.ts.map +1 -1
  220. package/dist/vite/index.html +2 -2
  221. package/dist/vite/index.js +16 -0
  222. package/dist/vite/index.js.map +1 -1
  223. package/dist/vite/plugins/chain-source-maps-plugin.js +1 -1
  224. package/dist/vite/plugins/chain-source-maps-plugin.js.map +1 -1
  225. package/dist/vite/plugins/clean-plugin.js +1 -1
  226. package/dist/vite/plugins/clean-plugin.js.map +1 -1
  227. package/dist/vite/plugins/css-injector-plugin.js +1 -1
  228. package/dist/vite/plugins/css-injector-plugin.js.map +1 -1
  229. package/dist/vite/plugins/design-system-guard-plugin.d.ts.map +1 -1
  230. package/dist/vite/plugins/design-system-guard-plugin.js +10 -5
  231. package/dist/vite/plugins/design-system-guard-plugin.js.map +1 -1
  232. package/dist/vite/plugins/dev-server-routing-plugin.js +1 -1
  233. package/dist/vite/plugins/dev-server-routing-plugin.js.map +1 -1
  234. package/dist/vite/plugins/externals-plugin.d.ts.map +1 -1
  235. package/dist/vite/plugins/externals-plugin.js +11 -5
  236. package/dist/vite/plugins/externals-plugin.js.map +1 -1
  237. package/dist/vite/plugins/html-plugin.d.ts.map +1 -1
  238. package/dist/vite/plugins/html-plugin.js +5 -3
  239. package/dist/vite/plugins/html-plugin.js.map +1 -1
  240. package/dist/vite/plugins/ignore-modules-plugin.d.ts +2 -2
  241. package/dist/vite/plugins/ignore-modules-plugin.d.ts.map +1 -1
  242. package/dist/vite/plugins/ignore-modules-plugin.js +36 -24
  243. package/dist/vite/plugins/ignore-modules-plugin.js.map +1 -1
  244. package/dist/vite/plugins/index.d.ts +3 -0
  245. package/dist/vite/plugins/index.d.ts.map +1 -1
  246. package/dist/vite/plugins/index.js +3 -0
  247. package/dist/vite/plugins/index.js.map +1 -1
  248. package/dist/vite/plugins/less-tilde-plugin.d.ts +8 -0
  249. package/dist/vite/plugins/less-tilde-plugin.d.ts.map +1 -0
  250. package/dist/vite/plugins/less-tilde-plugin.js +53 -0
  251. package/dist/vite/plugins/less-tilde-plugin.js.map +1 -0
  252. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js +1 -1
  253. package/dist/vite/plugins/magic-comments-plugin/magic-comments-plugin.js.map +1 -1
  254. package/dist/vite/plugins/metadata-plugin.js +1 -1
  255. package/dist/vite/plugins/metadata-plugin.js.map +1 -1
  256. package/dist/vite/plugins/moment-locales-plugin.d.ts +1 -1
  257. package/dist/vite/plugins/moment-locales-plugin.d.ts.map +1 -1
  258. package/dist/vite/plugins/moment-locales-plugin.js +30 -14
  259. package/dist/vite/plugins/moment-locales-plugin.js.map +1 -1
  260. package/dist/vite/plugins/react-refresh-plugin/index.d.ts +2 -0
  261. package/dist/vite/plugins/react-refresh-plugin/index.d.ts.map +1 -0
  262. package/dist/vite/plugins/react-refresh-plugin/index.js +20 -0
  263. package/dist/vite/plugins/react-refresh-plugin/index.js.map +1 -0
  264. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts +4 -0
  265. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.d.ts.map +1 -0
  266. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js +143 -0
  267. package/dist/vite/plugins/react-refresh-plugin/react-refresh-plugin.js.map +1 -0
  268. package/dist/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
  269. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.d.ts.map +1 -1
  270. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js +14 -11
  271. package/dist/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.js.map +1 -1
  272. package/dist/vite/plugins/style-urls-plugin.js +1 -1
  273. package/dist/vite/plugins/style-urls-plugin.js.map +1 -1
  274. package/dist/vite/plugins/virtual-modules-plugin.d.ts.map +1 -1
  275. package/dist/vite/plugins/virtual-modules-plugin.js +9 -6
  276. package/dist/vite/plugins/virtual-modules-plugin.js.map +1 -1
  277. package/dist/vite/plugins/window-externals-plugin.d.ts +22 -0
  278. package/dist/vite/plugins/window-externals-plugin.d.ts.map +1 -0
  279. package/dist/vite/plugins/window-externals-plugin.js +74 -0
  280. package/dist/vite/plugins/window-externals-plugin.js.map +1 -0
  281. package/dist/webpack/bundle-webpack.d.ts.map +1 -1
  282. package/dist/webpack/bundle-webpack.js +6 -1
  283. package/dist/webpack/bundle-webpack.js.map +1 -1
  284. package/dist/webpack/configs/optimization-config.js +17 -12
  285. package/dist/webpack/configs/optimization-config.js.map +1 -1
  286. package/dist/webpack/configs/output-config.js +1 -1
  287. package/dist/webpack/configs/output-config.js.map +1 -1
  288. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js +1 -3
  289. package/dist/webpack/configs/plugins/ignore-plugin/ignore-plugin.js.map +1 -1
  290. package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/configuration.expose-loader.js +13 -0
  291. package/dist/webpack/loaders/expose-loader/__tests__/__mocks__/index.js +1 -0
  292. package/dist/webpack/utils/index.d.ts +1 -0
  293. package/dist/webpack/utils/index.d.ts.map +1 -1
  294. package/dist/webpack/utils/index.js +1 -0
  295. package/dist/webpack/utils/index.js.map +1 -1
  296. package/dist/webpack/utils/normalize-proxy-config.d.ts +6 -0
  297. package/dist/webpack/utils/normalize-proxy-config.d.ts.map +1 -0
  298. package/dist/webpack/utils/normalize-proxy-config.js +52 -0
  299. package/dist/webpack/utils/normalize-proxy-config.js.map +1 -0
  300. package/package.json +32 -26
  301. package/src/cli/commands/__tests__/build.test.ts +81 -20
  302. package/src/cli/commands/__tests__/bundle-package.test.ts +65 -0
  303. package/src/cli/commands/__tests__/command.test.ts +154 -0
  304. package/src/cli/commands/__tests__/init.test.ts +1 -1
  305. package/src/cli/commands/__tests__/install.test.ts +5 -72
  306. package/src/cli/commands/__tests__/mfe-check.test.ts +26 -5
  307. package/src/cli/commands/__tests__/run-task.test.ts +20 -1
  308. package/src/cli/commands/__tests__/start.test.ts +77 -16
  309. package/src/cli/commands/build.ts +15 -6
  310. package/src/cli/commands/bundle-package.ts +20 -0
  311. package/src/cli/commands/command.ts +64 -0
  312. package/src/cli/commands/init.ts +0 -1
  313. package/src/cli/commands/install.ts +5 -21
  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/install.ts +1 -6
  319. package/src/cli/commands/registry/start.ts +3 -2
  320. package/src/cli/commands/run-task.ts +8 -2
  321. package/src/cli/commands/start.ts +17 -6
  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-git.test.ts +54 -3
  335. package/src/cli/utils/__tests__/cli-npm.test.ts +33 -0
  336. package/src/cli/utils/__tests__/cli-os.test.ts +183 -4
  337. package/src/cli/utils/__tests__/compile.test.ts +37 -2
  338. package/src/cli/utils/__tests__/copy-files.test.ts +1 -1
  339. package/src/cli/utils/__tests__/with-exponential-backoff.test.ts +119 -0
  340. package/src/cli/utils/cli-git.ts +27 -1
  341. package/src/cli/utils/cli-npm.ts +19 -4
  342. package/src/cli/utils/cli-os.ts +44 -0
  343. package/src/cli/utils/compile.ts +8 -1
  344. package/src/cli/utils/copy-files.ts +1 -1
  345. package/src/cli/utils/index.ts +1 -1
  346. package/src/cli/utils/resolve-bundler.ts +2 -1
  347. package/src/cli/utils/ts-config.ts +1 -1
  348. package/src/cli/utils/with-exponential-backoff.ts +28 -0
  349. package/src/core/constants.ts +2 -0
  350. package/src/storybook-config/__tests__/vite-final.test.ts +6 -0
  351. package/src/storybook-config/__tests__/webpack-final.test.ts +26 -12
  352. package/src/storybook-config/webpack-final.ts +10 -4
  353. package/src/telemetry/__tests__/telemetry.test.ts +326 -0
  354. package/src/telemetry/index.ts +2 -0
  355. package/src/telemetry/telemetry.ts +134 -0
  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 +12 -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 +3 -2
  368. package/src/vite/config/__tests__/create-vite-config.test.ts +6 -3
  369. package/src/vite/config/base-config.ts +13 -1
  370. package/src/vite/config/create-filtering-logger.ts +8 -2
  371. package/src/vite/config/create-vite-config.ts +6 -3
  372. package/src/vite/index.html +2 -2
  373. package/src/vite/index.ts +2 -0
  374. package/src/vite/plugins/__tests__/chain-source-maps-plugin.test.ts +1 -1
  375. package/src/vite/plugins/__tests__/clean-plugin.test.ts +1 -1
  376. package/src/vite/plugins/__tests__/css-injector-plugin.test.ts +1 -1
  377. package/src/vite/plugins/__tests__/design-system-guard-plugin.test.ts +15 -3
  378. package/src/vite/plugins/__tests__/dev-server-routing-plugin.test.ts +1 -1
  379. package/src/vite/plugins/__tests__/externals-plugin.test.ts +24 -3
  380. package/src/vite/plugins/__tests__/html-plugin.test.ts +10 -3
  381. package/src/vite/plugins/__tests__/html-template.test.ts +10 -2
  382. package/src/vite/plugins/__tests__/ignore-modules-plugin.test.ts +30 -6
  383. package/src/vite/plugins/__tests__/less-tilde-plugin.test.ts +91 -0
  384. package/src/vite/plugins/__tests__/metadata-plugin.test.ts +1 -1
  385. package/src/vite/plugins/__tests__/moment-locales-plugin.test.ts +35 -25
  386. package/src/vite/plugins/__tests__/style-urls-plugin.test.ts +1 -1
  387. package/src/vite/plugins/__tests__/virtual-modules-plugin.test.ts +20 -9
  388. package/src/vite/plugins/__tests__/window-externals-plugin.test.ts +128 -0
  389. package/src/vite/plugins/chain-source-maps-plugin.ts +1 -1
  390. package/src/vite/plugins/clean-plugin.ts +1 -1
  391. package/src/vite/plugins/css-injector-plugin.ts +1 -1
  392. package/src/vite/plugins/design-system-guard-plugin.ts +11 -8
  393. package/src/vite/plugins/dev-server-routing-plugin.ts +1 -1
  394. package/src/vite/plugins/externals-plugin.ts +15 -6
  395. package/src/vite/plugins/html-plugin.ts +4 -2
  396. package/src/vite/plugins/ignore-modules-plugin.ts +32 -23
  397. package/src/vite/plugins/index.ts +3 -0
  398. package/src/vite/plugins/less-tilde-plugin.ts +64 -0
  399. package/src/vite/plugins/magic-comments-plugin/magic-comments-plugin.ts +1 -1
  400. package/src/vite/plugins/metadata-plugin.ts +1 -1
  401. package/src/vite/plugins/moment-locales-plugin.ts +24 -14
  402. package/src/vite/plugins/react-refresh-plugin/README.md +165 -0
  403. package/src/vite/plugins/react-refresh-plugin/__tests__/react-refresh-plugin.test.ts +366 -0
  404. package/src/vite/plugins/react-refresh-plugin/__tests__/refresh-runtime.test.ts +193 -0
  405. package/src/vite/plugins/react-refresh-plugin/index.ts +1 -0
  406. package/src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts +144 -0
  407. package/src/vite/plugins/react-refresh-plugin/refresh-runtime.js +113 -0
  408. package/src/vite/plugins/shared-dependencies-plugin/__tests__/shared-dependencies-plugin.test.ts +21 -16
  409. package/src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts +13 -12
  410. package/src/vite/plugins/style-urls-plugin.ts +1 -1
  411. package/src/vite/plugins/virtual-modules-plugin.ts +8 -7
  412. package/src/vite/plugins/window-externals-plugin.ts +94 -0
  413. package/src/webpack/__tests__/bundle-webpack.test.ts +32 -0
  414. package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +27 -1
  415. package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +17 -5
  416. package/src/webpack/__tests__/create-webpack-config.test.ts +10 -6
  417. package/src/webpack/bundle-webpack.ts +7 -1
  418. package/src/webpack/configs/optimization-config.ts +22 -11
  419. package/src/webpack/configs/output-config.ts +1 -1
  420. package/src/webpack/utils/__tests__/normalize-proxy-config.test.ts +121 -0
  421. package/src/webpack/utils/index.ts +1 -0
  422. package/src/webpack/utils/normalize-proxy-config.ts +59 -0
  423. package/tsconfig/types.d.ts +10 -0
  424. package/dist/cli/utils/get-bundle-command.d.ts +0 -3
  425. package/dist/cli/utils/get-bundle-command.d.ts.map +0 -1
  426. package/dist/cli/utils/get-bundle-command.js +0 -16
  427. package/dist/cli/utils/get-bundle-command.js.map +0 -1
  428. package/src/cli/utils/__tests__/get-bundle-command.test.ts +0 -23
  429. package/src/cli/utils/get-bundle-command.ts +0 -5
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "reactRefreshPlugin", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return reactRefreshPlugin;
9
+ }
10
+ });
11
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
+ const _magicstring = /*#__PURE__*/ _interop_require_default(require("magic-string"));
13
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
14
+ const _utils = require("../../../utils");
15
+ function _interop_require_default(obj) {
16
+ return obj && obj.__esModule ? obj : {
17
+ default: obj
18
+ };
19
+ }
20
+ const RUNTIME_ID = '/@react-refresh';
21
+ const RUNTIME_HELPERS_PATH = _path.default.join(__dirname, 'refresh-runtime.js');
22
+ /* Triggers injectIntoGlobalHook (via the virtual module's side effect) before app code executes. */ const preamble = `import "${RUNTIME_ID}";`;
23
+ /*
24
+ * Per-module locals satisfy swc's $RefreshReg$/$RefreshSig$ calls without relying on
25
+ * window globals. Scoping the registration id to the served module URL ensures host and
26
+ * MFE servers sharing one runtime singleton cannot produce colliding refresh families.
27
+ */ const modulePrelude = `import RefreshRuntime from "${RUNTIME_ID}";
28
+ const __react_refresh_id__ = import.meta.url.replace(/[?#].*$/, "");
29
+ var $RefreshReg$ = (type, id) => RefreshRuntime.register(type, __react_refresh_id__ + " " + id);
30
+ var $RefreshSig$ = () => RefreshRuntime.createSignatureFunctionForTransform();\n`;
31
+ /* Makes refreshable modules self-accepting and runs React Fast Refresh after safe updates. */ const postlude = `
32
+ import {
33
+ __hmr_import,
34
+ registerExportsForReactRefresh,
35
+ validateRefreshBoundaryAndEnqueueUpdate,
36
+ } from "${RUNTIME_ID}";
37
+ if (import.meta.hot) {
38
+ __hmr_import(__react_refresh_id__).then(currentExports => {
39
+ registerExportsForReactRefresh(__react_refresh_id__, currentExports);
40
+ import.meta.hot.accept(nextExports => {
41
+ if (!nextExports) {
42
+ return;
43
+ }
44
+
45
+ const invalidateMessage = validateRefreshBoundaryAndEnqueueUpdate(
46
+ __react_refresh_id__,
47
+ currentExports,
48
+ nextExports
49
+ );
50
+
51
+ if (invalidateMessage) {
52
+ import.meta.hot.invalidate(invalidateMessage);
53
+ }
54
+ });
55
+ });
56
+ }`;
57
+ function transformWithSourceMap(source, id) {
58
+ return {
59
+ code: source.toString(),
60
+ map: source.generateMap({
61
+ hires: true,
62
+ source: id
63
+ })
64
+ };
65
+ }
66
+ function normalizeSlashes(filePath) {
67
+ return filePath.replaceAll('\\', '/');
68
+ }
69
+ function getRefreshRuntimeCode() {
70
+ return `\
71
+ import _RefreshRuntime from "react-refresh/runtime";
72
+ const RefreshRuntime = window.__ReactRefreshRuntime || _RefreshRuntime;
73
+ if (!window.__ReactRefreshRuntime) {
74
+ _RefreshRuntime.injectIntoGlobalHook(window);
75
+ }
76
+ window.__ReactRefreshRuntime = RefreshRuntime;
77
+ ${_fs.default.readFileSync(RUNTIME_HELPERS_PATH, 'utf8')}
78
+ export default RefreshRuntime;`;
79
+ }
80
+ function reactRefreshPlugin(context) {
81
+ if (context.build.isProduction) {
82
+ return;
83
+ }
84
+ const refreshableModuleDirs = (0, _utils.findPackages)().map(({ location })=>normalizeSlashes(location) + '/');
85
+ return {
86
+ name: 'react-refresh',
87
+ enforce: 'pre',
88
+ /* Serve react-refresh/runtime as an ESM virtual module. */ resolveId (source) {
89
+ if (source === RUNTIME_ID) {
90
+ return {
91
+ id: RUNTIME_ID,
92
+ moduleSideEffects: true
93
+ };
94
+ }
95
+ },
96
+ load (id) {
97
+ if (id === RUNTIME_ID) {
98
+ return {
99
+ code: getRefreshRuntimeCode()
100
+ };
101
+ }
102
+ },
103
+ /* Inject the preamble before React and app code load. */ transformIndexHtml () {
104
+ return [
105
+ {
106
+ tag: 'script',
107
+ attrs: {
108
+ type: 'module'
109
+ },
110
+ children: preamble,
111
+ injectTo: 'head-prepend'
112
+ }
113
+ ];
114
+ },
115
+ /* Handle modules compiled with swc refresh markers. */ transform: {
116
+ filter: {
117
+ code: /\$RefreshReg\$|\$RefreshSig\$/
118
+ },
119
+ handler (code, id) {
120
+ const normalizedId = normalizeSlashes(id);
121
+ const isRefreshableModule = refreshableModuleDirs.some((dir)=>normalizedId.startsWith(dir));
122
+ /* Prevent non-workspace libraries from registering duplicate refresh families. */ if (!isRefreshableModule) {
123
+ const source = new _magicstring.default(code);
124
+ const noopPreamble = 'var $RefreshReg$ = () => {};\nvar $RefreshSig$ = () => (t) => t;\n';
125
+ source.prepend(noopPreamble);
126
+ return transformWithSourceMap(source, id);
127
+ }
128
+ /*
129
+ * Workspace modules always get per-module refresh locals. This satisfies
130
+ * $RefreshSig$ calls in HOC-wrapped modules without relying on window globals.
131
+ * Modules with registered component families additionally get an HMR postlude.
132
+ */ const source = new _magicstring.default(code);
133
+ source.prepend(modulePrelude);
134
+ if (code.includes('$RefreshReg$')) {
135
+ source.append(postlude);
136
+ }
137
+ return transformWithSourceMap(source, id);
138
+ }
139
+ }
140
+ };
141
+ }
142
+
143
+ //# sourceMappingURL=react-refresh-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/vite/plugins/react-refresh-plugin/react-refresh-plugin.ts"],"sourcesContent":["import fs from 'fs';\nimport MagicString from 'magic-string';\nimport path from 'path';\nimport type { Plugin } from 'vite';\nimport type { BuildContext } from '../../../core';\nimport { findPackages } from '../../../utils';\n\nconst RUNTIME_ID = '/@react-refresh';\nconst RUNTIME_HELPERS_PATH = path.join(__dirname, 'refresh-runtime.js');\n\n/* Triggers injectIntoGlobalHook (via the virtual module's side effect) before app code executes. */\nconst preamble = `import \"${RUNTIME_ID}\";`;\n\n/*\n * Per-module locals satisfy swc's $RefreshReg$/$RefreshSig$ calls without relying on\n * window globals. Scoping the registration id to the served module URL ensures host and\n * MFE servers sharing one runtime singleton cannot produce colliding refresh families.\n */\nconst modulePrelude = `import RefreshRuntime from \"${RUNTIME_ID}\";\nconst __react_refresh_id__ = import.meta.url.replace(/[?#].*$/, \"\");\nvar $RefreshReg$ = (type, id) => RefreshRuntime.register(type, __react_refresh_id__ + \" \" + id);\nvar $RefreshSig$ = () => RefreshRuntime.createSignatureFunctionForTransform();\\n`;\n\n/* Makes refreshable modules self-accepting and runs React Fast Refresh after safe updates. */\nconst postlude = `\nimport {\n __hmr_import,\n registerExportsForReactRefresh,\n validateRefreshBoundaryAndEnqueueUpdate,\n} from \"${RUNTIME_ID}\";\nif (import.meta.hot) {\n __hmr_import(__react_refresh_id__).then(currentExports => {\n registerExportsForReactRefresh(__react_refresh_id__, currentExports);\n import.meta.hot.accept(nextExports => {\n if (!nextExports) {\n return;\n }\n\n const invalidateMessage = validateRefreshBoundaryAndEnqueueUpdate(\n __react_refresh_id__,\n currentExports,\n nextExports\n );\n\n if (invalidateMessage) {\n import.meta.hot.invalidate(invalidateMessage);\n }\n });\n });\n}`;\n\nfunction transformWithSourceMap(source: MagicString, id: string) {\n return {\n code: source.toString(),\n map: source.generateMap({ hires: true, source: id }),\n };\n}\n\nfunction normalizeSlashes(filePath: string) {\n return filePath.replaceAll('\\\\', '/');\n}\n\nfunction getRefreshRuntimeCode() {\n return `\\\nimport _RefreshRuntime from \"react-refresh/runtime\";\nconst RefreshRuntime = window.__ReactRefreshRuntime || _RefreshRuntime;\nif (!window.__ReactRefreshRuntime) {\n _RefreshRuntime.injectIntoGlobalHook(window);\n}\nwindow.__ReactRefreshRuntime = RefreshRuntime;\n${fs.readFileSync(RUNTIME_HELPERS_PATH, 'utf8')}\nexport default RefreshRuntime;`;\n}\n\n/* Bridges swc's refresh markers to Vite HMR and the React Fast Refresh runtime. */\nexport function reactRefreshPlugin(context: BuildContext): Plugin | undefined {\n if (context.build.isProduction) {\n return;\n }\n\n const refreshableModuleDirs = findPackages().map(\n ({ location }) => normalizeSlashes(location) + '/'\n );\n\n return {\n name: 'react-refresh',\n enforce: 'pre',\n /* Serve react-refresh/runtime as an ESM virtual module. */\n resolveId(source) {\n if (source === RUNTIME_ID) {\n return { id: RUNTIME_ID, moduleSideEffects: true };\n }\n },\n load(id) {\n if (id === RUNTIME_ID) {\n return { code: getRefreshRuntimeCode() };\n }\n },\n /* Inject the preamble before React and app code load. */\n transformIndexHtml() {\n return [\n {\n tag: 'script',\n attrs: { type: 'module' },\n children: preamble,\n injectTo: 'head-prepend',\n },\n ];\n },\n /* Handle modules compiled with swc refresh markers. */\n transform: {\n filter: { code: /\\$RefreshReg\\$|\\$RefreshSig\\$/ },\n handler(code, id) {\n const normalizedId = normalizeSlashes(id);\n const isRefreshableModule = refreshableModuleDirs.some(dir =>\n normalizedId.startsWith(dir)\n );\n\n /* Prevent non-workspace libraries from registering duplicate refresh families. */\n if (!isRefreshableModule) {\n const source = new MagicString(code);\n const noopPreamble =\n 'var $RefreshReg$ = () => {};\\nvar $RefreshSig$ = () => (t) => t;\\n';\n source.prepend(noopPreamble);\n return transformWithSourceMap(source, id);\n }\n\n /*\n * Workspace modules always get per-module refresh locals. This satisfies\n * $RefreshSig$ calls in HOC-wrapped modules without relying on window globals.\n * Modules with registered component families additionally get an HMR postlude.\n */\n const source = new MagicString(code);\n source.prepend(modulePrelude);\n\n if (code.includes('$RefreshReg$')) {\n source.append(postlude);\n }\n\n return transformWithSourceMap(source, id);\n },\n },\n };\n}\n"],"names":["reactRefreshPlugin","RUNTIME_ID","RUNTIME_HELPERS_PATH","path","join","__dirname","preamble","modulePrelude","postlude","transformWithSourceMap","source","id","code","toString","map","generateMap","hires","normalizeSlashes","filePath","replaceAll","getRefreshRuntimeCode","fs","readFileSync","context","build","isProduction","refreshableModuleDirs","findPackages","location","name","enforce","resolveId","moduleSideEffects","load","transformIndexHtml","tag","attrs","type","children","injectTo","transform","filter","handler","normalizedId","isRefreshableModule","some","dir","startsWith","MagicString","noopPreamble","prepend","includes","append"],"mappings":";;;;+BA2EgBA;;;eAAAA;;;2DA3ED;oEACS;6DACP;uBAGY;;;;;;AAE7B,MAAMC,aAAa;AACnB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;aACH;QACL;QACA,qDAAqD,GACrDC,WAAW;YACPC,QAAQ;gBAAE7B,MAAM;YAAgC;YAChD8B,SAAQ9B,IAAI,EAAED,EAAE;gBACZ,MAAMgC,eAAe1B,iBAAiBN;gBACtC,MAAMiC,sBAAsBlB,sBAAsBmB,IAAI,CAACC,CAAAA,MACnDH,aAAaI,UAAU,CAACD;gBAG5B,gFAAgF,GAChF,IAAI,CAACF,qBAAqB;oBACtB,MAAMlC,SAAS,IAAIsC,oBAAW,CAACpC;oBAC/B,MAAMqC,eACF;oBACJvC,OAAOwC,OAAO,CAACD;oBACf,OAAOxC,uBAAuBC,QAAQC;gBAC1C;gBAEA;;;;iBAIC,GACD,MAAMD,SAAS,IAAIsC,oBAAW,CAACpC;gBAC/BF,OAAOwC,OAAO,CAAC3C;gBAEf,IAAIK,KAAKuC,QAAQ,CAAC,iBAAiB;oBAC/BzC,OAAO0C,MAAM,CAAC5C;gBAClB;gBAEA,OAAOC,uBAAuBC,QAAQC;YAC1C;QACJ;IACJ;AACJ"}
@@ -0,0 +1,113 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ /*
26
+ * Adapted from https://github.com/vitejs/vite-plugin-react/blob/84693214ef8cccc3357561fe4654f401a30dab62/packages/common/refresh-runtime.js.
27
+ * Keep this local because the helpers are bundled into that plugin's virtual
28
+ * runtime and are not exposed as stable public package exports.
29
+ *
30
+ * This file is served inside the browser-only /@react-refresh virtual module.
31
+ * It relies on that module storing the runtime on window.__ReactRefreshRuntime.
32
+ */
33
+ const refreshCallbacks = [];
34
+
35
+ function getRefreshRuntime() {
36
+ return window.__ReactRefreshRuntime;
37
+ }
38
+
39
+ // Hook for integrations to finish async work before the debounced refresh flush.
40
+ window.__registerBeforePerformReactRefresh = callback => {
41
+ refreshCallbacks.push(callback);
42
+ };
43
+
44
+ function debounce(fn, delay) {
45
+ let handle;
46
+ return () => {
47
+ clearTimeout(handle);
48
+ handle = setTimeout(fn, delay);
49
+ };
50
+ }
51
+
52
+ const enqueueUpdate = debounce(async () => {
53
+ if (refreshCallbacks.length) {
54
+ await Promise.all(refreshCallbacks.map(callback => callback()));
55
+ }
56
+ getRefreshRuntime().performReactRefresh();
57
+ }, 16);
58
+
59
+ function predicateOnExport(moduleExports, predicate) {
60
+ for (const key in moduleExports) {
61
+ if (key === '__esModule') {
62
+ continue;
63
+ }
64
+ const descriptor = Object.getOwnPropertyDescriptor(moduleExports, key);
65
+ if (descriptor?.get) {
66
+ return key;
67
+ }
68
+ if (!predicate(key, moduleExports[key])) {
69
+ return key;
70
+ }
71
+ }
72
+ return true;
73
+ }
74
+
75
+ export function registerExportsForReactRefresh(id, moduleExports) {
76
+ for (const key in moduleExports) {
77
+ if (key === '__esModule') {
78
+ continue;
79
+ }
80
+ const exportValue = moduleExports[key];
81
+ if (getRefreshRuntime().isLikelyComponentType(exportValue)) {
82
+ getRefreshRuntime().register(exportValue, `${id} export ${key}`);
83
+ }
84
+ }
85
+ }
86
+
87
+ export function validateRefreshBoundaryAndEnqueueUpdate(id, prevExports, nextExports) {
88
+ if (predicateOnExport(prevExports, key => key in nextExports) !== true) {
89
+ return 'Could not Fast Refresh (export removed)';
90
+ }
91
+ if (predicateOnExport(nextExports, key => key in prevExports) !== true) {
92
+ return 'Could not Fast Refresh (new export)';
93
+ }
94
+
95
+ let hasExports = false;
96
+ const allExportsAreComponentsOrUnchanged = predicateOnExport(nextExports, (key, value) => {
97
+ hasExports = true;
98
+ if (getRefreshRuntime().isLikelyComponentType(value)) {
99
+ return true;
100
+ }
101
+ return prevExports[key] === nextExports[key];
102
+ });
103
+
104
+ if (hasExports && allExportsAreComponentsOrUnchanged === true) {
105
+ enqueueUpdate();
106
+ } else {
107
+ return `Could not Fast Refresh ("${allExportsAreComponentsOrUnchanged}" export is incompatible).`;
108
+ }
109
+ }
110
+
111
+ export function __hmr_import(module) {
112
+ return import(/* @vite-ignore */ module);
113
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"shared-dependencies-plugin.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAM9B,MAAM,WAAW,+BAA+B;IAC5C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAKD,wBAAgB,wBAAwB,CAAC,EACrC,YAAY,EACZ,GAAG,EACH,WAAW,GACd,EAAE,+BAA+B,GAAG,MAAM,CAgK1C"}
1
+ {"version":3,"file":"shared-dependencies-plugin.d.ts","sourceRoot":"","sources":["../../../../src/vite/plugins/shared-dependencies-plugin/shared-dependencies-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAM9B,MAAM,WAAW,+BAA+B;IAC5C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAKD,wBAAgB,wBAAwB,CAAC,EACrC,YAAY,EACZ,GAAG,EACH,WAAW,GACd,EAAE,+BAA+B,GAAG,MAAM,CAiK1C"}
@@ -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":";;;;+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;IAE3B,MAAMC,kBAAkBC,OAAOC,IAAI,CAACN;IACpC,MAAMO,gBAAgB,IAAIC,IAAIJ;IAC9B,MAAMK,aAAaR,gBAAAA,iBAAAA,MAAO,CAAC;IAC3B,MAAMS,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,GAAGT,qBAAqBS;YACvC;YAEA,OAAO;gBACH,sFAAsF;gBACtFW,MAAM;gBACN,4FAA4F;gBAC5FC,QAAQ;oBACJ,wBAAwBC,KAAKC,SAAS,CAACV,IAAIC,IAAI;gBACnD;gBACAU,OAAO;oBACHC,iBAAiB;wBACb,wEAAwE;wBACxEC,yBAAyB;wBACzBT;wBACAU,QAAQ;4BACJ;;;6BAGC,GACDC,QAAQ;4BACRC,SAAS;4BACTC,gBAAgB,CAAC,MAAM,EAAElC,mBAAmB;4BAC5CmC,gBAAgB;4BAChBC,gBAAgBC,CAAAA;0CAEAC;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NH,UAAUgB;gBACVnC,QAAQyB;YACZ;YAEA,MAAMY,WAAWC,IAAAA,mBAAa,EAC1B9E,OAAOC,IAAI,CAACsD,QAAQwB,MAAM,CAACC,CAAAA,IAAKA,EAAEC,QAAQ,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,sFA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AAOoD,MAAM,CAAC,GAAGlD,OAAOf,mBAAmB,CAAC;YAChD;YAEA,MAAM2E,OAAOI,IAAAA,0BAAY,EAACZ,SAASC;YACnC,MAAMY,OAAOC,eAAM,CAACC,UAAU,CAAC,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,C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CAACN,GAAG,CAACgB,CAAAA,OAAQ,CAAC,aAAa,EAAEA,KAAK,MAAM,EAAEA,KAAK,CAAC,CAAC;iBACtE,CAACW,IAAI,CAAC;YACX;QACJ;IACJ;AACJ"}
@@ -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) {