adnbn 0.11.0 → 0.13.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 (378) hide show
  1. package/README.md +3 -0
  2. package/dist/cli/builders/manifest/ManifestBase.js +1 -1
  3. package/dist/cli/bundler/index.d.ts +1 -0
  4. package/dist/cli/bundler/index.js +1 -0
  5. package/dist/cli/bundler/index.js.map +1 -1
  6. package/dist/cli/bundler/layers.d.ts +5 -0
  7. package/dist/cli/bundler/layers.js +11 -0
  8. package/dist/cli/bundler/layers.js.map +1 -0
  9. package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js +44 -15
  10. package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js.map +1 -1
  11. package/dist/cli/bundler/plugins/build-assets-map/index.d.ts +1 -2
  12. package/dist/cli/bundler/plugins/build-assets-map/index.js +0 -3
  13. package/dist/cli/bundler/plugins/build-assets-map/index.js.map +1 -1
  14. package/dist/cli/bundler/plugins/build-assets-map/normalize.d.ts +3 -0
  15. package/dist/cli/bundler/plugins/build-assets-map/normalize.js +24 -0
  16. package/dist/cli/bundler/plugins/build-assets-map/normalize.js.map +1 -0
  17. package/dist/cli/bundler/plugins/build-assets-map/templates/runtime.template.d.ts +2 -0
  18. package/dist/cli/bundler/plugins/build-assets-map/templates.d.ts +9 -0
  19. package/dist/cli/bundler/plugins/build-assets-map/templates.js +32 -0
  20. package/dist/cli/bundler/plugins/build-assets-map/usage.d.ts +3 -6
  21. package/dist/cli/bundler/plugins/build-assets-map/usage.js +6 -3
  22. package/dist/cli/bundler/plugins/build-assets-map/usage.js.map +1 -1
  23. package/dist/cli/bundler/plugins/entrypoint/EntrypointPlugin.js +11 -0
  24. package/dist/cli/bundler/plugins/entrypoint/EntrypointPlugin.js.map +1 -1
  25. package/dist/cli/bundler/plugins/index.d.ts +2 -2
  26. package/dist/cli/bundler/plugins/index.js +2 -6
  27. package/dist/cli/bundler/plugins/index.js.map +1 -1
  28. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.d.ts +1 -1
  29. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js +38 -13
  30. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js.map +1 -1
  31. package/dist/cli/bundler/plugins/isolated-styles/chunks.d.ts +7 -0
  32. package/dist/cli/bundler/plugins/isolated-styles/chunks.js +33 -0
  33. package/dist/cli/bundler/plugins/isolated-styles/chunks.js.map +1 -0
  34. package/dist/cli/bundler/plugins/isolated-styles/split-chunks.d.ts +4 -0
  35. package/dist/cli/bundler/plugins/isolated-styles/split-chunks.js +51 -0
  36. package/dist/cli/bundler/plugins/isolated-styles/split-chunks.js.map +1 -0
  37. package/dist/cli/bundler/plugins/isolated-styles/templates.js +36 -6
  38. package/dist/cli/bundler/plugins/manifest/ManifestPlugin.js +1 -2
  39. package/dist/cli/bundler/plugins/manifest/ManifestPlugin.js.map +1 -1
  40. package/dist/cli/bundler/plugins/types.d.ts +4 -0
  41. package/dist/cli/bundler/plugins/utils/compilation-assets.d.ts +4 -0
  42. package/dist/cli/bundler/plugins/utils/compilation-assets.js +12 -0
  43. package/dist/cli/bundler/plugins/utils/compilation-assets.js.map +1 -0
  44. package/dist/cli/bundler/plugins/utils/index.d.ts +2 -0
  45. package/dist/cli/bundler/plugins/utils/index.js +5 -0
  46. package/dist/cli/bundler/plugins/utils/index.js.map +1 -1
  47. package/dist/cli/bundler/plugins/utils/runtime-module.d.ts +3 -0
  48. package/dist/cli/bundler/plugins/utils/runtime-module.js +11 -0
  49. package/dist/cli/bundler/plugins/utils/runtime-module.js.map +1 -0
  50. package/dist/cli/bundler/utils/app-filename.d.ts +2 -0
  51. package/dist/cli/bundler/utils/app-filename.js +19 -0
  52. package/dist/cli/bundler/utils/app-filename.js.map +1 -0
  53. package/dist/cli/bundler/utils/assets.d.ts +3 -0
  54. package/dist/cli/bundler/utils/{output.js → assets.js} +22 -33
  55. package/dist/cli/bundler/utils/assets.js.map +1 -0
  56. package/dist/cli/bundler/utils/index.d.ts +2 -3
  57. package/dist/cli/bundler/utils/index.js +2 -3
  58. package/dist/cli/bundler/utils/index.js.map +1 -1
  59. package/dist/cli/entrypoint/file/injectors/core.js +1 -1
  60. package/dist/cli/entrypoint/finder/ContentFinder.d.ts +1 -1
  61. package/dist/cli/entrypoint/parser/ContentParser.d.ts +2 -2
  62. package/dist/cli/entrypoint/parser/ContentParser.js +6 -22
  63. package/dist/cli/entrypoint/parser/ContentParser.js.map +1 -1
  64. package/dist/cli/entrypoint/parser/RelayParser.js +1 -1
  65. package/dist/cli/entrypoint/parser/utils/content/default-render.d.ts +3 -0
  66. package/dist/cli/entrypoint/parser/utils/content/default-render.js +21 -0
  67. package/dist/cli/entrypoint/parser/utils/content/default-render.js.map +1 -0
  68. package/dist/cli/plugins/content/Content.d.ts +1 -1
  69. package/dist/cli/plugins/content/ContentDriver.d.ts +1 -1
  70. package/dist/cli/plugins/content/ContentManager.d.ts +1 -1
  71. package/dist/cli/plugins/content/ContentManager.js +1 -1
  72. package/dist/cli/plugins/content/ContentName.d.ts +1 -1
  73. package/dist/cli/plugins/content/ContentName.js +1 -1
  74. package/dist/cli/plugins/content/Relay.d.ts +1 -1
  75. package/dist/cli/plugins/content/RelayDriver.d.ts +1 -1
  76. package/dist/cli/plugins/content/RelayDriver.js +1 -1
  77. package/dist/cli/plugins/content/bundler.d.ts +1 -4
  78. package/dist/cli/plugins/content/bundler.js +5 -21
  79. package/dist/cli/plugins/content/bundler.js.map +1 -1
  80. package/dist/cli/plugins/content/index.js +4 -5
  81. package/dist/cli/plugins/content/index.js.map +1 -1
  82. package/dist/cli/plugins/content/types.d.ts +1 -1
  83. package/dist/cli/plugins/content/utils.d.ts +1 -1
  84. package/dist/cli/plugins/content/utils.js +1 -1
  85. package/dist/cli/plugins/index.d.ts +1 -1
  86. package/dist/cli/plugins/index.js +1 -1
  87. package/dist/cli/plugins/locale/Locale.js +5 -2
  88. package/dist/cli/plugins/locale/Locale.js.map +1 -1
  89. package/dist/cli/plugins/locale/index.js +2 -2
  90. package/dist/cli/plugins/locale/index.js.map +1 -1
  91. package/dist/cli/plugins/output/index.d.ts +2 -0
  92. package/dist/cli/plugins/{output.js → output/index.js} +11 -13
  93. package/dist/cli/plugins/output/index.js.map +1 -0
  94. package/dist/cli/plugins/output/runtime.d.ts +26 -0
  95. package/dist/cli/plugins/output/runtime.js +19 -0
  96. package/dist/cli/plugins/output/runtime.js.map +1 -0
  97. package/dist/cli/plugins/style/index.d.ts +1 -2
  98. package/dist/cli/plugins/style/index.js +19 -30
  99. package/dist/cli/plugins/style/index.js.map +1 -1
  100. package/dist/cli/resolvers/config.js +1 -2
  101. package/dist/cli/resolvers/config.js.map +1 -1
  102. package/dist/cli/virtual/index.js +4 -4
  103. package/dist/cli/virtual/virtual.d.ts +8 -3
  104. package/dist/content/index.d.ts +3 -0
  105. package/dist/content/index.js +8 -0
  106. package/dist/content/index.js.map +1 -0
  107. package/dist/entry/content/adapters/react/Builder.d.ts +7 -6
  108. package/dist/entry/content/adapters/react/Builder.js +12 -19
  109. package/dist/entry/content/adapters/react/Builder.js.map +1 -1
  110. package/dist/entry/content/adapters/react/Node.d.ts +6 -14
  111. package/dist/entry/content/adapters/react/Node.js +11 -35
  112. package/dist/entry/content/adapters/react/Node.js.map +1 -1
  113. package/dist/entry/content/adapters/react/definition.d.ts +2 -0
  114. package/dist/entry/content/adapters/react/definition.js +12 -0
  115. package/dist/entry/content/adapters/react/definition.js.map +1 -0
  116. package/dist/entry/content/adapters/react/index.d.ts +2 -1
  117. package/dist/entry/content/adapters/react/index.js +3 -1
  118. package/dist/entry/content/adapters/react/index.js.map +1 -1
  119. package/dist/entry/content/adapters/vanilla/Builder.d.ts +7 -5
  120. package/dist/entry/content/adapters/vanilla/Builder.js +17 -14
  121. package/dist/entry/content/adapters/vanilla/Builder.js.map +1 -1
  122. package/dist/entry/content/adapters/vanilla/Node.d.ts +5 -11
  123. package/dist/entry/content/adapters/vanilla/Node.js +11 -37
  124. package/dist/entry/content/adapters/vanilla/Node.js.map +1 -1
  125. package/dist/entry/content/adapters/vanilla/definition.d.ts +2 -0
  126. package/dist/entry/content/adapters/vanilla/definition.js +9 -0
  127. package/dist/entry/content/adapters/vanilla/definition.js.map +1 -0
  128. package/dist/entry/content/adapters/vanilla/index.d.ts +2 -1
  129. package/dist/entry/content/adapters/vanilla/index.js +3 -1
  130. package/dist/entry/content/adapters/vanilla/index.js.map +1 -1
  131. package/dist/entry/content/adapters/vanilla/utils.d.ts +1 -0
  132. package/dist/entry/content/adapters/vanilla/utils.js +7 -0
  133. package/dist/entry/content/adapters/vanilla/utils.js.map +1 -0
  134. package/dist/entry/content/index.d.ts +5 -1
  135. package/dist/entry/content/index.js +8 -1
  136. package/dist/entry/content/index.js.map +1 -1
  137. package/dist/entry/content/lifecycle/Builder.d.ts +32 -0
  138. package/dist/entry/content/lifecycle/Builder.js +254 -0
  139. package/dist/entry/content/lifecycle/Builder.js.map +1 -0
  140. package/dist/entry/content/lifecycle/IsolationSetup.d.ts +16 -0
  141. package/dist/entry/content/lifecycle/IsolationSetup.js +37 -0
  142. package/dist/entry/content/lifecycle/IsolationSetup.js.map +1 -0
  143. package/dist/entry/content/lifecycle/MountBuilder.d.ts +11 -0
  144. package/dist/entry/content/lifecycle/MountBuilder.js +73 -0
  145. package/dist/entry/content/lifecycle/MountBuilder.js.map +1 -0
  146. package/dist/entry/content/lifecycle/context/ContainerRegistry.d.ts +7 -0
  147. package/dist/entry/content/lifecycle/context/ContainerRegistry.js +45 -0
  148. package/dist/entry/content/lifecycle/context/ContainerRegistry.js.map +1 -0
  149. package/dist/entry/content/lifecycle/context/Context.d.ts +17 -0
  150. package/dist/entry/content/lifecycle/context/Context.js +88 -0
  151. package/dist/entry/content/lifecycle/context/Context.js.map +1 -0
  152. package/dist/entry/content/{core → lifecycle}/context/EventEmitter.d.ts +2 -2
  153. package/dist/entry/content/{core → lifecycle}/context/EventEmitter.js +3 -3
  154. package/dist/entry/content/lifecycle/context/EventEmitter.js.map +1 -0
  155. package/dist/entry/content/lifecycle/context/ManagedContext.d.ts +8 -0
  156. package/dist/entry/content/lifecycle/context/ManagedContext.js +19 -0
  157. package/dist/entry/content/lifecycle/context/ManagedContext.js.map +1 -0
  158. package/dist/entry/content/{core → lifecycle}/context/index.d.ts +1 -0
  159. package/dist/entry/content/lifecycle/context/index.js +11 -0
  160. package/dist/entry/content/lifecycle/context/index.js.map +1 -0
  161. package/dist/entry/content/{core → lifecycle}/markers/AbstractMarker.d.ts +2 -2
  162. package/dist/entry/content/{core → lifecycle}/markers/AbstractMarker.js +3 -3
  163. package/dist/entry/content/lifecycle/markers/AbstractMarker.js.map +1 -0
  164. package/dist/entry/content/{core → lifecycle}/markers/AttributeMarker.d.ts +2 -2
  165. package/dist/entry/content/{core → lifecycle}/markers/AttributeMarker.js +5 -3
  166. package/dist/entry/content/lifecycle/markers/AttributeMarker.js.map +1 -0
  167. package/dist/entry/content/{core → lifecycle}/markers/WeakMarker.d.ts +2 -2
  168. package/dist/entry/content/{core → lifecycle}/markers/WeakMarker.js +2 -2
  169. package/dist/entry/content/lifecycle/markers/WeakMarker.js.map +1 -0
  170. package/dist/entry/content/lifecycle/markers/index.js.map +1 -0
  171. package/dist/entry/content/lifecycle/nodes/EventNode.d.ts +15 -0
  172. package/dist/entry/content/lifecycle/nodes/EventNode.js +49 -0
  173. package/dist/entry/content/lifecycle/nodes/EventNode.js.map +1 -0
  174. package/dist/entry/content/lifecycle/nodes/FrameNode.d.ts +30 -0
  175. package/dist/entry/content/lifecycle/nodes/FrameNode.js +190 -0
  176. package/dist/entry/content/lifecycle/nodes/FrameNode.js.map +1 -0
  177. package/dist/entry/content/{core → lifecycle}/nodes/MarkerNode.d.ts +3 -2
  178. package/dist/entry/content/{core → lifecycle}/nodes/MarkerNode.js +5 -2
  179. package/dist/entry/content/lifecycle/nodes/MarkerNode.js.map +1 -0
  180. package/dist/entry/content/lifecycle/nodes/MountNode.d.ts +17 -0
  181. package/dist/entry/content/lifecycle/nodes/MountNode.js +80 -0
  182. package/dist/entry/content/lifecycle/nodes/MountNode.js.map +1 -0
  183. package/dist/entry/content/{core → lifecycle}/nodes/Node.d.ts +2 -2
  184. package/dist/entry/content/{core → lifecycle}/nodes/Node.js +2 -2
  185. package/dist/entry/content/lifecycle/nodes/Node.js.map +1 -0
  186. package/dist/entry/content/lifecycle/nodes/RenderNode.d.ts +28 -0
  187. package/dist/entry/content/lifecycle/nodes/RenderNode.js +140 -0
  188. package/dist/entry/content/lifecycle/nodes/RenderNode.js.map +1 -0
  189. package/dist/entry/content/lifecycle/nodes/ShadowNode.d.ts +22 -0
  190. package/dist/entry/content/lifecycle/nodes/ShadowNode.js +124 -0
  191. package/dist/entry/content/lifecycle/nodes/ShadowNode.js.map +1 -0
  192. package/dist/entry/content/{core → lifecycle}/nodes/index.d.ts +1 -0
  193. package/dist/entry/content/lifecycle/nodes/index.js +17 -0
  194. package/dist/entry/content/lifecycle/nodes/index.js.map +1 -0
  195. package/dist/entry/content/{core → lifecycle}/nodes/isolated-styles.d.ts +1 -1
  196. package/dist/entry/content/{core → lifecycle}/nodes/isolated-styles.js +2 -2
  197. package/dist/entry/content/lifecycle/nodes/isolated-styles.js.map +1 -0
  198. package/dist/entry/content/lifecycle/types.d.ts +28 -0
  199. package/dist/entry/content/resolvers/anchor.d.ts +2 -0
  200. package/dist/entry/content/{core/resolvers → resolvers}/anchor.js +2 -2
  201. package/dist/entry/content/resolvers/anchor.js.map +1 -0
  202. package/dist/entry/content/resolvers/container.d.ts +2 -0
  203. package/dist/entry/content/{core/resolvers → resolvers}/container.js +2 -2
  204. package/dist/entry/content/resolvers/container.js.map +1 -0
  205. package/dist/entry/content/resolvers/definition.d.ts +5 -0
  206. package/dist/entry/content/resolvers/definition.js +24 -0
  207. package/dist/entry/content/resolvers/definition.js.map +1 -0
  208. package/dist/entry/content/{core/resolvers → resolvers}/index.d.ts +1 -1
  209. package/dist/entry/content/{core/resolvers → resolvers}/index.js +1 -1
  210. package/dist/entry/content/resolvers/index.js.map +1 -0
  211. package/dist/entry/content/resolvers/mount.d.ts +2 -0
  212. package/dist/entry/content/{core/resolvers → resolvers}/mount.js +3 -3
  213. package/dist/entry/content/resolvers/mount.js.map +1 -0
  214. package/dist/entry/content/resolvers/target.d.ts +3 -0
  215. package/dist/entry/content/resolvers/target.js +34 -0
  216. package/dist/entry/content/resolvers/target.js.map +1 -0
  217. package/dist/entry/content/resolvers/watch.d.ts +6 -0
  218. package/dist/entry/content/resolvers/watch.js +81 -0
  219. package/dist/entry/content/resolvers/watch.js.map +1 -0
  220. package/dist/entry/relay/Builder.d.ts +8 -8
  221. package/dist/entry/relay/Builder.js +28 -19
  222. package/dist/entry/relay/Builder.js.map +1 -1
  223. package/dist/entry/relay/TransportBuilder.d.ts +3 -2
  224. package/dist/entry/relay/TransportBuilder.js +3 -3
  225. package/dist/entry/relay/TransportBuilder.js.map +1 -1
  226. package/dist/entry/relay/index.d.ts +5 -2
  227. package/dist/entry/relay/index.js +8 -2
  228. package/dist/entry/relay/index.js.map +1 -1
  229. package/dist/entry/relay/resolvers/definition.d.ts +4 -0
  230. package/dist/entry/relay/resolvers/definition.js +16 -0
  231. package/dist/entry/relay/resolvers/definition.js.map +1 -0
  232. package/dist/main/content.d.ts +4 -6
  233. package/dist/main/content.js +3 -16
  234. package/dist/main/content.js.map +1 -1
  235. package/dist/main/entrypoint.js +1 -1
  236. package/dist/main/entrypoint.js.map +1 -1
  237. package/dist/main/relay.d.ts +2 -1
  238. package/dist/main/relay.js.map +1 -1
  239. package/dist/relay/RelayPermission.js +1 -1
  240. package/dist/shared/content/isolation.d.ts +1 -1
  241. package/dist/shared/content/isolation.js +13 -20
  242. package/dist/shared/content/isolation.js.map +1 -1
  243. package/dist/shared/locale/index.d.ts +1 -1
  244. package/dist/shared/locale/index.js +3 -1
  245. package/dist/shared/locale/index.js.map +1 -1
  246. package/dist/shared/locale/messages.d.ts +4 -0
  247. package/dist/shared/locale/messages.js +12 -0
  248. package/dist/shared/locale/messages.js.map +1 -1
  249. package/dist/types/content/adapters/index.d.ts +2 -0
  250. package/dist/types/content/adapters/index.js +1 -0
  251. package/dist/types/content/adapters/index.js.map +1 -0
  252. package/dist/types/content/adapters/react.d.ts +4 -0
  253. package/dist/types/content/adapters/react.js +1 -0
  254. package/dist/types/content/adapters/react.js.map +1 -0
  255. package/dist/types/content/adapters/vanilla.d.ts +1 -0
  256. package/dist/types/content/adapters/vanilla.js +1 -0
  257. package/dist/types/content/adapters/vanilla.js.map +1 -0
  258. package/dist/types/content/boundary.d.ts +17 -0
  259. package/dist/types/content/boundary.js +1 -0
  260. package/dist/types/content/boundary.js.map +1 -0
  261. package/dist/types/{content.d.ts → content/common.d.ts} +32 -53
  262. package/dist/types/{content.js → content/common.js} +1 -1
  263. package/dist/types/content/common.js.map +1 -0
  264. package/dist/types/content/definition.d.ts +66 -0
  265. package/dist/types/content/definition.js +1 -0
  266. package/dist/types/content/definition.js.map +1 -0
  267. package/dist/types/content/index.d.ts +7 -0
  268. package/dist/types/content/index.js +2 -0
  269. package/dist/types/content/index.js.map +1 -0
  270. package/dist/types/content/prepare.d.ts +9 -0
  271. package/dist/types/content/prepare.js +1 -0
  272. package/dist/types/content/prepare.js.map +1 -0
  273. package/dist/types/content/render.d.ts +6 -0
  274. package/dist/types/content/render.js +1 -0
  275. package/dist/types/content/render.js.map +1 -0
  276. package/dist/types/content/target.d.ts +13 -0
  277. package/dist/types/content/target.js +1 -0
  278. package/dist/types/content/target.js.map +1 -0
  279. package/dist/types/locale.d.ts +3 -0
  280. package/dist/types/locale.js.map +1 -1
  281. package/dist/types/manifest.d.ts +1 -1
  282. package/dist/types/relay.d.ts +3 -4
  283. package/dist/types/relay.js.map +1 -1
  284. package/dist/virtual/modules.d.ts +4 -3
  285. package/dist/virtual/{entrypoint.d.ts → runtime.d.ts} +3 -0
  286. package/dist/virtual/runtime.js +9 -0
  287. package/dist/virtual/runtime.js.map +1 -0
  288. package/package.json +32 -25
  289. package/scripts/merge-coverage.mjs +12 -0
  290. package/scripts/pre-commit.mjs +22 -0
  291. package/scripts/test-inventory.mjs +38 -0
  292. package/scripts/test-run.mjs +25 -0
  293. package/types/client.d.ts +3 -3
  294. package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.d.ts +0 -13
  295. package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.js +0 -16
  296. package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.js.map +0 -1
  297. package/dist/cli/bundler/utils/layers.d.ts +0 -4
  298. package/dist/cli/bundler/utils/layers.js +0 -10
  299. package/dist/cli/bundler/utils/layers.js.map +0 -1
  300. package/dist/cli/bundler/utils/output.d.ts +0 -6
  301. package/dist/cli/bundler/utils/output.js.map +0 -1
  302. package/dist/cli/bundler/utils/styles.d.ts +0 -5
  303. package/dist/cli/bundler/utils/styles.js +0 -30
  304. package/dist/cli/bundler/utils/styles.js.map +0 -1
  305. package/dist/cli/plugins/output.d.ts +0 -2
  306. package/dist/cli/plugins/output.js.map +0 -1
  307. package/dist/cli/plugins/style/types.d.ts +0 -5
  308. package/dist/entry/content/adapters/react/resolvers/index.d.ts +0 -1
  309. package/dist/entry/content/adapters/react/resolvers/index.js +0 -2
  310. package/dist/entry/content/adapters/react/resolvers/index.js.map +0 -1
  311. package/dist/entry/content/adapters/react/resolvers/render.d.ts +0 -2
  312. package/dist/entry/content/adapters/react/resolvers/render.js +0 -11
  313. package/dist/entry/content/adapters/react/resolvers/render.js.map +0 -1
  314. package/dist/entry/content/core/Builder.d.ts +0 -26
  315. package/dist/entry/content/core/Builder.js +0 -128
  316. package/dist/entry/content/core/Builder.js.map +0 -1
  317. package/dist/entry/content/core/MountBuilder.d.ts +0 -10
  318. package/dist/entry/content/core/MountBuilder.js +0 -48
  319. package/dist/entry/content/core/MountBuilder.js.map +0 -1
  320. package/dist/entry/content/core/context/Context.d.ts +0 -12
  321. package/dist/entry/content/core/context/Context.js +0 -50
  322. package/dist/entry/content/core/context/Context.js.map +0 -1
  323. package/dist/entry/content/core/context/EventEmitter.js.map +0 -1
  324. package/dist/entry/content/core/context/ManagedContext.d.ts +0 -5
  325. package/dist/entry/content/core/context/ManagedContext.js +0 -12
  326. package/dist/entry/content/core/context/ManagedContext.js.map +0 -1
  327. package/dist/entry/content/core/context/index.js +0 -9
  328. package/dist/entry/content/core/context/index.js.map +0 -1
  329. package/dist/entry/content/core/markers/AbstractMarker.js.map +0 -1
  330. package/dist/entry/content/core/markers/AttributeMarker.js.map +0 -1
  331. package/dist/entry/content/core/markers/WeakMarker.js.map +0 -1
  332. package/dist/entry/content/core/markers/index.js.map +0 -1
  333. package/dist/entry/content/core/nodes/EventNode.d.ts +0 -11
  334. package/dist/entry/content/core/nodes/EventNode.js +0 -35
  335. package/dist/entry/content/core/nodes/EventNode.js.map +0 -1
  336. package/dist/entry/content/core/nodes/FrameNode.d.ts +0 -23
  337. package/dist/entry/content/core/nodes/FrameNode.js +0 -125
  338. package/dist/entry/content/core/nodes/FrameNode.js.map +0 -1
  339. package/dist/entry/content/core/nodes/MarkerNode.js.map +0 -1
  340. package/dist/entry/content/core/nodes/MountNode.d.ts +0 -12
  341. package/dist/entry/content/core/nodes/MountNode.js +0 -42
  342. package/dist/entry/content/core/nodes/MountNode.js.map +0 -1
  343. package/dist/entry/content/core/nodes/Node.js.map +0 -1
  344. package/dist/entry/content/core/nodes/ShadowNode.d.ts +0 -14
  345. package/dist/entry/content/core/nodes/ShadowNode.js +0 -67
  346. package/dist/entry/content/core/nodes/ShadowNode.js.map +0 -1
  347. package/dist/entry/content/core/nodes/index.js +0 -15
  348. package/dist/entry/content/core/nodes/index.js.map +0 -1
  349. package/dist/entry/content/core/nodes/isolated-styles.js.map +0 -1
  350. package/dist/entry/content/core/resolvers/anchor.d.ts +0 -2
  351. package/dist/entry/content/core/resolvers/anchor.js.map +0 -1
  352. package/dist/entry/content/core/resolvers/container.d.ts +0 -2
  353. package/dist/entry/content/core/resolvers/container.js.map +0 -1
  354. package/dist/entry/content/core/resolvers/definition.d.ts +0 -3
  355. package/dist/entry/content/core/resolvers/definition.js +0 -12
  356. package/dist/entry/content/core/resolvers/definition.js.map +0 -1
  357. package/dist/entry/content/core/resolvers/index.js.map +0 -1
  358. package/dist/entry/content/core/resolvers/mount.d.ts +0 -2
  359. package/dist/entry/content/core/resolvers/mount.js.map +0 -1
  360. package/dist/entry/content/core/resolvers/render.d.ts +0 -3
  361. package/dist/entry/content/core/resolvers/render.js +0 -18
  362. package/dist/entry/content/core/resolvers/render.js.map +0 -1
  363. package/dist/entry/content/core/resolvers/watch.d.ts +0 -4
  364. package/dist/entry/content/core/resolvers/watch.js +0 -62
  365. package/dist/entry/content/core/resolvers/watch.js.map +0 -1
  366. package/dist/entry/content/frame/Builder.d.ts +0 -7
  367. package/dist/entry/content/frame/Builder.js +0 -14
  368. package/dist/entry/content/frame/Builder.js.map +0 -1
  369. package/dist/entry/content/frame/index.d.ts +0 -4
  370. package/dist/entry/content/frame/index.js +0 -7
  371. package/dist/entry/content/frame/index.js.map +0 -1
  372. package/dist/types/content.js.map +0 -1
  373. package/dist/virtual/entrypoint.js +0 -7
  374. package/dist/virtual/entrypoint.js.map +0 -1
  375. /package/dist/entry/content/{core → lifecycle}/markers/index.d.ts +0 -0
  376. /package/dist/entry/content/{core → lifecycle}/markers/index.js +0 -0
  377. /package/dist/{cli/plugins/style → entry/content/lifecycle}/types.js +0 -0
  378. /package/dist/{cli/plugins/style → entry/content/lifecycle}/types.js.map +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/cli/bundler/plugins/entrypoint/EntrypointPlugin.ts"],"sourcesContent":["import _ from \"lodash\";\nimport path from \"path\";\n\nimport {Compiler, type EntryDescription, EntryNormalized} from \"@rspack/core\";\nimport {RspackVirtualModulePlugin as VirtualModulesPlugin} from \"rspack-plugin-virtual-module\";\n\nimport {EntrypointEntries, EntrypointFile} from \"@typing/entrypoint\";\n\nexport type EntrypointPluginTemplate = (file: EntrypointFile) => string;\n\nexport type EntrypointPluginUpdate = (files: ReadonlySet<string>) => Promise<EntrypointEntries>;\n\nexport interface EntrypointPluginModule {\n /**\n * Virtual module name, used in the rspack entry and virtual module.\n */\n name: string;\n\n /**\n * Virtual module content.\n */\n module: string;\n}\n\nexport type EntrypointPluginModules = Map<EntrypointFile, EntrypointPluginModule>;\n\nexport type EntrypointPluginEntryModules = Map<string, EntrypointPluginModules>;\n\nexport type EntrypointPluginEntryOptions = Omit<EntryDescription, \"import\">;\n\nexport type EntrypointPluginEntryOptionsResolver = (name: string) => EntrypointPluginEntryOptions;\n\nexport default class EntrypointPlugin {\n private readonly pluginName: string = \"EntrypointPlugin\";\n\n private _plugin?: VirtualModulesPlugin;\n private _modules?: EntrypointPluginEntryModules;\n private readonly _entryOptions: EntrypointPluginEntryOptionsResolver[] = [];\n\n protected template?: EntrypointPluginTemplate;\n protected update?: EntrypointPluginUpdate;\n\n public static filename(file: EntrypointFile): string {\n let name = file.file;\n\n if (file.external) {\n const {ext} = path.parse(name);\n name = file.import + ext;\n }\n\n return path.join(\"virtual\", name);\n }\n\n protected get plugin(): VirtualModulesPlugin {\n if (this._plugin) {\n return this._plugin;\n }\n\n const modules = Object.fromEntries(this.getModuleContents(this.modules));\n\n return (this._plugin = new VirtualModulesPlugin(modules, \"entrypoint\"));\n }\n\n protected get modules(): EntrypointPluginEntryModules {\n return (this._modules ??= this.createModules(this.entries));\n }\n\n protected get watchFiles(): ReadonlySet<string> {\n const files = Array.from(this.modules.values())\n .flatMap(modules => Array.from(modules.keys()))\n .filter(({external}) => !external)\n .map(({file}) => file);\n\n return new Set(files);\n }\n\n public static from(entries: EntrypointEntries): EntrypointPlugin {\n return new EntrypointPlugin(entries);\n }\n\n constructor(private readonly entries: EntrypointEntries = new Map()) {}\n\n public virtual(template: EntrypointPluginTemplate): this {\n this.template = template;\n\n return this;\n }\n\n public entryOptions(options: EntrypointPluginEntryOptions | EntrypointPluginEntryOptionsResolver): this {\n this._entryOptions.push(_.isFunction(options) ? options : () => options);\n\n return this;\n }\n\n public watch(update: EntrypointPluginUpdate): this {\n this.update = update;\n\n return this;\n }\n\n public apply(compiler: Compiler): void {\n this.plugin.apply(compiler);\n\n compiler.hooks.entryOption.tap(this.pluginName, (_, entry) => {\n this.hookEntryOption(entry);\n });\n\n if (this.update) {\n compiler.hooks.watchRun.tapAsync(this.pluginName, (compiler, callback) => {\n this.hookWatchRun(compiler)\n .then(() => callback())\n .catch(callback);\n });\n }\n }\n\n protected hookEntryOption(entry: EntryNormalized): void {\n if (_.isPlainObject(entry)) {\n this.modules.entries().forEach(([name, modules]) => {\n const current = structuredClone(entry[name] ?? []);\n let currentFiles = current;\n let currentOptions: EntrypointPluginEntryOptions = {};\n\n if (\"import\" in currentFiles) {\n currentOptions = currentFiles;\n currentFiles = currentFiles.import;\n }\n\n currentFiles.push(...Array.from(modules.values(), ({name}) => name));\n\n entry[name] = {\n ...currentOptions,\n ...this.resolveEntryOptions(name),\n import: _.uniq(currentFiles),\n };\n });\n } else {\n throw new Error(\"EntrypointPlugin: entry is not an object\");\n }\n }\n\n protected async hookWatchRun(compiler: Compiler): Promise<void> {\n const {modifiedFiles = new Set()} = compiler;\n\n const watchFiles = new Set(Array.from(this.watchFiles, file => path.resolve(compiler.context, file)));\n const needUpdate = Array.from(modifiedFiles).some(file => watchFiles.has(path.resolve(compiler.context, file)));\n\n if (!needUpdate) {\n return;\n }\n\n const updatedEntries = await this.update!(modifiedFiles);\n\n const updatedModules = this.createModules(updatedEntries);\n\n const currentContents = this.getModuleContents(this.modules);\n const updatedContents = this.getModuleContents(updatedModules);\n\n const removedContents = new Map(Array.from(currentContents).filter(entry => !updatedContents.has(entry[0])));\n\n const changedContents = new Map(\n Array.from(updatedContents).filter(([name, content]) => currentContents.get(name) !== content)\n );\n\n removedContents.keys().forEach(name => {\n this.plugin.writeModule(name, \"\");\n });\n\n changedContents.forEach((content, name) => {\n this.plugin.writeModule(name, content);\n });\n\n this.modules.keys().forEach(name => {\n if (!updatedModules.has(name)) {\n delete compiler.options.entry[name];\n }\n });\n\n updatedModules.entries().forEach(([name, modules]) => {\n const current = structuredClone(compiler.options.entry[name] ?? []);\n let entry = current;\n let currentOptions: EntrypointPluginEntryOptions = {};\n\n if (\"import\" in entry) {\n currentOptions = entry;\n entry = entry.import as string[];\n }\n\n entry = entry.filter(file => !removedContents.has(file));\n\n entry.push(...Array.from(modules.values(), ({name}) => name));\n\n compiler.options.entry[name] = {\n ...currentOptions,\n ...this.resolveEntryOptions(name),\n import: _.uniq(entry),\n };\n });\n\n this._modules = updatedModules;\n }\n\n protected resolveEntryOptions(name: string): EntrypointPluginEntryOptions {\n return Object.assign({}, ...this._entryOptions.map(resolve => resolve(name)));\n }\n\n protected createModules(entries: EntrypointEntries): EntrypointPluginEntryModules {\n const entryModules: EntrypointPluginEntryModules = new Map();\n\n for (const [name, files] of entries) {\n const modules: EntrypointPluginModules = new Map();\n\n for (const file of files) {\n modules.set(file, {\n name: EntrypointPlugin.filename(file),\n module: this.template ? this.template(file) : \"\",\n });\n }\n\n entryModules.set(name, modules);\n }\n\n return entryModules;\n }\n\n protected getModuleContents(modules: EntrypointPluginEntryModules): Map<string, string> {\n const content = new Map<string, string>();\n\n modules.values().forEach(modules => {\n modules.forEach(({name, module}) => {\n content.set(name, module);\n });\n });\n\n return content;\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AACd,OAAO,UAAU;AAGjB,SAAQ,6BAA6B,4BAA2B;AA4BhE,MAAO,iBAA+B;AAAA,EAgDlC,YAA6B,UAA6B,oBAAI,IAAI,GAAG;AAAxC;AAAA,EAAyC;AAAA,EAAzC;AAAA,EA/CZ,aAAqB;AAAA,EAE9B;AAAA,EACA;AAAA,EACS,gBAAwD,CAAC;AAAA,EAEhE;AAAA,EACA;AAAA,EAEV,OAAc,SAAS,MAA8B;AACjD,QAAI,OAAO,KAAK;AAEhB,QAAI,KAAK,UAAU;AACf,YAAM,EAAC,IAAG,IAAI,KAAK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IACJ,CAAC;AAED,SAAK,WAAW;AAAA,EACpB;AAAA,EAEU,oBAAoB,MAA4C;AACtE,WAAO,OAAO,OAAO,CAAC,GAAG,GAAG,KAAK,cAAc,IAAI,aAAW,QAAQ,IAAI,CAAC,CAAC;AAAA,EAChF;AAAA,EAEU,cAAc,SAA0D;AAC9E,UAAM,eAA6C,oBAAI,IAAI;AAE3D,eAAW,CAAC,MAAM,KAAK,KAAK,SAAS;AACjC,YAAM,UAAmC,oBAAI,IAAI;AAEjD,iBAAW,QAAQ,OAAO;AACtB,gBAAQ,IAAI,MAAM;AAAA,UACd,MAAM,iBAAiB,SAAS,IAAI;AAAA,UACpC,QAAQ,KAAK,WAAW,KAAK,SAAS,IAAI,IAAI;AAAA,QAClD,CAAC;AAAA,MACL;AAEA,mBAAa,IAAI,MAAM,OAAO;AAAA,IAClC;AAEA,WAAO;AAAA,EACX;AAAA,EAEU,kBAAkB,SAA4D;AACpF,UAAM,UAAU,oBAAI,IAAoB;AAExC,YAAQ,OAAO,EAAE,QAAQ,CAAAC,aAAW;AAChC,MAAAA,SAAQ,QAAQ,CAAC,EAAC,MAAM,OAAM,MAAM;AAChC,gBAAQ,IAAI,MAAM,MAAM;AAAA,MAC5B,CAAC;AAAA,IACL,CAAC;AAED,WAAO;AAAA,EACX;AACJ;","names":["_","compiler","name","modules"]}
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/entrypoint/EntrypointPlugin.ts"],"sourcesContent":["import _ from \"lodash\";\nimport path from \"path\";\n\nimport {Compiler, DynamicEntryPlugin, type EntryDescription, EntryNormalized} from \"@rspack/core\";\nimport {RspackVirtualModulePlugin as VirtualModulesPlugin} from \"rspack-plugin-virtual-module\";\n\nimport {EntrypointEntries, EntrypointFile} from \"@typing/entrypoint\";\n\nexport type EntrypointPluginTemplate = (file: EntrypointFile) => string;\n\nexport type EntrypointPluginUpdate = (files: ReadonlySet<string>) => Promise<EntrypointEntries>;\n\nexport interface EntrypointPluginModule {\n /**\n * Virtual module name, used in the rspack entry and virtual module.\n */\n name: string;\n\n /**\n * Virtual module content.\n */\n module: string;\n}\n\nexport type EntrypointPluginModules = Map<EntrypointFile, EntrypointPluginModule>;\n\nexport type EntrypointPluginEntryModules = Map<string, EntrypointPluginModules>;\n\nexport type EntrypointPluginEntryOptions = Omit<EntryDescription, \"import\">;\n\nexport type EntrypointPluginEntryOptionsResolver = (name: string) => EntrypointPluginEntryOptions;\n\nexport default class EntrypointPlugin {\n private readonly pluginName: string = \"EntrypointPlugin\";\n\n private _plugin?: VirtualModulesPlugin;\n private _modules?: EntrypointPluginEntryModules;\n private readonly _entryOptions: EntrypointPluginEntryOptionsResolver[] = [];\n\n protected template?: EntrypointPluginTemplate;\n protected update?: EntrypointPluginUpdate;\n\n public static filename(file: EntrypointFile): string {\n let name = file.file;\n\n if (file.external) {\n const {ext} = path.parse(name);\n name = file.import + ext;\n }\n\n return path.join(\"virtual\", name);\n }\n\n protected get plugin(): VirtualModulesPlugin {\n if (this._plugin) {\n return this._plugin;\n }\n\n const modules = Object.fromEntries(this.getModuleContents(this.modules));\n\n return (this._plugin = new VirtualModulesPlugin(modules, \"entrypoint\"));\n }\n\n protected get modules(): EntrypointPluginEntryModules {\n return (this._modules ??= this.createModules(this.entries));\n }\n\n protected get watchFiles(): ReadonlySet<string> {\n const files = Array.from(this.modules.values())\n .flatMap(modules => Array.from(modules.keys()))\n .filter(({external}) => !external)\n .map(({file}) => file);\n\n return new Set(files);\n }\n\n public static from(entries: EntrypointEntries): EntrypointPlugin {\n return new EntrypointPlugin(entries);\n }\n\n constructor(private readonly entries: EntrypointEntries = new Map()) {}\n\n public virtual(template: EntrypointPluginTemplate): this {\n this.template = template;\n\n return this;\n }\n\n public entryOptions(options: EntrypointPluginEntryOptions | EntrypointPluginEntryOptionsResolver): this {\n this._entryOptions.push(_.isFunction(options) ? options : () => options);\n\n return this;\n }\n\n public watch(update: EntrypointPluginUpdate): this {\n this.update = update;\n\n return this;\n }\n\n public apply(compiler: Compiler): void {\n this.plugin.apply(compiler);\n\n compiler.hooks.entryOption.tap(this.pluginName, (_, entry) => {\n this.hookEntryOption(entry);\n });\n\n if (this.update) {\n // Static EntryPlugin captures options once. Resolve the completed entry table\n // per compilation so watch changes to layers and asyncChunks reach Rspack too.\n // Register after other plugins have prepared their entryOption hooks, but\n // before Rspack installs its default static entry handler.\n compiler.hooks.afterEnvironment.tap(this.pluginName, () => {\n compiler.hooks.entryOption.tap(`${this.pluginName}:watch`, (context, entry) => {\n compiler.options.entry = entry;\n\n new DynamicEntryPlugin(context, async () => {\n const entry = compiler.options.entry;\n\n return typeof entry === \"function\" ? entry() : entry;\n }).apply(compiler);\n\n return true;\n });\n });\n\n compiler.hooks.watchRun.tapAsync(this.pluginName, (compiler, callback) => {\n this.hookWatchRun(compiler)\n .then(() => callback())\n .catch(callback);\n });\n }\n }\n\n protected hookEntryOption(entry: EntryNormalized): void {\n if (_.isPlainObject(entry)) {\n this.modules.entries().forEach(([name, modules]) => {\n const current = structuredClone(entry[name] ?? []);\n let currentFiles = current;\n let currentOptions: EntrypointPluginEntryOptions = {};\n\n if (\"import\" in currentFiles) {\n currentOptions = currentFiles;\n currentFiles = currentFiles.import;\n }\n\n currentFiles.push(...Array.from(modules.values(), ({name}) => name));\n\n entry[name] = {\n ...currentOptions,\n ...this.resolveEntryOptions(name),\n import: _.uniq(currentFiles),\n };\n });\n } else {\n throw new Error(\"EntrypointPlugin: entry is not an object\");\n }\n }\n\n protected async hookWatchRun(compiler: Compiler): Promise<void> {\n const {modifiedFiles = new Set()} = compiler;\n\n const watchFiles = new Set(Array.from(this.watchFiles, file => path.resolve(compiler.context, file)));\n const needUpdate = Array.from(modifiedFiles).some(file => watchFiles.has(path.resolve(compiler.context, file)));\n\n if (!needUpdate) {\n return;\n }\n\n const updatedEntries = await this.update!(modifiedFiles);\n\n const updatedModules = this.createModules(updatedEntries);\n\n const currentContents = this.getModuleContents(this.modules);\n const updatedContents = this.getModuleContents(updatedModules);\n\n const removedContents = new Map(Array.from(currentContents).filter(entry => !updatedContents.has(entry[0])));\n\n const changedContents = new Map(\n Array.from(updatedContents).filter(([name, content]) => currentContents.get(name) !== content)\n );\n\n removedContents.keys().forEach(name => {\n this.plugin.writeModule(name, \"\");\n });\n\n changedContents.forEach((content, name) => {\n this.plugin.writeModule(name, content);\n });\n\n this.modules.keys().forEach(name => {\n if (!updatedModules.has(name)) {\n delete compiler.options.entry[name];\n }\n });\n\n updatedModules.entries().forEach(([name, modules]) => {\n const current = structuredClone(compiler.options.entry[name] ?? []);\n let entry = current;\n let currentOptions: EntrypointPluginEntryOptions = {};\n\n if (\"import\" in entry) {\n currentOptions = entry;\n entry = entry.import as string[];\n }\n\n entry = entry.filter(file => !removedContents.has(file));\n\n entry.push(...Array.from(modules.values(), ({name}) => name));\n\n compiler.options.entry[name] = {\n ...currentOptions,\n ...this.resolveEntryOptions(name),\n import: _.uniq(entry),\n };\n });\n\n this._modules = updatedModules;\n }\n\n protected resolveEntryOptions(name: string): EntrypointPluginEntryOptions {\n return Object.assign({}, ...this._entryOptions.map(resolve => resolve(name)));\n }\n\n protected createModules(entries: EntrypointEntries): EntrypointPluginEntryModules {\n const entryModules: EntrypointPluginEntryModules = new Map();\n\n for (const [name, files] of entries) {\n const modules: EntrypointPluginModules = new Map();\n\n for (const file of files) {\n modules.set(file, {\n name: EntrypointPlugin.filename(file),\n module: this.template ? this.template(file) : \"\",\n });\n }\n\n entryModules.set(name, modules);\n }\n\n return entryModules;\n }\n\n protected getModuleContents(modules: EntrypointPluginEntryModules): Map<string, string> {\n const content = new Map<string, string>();\n\n modules.values().forEach(modules => {\n modules.forEach(({name, module}) => {\n content.set(name, module);\n });\n });\n\n return content;\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AACd,OAAO,UAAU;AAEjB,SAAkB,0BAAiE;AACnF,SAAQ,6BAA6B,4BAA2B;AA4BhE,MAAO,iBAA+B;AAAA,EAgDlC,YAA6B,UAA6B,oBAAI,IAAI,GAAG;AAAxC;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CAAAC,aAAW;AAChC,MAAAA,SAAQ,QAAQ,CAAC,EAAC,MAAM,OAAM,MAAM;AAChC,gBAAQ,IAAI,MAAM,MAAM;AAAA,MAC5B,CAAC;AAAA,IACL,CAAC;AAED,WAAO;AAAA,EACX;AACJ;","names":["_","entry","compiler","name","modules"]}
@@ -1,11 +1,11 @@
1
1
  export { default as EntrypointPlugin, type EntrypointPluginEntryOptions, type EntrypointPluginEntryOptionsResolver, type EntrypointPluginModules, type EntrypointPluginModule, type EntrypointPluginEntryModules, type EntrypointPluginTemplate, type EntrypointPluginUpdate, } from "./entrypoint/index.js";
2
2
  export { default as ChunkLoaderPlugin, type ChunkLoaderPluginOptions } from "./chunk-loader/index.js";
3
3
  export { default as IsolatedStylesPlugin, type IsolatedStylesPluginOptions, type IsolatedStylesPluginFiles, } from "./isolated-styles/index.js";
4
- export { default as BuildAssetsMapPlugin, type BuildAssetsMapPluginOptions, type BuildAssetsMapPluginModuleOptions, type BuildAssetsMapPluginExportOptions, createEntrypointModule, EntrypointAssetsModule, } from "./build-assets-map/index.js";
4
+ export { default as BuildAssetsMapPlugin, type BuildAssetsMapPluginOptions, type BuildAssetsMapPluginModuleOptions, } from "./build-assets-map/index.js";
5
5
  export { default as GenerateJsonPlugin, type GenerateJsonPluginData, type GenerateJsonPluginUpdate, } from "./generate-json/index.js";
6
6
  export { GenerateModulePlugin, type GenerateModulePluginDependencies, type GenerateModulePluginDependenciesResolver, type GenerateModulePluginModules, type GenerateModulePluginUpdate, } from "./generate-module/index.js";
7
7
  export { default as ManifestPlugin } from "./manifest/index.js";
8
8
  export { default as ResourceAccessPlugin, type ResourceAccessPluginOptions, type ResourceAccessPluginRequirement, } from "./resource-access/index.js";
9
9
  export { default as ReplacePlugin } from "./replace/index.js";
10
10
  export { default as WatchPlugin } from "./watch/index.js";
11
- export type { RuntimePropertyOptions } from "./types.js";
11
+ export type { RuntimePropertyOptions, RuntimeModuleReaderOptions } from "./types.js";
@@ -6,9 +6,7 @@ import {
6
6
  default as default4
7
7
  } from "./isolated-styles/index.js";
8
8
  import {
9
- default as default5,
10
- createEntrypointModule,
11
- EntrypointAssetsModule
9
+ default as default5
12
10
  } from "./build-assets-map/index.js";
13
11
  import {
14
12
  default as default6
@@ -25,7 +23,6 @@ import { default as default10 } from "./watch/index.js";
25
23
  export {
26
24
  default5 as BuildAssetsMapPlugin,
27
25
  default3 as ChunkLoaderPlugin,
28
- EntrypointAssetsModule,
29
26
  default2 as EntrypointPlugin,
30
27
  default6 as GenerateJsonPlugin,
31
28
  GenerateModulePlugin,
@@ -33,7 +30,6 @@ export {
33
30
  default7 as ManifestPlugin,
34
31
  default9 as ReplacePlugin,
35
32
  default8 as ResourceAccessPlugin,
36
- default10 as WatchPlugin,
37
- createEntrypointModule
33
+ default10 as WatchPlugin
38
34
  };
39
35
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/cli/bundler/plugins/index.ts"],"sourcesContent":["export {\n default as EntrypointPlugin,\n type EntrypointPluginEntryOptions,\n type EntrypointPluginEntryOptionsResolver,\n type EntrypointPluginModules,\n type EntrypointPluginModule,\n type EntrypointPluginEntryModules,\n type EntrypointPluginTemplate,\n type EntrypointPluginUpdate,\n} from \"./entrypoint\";\n\nexport {default as ChunkLoaderPlugin, type ChunkLoaderPluginOptions} from \"./chunk-loader\";\n\nexport {\n default as IsolatedStylesPlugin,\n type IsolatedStylesPluginOptions,\n type IsolatedStylesPluginFiles,\n} from \"./isolated-styles\";\n\nexport {\n default as BuildAssetsMapPlugin,\n type BuildAssetsMapPluginOptions,\n type BuildAssetsMapPluginModuleOptions,\n type BuildAssetsMapPluginExportOptions,\n createEntrypointModule,\n EntrypointAssetsModule,\n} from \"./build-assets-map\";\n\nexport {\n default as GenerateJsonPlugin,\n type GenerateJsonPluginData,\n type GenerateJsonPluginUpdate,\n} from \"./generate-json\";\n\nexport {\n GenerateModulePlugin,\n type GenerateModulePluginDependencies,\n type GenerateModulePluginDependenciesResolver,\n type GenerateModulePluginModules,\n type GenerateModulePluginUpdate,\n} from \"./generate-module\";\n\nexport {default as ManifestPlugin} from \"./manifest\";\n\nexport {\n default as ResourceAccessPlugin,\n type ResourceAccessPluginOptions,\n type ResourceAccessPluginRequirement,\n} from \"./resource-access\";\n\nexport {default as ReplacePlugin} from \"./replace\";\n\nexport {default as WatchPlugin} from \"./watch\";\n\nexport type {RuntimePropertyOptions} from \"./types\";\n"],"mappings":"AAAA;AAAA,EACe,WAAXA;AAAA,OAQG;AAEP,SAAmB,WAAXA,gBAAkE;AAE1E;AAAA,EACe,WAAXA;AAAA,OAGG;AAEP;AAAA,EACe,WAAXA;AAAA,EAIA;AAAA,EACA;AAAA,OACG;AAEP;AAAA,EACe,WAAXA;AAAA,OAGG;AAEP;AAAA,EACI;AAAA,OAKG;AAEP,SAAmB,WAAXA,gBAAgC;AAExC;AAAA,EACe,WAAXA;AAAA,OAGG;AAEP,SAAmB,WAAXA,gBAA+B;AAEvC,SAAmB,WAAXA,iBAA6B;","names":["default"]}
1
+ {"version":3,"sources":["../../../../src/cli/bundler/plugins/index.ts"],"sourcesContent":["export {\n default as EntrypointPlugin,\n type EntrypointPluginEntryOptions,\n type EntrypointPluginEntryOptionsResolver,\n type EntrypointPluginModules,\n type EntrypointPluginModule,\n type EntrypointPluginEntryModules,\n type EntrypointPluginTemplate,\n type EntrypointPluginUpdate,\n} from \"./entrypoint\";\n\nexport {default as ChunkLoaderPlugin, type ChunkLoaderPluginOptions} from \"./chunk-loader\";\n\nexport {\n default as IsolatedStylesPlugin,\n type IsolatedStylesPluginOptions,\n type IsolatedStylesPluginFiles,\n} from \"./isolated-styles\";\n\nexport {\n default as BuildAssetsMapPlugin,\n type BuildAssetsMapPluginOptions,\n type BuildAssetsMapPluginModuleOptions,\n} from \"./build-assets-map\";\n\nexport {\n default as GenerateJsonPlugin,\n type GenerateJsonPluginData,\n type GenerateJsonPluginUpdate,\n} from \"./generate-json\";\n\nexport {\n GenerateModulePlugin,\n type GenerateModulePluginDependencies,\n type GenerateModulePluginDependenciesResolver,\n type GenerateModulePluginModules,\n type GenerateModulePluginUpdate,\n} from \"./generate-module\";\n\nexport {default as ManifestPlugin} from \"./manifest\";\n\nexport {\n default as ResourceAccessPlugin,\n type ResourceAccessPluginOptions,\n type ResourceAccessPluginRequirement,\n} from \"./resource-access\";\n\nexport {default as ReplacePlugin} from \"./replace\";\n\nexport {default as WatchPlugin} from \"./watch\";\n\nexport type {RuntimePropertyOptions, RuntimeModuleReaderOptions} from \"./types\";\n"],"mappings":"AAAA;AAAA,EACe,WAAXA;AAAA,OAQG;AAEP,SAAmB,WAAXA,gBAAkE;AAE1E;AAAA,EACe,WAAXA;AAAA,OAGG;AAEP;AAAA,EACe,WAAXA;AAAA,OAGG;AAEP;AAAA,EACe,WAAXA;AAAA,OAGG;AAEP;AAAA,EACI;AAAA,OAKG;AAEP,SAAmB,WAAXA,gBAAgC;AAExC;AAAA,EACe,WAAXA;AAAA,OAGG;AAEP,SAAmB,WAAXA,gBAA+B;AAEvC,SAAmB,WAAXA,iBAA6B;","names":["default"]}
@@ -5,7 +5,7 @@ export interface IsolatedStylesPluginOptions extends RuntimePropertyOptions {
5
5
  cssChunkFilename: Filename;
6
6
  test: (entry: string) => boolean;
7
7
  timeout?: number;
8
- /** Inspects every entry's initial, shared and async CSS, independently of test. Throw to reject; return warning messages to report without changing delivery. */
8
+ /** Inspects every entry's initial, shared and async CSS using its delivery policy. Throw to reject; return warning messages without changing delivery. */
9
9
  validate?: (entry: string, files: IsolatedStylesPluginFiles) => void | readonly string[];
10
10
  }
11
11
  /** CSS destinations in one entrypoint's complete dependency graph, for build diagnostics only. */
@@ -1,8 +1,9 @@
1
1
  import { RuntimeGlobals, RuntimeModule } from "@rspack/core";
2
- import { getIsolatedStylesFiles, isIsolatedStylesChunk } from "./../../../../cli/bundler/utils/styles.js";
3
2
  import { CssContentHashType, filenameRequiresFullHash, resolveChunkFilename } from "./../../../../cli/bundler/utils/chunk-filename.js";
4
3
  import { getManifestHooks } from "../utils/manifest-hooks.js";
5
4
  import { renderIsolatedStylesCssLoader, renderIsolatedStylesRuntime } from "./templates.js";
5
+ import { getStylesFiles, isIsolatedStylesChunk } from "./chunks.js";
6
+ import { createStylesCacheGroup, DocumentStylesCacheGroup } from "./split-chunks.js";
6
7
  const PluginName = "IsolatedStylesPlugin";
7
8
  const CssLoadingRuntimeIdentifier = "webpack/runtime/css loading";
8
9
  const CssRuntimeBoundary = "// object to store loaded CSS chunks";
@@ -25,7 +26,9 @@ class IsolatedStylesRuntimeModule extends RuntimeModule {
25
26
  cssChunkFilename;
26
27
  generate() {
27
28
  const compilation = this.compilation;
28
- if (!compilation) throw new Error("Isolated styles runtime is not attached to a compilation");
29
+ if (!compilation) {
30
+ throw new Error("Isolated styles runtime is not attached to a compilation");
31
+ }
29
32
  const initialStyles = initialStyleChunks(compilation, this.entry, this.cssFilename, this.cssChunkFilename).map(
30
33
  ({ chunk, filename }) => resolveChunkFilename(compilation, chunk, filename, CssContentHashType)
31
34
  );
@@ -40,9 +43,10 @@ class IsolatedStylesRuntimeModule extends RuntimeModule {
40
43
  }
41
44
  const initialStyleChunks = (compilation, entry, cssFilename, cssChunkFilename) => {
42
45
  const entrypoint = compilation.entrypoints.get(entry);
43
- if (!entrypoint) throw new Error(`Isolated styles entrypoint "${entry}" is unavailable`);
44
- const entryChunk = entrypoint.getEntrypointChunk();
45
- return Array.from(entrypoint.chunks).filter((chunk) => isIsolatedStylesChunk(compilation, chunk)).map((chunk) => ({ chunk, filename: chunk === entryChunk ? cssFilename : cssChunkFilename }));
46
+ if (!entrypoint) {
47
+ throw new Error(`Isolated styles entrypoint "${entry}" is unavailable`);
48
+ }
49
+ return Array.from(entrypoint.chunks).filter((chunk) => isIsolatedStylesChunk(compilation, chunk)).map((chunk) => ({ chunk, filename: chunk.canBeInitial() ? cssFilename : cssChunkFilename }));
46
50
  };
47
51
  const hasAsyncCss = (chunk) => {
48
52
  return Array.from(chunk.getAllAsyncChunks()).some((candidate) => {
@@ -56,14 +60,31 @@ class IsolatedStylesPlugin {
56
60
  options;
57
61
  originalRuntimeSources = /* @__PURE__ */ new WeakMap();
58
62
  apply(compiler) {
63
+ const cacheGroup = createStylesCacheGroup(compiler, this.options.test);
64
+ compiler.hooks.afterEnvironment.tap(PluginName, () => {
65
+ const splitChunks = compiler.options.optimization.splitChunks;
66
+ if (splitChunks) {
67
+ splitChunks.cacheGroups = {
68
+ [DocumentStylesCacheGroup]: cacheGroup,
69
+ ...splitChunks.cacheGroups
70
+ };
71
+ }
72
+ });
59
73
  compiler.hooks.compilation.tap(PluginName, (compilation) => {
60
74
  getManifestHooks(compilation).prepareDependencies.tap(PluginName, (dependencies) => {
61
- const isolatedFiles = getIsolatedStylesFiles(compilation);
75
+ var _a;
62
76
  for (const [entry, dependency] of dependencies) {
63
- if (!this.options.test(entry)) continue;
77
+ if (!this.options.test(entry)) {
78
+ continue;
79
+ }
80
+ const files = getStylesFiles(compilation, ((_a = compilation.entrypoints.get(entry)) == null ? void 0 : _a.chunks) ?? []);
64
81
  for (const file of dependency.css) {
65
- if (!isolatedFiles.has(file)) continue;
66
- dependency.css.delete(file);
82
+ if (!files.defaults.has(file)) {
83
+ continue;
84
+ }
85
+ if (!files.document.has(file)) {
86
+ dependency.css.delete(file);
87
+ }
67
88
  dependency.assets.add(file);
68
89
  }
69
90
  }
@@ -127,7 +148,7 @@ class IsolatedStylesPlugin {
127
148
  }
128
149
  source.source = renderIsolatedStylesCssLoader({
129
150
  isolatedChunks: Object.fromEntries(
130
- [...compilation.chunks].filter((candidate) => isIsolatedStylesChunk(compilation, candidate)).map((candidate) => [candidate.id, true])
151
+ [...chunk.getAllReferencedChunks()].filter((candidate) => isIsolatedStylesChunk(compilation, candidate)).map((candidate) => [candidate.id, true])
131
152
  ),
132
153
  originalLoader: originalSource.slice(0, boundary),
133
154
  cssFilenameExpression: filenameExpression,
@@ -149,16 +170,20 @@ class IsolatedStylesPlugin {
149
170
  ...entrypoint.getEntrypointChunk().getAllReferencedChunks()
150
171
  ]);
151
172
  for (const candidate of referenced) {
152
- const destination = isIsolatedStylesChunk(compilation, candidate) ? isolated : document;
173
+ const destination = this.options.test(entry) && isIsolatedStylesChunk(compilation, candidate) ? isolated : document;
153
174
  for (const file of candidate.files) {
154
- if (file.endsWith(".css")) destination.add(file);
175
+ if (file.endsWith(".css")) {
176
+ destination.add(file);
177
+ }
155
178
  }
156
179
  }
157
180
  const warnings = this.options.validate(entry, {
158
181
  document: [...document].sort(),
159
182
  isolated: [...isolated].sort()
160
183
  });
161
- for (const message of warnings ?? []) compilation.warnings.push(new Error(message));
184
+ for (const message of warnings ?? []) {
185
+ compilation.warnings.push(new Error(message));
186
+ }
162
187
  }
163
188
  if (chunk && chunk.name !== void 0 && this.options.test(chunk.name) && hasAsyncCss(entrypoint.getEntrypointChunk()) && !patched.has(chunk)) {
164
189
  throw new Error(`CSS loading runtime for isolated entrypoint "${chunk.name}" was not replaced`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.ts"],"sourcesContent":["import {type Chunk, type Compilation, type Compiler, type Filename, RuntimeGlobals, RuntimeModule} from \"@rspack/core\";\n\nimport {getIsolatedStylesFiles, isIsolatedStylesChunk} from \"@cli/bundler/utils/styles\";\nimport {CssContentHashType, filenameRequiresFullHash, resolveChunkFilename} from \"@cli/bundler/utils/chunk-filename\";\nimport type {RuntimePropertyOptions} from \"../types\";\nimport {getManifestHooks} from \"../utils/manifest-hooks\";\n\nimport {renderIsolatedStylesCssLoader, renderIsolatedStylesRuntime} from \"./templates\";\n\nconst PluginName = \"IsolatedStylesPlugin\";\nconst CssLoadingRuntimeIdentifier = \"webpack/runtime/css loading\";\nconst CssRuntimeBoundary = \"// object to store loaded CSS chunks\";\nconst CssFilenameExpression = /var href = (.+?)\\(chunkId\\);/;\n\nexport interface IsolatedStylesPluginOptions extends RuntimePropertyOptions {\n cssFilename: Filename;\n cssChunkFilename: Filename;\n test: (entry: string) => boolean;\n timeout?: number;\n /** Inspects every entry's initial, shared and async CSS, independently of test. Throw to reject; return warning messages to report without changing delivery. */\n validate?: (entry: string, files: IsolatedStylesPluginFiles) => void | readonly string[];\n}\n\n/** CSS destinations in one entrypoint's complete dependency graph, for build diagnostics only. */\nexport interface IsolatedStylesPluginFiles {\n readonly document: readonly string[];\n readonly isolated: readonly string[];\n}\n\nclass IsolatedStylesRuntimeModule extends RuntimeModule {\n public constructor(\n private readonly entry: string,\n private readonly property: string,\n private readonly timeout: number,\n private readonly cssFilename: Filename,\n private readonly cssChunkFilename: Filename,\n fullHash: boolean\n ) {\n super(`isolated styles ${entry}`, RuntimeModule.STAGE_ATTACH);\n this.dependentHash = true;\n this.fullHash = fullHash;\n }\n\n public generate(): string {\n const compilation = this.compilation;\n if (!compilation) throw new Error(\"Isolated styles runtime is not attached to a compilation\");\n\n const initialStyles = initialStyleChunks(compilation, this.entry, this.cssFilename, this.cssChunkFilename).map(\n ({chunk, filename}) => resolveChunkFilename(compilation, chunk, filename, CssContentHashType)\n );\n\n return renderIsolatedStylesRuntime({\n entry: this.entry,\n require: RuntimeGlobals.require,\n property: this.property,\n timeout: this.timeout,\n initialStyles,\n });\n }\n}\n\nconst initialStyleChunks = (\n compilation: Compilation,\n entry: string,\n cssFilename: Filename,\n cssChunkFilename: Filename\n): {chunk: Chunk; filename: Filename}[] => {\n const entrypoint = compilation.entrypoints.get(entry);\n if (!entrypoint) throw new Error(`Isolated styles entrypoint \"${entry}\" is unavailable`);\n\n const entryChunk = entrypoint.getEntrypointChunk();\n return Array.from(entrypoint.chunks)\n .filter(chunk => isIsolatedStylesChunk(compilation, chunk))\n .map(chunk => ({chunk, filename: chunk === entryChunk ? cssFilename : cssChunkFilename}));\n};\n\nconst hasAsyncCss = (chunk: Chunk): boolean => {\n return Array.from(chunk.getAllAsyncChunks()).some(candidate => {\n return [...candidate.files, ...candidate.auxiliaryFiles].some(file => file.endsWith(\".css\"));\n });\n};\n\nexport default class IsolatedStylesPlugin {\n private readonly originalRuntimeSources = new WeakMap<RuntimeModule, string>();\n\n public constructor(private readonly options: IsolatedStylesPluginOptions) {}\n\n public apply(compiler: Compiler): void {\n compiler.hooks.compilation.tap(PluginName, compilation => {\n getManifestHooks(compilation).prepareDependencies.tap(PluginName, dependencies => {\n const isolatedFiles = getIsolatedStylesFiles(compilation);\n for (const [entry, dependency] of dependencies) {\n if (!this.options.test(entry)) continue;\n\n for (const file of dependency.css) {\n if (!isolatedFiles.has(file)) continue;\n dependency.css.delete(file);\n dependency.assets.add(file);\n }\n }\n });\n });\n\n const timeout = this.options.timeout ?? compiler.options.output.chunkLoadTimeout ?? 120_000;\n\n compiler.hooks.thisCompilation.tap(PluginName, compilation => {\n const injected = new Set<Chunk>();\n const patched = new Set<Chunk>();\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(PluginName, (chunk, requirements) => {\n if (chunk.name === undefined || !this.options.test(chunk.name) || injected.has(chunk)) {\n return;\n }\n\n requirements.add(RuntimeGlobals.require);\n requirements.add(RuntimeGlobals.publicPath);\n injected.add(chunk);\n const fullHash = initialStyleChunks(\n compilation,\n chunk.name,\n this.options.cssFilename,\n this.options.cssChunkFilename\n ).some(({chunk, filename}) =>\n filenameRequiresFullHash(compilation, chunk, filename, CssContentHashType)\n );\n compilation.addRuntimeModule(\n chunk,\n new IsolatedStylesRuntimeModule(\n chunk.name,\n this.options.property,\n timeout,\n this.options.cssFilename,\n this.options.cssChunkFilename,\n fullHash\n )\n );\n });\n\n compilation.hooks.runtimeModule.tap(PluginName, (runtimeModule, chunk) => {\n if (chunk.name === undefined || runtimeModule.identifier() !== CssLoadingRuntimeIdentifier) {\n return;\n }\n\n const source = runtimeModule.source;\n\n if (!source || typeof source.source !== \"string\") {\n throw new Error(\n `CSS loading runtime source for isolated entrypoint \"${chunk.name}\" is unavailable`\n );\n }\n\n if (source.source.length === 0) {\n return;\n }\n\n const originalSource = this.originalRuntimeSources.get(runtimeModule) ?? source.source;\n this.originalRuntimeSources.set(runtimeModule, originalSource);\n source.source = originalSource;\n\n if (!this.options.test(chunk.name)) {\n return;\n }\n\n const boundary = originalSource.indexOf(CssRuntimeBoundary);\n const filenameExpression = originalSource.match(CssFilenameExpression)?.[1];\n\n if (boundary < 0 || !filenameExpression) {\n throw new Error(`CSS loading runtime seam for isolated entrypoint \"${chunk.name}\" is unavailable`);\n }\n\n source.source = renderIsolatedStylesCssLoader({\n isolatedChunks: Object.fromEntries(\n [...compilation.chunks]\n .filter(candidate => isIsolatedStylesChunk(compilation, candidate))\n .map(candidate => [candidate.id, true])\n ),\n originalLoader: originalSource.slice(0, boundary),\n cssFilenameExpression: filenameExpression,\n originalRuntime: originalSource.slice(boundary),\n publicPath: RuntimeGlobals.publicPath,\n require: RuntimeGlobals.require,\n property: this.options.property,\n });\n patched.add(chunk);\n });\n\n compilation.hooks.afterSeal.tap(PluginName, () => {\n for (const [entry, entrypoint] of compilation.entrypoints) {\n const chunk = entrypoint.getRuntimeChunk();\n\n if (this.options.validate) {\n const document = new Set<string>();\n const isolated = new Set<string>();\n const referenced = new Set([\n ...entrypoint.chunks,\n ...entrypoint.getEntrypointChunk().getAllReferencedChunks(),\n ]);\n for (const candidate of referenced) {\n const destination = isIsolatedStylesChunk(compilation, candidate) ? isolated : document;\n for (const file of candidate.files) {\n if (file.endsWith(\".css\")) destination.add(file);\n }\n }\n const warnings = this.options.validate(entry, {\n document: [...document].sort(),\n isolated: [...isolated].sort(),\n });\n for (const message of warnings ?? []) compilation.warnings.push(new Error(message));\n }\n\n if (\n chunk &&\n chunk.name !== undefined &&\n this.options.test(chunk.name) &&\n hasAsyncCss(entrypoint.getEntrypointChunk()) &&\n !patched.has(chunk)\n ) {\n throw new Error(`CSS loading runtime for isolated entrypoint \"${chunk.name}\" was not replaced`);\n }\n }\n });\n });\n }\n}\n"],"mappings":"AAAA,SAAoE,gBAAgB,qBAAoB;AAExG,SAAQ,wBAAwB,6BAA4B;AAC5D,SAAQ,oBAAoB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;AACE,kBAAM,IAAI,MAAM,gDAAgD,MAAM,IAAI,oBAAoB;AAAA,UAClG;AAAA,QACJ;AAAA,MACJ,CAAC;AAAA,IACL,CAAC;AAAA,EACL;AACJ;","names":["chunk"]}
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.ts"],"sourcesContent":["import {type Chunk, type Compilation, type Compiler, type Filename, RuntimeGlobals, RuntimeModule} from \"@rspack/core\";\n\nimport {CssContentHashType, filenameRequiresFullHash, resolveChunkFilename} from \"@cli/bundler/utils/chunk-filename\";\nimport type {RuntimePropertyOptions} from \"../types\";\nimport {getManifestHooks} from \"../utils/manifest-hooks\";\n\nimport {renderIsolatedStylesCssLoader, renderIsolatedStylesRuntime} from \"./templates\";\nimport {getStylesFiles, isIsolatedStylesChunk} from \"./chunks\";\nimport {createStylesCacheGroup, DocumentStylesCacheGroup} from \"./split-chunks\";\n\nconst PluginName = \"IsolatedStylesPlugin\";\nconst CssLoadingRuntimeIdentifier = \"webpack/runtime/css loading\";\nconst CssRuntimeBoundary = \"// object to store loaded CSS chunks\";\nconst CssFilenameExpression = /var href = (.+?)\\(chunkId\\);/;\n\nexport interface IsolatedStylesPluginOptions extends RuntimePropertyOptions {\n cssFilename: Filename;\n cssChunkFilename: Filename;\n test: (entry: string) => boolean;\n timeout?: number;\n /** Inspects every entry's initial, shared and async CSS using its delivery policy. Throw to reject; return warning messages without changing delivery. */\n validate?: (entry: string, files: IsolatedStylesPluginFiles) => void | readonly string[];\n}\n\n/** CSS destinations in one entrypoint's complete dependency graph, for build diagnostics only. */\nexport interface IsolatedStylesPluginFiles {\n readonly document: readonly string[];\n readonly isolated: readonly string[];\n}\n\nclass IsolatedStylesRuntimeModule extends RuntimeModule {\n public constructor(\n private readonly entry: string,\n private readonly property: string,\n private readonly timeout: number,\n private readonly cssFilename: Filename,\n private readonly cssChunkFilename: Filename,\n fullHash: boolean\n ) {\n super(`isolated styles ${entry}`, RuntimeModule.STAGE_ATTACH);\n this.dependentHash = true;\n this.fullHash = fullHash;\n }\n\n public generate(): string {\n const compilation = this.compilation;\n\n if (!compilation) {\n throw new Error(\"Isolated styles runtime is not attached to a compilation\");\n }\n\n const initialStyles = initialStyleChunks(compilation, this.entry, this.cssFilename, this.cssChunkFilename).map(\n ({chunk, filename}) => resolveChunkFilename(compilation, chunk, filename, CssContentHashType)\n );\n\n return renderIsolatedStylesRuntime({\n entry: this.entry,\n require: RuntimeGlobals.require,\n property: this.property,\n timeout: this.timeout,\n initialStyles,\n });\n }\n}\n\nconst initialStyleChunks = (\n compilation: Compilation,\n entry: string,\n cssFilename: Filename,\n cssChunkFilename: Filename\n): {chunk: Chunk; filename: Filename}[] => {\n const entrypoint = compilation.entrypoints.get(entry);\n\n if (!entrypoint) {\n throw new Error(`Isolated styles entrypoint \"${entry}\" is unavailable`);\n }\n\n return Array.from(entrypoint.chunks)\n .filter(chunk => isIsolatedStylesChunk(compilation, chunk))\n .map(chunk => ({chunk, filename: chunk.canBeInitial() ? cssFilename : cssChunkFilename}));\n};\n\nconst hasAsyncCss = (chunk: Chunk): boolean => {\n return Array.from(chunk.getAllAsyncChunks()).some(candidate => {\n return [...candidate.files, ...candidate.auxiliaryFiles].some(file => file.endsWith(\".css\"));\n });\n};\n\nexport default class IsolatedStylesPlugin {\n private readonly originalRuntimeSources = new WeakMap<RuntimeModule, string>();\n\n public constructor(private readonly options: IsolatedStylesPluginOptions) {}\n\n public apply(compiler: Compiler): void {\n const cacheGroup = createStylesCacheGroup(compiler, this.options.test);\n\n // Defaults are resolved before this hook; SplitChunksPlugin is configured afterwards.\n compiler.hooks.afterEnvironment.tap(PluginName, () => {\n const splitChunks = compiler.options.optimization.splitChunks;\n\n if (splitChunks) {\n splitChunks.cacheGroups = {\n [DocumentStylesCacheGroup]: cacheGroup,\n ...splitChunks.cacheGroups,\n };\n }\n });\n\n compiler.hooks.compilation.tap(PluginName, compilation => {\n getManifestHooks(compilation).prepareDependencies.tap(PluginName, dependencies => {\n for (const [entry, dependency] of dependencies) {\n if (!this.options.test(entry)) {\n continue;\n }\n\n const files = getStylesFiles(compilation, compilation.entrypoints.get(entry)?.chunks ?? []);\n\n for (const file of dependency.css) {\n if (!files.defaults.has(file)) {\n continue;\n }\n\n // Identical CSS can have the same contenthash filename in both destinations.\n if (!files.document.has(file)) {\n dependency.css.delete(file);\n }\n\n dependency.assets.add(file);\n }\n }\n });\n });\n\n const timeout = this.options.timeout ?? compiler.options.output.chunkLoadTimeout ?? 120_000;\n\n compiler.hooks.thisCompilation.tap(PluginName, compilation => {\n const injected = new Set<Chunk>();\n const patched = new Set<Chunk>();\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(PluginName, (chunk, requirements) => {\n if (chunk.name === undefined || !this.options.test(chunk.name) || injected.has(chunk)) {\n return;\n }\n\n requirements.add(RuntimeGlobals.require);\n requirements.add(RuntimeGlobals.publicPath);\n injected.add(chunk);\n\n const fullHash = initialStyleChunks(\n compilation,\n chunk.name,\n this.options.cssFilename,\n this.options.cssChunkFilename\n ).some(({chunk, filename}) =>\n filenameRequiresFullHash(compilation, chunk, filename, CssContentHashType)\n );\n\n compilation.addRuntimeModule(\n chunk,\n new IsolatedStylesRuntimeModule(\n chunk.name,\n this.options.property,\n timeout,\n this.options.cssFilename,\n this.options.cssChunkFilename,\n fullHash\n )\n );\n });\n\n compilation.hooks.runtimeModule.tap(PluginName, (runtimeModule, chunk) => {\n if (chunk.name === undefined || runtimeModule.identifier() !== CssLoadingRuntimeIdentifier) {\n return;\n }\n\n const source = runtimeModule.source;\n\n if (!source || typeof source.source !== \"string\") {\n throw new Error(\n `CSS loading runtime source for isolated entrypoint \"${chunk.name}\" is unavailable`\n );\n }\n\n if (source.source.length === 0) {\n return;\n }\n\n const originalSource = this.originalRuntimeSources.get(runtimeModule) ?? source.source;\n this.originalRuntimeSources.set(runtimeModule, originalSource);\n source.source = originalSource;\n\n if (!this.options.test(chunk.name)) {\n return;\n }\n\n const boundary = originalSource.indexOf(CssRuntimeBoundary);\n const filenameExpression = originalSource.match(CssFilenameExpression)?.[1];\n\n if (boundary < 0 || !filenameExpression) {\n throw new Error(`CSS loading runtime seam for isolated entrypoint \"${chunk.name}\" is unavailable`);\n }\n\n source.source = renderIsolatedStylesCssLoader({\n isolatedChunks: Object.fromEntries(\n [...chunk.getAllReferencedChunks()]\n .filter(candidate => isIsolatedStylesChunk(compilation, candidate))\n .map(candidate => [candidate.id, true])\n ),\n originalLoader: originalSource.slice(0, boundary),\n cssFilenameExpression: filenameExpression,\n originalRuntime: originalSource.slice(boundary),\n publicPath: RuntimeGlobals.publicPath,\n require: RuntimeGlobals.require,\n property: this.options.property,\n });\n\n patched.add(chunk);\n });\n\n compilation.hooks.afterSeal.tap(PluginName, () => {\n for (const [entry, entrypoint] of compilation.entrypoints) {\n const chunk = entrypoint.getRuntimeChunk();\n\n if (this.options.validate) {\n const document = new Set<string>();\n const isolated = new Set<string>();\n\n const referenced = new Set([\n ...entrypoint.chunks,\n ...entrypoint.getEntrypointChunk().getAllReferencedChunks(),\n ]);\n\n for (const candidate of referenced) {\n const destination =\n this.options.test(entry) && isIsolatedStylesChunk(compilation, candidate)\n ? isolated\n : document;\n\n for (const file of candidate.files) {\n if (file.endsWith(\".css\")) {\n destination.add(file);\n }\n }\n }\n\n const warnings = this.options.validate(entry, {\n document: [...document].sort(),\n isolated: [...isolated].sort(),\n });\n\n for (const message of warnings ?? []) {\n compilation.warnings.push(new Error(message));\n }\n }\n\n if (\n chunk &&\n chunk.name !== undefined &&\n this.options.test(chunk.name) &&\n hasAsyncCss(entrypoint.getEntrypointChunk()) &&\n !patched.has(chunk)\n ) {\n throw new Error(`CSS loading runtime for isolated entrypoint \"${chunk.name}\" was not replaced`);\n }\n }\n });\n });\n }\n}\n"],"mappings":"AAAA,SAAoE,gBAAgB,qBAAoB;AAExG,SAAQ,oBAAoB,0BAA0B,4BAA2B;AAEjF,SAAQ,wBAAuB;AAE/B,SAAQ,+BAA+B,mCAAkC;AACzE,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OAAO;AAChC,oBAAI,KAAK,SAAS,MAAM,GAAG;AACvB,8BAAY,IAAI,IAAI;AAAA,gBACxB;AAAA,cACJ;AAAA,YACJ;AAEA,kBAAM,WAAW,KAAK,QAAQ,SAAS,OAAO;AAAA,cAC1C,UAAU,CAAC,GAAG,QAAQ,EAAE,KAAK;AAAA,cAC7B,UAAU,CAAC,GAAG,QAAQ,EAAE,KAAK;AAAA,YACjC,CAAC;AAED,uBAAW,WAAW,YAAY,CAAC,GAAG;AAClC,0BAAY,SAAS,KAAK,IAAI,MAAM,OAAO,CAAC;AAAA,YAChD;AAAA,UACJ;AAEA,cACI,SACA,MAAM,SAAS,UACf,KAAK,QAAQ,KAAK,MAAM,IAAI,KAC5B,YAAY,WAAW,mBAAmB,CAAC,KAC3C,CAAC,QAAQ,IAAI,KAAK,GACpB;AACE,kBAAM,IAAI,MAAM,gDAAgD,MAAM,IAAI,oBAAoB;AAAA,UAClG;AAAA,QACJ;AAAA,MACJ,CAAC;AAAA,IACL,CAAC;AAAA,EACL;AACJ;","names":["chunk"]}
@@ -0,0 +1,7 @@
1
+ import type { Chunk, Compilation } from "@rspack/core";
2
+ /** Only call for chunks reachable by an entry with isolated delivery. Other entries may mix CSS categories. */
3
+ export declare const isIsolatedStylesChunk: (compilation: Compilation, chunk: Chunk) => boolean;
4
+ export declare const getStylesFiles: (compilation: Compilation, chunks: Iterable<Chunk>) => {
5
+ document: ReadonlySet<string>;
6
+ defaults: ReadonlySet<string>;
7
+ };
@@ -0,0 +1,33 @@
1
+ import { DocumentStylesLayer } from "./../../../../cli/bundler/layers.js";
2
+ import { DocumentStylesCacheGroup } from "./split-chunks.js";
3
+ const isDocumentStylesModule = (module) => module.layer === DocumentStylesLayer;
4
+ const isIsolatedStylesChunk = (compilation, chunk) => {
5
+ const modules = [...compilation.chunkGraph.getChunkModulesIterable(chunk)].filter(
6
+ (module) => module.type === "css/mini-extract"
7
+ );
8
+ const document = modules.some(isDocumentStylesModule);
9
+ if (document && !modules.every(isDocumentStylesModule)) {
10
+ throw new Error(
11
+ `CSS chunk "${chunk.name ?? chunk.id}" mixes document and default styles for isolated delivery. Preserve the ${DocumentStylesCacheGroup} CSS cache group in your bundler configuration.`
12
+ );
13
+ }
14
+ return modules.length > 0 && !document;
15
+ };
16
+ const getStylesFiles = (compilation, chunks) => {
17
+ const document = /* @__PURE__ */ new Set();
18
+ const defaults = /* @__PURE__ */ new Set();
19
+ for (const chunk of chunks) {
20
+ const files = isIsolatedStylesChunk(compilation, chunk) ? defaults : document;
21
+ for (const file of chunk.files) {
22
+ if (file.endsWith(".css")) {
23
+ files.add(file);
24
+ }
25
+ }
26
+ }
27
+ return { document, defaults };
28
+ };
29
+ export {
30
+ getStylesFiles,
31
+ isIsolatedStylesChunk
32
+ };
33
+ //# sourceMappingURL=chunks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/isolated-styles/chunks.ts"],"sourcesContent":["import type {Chunk, Compilation, Module} from \"@rspack/core\";\n\nimport {DocumentStylesLayer} from \"@cli/bundler/layers\";\nimport {DocumentStylesCacheGroup} from \"./split-chunks\";\n\nconst isDocumentStylesModule = (module: Module): boolean => module.layer === DocumentStylesLayer;\n\n/** Only call for chunks reachable by an entry with isolated delivery. Other entries may mix CSS categories. */\nexport const isIsolatedStylesChunk = (compilation: Compilation, chunk: Chunk): boolean => {\n const modules = [...compilation.chunkGraph.getChunkModulesIterable(chunk)].filter(\n module => module.type === \"css/mini-extract\"\n );\n\n const document = modules.some(isDocumentStylesModule);\n\n if (document && !modules.every(isDocumentStylesModule)) {\n throw new Error(\n `CSS chunk \"${chunk.name ?? chunk.id}\" mixes document and default styles for isolated delivery. Preserve the ${DocumentStylesCacheGroup} CSS cache group in your bundler configuration.`\n );\n }\n\n return modules.length > 0 && !document;\n};\n\nexport const getStylesFiles = (\n compilation: Compilation,\n chunks: Iterable<Chunk>\n): {document: ReadonlySet<string>; defaults: ReadonlySet<string>} => {\n const document = new Set<string>();\n const defaults = new Set<string>();\n\n for (const chunk of chunks) {\n const files = isIsolatedStylesChunk(compilation, chunk) ? defaults : document;\n\n for (const file of chunk.files) {\n if (file.endsWith(\".css\")) {\n files.add(file);\n }\n }\n }\n\n return {document, defaults};\n};\n"],"mappings":"AAEA,SAAQ,2BAA0B;AAClC,SAAQ,gCAA+B;AAEvC,MAAM,yBAAyB,CAAC,WAA4B,OAAO,UAAU;AAGtE,MAAM,wBAAwB,CAAC,aAA0B,UAA0B;AACtF,QAAM,UAAU,CAAC,GAAG,YAAY,WAAW,wBAAwB,KAAK,CAAC,EAAE;AAAA,IACvE,YAAU,OAAO,SAAS;AAAA,EAC9B;AAEA,QAAM,WAAW,QAAQ,KAAK,sBAAsB;AAEpD,MAAI,YAAY,CAAC,QAAQ,MAAM,sBAAsB,GAAG;AACpD,UAAM,IAAI;AAAA,MACN,cAAc,MAAM,QAAQ,MAAM,EAAE,2EAA2E,wBAAwB;AAAA,IAC3I;AAAA,EACJ;AAEA,SAAO,QAAQ,SAAS,KAAK,CAAC;AAClC;AAEO,MAAM,iBAAiB,CAC1B,aACA,WACiE;AACjE,QAAM,WAAW,oBAAI,IAAY;AACjC,QAAM,WAAW,oBAAI,IAAY;AAEjC,aAAW,SAAS,QAAQ;AACxB,UAAM,QAAQ,sBAAsB,aAAa,KAAK,IAAI,WAAW;AAErE,eAAW,QAAQ,MAAM,OAAO;AAC5B,UAAI,KAAK,SAAS,MAAM,GAAG;AACvB,cAAM,IAAI,IAAI;AAAA,MAClB;AAAA,IACJ;AAAA,EACJ;AAEA,SAAO,EAAC,UAAU,SAAQ;AAC9B;","names":[]}
@@ -0,0 +1,4 @@
1
+ import type { Compiler, OptimizationSplitChunksCacheGroup } from "@rspack/core";
2
+ export declare const DocumentStylesCacheGroup = "adnbnDocumentStyles";
3
+ /** Partition CSS only where an entry needs separate document and isolated delivery. */
4
+ export declare const createStylesCacheGroup: (compiler: Compiler, test: (entry: string) => boolean) => OptimizationSplitChunksCacheGroup;
@@ -0,0 +1,51 @@
1
+ import { DocumentStylesLayer } from "./../../../../cli/bundler/layers.js";
2
+ const DocumentStylesCacheGroup = "adnbnDocumentStyles";
3
+ const createStylesCacheGroup = (compiler, test) => {
4
+ let compilation;
5
+ let selectedGroups = /* @__PURE__ */ new WeakMap();
6
+ compiler.hooks.thisCompilation.tap("IsolatedStylesPlugin", (current) => {
7
+ compilation = current;
8
+ selectedGroups = /* @__PURE__ */ new WeakMap();
9
+ });
10
+ const selected = (group) => {
11
+ const cached = selectedGroups.get(group);
12
+ if (cached !== void 0) {
13
+ return cached;
14
+ }
15
+ const pending = [group];
16
+ const visited = /* @__PURE__ */ new Set();
17
+ while (pending.length) {
18
+ const parent = pending.pop();
19
+ if (visited.has(parent)) {
20
+ continue;
21
+ }
22
+ visited.add(parent);
23
+ if (parent.isInitial() && parent.name !== void 0 && test(parent.name)) {
24
+ selectedGroups.set(group, true);
25
+ return true;
26
+ }
27
+ pending.push(...parent.getParents());
28
+ }
29
+ selectedGroups.set(group, false);
30
+ return false;
31
+ };
32
+ return {
33
+ type: "css/mini-extract",
34
+ layer: DocumentStylesLayer,
35
+ chunks: (chunk) => {
36
+ const modules = compilation.chunkGraph.getChunkModulesIterable(chunk);
37
+ if (![...modules].some((module) => module.type === "css/mini-extract")) {
38
+ return false;
39
+ }
40
+ return [...chunk.groupsIterable].some(selected);
41
+ },
42
+ enforce: true,
43
+ name: false,
44
+ priority: 100
45
+ };
46
+ };
47
+ export {
48
+ DocumentStylesCacheGroup,
49
+ createStylesCacheGroup
50
+ };
51
+ //# sourceMappingURL=split-chunks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/isolated-styles/split-chunks.ts"],"sourcesContent":["import type {Chunk, ChunkGroup, Compilation, Compiler, OptimizationSplitChunksCacheGroup} from \"@rspack/core\";\n\nimport {DocumentStylesLayer} from \"@cli/bundler/layers\";\n\nexport const DocumentStylesCacheGroup = \"adnbnDocumentStyles\";\n\n/** Partition CSS only where an entry needs separate document and isolated delivery. */\nexport const createStylesCacheGroup = (\n compiler: Compiler,\n test: (entry: string) => boolean\n): OptimizationSplitChunksCacheGroup => {\n let compilation: Compilation;\n let selectedGroups = new WeakMap<ChunkGroup, boolean>();\n\n compiler.hooks.thisCompilation.tap(\"IsolatedStylesPlugin\", current => {\n compilation = current;\n selectedGroups = new WeakMap();\n });\n\n const selected = (group: ChunkGroup): boolean => {\n const cached = selectedGroups.get(group);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const pending = [group];\n const visited = new Set<ChunkGroup>();\n\n while (pending.length) {\n const parent = pending.pop()!;\n\n if (visited.has(parent)) {\n continue;\n }\n\n visited.add(parent);\n\n if (parent.isInitial() && parent.name !== undefined && test(parent.name)) {\n selectedGroups.set(group, true);\n\n return true;\n }\n\n pending.push(...parent.getParents());\n }\n\n selectedGroups.set(group, false);\n\n return false;\n };\n\n return {\n type: \"css/mini-extract\",\n layer: DocumentStylesLayer,\n chunks: (chunk: Chunk): boolean => {\n const modules = compilation.chunkGraph.getChunkModulesIterable(chunk);\n\n if (![...modules].some(module => module.type === \"css/mini-extract\")) {\n return false;\n }\n\n return [...chunk.groupsIterable].some(selected);\n },\n enforce: true,\n name: false,\n priority: 100,\n };\n};\n"],"mappings":"AAEA,SAAQ,2BAA0B;AAE3B,MAAM,2BAA2B;AAGjC,MAAM,yBAAyB,CAClC,UACA,SACoC;AACpC,MAAI;AACJ,MAAI,iBAAiB,oBAAI,QAA6B;AAEtD,WAAS,MAAM,gBAAgB,IAAI,wBAAwB,aAAW;AAClE,kBAAc;AACd,qBAAiB,oBAAI,QAAQ;AAAA,EACjC,CAAC;AAED,QAAM,WAAW,CAAC,UAA+B;AAC7C,UAAM,SAAS,eAAe,IAAI,KAAK;AAEvC,QAAI,WAAW,QAAW;AACtB,aAAO;AAAA,IACX;AAEA,UAAM,UAAU,CAAC,KAAK;AACtB,UAAM,UAAU,oBAAI,IAAgB;AAEpC,WAAO,QAAQ,QAAQ;AACnB,YAAM,SAAS,QAAQ,IAAI;AAE3B,UAAI,QAAQ,IAAI,MAAM,GAAG;AACrB;AAAA,MACJ;AAEA,cAAQ,IAAI,MAAM;AAElB,UAAI,OAAO,UAAU,KAAK,OAAO,SAAS,UAAa,KAAK,OAAO,IAAI,GAAG;AACtE,uBAAe,IAAI,OAAO,IAAI;AAE9B,eAAO;AAAA,MACX;AAEA,cAAQ,KAAK,GAAG,OAAO,WAAW,CAAC;AAAA,IACvC;AAEA,mBAAe,IAAI,OAAO,KAAK;AAE/B,WAAO;AAAA,EACX;AAEA,SAAO;AAAA,IACH,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ,CAAC,UAA0B;AAC/B,YAAM,UAAU,YAAY,WAAW,wBAAwB,KAAK;AAEpE,UAAI,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,YAAU,OAAO,SAAS,kBAAkB,GAAG;AAClE,eAAO;AAAA,MACX;AAEA,aAAO,CAAC,GAAG,MAAM,cAAc,EAAE,KAAK,QAAQ;AAAA,IAClD;AAAA,IACA,SAAS;AAAA,IACT,MAAM;AAAA,IACN,UAAU;AAAA,EACd;AACJ;","names":[]}
@@ -25,6 +25,8 @@ var attachStyle = function (root, url, retry) {
25
25
 
26
26
  if (existing) return existing.promise;
27
27
 
28
+ rootState.order.add(url);
29
+
28
30
  var resolveStyle;
29
31
  var rejectStyle;
30
32
  var promise = new Promise(function (resolve, reject) {
@@ -52,6 +54,7 @@ var attachStyle = function (root, url, retry) {
52
54
  if (error) {
53
55
  rootState.styles.delete(url);
54
56
  record.link.remove();
57
+ console.error(error);
55
58
  rejectStyle(error);
56
59
  } else {
57
60
  resolveStyle();
@@ -78,8 +81,26 @@ var attachStyle = function (root, url, retry) {
78
81
  settle(createStyleError(url, type));
79
82
  }
80
83
  };
81
- // Replace in place: appending a retry could change the CSS cascade order.
82
- root.insertBefore(link, previous || rootState.target);
84
+ // A failed link may be retried after later styles succeeded. Preserve its original position.
85
+ var next = previous || rootState.target;
86
+ var after = false;
87
+
88
+ if (!previous) {
89
+ for (var file of rootState.order) {
90
+ if (file === url) {
91
+ after = true;
92
+ } else if (after) {
93
+ var following = rootState.styles.get(file);
94
+
95
+ if (following && following.link) {
96
+ next = following.link;
97
+ break;
98
+ }
99
+ }
100
+ }
101
+ }
102
+
103
+ root.insertBefore(link, next);
83
104
  if (previous) previous.remove();
84
105
  };
85
106
  // One budget for both attempts, never another timer for the retry.
@@ -101,14 +122,23 @@ __ADNBN_REQUIRE__[__ADNBN_PROPERTY__] = {
101
122
  if (!isolatedInitialStyles)
102
123
  throw new Error('Isolated stylesheet URLs for entrypoint "' + isolatedStyleEntry + '" are not initialized');
103
124
 
104
- isolatedStyleRoots.set(root, {target: target, styles: new Map()});
125
+ isolatedStyleRoots.set(root, {target: target, styles: new Map(), order: new Set()});
105
126
 
106
127
  isolatedInitialStyles.concat(Array.from(isolatedRequestedStyles)).forEach(function (url) {
107
- attachStyle(root, url, retry).catch(function (error) {
108
- console.error(error);
109
- });
128
+ attachStyle(root, url, retry).catch(function () {});
110
129
  });
111
130
  },
131
+ ready: function (root) {
132
+ if (!isolatedStyleRoots.has(root)) {
133
+ return Promise.resolve();
134
+ }
135
+
136
+ return Promise.all(
137
+ isolatedInitialStyles.concat(Array.from(isolatedRequestedStyles)).map(function (url) {
138
+ return attachStyle(root, url);
139
+ })
140
+ ).then(function () {});
141
+ },
112
142
  delete: function (root) {
113
143
  var rootState = isolatedStyleRoots.get(root);
114
144
 
@@ -1,6 +1,5 @@
1
1
  import rspack, { Compilation } from "@rspack/core";
2
- import { getCompilationBuildAssets } from "./../../../../cli/bundler/utils/output.js";
3
- import { getManifestHooks } from "../utils/manifest-hooks.js";
2
+ import { getCompilationBuildAssets, getManifestHooks } from "../utils/index.js";
4
3
  const createManifestDependencies = (buildAssets) => {
5
4
  const entryDependencies = /* @__PURE__ */ new Map();
6
5
  Object.entries(buildAssets).forEach(([entryName, assets]) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/cli/bundler/plugins/manifest/ManifestPlugin.ts"],"sourcesContent":["import rspack, {Compilation, Compiler} from \"@rspack/core\";\n\nimport {getCompilationBuildAssets} from \"@cli/bundler/utils/output\";\nimport {getManifestHooks} from \"../utils/manifest-hooks\";\n\nimport {ManifestBuilder, ManifestDependencies, ManifestDependency} from \"@typing/manifest\";\nimport {EntrypointAssetsMap} from \"@typing/entrypoint\";\n\nexport const createManifestDependencies = (buildAssets: EntrypointAssetsMap): ManifestDependencies => {\n const entryDependencies: ManifestDependencies = new Map();\n\n Object.entries(buildAssets).forEach(([entryName, assets]) => {\n const dependencies: ManifestDependency = {\n assets: new Set([...assets.assets, ...assets.async.js, ...assets.async.css]),\n css: new Set(assets.initial.css),\n js: new Set(assets.initial.js),\n };\n\n entryDependencies.set(entryName, dependencies);\n });\n\n return entryDependencies;\n};\n\nclass ManifestPlugin {\n constructor(private readonly manifest: ManifestBuilder | (() => ManifestBuilder)) {}\n\n apply(compiler: Compiler): void {\n compiler.hooks.compilation.tap(\"ManifestPlugin\", compilation => {\n const hooks = getManifestHooks(compilation);\n\n compilation.hooks.processAssets.tapPromise(\n {\n name: \"ManifestPlugin\",\n stage: Compilation.PROCESS_ASSETS_STAGE_REPORT,\n },\n async () => {\n try {\n const buildAssets = getCompilationBuildAssets(compilation);\n\n if (!buildAssets) {\n throw new Error(\"Build assets are unavailable before manifest generation\");\n }\n\n const dependencies = createManifestDependencies(buildAssets);\n await hooks.prepareDependencies.promise(dependencies, buildAssets);\n\n const builder = typeof this.manifest === \"function\" ? this.manifest() : this.manifest;\n const manifest = builder.setDependencies(dependencies).get();\n await hooks.validate.promise(manifest);\n\n const json = JSON.stringify(manifest, null, 2);\n\n compilation.emitAsset(\"manifest.json\", new rspack.sources.RawSource(json));\n } catch (error) {\n // A manifest failure rejects this build without terminating the watch compiler.\n compilation.errors.push(error instanceof Error ? error : new Error(String(error)));\n }\n }\n );\n });\n }\n}\n\nexport default ManifestPlugin;\n"],"mappings":"AAAA,OAAO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,iBAAiB,IAAI,OAAO,QAAQ,UAAU,IAAI,CAAC;AAAA,UAC7E,SAAS,OAAO;AAEZ,wBAAY,OAAO,KAAK,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;AAAA,UACrF;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AAEA,IAAO,yBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/manifest/ManifestPlugin.ts"],"sourcesContent":["import rspack, {Compilation, Compiler} from \"@rspack/core\";\n\nimport {getCompilationBuildAssets, getManifestHooks} from \"../utils\";\n\nimport {ManifestBuilder, ManifestDependencies, ManifestDependency} from \"@typing/manifest\";\nimport {EntrypointAssetsMap} from \"@typing/entrypoint\";\n\nexport const createManifestDependencies = (buildAssets: EntrypointAssetsMap): ManifestDependencies => {\n const entryDependencies: ManifestDependencies = new Map();\n\n Object.entries(buildAssets).forEach(([entryName, assets]) => {\n const dependencies: ManifestDependency = {\n assets: new Set([...assets.assets, ...assets.async.js, ...assets.async.css]),\n css: new Set(assets.initial.css),\n js: new Set(assets.initial.js),\n };\n\n entryDependencies.set(entryName, dependencies);\n });\n\n return entryDependencies;\n};\n\nclass ManifestPlugin {\n constructor(private readonly manifest: ManifestBuilder | (() => ManifestBuilder)) {}\n\n apply(compiler: Compiler): void {\n compiler.hooks.compilation.tap(\"ManifestPlugin\", compilation => {\n const hooks = getManifestHooks(compilation);\n\n compilation.hooks.processAssets.tapPromise(\n {\n name: \"ManifestPlugin\",\n stage: Compilation.PROCESS_ASSETS_STAGE_REPORT,\n },\n async () => {\n try {\n const buildAssets = getCompilationBuildAssets(compilation);\n\n if (!buildAssets) {\n throw new Error(\"Build assets are unavailable before manifest generation\");\n }\n\n const dependencies = createManifestDependencies(buildAssets);\n await hooks.prepareDependencies.promise(dependencies, buildAssets);\n\n const builder = typeof this.manifest === \"function\" ? this.manifest() : this.manifest;\n const manifest = builder.setDependencies(dependencies).get();\n await hooks.validate.promise(manifest);\n\n const json = JSON.stringify(manifest, null, 2);\n\n compilation.emitAsset(\"manifest.json\", new rspack.sources.RawSource(json));\n } catch (error) {\n // A manifest failure rejects this build without terminating the watch compiler.\n compilation.errors.push(error instanceof Error ? error : new Error(String(error)));\n }\n }\n );\n });\n }\n}\n\nexport default ManifestPlugin;\n"],"mappings":"AAAA,OAAO,UAAS,mBAA4B;AAE5C,SAAQ,2BAA2B,wBAAuB;AAKnD,MAAM,6BAA6B,CAAC,gBAA2D;AAClG,QAAM,oBAA0C,oBAAI,IAAI;AAExD,SAAO,QAAQ,WAAW,EAAE,QAAQ,CAAC,CAAC,WAAW,MAAM,MAAM;AACzD,UAAM,eAAmC;AAAA,MACrC,QAAQ,oBAAI,IAAI,CAAC,GAAG,OAAO,QAAQ,GAAG,OAAO,MAAM,IAAI,GAAG,OAAO,MAAM,GAAG,CAAC;AAAA,MAC3E,KAAK,IAAI,IAAI,OAAO,QAAQ,GAAG;AAAA,MAC/B,IAAI,IAAI,IAAI,OAAO,QAAQ,EAAE;AAAA,IACjC;AAEA,sBAAkB,IAAI,WAAW,YAAY;AAAA,EACjD,CAAC;AAED,SAAO;AACX;AAEA,MAAM,eAAe;AAAA,EACjB,YAA6B,UAAqD;AAArD;AAAA,EAAsD;AAAA,EAAtD;AAAA,EAE7B,MAAM,UAA0B;AAC5B,aAAS,MAAM,YAAY,IAAI,kBAAkB,iBAAe;AAC5D,YAAM,QAAQ,iBAAiB,WAAW;AAE1C,kBAAY,MAAM,cAAc;AAAA,QAC5B;AAAA,UACI,MAAM;AAAA,UACN,OAAO,YAAY;AAAA,QACvB;AAAA,QACA,YAAY;AACR,cAAI;AACA,kBAAM,cAAc,0BAA0B,WAAW;AAEzD,gBAAI,CAAC,aAAa;AACd,oBAAM,IAAI,MAAM,yDAAyD;AAAA,YAC7E;AAEA,kBAAM,eAAe,2BAA2B,WAAW;AAC3D,kBAAM,MAAM,oBAAoB,QAAQ,cAAc,WAAW;AAEjE,kBAAM,UAAU,OAAO,KAAK,aAAa,aAAa,KAAK,SAAS,IAAI,KAAK;AAC7E,kBAAM,WAAW,QAAQ,gBAAgB,YAAY,EAAE,IAAI;AAC3D,kBAAM,MAAM,SAAS,QAAQ,QAAQ;AAErC,kBAAM,OAAO,KAAK,UAAU,UAAU,MAAM,CAAC;AAE7C,wBAAY,UAAU,iBAAiB,IAAI,OAAO,QAAQ,UAAU,IAAI,CAAC;AAAA,UAC7E,SAAS,OAAO;AAEZ,wBAAY,OAAO,KAAK,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;AAAA,UACrF;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AAEA,IAAO,yBAAQ;","names":[]}
@@ -2,3 +2,7 @@
2
2
  export interface RuntimePropertyOptions {
3
3
  readonly property: string;
4
4
  }
5
+ /** Names a module export that reads one property of the calling bundler runtime. */
6
+ export interface RuntimeModuleReaderOptions extends RuntimePropertyOptions {
7
+ readonly export: string;
8
+ }
@@ -0,0 +1,4 @@
1
+ import type { Compilation } from "@rspack/core";
2
+ import type { EntrypointAssetsMap } from "../../../../types/entrypoint.js";
3
+ export declare const setCompilationBuildAssets: (compilation: Compilation, assets: EntrypointAssetsMap) => void;
4
+ export declare const getCompilationBuildAssets: (compilation: Compilation) => EntrypointAssetsMap | undefined;
@@ -0,0 +1,12 @@
1
+ const compilationBuildAssets = /* @__PURE__ */ new WeakMap();
2
+ const setCompilationBuildAssets = (compilation, assets) => {
3
+ compilationBuildAssets.set(compilation, assets);
4
+ };
5
+ const getCompilationBuildAssets = (compilation) => {
6
+ return compilationBuildAssets.get(compilation);
7
+ };
8
+ export {
9
+ getCompilationBuildAssets,
10
+ setCompilationBuildAssets
11
+ };
12
+ //# sourceMappingURL=compilation-assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/utils/compilation-assets.ts"],"sourcesContent":["import type {Compilation} from \"@rspack/core\";\n\nimport type {EntrypointAssetsMap} from \"@typing/entrypoint\";\n\nconst compilationBuildAssets = new WeakMap<Compilation, EntrypointAssetsMap>();\n\nexport const setCompilationBuildAssets = (compilation: Compilation, assets: EntrypointAssetsMap): void => {\n compilationBuildAssets.set(compilation, assets);\n};\n\nexport const getCompilationBuildAssets = (compilation: Compilation): EntrypointAssetsMap | undefined => {\n return compilationBuildAssets.get(compilation);\n};\n"],"mappings":"AAIA,MAAM,yBAAyB,oBAAI,QAA0C;AAEtE,MAAM,4BAA4B,CAAC,aAA0B,WAAsC;AACtG,yBAAuB,IAAI,aAAa,MAAM;AAClD;AAEO,MAAM,4BAA4B,CAAC,gBAA8D;AACpG,SAAO,uBAAuB,IAAI,WAAW;AACjD;","names":[]}
@@ -1,3 +1,5 @@
1
1
  export { getManifestHooks, type ManifestHooks } from "./manifest-hooks.js";
2
2
  export { renderRuntimeTemplate } from "./runtime-template.js";
3
3
  export { watchCompilation } from "./watch-compilation.js";
4
+ export { createRuntimeModule } from "./runtime-module.js";
5
+ export { getCompilationBuildAssets, setCompilationBuildAssets } from "./compilation-assets.js";
@@ -1,9 +1,14 @@
1
1
  import { getManifestHooks } from "./manifest-hooks.js";
2
2
  import { renderRuntimeTemplate } from "./runtime-template.js";
3
3
  import { watchCompilation } from "./watch-compilation.js";
4
+ import { createRuntimeModule } from "./runtime-module.js";
5
+ import { getCompilationBuildAssets, setCompilationBuildAssets } from "./compilation-assets.js";
4
6
  export {
7
+ createRuntimeModule,
8
+ getCompilationBuildAssets,
5
9
  getManifestHooks,
6
10
  renderRuntimeTemplate,
11
+ setCompilationBuildAssets,
7
12
  watchCompilation
8
13
  };
9
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/cli/bundler/plugins/utils/index.ts"],"sourcesContent":["export {getManifestHooks, type ManifestHooks} from \"./manifest-hooks\";\nexport {renderRuntimeTemplate} from \"./runtime-template\";\nexport {watchCompilation} from \"./watch-compilation\";\n"],"mappings":"AAAA,SAAQ,wBAA2C;AACnD,SAAQ,6BAA4B;AACpC,SAAQ,wBAAuB;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/utils/index.ts"],"sourcesContent":["export {getManifestHooks, type ManifestHooks} from \"./manifest-hooks\";\nexport {renderRuntimeTemplate} from \"./runtime-template\";\nexport {watchCompilation} from \"./watch-compilation\";\nexport {createRuntimeModule} from \"./runtime-module\";\nexport {getCompilationBuildAssets, setCompilationBuildAssets} from \"./compilation-assets\";\n"],"mappings":"AAAA,SAAQ,wBAA2C;AACnD,SAAQ,6BAA4B;AACpC,SAAQ,wBAAuB;AAC/B,SAAQ,2BAA0B;AAClC,SAAQ,2BAA2B,iCAAgC;","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { RuntimeModuleReaderOptions } from "../types.js";
2
+ /** Read the calling entrypoint's live runtime without initializing other features. */
3
+ export declare const createRuntimeModule: (readers: readonly RuntimeModuleReaderOptions[]) => string;
@@ -0,0 +1,11 @@
1
+ import { RuntimeGlobals } from "@rspack/core";
2
+ const createRuntimeModule = (readers) => {
3
+ return readers.map(
4
+ ({ export: name, property }) => `export const ${name} = () => ${RuntimeGlobals.require}[${JSON.stringify(property)}];
5
+ `
6
+ ).join("");
7
+ };
8
+ export {
9
+ createRuntimeModule
10
+ };
11
+ //# sourceMappingURL=runtime-module.js.map