adnbn 0.12.0 → 0.14.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 (400) hide show
  1. package/dist/cli/builders/manifest/ManifestBase.d.ts +4 -1
  2. package/dist/cli/builders/manifest/ManifestBase.js +14 -0
  3. package/dist/cli/builders/manifest/ManifestBase.js.map +1 -1
  4. package/dist/cli/bundler/layers.d.ts +3 -3
  5. package/dist/cli/bundler/layers.js +6 -7
  6. package/dist/cli/bundler/layers.js.map +1 -1
  7. package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js +42 -14
  8. package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js.map +1 -1
  9. package/dist/cli/bundler/plugins/build-assets-map/normalize.d.ts +3 -0
  10. package/dist/cli/bundler/plugins/build-assets-map/normalize.js +24 -0
  11. package/dist/cli/bundler/plugins/build-assets-map/normalize.js.map +1 -0
  12. package/dist/cli/bundler/plugins/build-assets-map/templates/runtime.template.d.ts +2 -0
  13. package/dist/cli/bundler/plugins/build-assets-map/templates.d.ts +9 -0
  14. package/dist/cli/bundler/plugins/build-assets-map/templates.js +32 -0
  15. package/dist/cli/bundler/plugins/entrypoint/EntrypointPlugin.js +11 -0
  16. package/dist/cli/bundler/plugins/entrypoint/EntrypointPlugin.js.map +1 -1
  17. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.d.ts +1 -1
  18. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js +38 -13
  19. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js.map +1 -1
  20. package/dist/cli/bundler/plugins/isolated-styles/chunks.d.ts +5 -1
  21. package/dist/cli/bundler/plugins/isolated-styles/chunks.js +17 -16
  22. package/dist/cli/bundler/plugins/isolated-styles/chunks.js.map +1 -1
  23. package/dist/cli/bundler/plugins/isolated-styles/split-chunks.d.ts +4 -0
  24. package/dist/cli/bundler/plugins/isolated-styles/split-chunks.js +51 -0
  25. package/dist/cli/bundler/plugins/isolated-styles/split-chunks.js.map +1 -0
  26. package/dist/cli/bundler/plugins/isolated-styles/templates.js +36 -6
  27. package/dist/cli/entrypoint/finder/AbstractOverrideFinder.d.ts +15 -0
  28. package/dist/cli/entrypoint/finder/AbstractOverrideFinder.js +20 -0
  29. package/dist/cli/entrypoint/finder/AbstractOverrideFinder.js.map +1 -0
  30. package/dist/cli/entrypoint/finder/AbstractViewFinder.d.ts +6 -1
  31. package/dist/cli/entrypoint/finder/AbstractViewFinder.js +15 -0
  32. package/dist/cli/entrypoint/finder/AbstractViewFinder.js.map +1 -1
  33. package/dist/cli/entrypoint/finder/BookmarksFinder.d.ts +9 -0
  34. package/dist/cli/entrypoint/finder/BookmarksFinder.js +18 -0
  35. package/dist/cli/entrypoint/finder/BookmarksFinder.js.map +1 -0
  36. package/dist/cli/entrypoint/finder/CommandFinder.d.ts +4 -0
  37. package/dist/cli/entrypoint/finder/CommandFinder.js +20 -6
  38. package/dist/cli/entrypoint/finder/CommandFinder.js.map +1 -1
  39. package/dist/cli/entrypoint/finder/HistoryFinder.d.ts +9 -0
  40. package/dist/cli/entrypoint/finder/HistoryFinder.js +18 -0
  41. package/dist/cli/entrypoint/finder/HistoryFinder.js.map +1 -0
  42. package/dist/cli/entrypoint/finder/NewtabFinder.d.ts +9 -0
  43. package/dist/cli/entrypoint/finder/NewtabFinder.js +18 -0
  44. package/dist/cli/entrypoint/finder/NewtabFinder.js.map +1 -0
  45. package/dist/cli/entrypoint/finder/OptionsFinder.d.ts +2 -2
  46. package/dist/cli/entrypoint/finder/OptionsFinder.js +2 -2
  47. package/dist/cli/entrypoint/finder/OptionsFinder.js.map +1 -1
  48. package/dist/cli/entrypoint/finder/PageFinder.js +1 -1
  49. package/dist/cli/entrypoint/finder/PageFinder.js.map +1 -1
  50. package/dist/cli/entrypoint/finder/PopupFinder.d.ts +2 -2
  51. package/dist/cli/entrypoint/finder/PopupFinder.js +2 -2
  52. package/dist/cli/entrypoint/finder/PopupFinder.js.map +1 -1
  53. package/dist/cli/entrypoint/finder/SidebarFinder.d.ts +2 -2
  54. package/dist/cli/entrypoint/finder/SidebarFinder.js +2 -2
  55. package/dist/cli/entrypoint/finder/SidebarFinder.js.map +1 -1
  56. package/dist/cli/entrypoint/finder/ViewCspFinder.d.ts +2 -3
  57. package/dist/cli/entrypoint/finder/ViewCspFinder.js.map +1 -1
  58. package/dist/cli/entrypoint/finder/ViewPermissionsFinder.d.ts +22 -0
  59. package/dist/cli/entrypoint/finder/ViewPermissionsFinder.js +43 -0
  60. package/dist/cli/entrypoint/finder/ViewPermissionsFinder.js.map +1 -0
  61. package/dist/cli/entrypoint/finder/index.d.ts +5 -0
  62. package/dist/cli/entrypoint/finder/index.js +50 -40
  63. package/dist/cli/entrypoint/finder/index.js.map +1 -1
  64. package/dist/cli/entrypoint/name/NameGenerator.d.ts +2 -0
  65. package/dist/cli/entrypoint/name/NameGenerator.js +5 -1
  66. package/dist/cli/entrypoint/name/NameGenerator.js.map +1 -1
  67. package/dist/cli/entrypoint/parser/AbstractOverrideParser.d.ts +9 -0
  68. package/dist/cli/entrypoint/parser/AbstractOverrideParser.js +11 -0
  69. package/dist/cli/entrypoint/parser/AbstractOverrideParser.js.map +1 -0
  70. package/dist/cli/entrypoint/parser/BackgroundParser.js +3 -6
  71. package/dist/cli/entrypoint/parser/BackgroundParser.js.map +1 -1
  72. package/dist/cli/entrypoint/parser/BookmarksParser.d.ts +5 -0
  73. package/dist/cli/entrypoint/parser/BookmarksParser.js +10 -0
  74. package/dist/cli/entrypoint/parser/BookmarksParser.js.map +1 -0
  75. package/dist/cli/entrypoint/parser/HistoryParser.d.ts +5 -0
  76. package/dist/cli/entrypoint/parser/HistoryParser.js +10 -0
  77. package/dist/cli/entrypoint/parser/HistoryParser.js.map +1 -0
  78. package/dist/cli/entrypoint/parser/NewtabParser.d.ts +5 -0
  79. package/dist/cli/entrypoint/parser/NewtabParser.js +10 -0
  80. package/dist/cli/entrypoint/parser/NewtabParser.js.map +1 -0
  81. package/dist/cli/entrypoint/parser/OptionsParser.js +2 -1
  82. package/dist/cli/entrypoint/parser/OptionsParser.js.map +1 -1
  83. package/dist/cli/entrypoint/parser/PopupParser.js +2 -1
  84. package/dist/cli/entrypoint/parser/PopupParser.js.map +1 -1
  85. package/dist/cli/entrypoint/parser/SidebarParser.js +2 -1
  86. package/dist/cli/entrypoint/parser/SidebarParser.js.map +1 -1
  87. package/dist/cli/entrypoint/parser/ViewCspParser.d.ts +1 -1
  88. package/dist/cli/entrypoint/parser/ViewParser.d.ts +1 -1243
  89. package/dist/cli/entrypoint/parser/ViewParser.js +2 -72
  90. package/dist/cli/entrypoint/parser/ViewParser.js.map +1 -1
  91. package/dist/cli/entrypoint/parser/index.d.ts +4 -0
  92. package/dist/cli/entrypoint/parser/index.js +28 -20
  93. package/dist/cli/entrypoint/parser/index.js.map +1 -1
  94. package/dist/cli/entrypoint/parser/schemas/html.d.ts +903 -0
  95. package/dist/cli/entrypoint/parser/schemas/html.js +64 -0
  96. package/dist/cli/entrypoint/parser/schemas/html.js.map +1 -0
  97. package/dist/cli/entrypoint/parser/schemas/permissions.d.ts +23 -0
  98. package/dist/cli/entrypoint/parser/schemas/permissions.js +11 -0
  99. package/dist/cli/entrypoint/parser/schemas/permissions.js.map +1 -0
  100. package/dist/cli/plugins/content/bundler.d.ts +0 -3
  101. package/dist/cli/plugins/content/bundler.js +4 -20
  102. package/dist/cli/plugins/content/bundler.js.map +1 -1
  103. package/dist/cli/plugins/content/index.js +2 -3
  104. package/dist/cli/plugins/content/index.js.map +1 -1
  105. package/dist/cli/plugins/index.d.ts +1 -0
  106. package/dist/cli/plugins/index.js +22 -20
  107. package/dist/cli/plugins/index.js.map +1 -1
  108. package/dist/cli/plugins/locale/Locale.js +5 -2
  109. package/dist/cli/plugins/locale/Locale.js.map +1 -1
  110. package/dist/cli/plugins/options/index.js +1 -1
  111. package/dist/cli/plugins/options/index.js.map +1 -1
  112. package/dist/cli/plugins/override/Override.d.ts +31 -0
  113. package/dist/cli/plugins/override/Override.js +112 -0
  114. package/dist/cli/plugins/override/Override.js.map +1 -0
  115. package/dist/cli/plugins/override/index.d.ts +2 -0
  116. package/dist/cli/plugins/override/index.js +48 -0
  117. package/dist/cli/plugins/override/index.js.map +1 -0
  118. package/dist/cli/plugins/popup/index.js +1 -1
  119. package/dist/cli/plugins/popup/index.js.map +1 -1
  120. package/dist/cli/plugins/sidebar/index.js +1 -2
  121. package/dist/cli/plugins/sidebar/index.js.map +1 -1
  122. package/dist/cli/plugins/style/index.d.ts +1 -2
  123. package/dist/cli/plugins/style/index.js +19 -30
  124. package/dist/cli/plugins/style/index.js.map +1 -1
  125. package/dist/cli/plugins/view/View.d.ts +1 -1
  126. package/dist/cli/plugins/view/View.js +2 -10
  127. package/dist/cli/plugins/view/View.js.map +1 -1
  128. package/dist/cli/plugins/view/index.js +10 -1
  129. package/dist/cli/plugins/view/index.js.map +1 -1
  130. package/dist/cli/resolvers/config.js +3 -2
  131. package/dist/cli/resolvers/config.js.map +1 -1
  132. package/dist/cli/virtual/index.js +14 -17
  133. package/dist/cli/virtual/virtual.d.ts +7 -127
  134. package/dist/entry/background/Builder.js +1 -1
  135. package/dist/entry/background/Builder.js.map +1 -1
  136. package/dist/entry/background/index.d.ts +1 -1
  137. package/dist/entry/background/index.js +3 -2
  138. package/dist/entry/background/index.js.map +1 -1
  139. package/dist/entry/background/resolvers/definition.d.ts +5 -1
  140. package/dist/entry/background/resolvers/definition.js +15 -4
  141. package/dist/entry/background/resolvers/definition.js.map +1 -1
  142. package/dist/entry/command/Builder.js +1 -1
  143. package/dist/entry/command/Builder.js.map +1 -1
  144. package/dist/entry/command/index.d.ts +1 -1
  145. package/dist/entry/command/index.js +3 -2
  146. package/dist/entry/command/index.js.map +1 -1
  147. package/dist/entry/command/resolvers/definition.d.ts +6 -2
  148. package/dist/entry/command/resolvers/definition.js +14 -4
  149. package/dist/entry/command/resolvers/definition.js.map +1 -1
  150. package/dist/entry/content/adapters/react/Builder.d.ts +4 -2
  151. package/dist/entry/content/adapters/react/Builder.js +13 -5
  152. package/dist/entry/content/adapters/react/Builder.js.map +1 -1
  153. package/dist/entry/content/adapters/react/Node.js +13 -8
  154. package/dist/entry/content/adapters/react/Node.js.map +1 -1
  155. package/dist/entry/content/adapters/react/definition.d.ts +2 -0
  156. package/dist/entry/content/adapters/react/definition.js +13 -0
  157. package/dist/entry/content/adapters/react/definition.js.map +1 -0
  158. package/dist/entry/content/adapters/react/index.d.ts +1 -1
  159. package/dist/entry/content/adapters/react/index.js +1 -1
  160. package/dist/entry/content/adapters/react/index.js.map +1 -1
  161. package/dist/entry/content/adapters/vanilla/Builder.d.ts +4 -2
  162. package/dist/entry/content/adapters/vanilla/Builder.js +14 -5
  163. package/dist/entry/content/adapters/vanilla/Builder.js.map +1 -1
  164. package/dist/entry/content/adapters/vanilla/Node.js +3 -5
  165. package/dist/entry/content/adapters/vanilla/Node.js.map +1 -1
  166. package/dist/entry/content/adapters/vanilla/definition.d.ts +2 -0
  167. package/dist/entry/content/adapters/vanilla/definition.js +9 -0
  168. package/dist/entry/content/adapters/vanilla/definition.js.map +1 -0
  169. package/dist/entry/content/adapters/vanilla/index.d.ts +1 -1
  170. package/dist/entry/content/adapters/vanilla/index.js +1 -1
  171. package/dist/entry/content/adapters/vanilla/index.js.map +1 -1
  172. package/dist/entry/content/lifecycle/Builder.d.ts +10 -4
  173. package/dist/entry/content/lifecycle/Builder.js +107 -69
  174. package/dist/entry/content/lifecycle/Builder.js.map +1 -1
  175. package/dist/entry/content/lifecycle/MountBuilder.d.ts +6 -3
  176. package/dist/entry/content/lifecycle/MountBuilder.js +32 -16
  177. package/dist/entry/content/lifecycle/MountBuilder.js.map +1 -1
  178. package/dist/entry/content/lifecycle/context/ContainerRegistry.d.ts +7 -0
  179. package/dist/entry/content/lifecycle/context/ContainerRegistry.js +45 -0
  180. package/dist/entry/content/lifecycle/context/ContainerRegistry.js.map +1 -0
  181. package/dist/entry/content/lifecycle/context/Context.d.ts +6 -3
  182. package/dist/entry/content/lifecycle/context/Context.js +21 -6
  183. package/dist/entry/content/lifecycle/context/Context.js.map +1 -1
  184. package/dist/entry/content/lifecycle/context/ManagedContext.d.ts +4 -1
  185. package/dist/entry/content/lifecycle/context/ManagedContext.js +7 -0
  186. package/dist/entry/content/lifecycle/context/ManagedContext.js.map +1 -1
  187. package/dist/entry/content/lifecycle/context/index.d.ts +1 -0
  188. package/dist/entry/content/lifecycle/context/index.js +6 -4
  189. package/dist/entry/content/lifecycle/context/index.js.map +1 -1
  190. package/dist/entry/content/lifecycle/markers/AttributeMarker.js +3 -1
  191. package/dist/entry/content/lifecycle/markers/AttributeMarker.js.map +1 -1
  192. package/dist/entry/content/lifecycle/nodes/EventNode.d.ts +4 -2
  193. package/dist/entry/content/lifecycle/nodes/EventNode.js +7 -2
  194. package/dist/entry/content/lifecycle/nodes/EventNode.js.map +1 -1
  195. package/dist/entry/content/lifecycle/nodes/FrameNode.d.ts +2 -1
  196. package/dist/entry/content/lifecycle/nodes/FrameNode.js +3 -0
  197. package/dist/entry/content/lifecycle/nodes/FrameNode.js.map +1 -1
  198. package/dist/entry/content/lifecycle/nodes/MarkerNode.d.ts +1 -1
  199. package/dist/entry/content/lifecycle/nodes/MarkerNode.js.map +1 -1
  200. package/dist/entry/content/lifecycle/nodes/MountNode.d.ts +7 -3
  201. package/dist/entry/content/lifecycle/nodes/MountNode.js +47 -12
  202. package/dist/entry/content/lifecycle/nodes/MountNode.js.map +1 -1
  203. package/dist/entry/content/lifecycle/nodes/Node.d.ts +1 -1
  204. package/dist/entry/content/lifecycle/nodes/Node.js.map +1 -1
  205. package/dist/entry/content/lifecycle/nodes/RenderNode.d.ts +13 -4
  206. package/dist/entry/content/lifecycle/nodes/RenderNode.js +71 -6
  207. package/dist/entry/content/lifecycle/nodes/RenderNode.js.map +1 -1
  208. package/dist/entry/content/lifecycle/nodes/ShadowNode.d.ts +2 -1
  209. package/dist/entry/content/lifecycle/nodes/ShadowNode.js +3 -0
  210. package/dist/entry/content/lifecycle/nodes/ShadowNode.js.map +1 -1
  211. package/dist/entry/content/lifecycle/types.d.ts +28 -0
  212. package/dist/entry/content/resolvers/watch.d.ts +1 -1
  213. package/dist/entry/content/resolvers/watch.js +29 -14
  214. package/dist/entry/content/resolvers/watch.js.map +1 -1
  215. package/dist/entry/core/react.d.ts +6 -0
  216. package/dist/entry/core/react.js +16 -0
  217. package/dist/entry/core/react.js.map +1 -0
  218. package/dist/entry/core/render.d.ts +5 -0
  219. package/dist/entry/core/render.js +16 -0
  220. package/dist/entry/core/render.js.map +1 -0
  221. package/dist/entry/offscreen/Builder.d.ts +6 -7
  222. package/dist/entry/offscreen/Builder.js +12 -13
  223. package/dist/entry/offscreen/Builder.js.map +1 -1
  224. package/dist/entry/offscreen/TransportBuilder.d.ts +1 -1
  225. package/dist/entry/offscreen/TransportBuilder.js +4 -3
  226. package/dist/entry/offscreen/TransportBuilder.js.map +1 -1
  227. package/dist/entry/offscreen/index.d.ts +5 -2
  228. package/dist/entry/offscreen/index.js +8 -2
  229. package/dist/entry/offscreen/index.js.map +1 -1
  230. package/dist/entry/offscreen/resolvers/definition.d.ts +4 -0
  231. package/dist/entry/offscreen/resolvers/definition.js +8 -0
  232. package/dist/entry/offscreen/resolvers/definition.js.map +1 -0
  233. package/dist/entry/relay/index.js.map +1 -1
  234. package/dist/entry/relay/resolvers/definition.d.ts +1 -1
  235. package/dist/entry/relay/resolvers/definition.js +2 -10
  236. package/dist/entry/relay/resolvers/definition.js.map +1 -1
  237. package/dist/entry/sandbox/Builder.d.ts +6 -7
  238. package/dist/entry/sandbox/Builder.js +8 -12
  239. package/dist/entry/sandbox/Builder.js.map +1 -1
  240. package/dist/entry/sandbox/TransportBuilder.d.ts +1 -1
  241. package/dist/entry/sandbox/TransportBuilder.js +4 -3
  242. package/dist/entry/sandbox/TransportBuilder.js.map +1 -1
  243. package/dist/entry/sandbox/index.d.ts +7 -2
  244. package/dist/entry/sandbox/index.js +10 -4
  245. package/dist/entry/sandbox/index.js.map +1 -1
  246. package/dist/entry/sandbox/resolvers/definition.d.ts +4 -0
  247. package/dist/entry/sandbox/resolvers/definition.js +8 -0
  248. package/dist/entry/sandbox/resolvers/definition.js.map +1 -0
  249. package/dist/entry/service/index.d.ts +1 -0
  250. package/dist/entry/service/index.js +3 -1
  251. package/dist/entry/service/index.js.map +1 -1
  252. package/dist/entry/service/resolvers/definition.d.ts +3 -0
  253. package/dist/entry/service/resolvers/definition.js +8 -0
  254. package/dist/entry/service/resolvers/definition.js.map +1 -0
  255. package/dist/entry/transport/AbstractBuilder.js +1 -1
  256. package/dist/entry/transport/AbstractBuilder.js.map +1 -1
  257. package/dist/entry/transport/resolvers/definition.d.ts +7 -5
  258. package/dist/entry/transport/resolvers/definition.js +15 -4
  259. package/dist/entry/transport/resolvers/definition.js.map +1 -1
  260. package/dist/entry/view/{core/Builder.d.ts → Builder.d.ts} +9 -4
  261. package/dist/entry/view/Builder.js +62 -0
  262. package/dist/entry/view/Builder.js.map +1 -0
  263. package/dist/entry/view/adapters/react/Builder.d.ts +6 -7
  264. package/dist/entry/view/adapters/react/Builder.js +20 -23
  265. package/dist/entry/view/adapters/react/Builder.js.map +1 -1
  266. package/dist/entry/view/adapters/react/definition.d.ts +2 -0
  267. package/dist/entry/view/adapters/react/definition.js +13 -0
  268. package/dist/entry/view/adapters/react/definition.js.map +1 -0
  269. package/dist/entry/view/adapters/react/index.d.ts +2 -1
  270. package/dist/entry/view/adapters/react/index.js +3 -1
  271. package/dist/entry/view/adapters/react/index.js.map +1 -1
  272. package/dist/entry/view/adapters/vanilla/Builder.d.ts +5 -6
  273. package/dist/entry/view/adapters/vanilla/Builder.js +14 -25
  274. package/dist/entry/view/adapters/vanilla/Builder.js.map +1 -1
  275. package/dist/entry/view/adapters/vanilla/definition.d.ts +2 -0
  276. package/dist/entry/view/adapters/vanilla/definition.js +9 -0
  277. package/dist/entry/view/adapters/vanilla/definition.js.map +1 -0
  278. package/dist/entry/view/adapters/vanilla/index.d.ts +2 -1
  279. package/dist/entry/view/adapters/vanilla/index.js +3 -1
  280. package/dist/entry/view/adapters/vanilla/index.js.map +1 -1
  281. package/dist/entry/view/{core/resolvers → resolvers}/container.d.ts +1 -1
  282. package/dist/entry/view/resolvers/container.js.map +1 -0
  283. package/dist/entry/view/resolvers/definition.d.ts +3 -0
  284. package/dist/entry/view/resolvers/definition.js +18 -0
  285. package/dist/entry/view/resolvers/definition.js.map +1 -0
  286. package/dist/main/index.d.ts +2 -0
  287. package/dist/main/index.js +2 -0
  288. package/dist/main/index.js.map +1 -1
  289. package/dist/main/override.d.ts +5 -0
  290. package/dist/main/override.js +15 -0
  291. package/dist/main/override.js.map +1 -0
  292. package/dist/main/permissions.d.ts +1 -0
  293. package/dist/main/permissions.js +1 -0
  294. package/dist/main/view.d.ts +1 -1
  295. package/dist/shared/locale/index.d.ts +1 -1
  296. package/dist/shared/locale/index.js +3 -1
  297. package/dist/shared/locale/index.js.map +1 -1
  298. package/dist/shared/locale/messages.d.ts +4 -0
  299. package/dist/shared/locale/messages.js +12 -0
  300. package/dist/shared/locale/messages.js.map +1 -1
  301. package/dist/types/background.d.ts +2 -8
  302. package/dist/types/background.js.map +1 -1
  303. package/dist/types/content/common.d.ts +8 -0
  304. package/dist/types/content/common.js.map +1 -1
  305. package/dist/types/content/definition.d.ts +5 -0
  306. package/dist/types/entrypoint.d.ts +5 -1
  307. package/dist/types/entrypoint.js +3 -0
  308. package/dist/types/entrypoint.js.map +1 -1
  309. package/dist/types/locale.d.ts +3 -0
  310. package/dist/types/locale.js.map +1 -1
  311. package/dist/types/manifest.d.ts +20 -2
  312. package/dist/types/manifest.js.map +1 -1
  313. package/dist/types/offscreen.d.ts +2 -2
  314. package/dist/types/offscreen.js.map +1 -1
  315. package/dist/types/options.d.ts +3 -2
  316. package/dist/types/override.d.ts +22 -0
  317. package/dist/types/override.js +1 -0
  318. package/dist/types/override.js.map +1 -0
  319. package/dist/types/page.d.ts +1 -1
  320. package/dist/types/permissions.d.ts +39 -0
  321. package/dist/types/permissions.js +1 -0
  322. package/dist/types/permissions.js.map +1 -0
  323. package/dist/types/plugin.d.ts +4 -1
  324. package/dist/types/popup.d.ts +3 -2
  325. package/dist/types/sandbox.d.ts +2 -2
  326. package/dist/types/sandbox.js.map +1 -1
  327. package/dist/types/sidebar.d.ts +3 -2
  328. package/dist/types/sidebar.js.map +1 -1
  329. package/dist/types/view/adapters/index.d.ts +2 -0
  330. package/dist/types/view/adapters/index.js +1 -0
  331. package/dist/types/view/adapters/index.js.map +1 -0
  332. package/dist/types/view/adapters/react.d.ts +4 -0
  333. package/dist/types/view/adapters/react.js +1 -0
  334. package/dist/types/view/adapters/react.js.map +1 -0
  335. package/dist/types/view/adapters/vanilla.d.ts +1 -0
  336. package/dist/types/view/adapters/vanilla.js +1 -0
  337. package/dist/types/view/adapters/vanilla.js.map +1 -0
  338. package/dist/types/{view.d.ts → view/common.d.ts} +2 -14
  339. package/dist/types/view/common.js +1 -0
  340. package/dist/types/view/common.js.map +1 -0
  341. package/dist/types/view/definition.d.ts +15 -0
  342. package/dist/types/view/definition.js +1 -0
  343. package/dist/types/view/definition.js.map +1 -0
  344. package/dist/types/view/index.d.ts +4 -0
  345. package/dist/types/view/index.js +1 -0
  346. package/dist/types/view/index.js.map +1 -0
  347. package/dist/types/view/render.d.ts +7 -0
  348. package/dist/types/view/render.js +1 -0
  349. package/dist/types/view/render.js.map +1 -0
  350. package/package.json +1 -3
  351. package/types/client.d.ts +3 -3
  352. package/dist/cli/plugins/style/types.d.ts +0 -5
  353. package/dist/entry/background/resolvers/index.d.ts +0 -1
  354. package/dist/entry/background/resolvers/index.js +0 -2
  355. package/dist/entry/background/resolvers/index.js.map +0 -1
  356. package/dist/entry/command/resolvers/index.d.ts +0 -1
  357. package/dist/entry/command/resolvers/index.js +0 -2
  358. package/dist/entry/command/resolvers/index.js.map +0 -1
  359. package/dist/entry/content/adapters/react/resolvers/definition.d.ts +0 -2
  360. package/dist/entry/content/adapters/react/resolvers/definition.js +0 -12
  361. package/dist/entry/content/adapters/react/resolvers/definition.js.map +0 -1
  362. package/dist/entry/content/adapters/react/resolvers/render.d.ts +0 -2
  363. package/dist/entry/content/adapters/react/resolvers/render.js +0 -9
  364. package/dist/entry/content/adapters/react/resolvers/render.js.map +0 -1
  365. package/dist/entry/content/adapters/vanilla/resolvers/definition.d.ts +0 -2
  366. package/dist/entry/content/adapters/vanilla/resolvers/definition.js +0 -9
  367. package/dist/entry/content/adapters/vanilla/resolvers/definition.js.map +0 -1
  368. package/dist/entry/content/adapters/vanilla/resolvers/render.d.ts +0 -3
  369. package/dist/entry/content/adapters/vanilla/resolvers/render.js +0 -15
  370. package/dist/entry/content/adapters/vanilla/resolvers/render.js.map +0 -1
  371. package/dist/entry/content/resolvers/index.d.ts +0 -6
  372. package/dist/entry/content/resolvers/index.js +0 -7
  373. package/dist/entry/content/resolvers/index.js.map +0 -1
  374. package/dist/entry/transport/index.d.ts +0 -1
  375. package/dist/entry/transport/index.js +0 -2
  376. package/dist/entry/transport/index.js.map +0 -1
  377. package/dist/entry/transport/resolvers/index.d.ts +0 -1
  378. package/dist/entry/transport/resolvers/index.js +0 -2
  379. package/dist/entry/transport/resolvers/index.js.map +0 -1
  380. package/dist/entry/view/adapters/react/resolvers/render.d.ts +0 -2
  381. package/dist/entry/view/adapters/react/resolvers/render.js +0 -11
  382. package/dist/entry/view/adapters/react/resolvers/render.js.map +0 -1
  383. package/dist/entry/view/core/Builder.js +0 -35
  384. package/dist/entry/view/core/Builder.js.map +0 -1
  385. package/dist/entry/view/core/resolvers/container.js.map +0 -1
  386. package/dist/entry/view/core/resolvers/definition.d.ts +0 -3
  387. package/dist/entry/view/core/resolvers/definition.js +0 -12
  388. package/dist/entry/view/core/resolvers/definition.js.map +0 -1
  389. package/dist/entry/view/core/resolvers/render.d.ts +0 -3
  390. package/dist/entry/view/core/resolvers/render.js +0 -18
  391. package/dist/entry/view/core/resolvers/render.js.map +0 -1
  392. package/dist/entry/view/index.d.ts +0 -1
  393. package/dist/entry/view/index.js +0 -2
  394. package/dist/entry/view/index.js.map +0 -1
  395. package/dist/types/view.js +0 -1
  396. /package/dist/cli/virtual/{transport.d.ts → service.d.ts} +0 -0
  397. /package/dist/{cli/plugins/style → entry/content/lifecycle}/types.js +0 -0
  398. /package/dist/{cli/plugins/style → entry/content/lifecycle}/types.js.map +0 -0
  399. /package/dist/entry/view/{core/resolvers → resolvers}/container.js +0 -0
  400. /package/dist/{types/view.js.map → main/permissions.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.ts"],"sourcesContent":["import {Chunk, Compilation, Compiler, Filename, RuntimeGlobals, RuntimeModule, sources} from \"@rspack/core\";\nimport stringify from \"json-stringify-deterministic\";\nimport ts from \"typescript\";\n\nimport {collectBuildAssets} from \"@cli/bundler/utils/assets\";\nimport {setCompilationBuildAssets} from \"../utils\";\nimport {\n CssContentHashType,\n JavaScriptContentHashType,\n resolveChunkFilename,\n resolveFilenameTemplate,\n filenameRequiresFullHash,\n} from \"@cli/bundler/utils/chunk-filename\";\nimport {toPosix} from \"@cli/utils/path\";\n\nimport type {EntrypointAssetsMap, EntrypointAssets} from \"@typing/entrypoint\";\n\nimport {trackModuleUsage, type BuildAssetsMapPluginModuleOptions} from \"./usage\";\n\nconst PluginName = \"BuildAssetsMapPlugin\";\n// Replaced with the full map once Rspack has resolved the output filenames.\nconst FullMapPlaceholder = \"__ADNBN_BUILD_ASSETS_FULL_MAP_PLACEHOLDER__\";\n// These JSON envelope keys let final validation locate each map after minification.\nconst FullMapEnvelopeKey = \"__adnbnBuildAssetsFullMap__\";\nconst CurrentMapEnvelopeKey = \"__adnbnBuildAssetsCurrentMap__\";\n// Hash-based output names are fixed when processAssets starts, so the asset graph is frozen here.\nconst EmbedStage = Number.NEGATIVE_INFINITY;\nconst FinalValidationStage = Infinity;\n\ninterface FullMapRuntime {\n readonly name: string;\n readonly runtime: Chunk;\n}\n\ninterface RuntimeSelection {\n readonly name: string;\n readonly fullMap: boolean;\n readonly property: string;\n}\n\nexport interface BuildAssetsMapPluginOptions {\n readonly module: BuildAssetsMapPluginModuleOptions;\n readonly buildHashSalt?: string;\n readonly cssChunkFilename: Filename;\n readonly cssFilename: Filename;\n readonly fullMapEntrypoint: string;\n}\n\ntype RuntimeModuleFingerprints = Map<Chunk, Map<string, string>>;\n\nconst validateAsyncChunkFilenames = (compilation: Compilation, cssChunkFilename: Filename): void => {\n const asyncChunks = new Set(\n Array.from(compilation.entrypoints.values()).flatMap(entrypoint => {\n return Array.from(entrypoint.getEntrypointChunk().getAllAsyncChunks());\n })\n );\n const validate = (\n filename: Filename,\n chunks: Iterable<Chunk>,\n contentHashType: string,\n assetType: \"CSS\" | \"JavaScript\",\n configName: \"cssFilename\" | \"jsFilename\"\n ): void => {\n if (typeof filename !== \"function\") {\n return;\n }\n\n const returnsFullHash = Array.from(chunks).some(chunk => {\n const template = resolveFilenameTemplate(compilation, chunk, filename, contentHashType);\n\n return /\\[(?:fullhash|hash)(?::\\d+)?\\]/i.test(template);\n });\n\n if (returnsFullHash) {\n const target = assetType === \"JavaScript\" ? \"async chunk URLs\" : \"async CSS chunk URLs\";\n\n throw new Error(\n `Rspack cannot generate ${target} when a filename callback returns [fullhash]; configure ${configName} as a string template instead`\n );\n }\n };\n\n if (compilation.outputOptions.chunkFilename) {\n validate(\n compilation.outputOptions.chunkFilename,\n asyncChunks,\n JavaScriptContentHashType,\n \"JavaScript\",\n \"jsFilename\"\n );\n }\n validate(\n cssChunkFilename,\n Array.from(asyncChunks).filter(chunk => chunkHasCss(compilation, chunk)),\n CssContentHashType,\n \"CSS\",\n \"cssFilename\"\n );\n};\n\nconst chunkHasCss = (compilation: Compilation, chunk: Chunk): boolean => {\n return Array.from(compilation.chunkGraph.getChunkModulesIterable(chunk)).some(module => {\n return module.type === CssContentHashType;\n });\n};\n\nconst chunkHasJavaScript = (compilation: Compilation, chunk: Chunk): boolean => {\n // splitChunks can move every user module out of an entry, but its bootstrap\n // still emits a JavaScript file and remains an initial dependency.\n if (chunk.hasRuntime()) return true;\n return Array.from(compilation.chunkGraph.getChunkModulesIterable(chunk)).some(module => {\n return module.type.startsWith(\"javascript\");\n });\n};\n\nconst getEntrypointRuntimeAssets = (\n compilation: Compilation,\n name: string,\n cssFilename: Filename,\n cssChunkFilename: Filename\n): EntrypointAssets => {\n const entrypoint = compilation.entrypoints.get(name);\n\n if (!entrypoint) {\n throw new Error(`Build assets entrypoint \"${name}\" is unavailable`);\n }\n\n const entryChunk = entrypoint.getEntrypointChunk();\n const initialChunks = Array.from(entrypoint.chunks);\n const asyncChunks = Array.from(entryChunk.getAllAsyncChunks());\n const jsFilename = compilation.outputOptions.filename;\n const jsChunkFilename = compilation.outputOptions.chunkFilename;\n\n if (!jsFilename || !jsChunkFilename) {\n throw new Error(\"Build assets require output.filename and output.chunkFilename\");\n }\n\n return {\n initial: {\n js: initialChunks\n .filter(chunk => chunkHasJavaScript(compilation, chunk))\n .map(chunk => {\n return resolveChunkFilename(\n compilation,\n chunk,\n chunk === entryChunk ? jsFilename : jsChunkFilename,\n JavaScriptContentHashType\n );\n }),\n css: initialChunks\n .filter(chunk => chunkHasCss(compilation, chunk))\n .map(chunk => {\n return resolveChunkFilename(\n compilation,\n chunk,\n chunk === entryChunk ? cssFilename : cssChunkFilename,\n CssContentHashType\n );\n }),\n },\n async: {\n js: asyncChunks\n .filter(chunk => chunkHasJavaScript(compilation, chunk))\n .map(chunk => {\n return resolveChunkFilename(compilation, chunk, jsChunkFilename, JavaScriptContentHashType);\n }),\n css: asyncChunks\n .filter(chunk => chunkHasCss(compilation, chunk))\n .map(chunk => {\n return resolveChunkFilename(compilation, chunk, cssChunkFilename, CssContentHashType);\n }),\n },\n };\n};\n\nconst entrypointRuntimeUsesFullHash = (\n compilation: Compilation,\n name: string,\n cssFilename: Filename,\n cssChunkFilename: Filename\n): boolean => {\n const entrypoint = compilation.entrypoints.get(name);\n\n if (!entrypoint) {\n return false;\n }\n\n const entryChunk = entrypoint.getEntrypointChunk();\n const initialChunks = Array.from(entrypoint.chunks);\n const asyncChunks = Array.from(entryChunk.getAllAsyncChunks());\n const jsFilename = compilation.outputOptions.filename;\n const jsChunkFilename = compilation.outputOptions.chunkFilename;\n\n if (!jsFilename || !jsChunkFilename) {\n return false;\n }\n\n return (\n initialChunks.some(chunk => {\n const js = filenameRequiresFullHash(\n compilation,\n chunk,\n chunk === entryChunk ? jsFilename : jsChunkFilename,\n JavaScriptContentHashType\n );\n const css =\n chunkHasCss(compilation, chunk) &&\n filenameRequiresFullHash(\n compilation,\n chunk,\n chunk === entryChunk ? cssFilename : cssChunkFilename,\n CssContentHashType\n );\n\n return js || css;\n }) ||\n asyncChunks.some(chunk => {\n const js = filenameRequiresFullHash(compilation, chunk, jsChunkFilename, JavaScriptContentHashType);\n const css =\n chunkHasCss(compilation, chunk) &&\n filenameRequiresFullHash(compilation, chunk, cssChunkFilename, CssContentHashType);\n\n return js || css;\n })\n );\n};\n\nconst getChunkKey = (chunk: Chunk): string => {\n return `${String(chunk.name ?? \"\")}:${String(chunk.id ?? \"\")}`;\n};\n\nconst getFullMapRuntime = (\n compilation: Compilation,\n name: string,\n runtimes: ReadonlySet<Chunk>\n): FullMapRuntime | undefined => {\n const entrypoint = compilation.entrypoints.get(name);\n\n if (!entrypoint || !runtimes.has(entrypoint.getRuntimeChunk())) {\n return;\n }\n\n return {name, runtime: entrypoint.getRuntimeChunk()};\n};\n\nconst getFullMapRuntimeFiles = (fullMap: FullMapRuntime, assets: EntrypointAssetsMap): readonly string[] => {\n const runtimeFiles = new Set(Array.from(fullMap.runtime.files, toPosix));\n\n return assets[fullMap.name].initial.js.filter(file => runtimeFiles.has(file));\n};\n\nconst validateEntrypointRuntime = (compilation: Compilation, name: string): void => {\n const entrypoint = compilation.entrypoints.get(name)!;\n if (entrypoint.getRuntimeChunk() !== entrypoint.getEntrypointChunk()) {\n throw new Error(\n `Build assets require a self-contained runtime for entrypoint \"${name}\"; disable optimization.runtimeChunk`\n );\n }\n};\n\nconst validateFullMapEntrypoint = (compilation: Compilation, name: string): void => {\n const entrypoint = compilation.entrypoints.get(name);\n\n if (!entrypoint) {\n return;\n }\n\n const entryChunk = entrypoint.getEntrypointChunk();\n const initialChunks = Array.from(entrypoint.chunks);\n const asyncChunks = Array.from(entryChunk.getAllAsyncChunks());\n\n if (initialChunks.length !== 1 || initialChunks[0] !== entryChunk || asyncChunks.length > 0) {\n throw new Error(\n `Full build-assets entrypoint \"${name}\" must be a single self-contained chunk; async chunks are not supported`\n );\n }\n};\n\nconst validateFullMapAssets = (assets: EntrypointAssetsMap, name: string): void => {\n const entrypoint = assets[name];\n\n if (!entrypoint) {\n return;\n }\n\n if (entrypoint.initial.js.length !== 1 || entrypoint.async.js.length > 0) {\n throw new Error(\n `Full build-assets entrypoint \"${name}\" must emit exactly one initial JavaScript file and no async JavaScript files`\n );\n }\n};\n\nconst serializeFilename = (filename: unknown): string => {\n return typeof filename === \"function\" ? filename.toString() : JSON.stringify(filename);\n};\n\nconst collectRuntimeModuleFingerprints = (compilation: Compilation): RuntimeModuleFingerprints => {\n const fingerprints: RuntimeModuleFingerprints = new Map();\n\n compilation.hooks.runtimeModule.tap(PluginName, (runtimeModule, chunk) => {\n if (runtimeModule.identifier().startsWith(\"webpack/runtime/build assets \")) {\n return;\n }\n\n let chunkFingerprints = fingerprints.get(chunk);\n\n if (!chunkFingerprints) {\n chunkFingerprints = new Map();\n fingerprints.set(chunk, chunkFingerprints);\n }\n\n chunkFingerprints.set(`${runtimeModule.stage}:${runtimeModule.identifier()}`, runtimeModule.generate());\n });\n\n return fingerprints;\n};\n\nconst updateBuildAssetsChunkHashes = (\n compilation: Compilation,\n options: Required<BuildAssetsMapPluginOptions>,\n runtimeModuleFingerprints: RuntimeModuleFingerprints,\n runtimes: ReadonlySet<Chunk>\n): void => {\n compilation.hooks.chunkHash.tap(PluginName, (chunk, hash) => {\n if (!runtimes.has(chunk)) return;\n const runtimeEntry = Array.from(compilation.entrypoints).find(([, entrypoint]) => {\n return entrypoint.getRuntimeChunk() === chunk;\n });\n\n if (!runtimeEntry) {\n return;\n }\n\n const [runtimeName] = runtimeEntry;\n const fullMap = runtimeName === options.fullMapEntrypoint;\n const entries = fullMap\n ? Array.from(compilation.entrypoints).toSorted(([left], [right]) => left.localeCompare(right))\n : [runtimeEntry];\n\n hash.update(`${PluginName}:runtime-map:${runtimeName}`, \"utf8\");\n hash.update(options.buildHashSalt, \"utf8\");\n hash.update(serializeFilename(compilation.outputOptions.filename), \"utf8\");\n hash.update(serializeFilename(compilation.outputOptions.chunkFilename), \"utf8\");\n hash.update(serializeFilename(options.cssFilename), \"utf8\");\n hash.update(serializeFilename(options.cssChunkFilename), \"utf8\");\n\n if (fullMap) {\n hash.update(serializeFilename(compilation.outputOptions.assetModuleFilename), \"utf8\");\n }\n\n for (const [entryName, entrypoint] of entries) {\n hash.update(entryName, \"utf8\");\n\n const entryChunk = entrypoint.getEntrypointChunk();\n const initialChunks = new Set(entrypoint.chunks);\n const chunks = Array.from(entryChunk.getAllReferencedChunks()).toSorted((left, right) =>\n getChunkKey(left).localeCompare(getChunkKey(right))\n );\n\n for (const referencedChunk of chunks) {\n const category = initialChunks.has(referencedChunk) ? \"initial\" : \"async\";\n\n hash.update(`${category}:${getChunkKey(referencedChunk)}`, \"utf8\");\n\n const jsFilename =\n referencedChunk === entryChunk\n ? compilation.outputOptions.filename\n : compilation.outputOptions.chunkFilename;\n\n if (jsFilename) {\n const template = resolveFilenameTemplate(\n compilation,\n referencedChunk,\n jsFilename,\n JavaScriptContentHashType\n );\n\n hash.update(`javascript-template:${template}`, \"utf8\");\n }\n\n if (chunkHasCss(compilation, referencedChunk)) {\n const cssFilename = referencedChunk === entryChunk ? options.cssFilename : options.cssChunkFilename;\n const template = resolveFilenameTemplate(\n compilation,\n referencedChunk,\n cssFilename,\n CssContentHashType\n );\n\n hash.update(`css-template:${template}`, \"utf8\");\n }\n\n const moduleHashes = Array.from(\n compilation.chunkGraph.getChunkModulesIterable(referencedChunk),\n module => {\n return compilation.chunkGraph.getModuleHash(module, new Set(referencedChunk.runtime)) ?? \"\";\n }\n ).toSorted();\n\n moduleHashes.forEach(moduleHash => hash.update(moduleHash, \"utf8\"));\n\n const runtimeFingerprints = runtimeModuleFingerprints.get(referencedChunk);\n\n if (runtimeFingerprints) {\n Array.from(runtimeFingerprints)\n .toSorted(([left], [right]) => left.localeCompare(right))\n .forEach(([identifier, source]) => {\n hash.update(`runtime-module:${identifier}`, \"utf8\");\n hash.update(source, \"utf8\");\n });\n }\n }\n }\n });\n};\n\nclass BuildAssetsRuntimeModule extends RuntimeModule {\n public constructor(\n private readonly fullMap: boolean,\n private readonly runtimeName: string,\n private readonly property: string,\n private readonly cssFilename: Filename,\n private readonly cssChunkFilename: Filename,\n fullHash: boolean\n ) {\n super(`build assets ${fullMap ? \"full\" : \"current\"} ${runtimeName}`, RuntimeModule.STAGE_TRIGGER);\n\n if (!fullMap) {\n this.dependentHash = true;\n this.fullHash = fullHash;\n }\n }\n\n public generate(): string {\n const runtime = RuntimeGlobals.require;\n\n if (this.fullMap) {\n return `${runtime}[${JSON.stringify(this.property)}] = JSON.parse(${JSON.stringify(FullMapPlaceholder)}).${FullMapEnvelopeKey};`;\n }\n\n const compilation = this.compilation;\n\n if (!compilation) {\n throw new Error(\"Build assets runtime is not attached to a compilation\");\n }\n\n const current = getEntrypointRuntimeAssets(\n compilation,\n this.runtimeName,\n this.cssFilename,\n this.cssChunkFilename\n );\n\n const envelope = JSON.stringify({[CurrentMapEnvelopeKey]: current});\n\n return `${runtime}[${JSON.stringify(this.property)}] = JSON.parse(${JSON.stringify(envelope)}).${CurrentMapEnvelopeKey};`;\n }\n}\n\nconst replaceFullMapPlaceholder = (\n compilation: Compilation,\n runtimeFiles: readonly string[],\n assets: EntrypointAssetsMap\n): void => {\n const placeholder = JSON.stringify(FullMapPlaceholder);\n const replacementValue = JSON.stringify(JSON.stringify({[FullMapEnvelopeKey]: assets}));\n let replacements = 0;\n\n for (const file of runtimeFiles) {\n const asset = compilation.getAsset(file);\n\n if (!asset) {\n continue;\n }\n\n const code = asset.source.source().toString();\n const start = code.indexOf(placeholder);\n\n if (start < 0) {\n continue;\n }\n\n if (code.indexOf(placeholder, start + placeholder.length) >= 0) {\n throw new Error(`Build assets placeholder occurs more than once in \"${file}\"`);\n }\n\n const source = new sources.ReplaceSource(asset.source);\n\n source.replace(start, start + placeholder.length - 1, replacementValue);\n compilation.updateAsset(file, source);\n replacements += 1;\n }\n\n if (replacements !== 1) {\n throw new Error(`Expected one full build-assets runtime, found ${replacements}`);\n }\n};\n\nconst extractEmbeddedEnvelope = <T>(file: string, source: string, key: string): T => {\n const sourceFile = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, false, ts.ScriptKind.JS);\n const values: T[] = [];\n\n const visit = (node: ts.Node): void => {\n if (ts.isStringLiteralLike(node) && node.text.includes(key)) {\n try {\n const envelope = JSON.parse(node.text) as Record<string, T>;\n\n if (Object.prototype.hasOwnProperty.call(envelope, key)) {\n values.push(envelope[key]);\n }\n } catch {}\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n\n if (values.length !== 1) {\n throw new Error(`Expected one embedded build assets value in \"${file}\", found ${values.length}`);\n }\n\n return values[0];\n};\n\nconst extractEmbeddedMap = (file: string, source: string): EntrypointAssetsMap => {\n return extractEmbeddedEnvelope<EntrypointAssetsMap>(file, source, FullMapEnvelopeKey);\n};\n\nconst validateEmbeddedMap = (compilation: Compilation, fullMap: FullMapRuntime, assets: EntrypointAssetsMap): void => {\n const runtimeFiles = getFullMapRuntimeFiles(fullMap, assets);\n const runtime = runtimeFiles\n .map(file => ({file, source: compilation.getAsset(file)?.source.source().toString() ?? \"\"}))\n .find(({source}) => source.length > 0);\n\n if (!runtime) {\n throw new Error(\n `Full build-assets runtime for entrypoint \"${fullMap.name}\" is unavailable after asset processing`\n );\n }\n\n const embedded = extractEmbeddedMap(runtime.file, runtime.source);\n\n if (stringify(embedded) !== stringify(assets)) {\n throw new Error(\n \"Build assets changed after the runtime map was embedded; finalize entrypoint assets before processAssets begins\"\n );\n }\n};\n\nconst validateCurrentEntrypointMaps = (\n compilation: Compilation,\n assets: EntrypointAssetsMap,\n fullMapEntrypoint: string,\n runtimes: ReadonlySet<Chunk>\n): void => {\n for (const [name, entrypointAssets] of Object.entries(assets)) {\n if (name === fullMapEntrypoint) {\n continue;\n }\n\n const entrypoint = compilation.entrypoints.get(name);\n\n if (!entrypoint) {\n throw new Error(`Build assets entrypoint \"${name}\" is unavailable`);\n }\n\n if (!runtimes.has(entrypoint.getRuntimeChunk())) continue;\n\n const runtimeFiles = new Set(Array.from(entrypoint.getRuntimeChunk().files, toPosix));\n const runtime = entrypointAssets.initial.js\n .filter(file => runtimeFiles.has(file))\n .map(file => ({file, source: compilation.getAsset(file)?.source.source().toString() ?? \"\"}))\n .find(({source}) => source.length > 0);\n\n if (!runtime) {\n throw new Error(`Runtime map for entrypoint \"${name}\" is unavailable after asset processing`);\n }\n\n const runtimeAssets = extractEmbeddedEnvelope<EntrypointAssets>(\n runtime.file,\n runtime.source,\n CurrentMapEnvelopeKey\n );\n const finalizedAssets: EntrypointAssets = {\n initial: entrypointAssets.initial,\n async: entrypointAssets.async,\n };\n\n if (stringify(runtimeAssets) !== stringify(finalizedAssets)) {\n throw new Error(\n `Build assets changed after the runtime map for entrypoint \"${name}\" was embedded: ${JSON.stringify({embedded: runtimeAssets, finalized: finalizedAssets})}`\n );\n }\n }\n};\n\nconst finalizeBuildAssets = (\n compilation: Compilation,\n options: Required<BuildAssetsMapPluginOptions>,\n runtimes: ReadonlySet<Chunk>\n): void => {\n const assets = collectBuildAssets(compilation);\n const fullMap = getFullMapRuntime(compilation, options.fullMapEntrypoint, runtimes);\n\n if (fullMap) {\n validateFullMapAssets(assets, options.fullMapEntrypoint);\n validateEmbeddedMap(compilation, fullMap, assets);\n }\n\n validateCurrentEntrypointMaps(compilation, assets, options.fullMapEntrypoint, runtimes);\n\n setCompilationBuildAssets(compilation, assets);\n};\n\nexport default class BuildAssetsMapPlugin {\n private readonly options: Required<BuildAssetsMapPluginOptions>;\n\n public constructor(options: BuildAssetsMapPluginOptions) {\n this.options = {\n ...options,\n buildHashSalt: options.buildHashSalt ?? \"\",\n };\n }\n\n public apply(compiler: Compiler): void {\n const runtimeSelections = new WeakMap<Compilation, ReadonlySet<Chunk>>();\n\n compiler.hooks.thisCompilation.tap({name: PluginName, stage: EmbedStage}, compilation => {\n const injectedRuntimes = new Set<Chunk>();\n runtimeSelections.set(compilation, injectedRuntimes);\n let filenamesValidated = false;\n let selectedRuntimes: Map<Chunk, RuntimeSelection> | undefined;\n const runtimeModuleFingerprints = collectRuntimeModuleFingerprints(compilation);\n const isUsed = trackModuleUsage(compiler, compilation, this.options.module);\n\n updateBuildAssetsChunkHashes(compilation, this.options, runtimeModuleFingerprints, injectedRuntimes);\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(PluginName, (chunk, requirements) => {\n if (!selectedRuntimes) {\n selectedRuntimes = new Map();\n // Select and validate in entrypoint order, independently of runtime hook order.\n for (const [name, entrypoint] of compilation.entrypoints) {\n const runtime = entrypoint.getRuntimeChunk();\n const fullMap = name === this.options.fullMapEntrypoint;\n const delivery = fullMap ? this.options.module.full : this.options.module.current;\n if (!isUsed(runtime, delivery.export)) continue;\n\n validateEntrypointRuntime(compilation, name);\n if (fullMap) validateFullMapEntrypoint(compilation, name);\n selectedRuntimes.set(runtime, {name, fullMap, property: delivery.property});\n }\n }\n\n if (!filenamesValidated) {\n validateAsyncChunkFilenames(compilation, this.options.cssChunkFilename);\n filenamesValidated = true;\n }\n\n const selection = selectedRuntimes.get(chunk);\n if (!selection || injectedRuntimes.has(chunk)) return;\n\n requirements.add(RuntimeGlobals.require);\n injectedRuntimes.add(chunk);\n compilation.addRuntimeModule(\n chunk,\n new BuildAssetsRuntimeModule(\n selection.fullMap,\n selection.name,\n selection.property,\n this.options.cssFilename,\n this.options.cssChunkFilename,\n entrypointRuntimeUsesFullHash(\n compilation,\n selection.name,\n this.options.cssFilename,\n this.options.cssChunkFilename\n )\n )\n );\n });\n\n compilation.hooks.processAssets.tap(\n {\n name: PluginName,\n stage: EmbedStage,\n },\n () => {\n const assets = collectBuildAssets(compilation);\n const fullMap = getFullMapRuntime(compilation, this.options.fullMapEntrypoint, injectedRuntimes);\n setCompilationBuildAssets(compilation, assets);\n\n if (fullMap) {\n validateFullMapAssets(assets, this.options.fullMapEntrypoint);\n replaceFullMapPlaceholder(compilation, getFullMapRuntimeFiles(fullMap, assets), assets);\n }\n }\n );\n\n compilation.hooks.processAssets.tap(\n {\n name: `${PluginName}:finalize`,\n stage: Compilation.PROCESS_ASSETS_STAGE_ANALYSE,\n },\n () => finalizeBuildAssets(compilation, this.options, injectedRuntimes)\n );\n });\n\n // Register after every afterPlugins callback, then run after ordinary emit taps but before files are written.\n compiler.hooks.afterPlugins.intercept({\n name: `${PluginName}:registerFinalValidation`,\n done: () => {\n compiler.hooks.emit.tap(\n {name: `${PluginName}:finalValidation`, stage: FinalValidationStage},\n compilation => {\n const runtimes = runtimeSelections.get(compilation);\n if (runtimes) finalizeBuildAssets(compilation, this.options, runtimes);\n }\n );\n },\n });\n }\n}\n"],"mappings":"AAAA,SAAe,aAAiC,gBAAgB,eAAe,eAAc;AAC7F,OAAO,eAAe;AACtB,OAAO,QAAQ;AAEf,SAAQ,0BAAyB;AACjC,SAAQ,iCAAgC;AACxC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAQ,eAAc;AAItB,SAAQ,wBAA+D;AAEvE,MAAM,aAAa;AAEnB,MAAM,qBAAqB;AAE3B,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAE9B,MAAM,aAAa,OAAO;AAC1B,MAAM,uBAAuB;AAuB7B,MAAM,8BAA8B,CAAC,aAA0B,qBAAqC;AA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A,YACb,KAAK,QAAQ;AAAA,YACb;AAAA,cACI;AAAA,cACA,UAAU;AAAA,cACV,KAAK,QAAQ;AAAA,cACb,KAAK,QAAQ;AAAA,YACjB;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ,CAAC;AAED,kBAAY,MAAM,cAAc;AAAA,QAC5B;AAAA,UACI,MAAM;AAAA,UACN,OAAO;AAAA,QACX;AAAA,QACA,MAAM;AACF,gBAAM,SAAS,mBAAmB,WAAW;AAC7C,gBAAM,UAAU,kBAAkB,aAAa,KAAK,QAAQ,mBAAmB,gBAAgB;AAC/F,oCAA0B,aAAa,MAAM;AAE7C,cAAI,SAAS;AACT,kCAAsB,QAAQ,KAAK,QAAQ,iBAAiB;AAC5D,sCAA0B,aAAa,uBAAuB,SAAS,MAAM,GAAG,MAAM;AAAA,UAC1F;AAAA,QACJ;AAAA,MACJ;AAEA,kBAAY,MAAM,cAAc;AAAA,QAC5B;AAAA,UACI,MAAM,GAAG,UAAU;AAAA,UACnB,OAAO,YAAY;AAAA,QACvB;AAAA,QACA,MAAM,oBAAoB,aAAa,KAAK,SAAS,gBAAgB;AAAA,MACzE;AAAA,IACJ,CAAC;AAGD,aAAS,MAAM,aAAa,UAAU;AAAA,MAClC,MAAM,GAAG,UAAU;AAAA,MACnB,MAAM,MAAM;AACR,iBAAS,MAAM,KAAK;AAAA,UAChB,EAAC,MAAM,GAAG,UAAU,oBAAoB,OAAO,qBAAoB;AAAA,UACnE,iBAAe;AACX,kBAAM,WAAW,kBAAkB,IAAI,WAAW;AAClD,gBAAI,SAAU,qBAAoB,aAAa,KAAK,SAAS,QAAQ;AAAA,UACzE;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.ts"],"sourcesContent":["import {Chunk, Compilation, Compiler, Filename, RuntimeGlobals, RuntimeModule, sources} from \"@rspack/core\";\nimport stringify from \"json-stringify-deterministic\";\nimport ts from \"typescript\";\n\nimport {collectBuildAssets} from \"@cli/bundler/utils/assets\";\nimport {normalizeAssets, normalizeAssetsMap} from \"./normalize\";\nimport {renderBuildAssetsRuntime} from \"./templates\";\nimport {setCompilationBuildAssets} from \"../utils\";\n\nimport {\n CssContentHashType,\n JavaScriptContentHashType,\n resolveChunkFilename,\n resolveFilenameTemplate,\n filenameRequiresFullHash,\n} from \"@cli/bundler/utils/chunk-filename\";\n\nimport {toPosix} from \"@cli/utils/path\";\n\nimport type {EntrypointAssetsMap, EntrypointAssets} from \"@typing/entrypoint\";\n\nimport {trackModuleUsage, type BuildAssetsMapPluginModuleOptions} from \"./usage\";\n\nconst PluginName = \"BuildAssetsMapPlugin\";\n// Replaced with the full map once Rspack has resolved the output filenames.\nconst FullMapPlaceholder = \"__ADNBN_BUILD_ASSETS_FULL_MAP_PLACEHOLDER__\";\n// These JSON envelope keys let final validation locate each map after minification.\nconst FullMapEnvelopeKey = \"__adnbnBuildAssetsFullMap__\";\nconst CurrentMapEnvelopeKey = \"__adnbnBuildAssetsCurrentMap__\";\n// Hash-based output names are fixed when processAssets starts, so the asset graph is frozen here.\nconst EmbedStage = Number.NEGATIVE_INFINITY;\nconst FinalValidationStage = Infinity;\n\ninterface FullMapRuntime {\n readonly name: string;\n readonly runtime: Chunk;\n}\n\ninterface RuntimeSelection {\n readonly name: string;\n readonly fullMap: boolean;\n readonly property: string;\n}\n\nexport interface BuildAssetsMapPluginOptions {\n readonly module: BuildAssetsMapPluginModuleOptions;\n readonly buildHashSalt?: string;\n readonly cssChunkFilename: Filename;\n readonly cssFilename: Filename;\n readonly fullMapEntrypoint: string;\n}\n\ntype RuntimeModuleFingerprints = Map<Chunk, Map<string, string>>;\n\nconst validateAsyncChunkFilenames = (compilation: Compilation, cssChunkFilename: Filename): void => {\n const asyncChunks = new Set(\n Array.from(compilation.entrypoints.values()).flatMap(entrypoint => {\n return Array.from(entrypoint.getEntrypointChunk().getAllAsyncChunks());\n })\n );\n\n const validate = (\n filename: Filename,\n chunks: Iterable<Chunk>,\n contentHashType: string,\n assetType: \"CSS\" | \"JavaScript\",\n configName: \"cssFilename\" | \"jsFilename\"\n ): void => {\n if (typeof filename !== \"function\") {\n return;\n }\n\n const returnsFullHash = Array.from(chunks).some(chunk => {\n const template = resolveFilenameTemplate(compilation, chunk, filename, contentHashType);\n\n return /\\[(?:fullhash|hash)(?::\\d+)?\\]/i.test(template);\n });\n\n if (returnsFullHash) {\n const target = assetType === \"JavaScript\" ? \"async chunk URLs\" : \"async CSS chunk URLs\";\n\n throw new Error(\n `Rspack cannot generate ${target} when a filename callback returns [fullhash]; configure ${configName} as a string template instead`\n );\n }\n };\n\n if (compilation.outputOptions.chunkFilename) {\n validate(\n compilation.outputOptions.chunkFilename,\n asyncChunks,\n JavaScriptContentHashType,\n \"JavaScript\",\n \"jsFilename\"\n );\n }\n\n validate(\n cssChunkFilename,\n Array.from(asyncChunks).filter(chunk => chunkHasCss(compilation, chunk)),\n CssContentHashType,\n \"CSS\",\n \"cssFilename\"\n );\n};\n\nconst chunkHasCss = (compilation: Compilation, chunk: Chunk): boolean => {\n return Array.from(compilation.chunkGraph.getChunkModulesIterable(chunk)).some(module => {\n return module.type === CssContentHashType;\n });\n};\n\nconst chunkHasJavaScript = (compilation: Compilation, chunk: Chunk): boolean => {\n // splitChunks can move every user module out of an entry, but its bootstrap\n // still emits a JavaScript file and remains an initial dependency.\n if (chunk.hasRuntime()) {\n return true;\n }\n\n return Array.from(compilation.chunkGraph.getChunkModulesIterable(chunk)).some(module => {\n return module.type.startsWith(\"javascript\");\n });\n};\n\nconst getEntrypointRuntimeAssets = (\n compilation: Compilation,\n name: string,\n cssFilename: Filename,\n cssChunkFilename: Filename\n): EntrypointAssets => {\n const entrypoint = compilation.entrypoints.get(name);\n\n if (!entrypoint) {\n throw new Error(`Build assets entrypoint \"${name}\" is unavailable`);\n }\n\n const entryChunk = entrypoint.getEntrypointChunk();\n const initialChunks = Array.from(entrypoint.chunks);\n const asyncChunks = Array.from(entryChunk.getAllAsyncChunks());\n const jsFilename = compilation.outputOptions.filename;\n const jsChunkFilename = compilation.outputOptions.chunkFilename;\n\n if (!jsFilename || !jsChunkFilename) {\n throw new Error(\"Build assets require output.filename and output.chunkFilename\");\n }\n\n return {\n initial: {\n js: initialChunks\n .filter(chunk => chunkHasJavaScript(compilation, chunk))\n .map(chunk => {\n return resolveChunkFilename(\n compilation,\n chunk,\n chunk === entryChunk ? jsFilename : jsChunkFilename,\n JavaScriptContentHashType\n );\n }),\n css: initialChunks\n .filter(chunk => chunkHasCss(compilation, chunk))\n .map(chunk => {\n return resolveChunkFilename(\n compilation,\n chunk,\n chunk.canBeInitial() ? cssFilename : cssChunkFilename,\n CssContentHashType\n );\n }),\n },\n async: {\n js: asyncChunks\n .filter(chunk => chunkHasJavaScript(compilation, chunk))\n .map(chunk => {\n return resolveChunkFilename(compilation, chunk, jsChunkFilename, JavaScriptContentHashType);\n }),\n css: asyncChunks\n .filter(chunk => chunkHasCss(compilation, chunk))\n .map(chunk => {\n return resolveChunkFilename(compilation, chunk, cssChunkFilename, CssContentHashType);\n }),\n },\n };\n};\n\nconst entrypointRuntimeUsesFullHash = (\n compilation: Compilation,\n name: string,\n cssFilename: Filename,\n cssChunkFilename: Filename\n): boolean => {\n const entrypoint = compilation.entrypoints.get(name);\n\n if (!entrypoint) {\n return false;\n }\n\n const entryChunk = entrypoint.getEntrypointChunk();\n const initialChunks = Array.from(entrypoint.chunks);\n const asyncChunks = Array.from(entryChunk.getAllAsyncChunks());\n const jsFilename = compilation.outputOptions.filename;\n const jsChunkFilename = compilation.outputOptions.chunkFilename;\n\n if (!jsFilename || !jsChunkFilename) {\n return false;\n }\n\n return (\n initialChunks.some(chunk => {\n const js = filenameRequiresFullHash(\n compilation,\n chunk,\n chunk === entryChunk ? jsFilename : jsChunkFilename,\n JavaScriptContentHashType\n );\n\n const css =\n chunkHasCss(compilation, chunk) &&\n filenameRequiresFullHash(\n compilation,\n chunk,\n chunk.canBeInitial() ? cssFilename : cssChunkFilename,\n CssContentHashType\n );\n\n return js || css;\n }) ||\n asyncChunks.some(chunk => {\n const js = filenameRequiresFullHash(compilation, chunk, jsChunkFilename, JavaScriptContentHashType);\n\n const css =\n chunkHasCss(compilation, chunk) &&\n filenameRequiresFullHash(compilation, chunk, cssChunkFilename, CssContentHashType);\n\n return js || css;\n })\n );\n};\n\nconst getChunkKey = (chunk: Chunk): string => {\n return `${String(chunk.name ?? \"\")}:${String(chunk.id ?? \"\")}`;\n};\n\nconst getFullMapRuntime = (\n compilation: Compilation,\n name: string,\n runtimes: ReadonlySet<Chunk>\n): FullMapRuntime | undefined => {\n const entrypoint = compilation.entrypoints.get(name);\n\n if (!entrypoint || !runtimes.has(entrypoint.getRuntimeChunk())) {\n return;\n }\n\n return {name, runtime: entrypoint.getRuntimeChunk()};\n};\n\nconst getFullMapRuntimeFiles = (fullMap: FullMapRuntime, assets: EntrypointAssetsMap): readonly string[] => {\n const runtimeFiles = new Set(Array.from(fullMap.runtime.files, toPosix));\n\n return assets[fullMap.name].initial.js.filter(file => runtimeFiles.has(file));\n};\n\nconst validateEntrypointRuntime = (compilation: Compilation, name: string): void => {\n const entrypoint = compilation.entrypoints.get(name)!;\n\n if (entrypoint.getRuntimeChunk() !== entrypoint.getEntrypointChunk()) {\n throw new Error(\n `Build assets require a self-contained runtime for entrypoint \"${name}\"; disable optimization.runtimeChunk`\n );\n }\n};\n\nconst validateFullMapEntrypoint = (compilation: Compilation, name: string): void => {\n const entrypoint = compilation.entrypoints.get(name);\n\n if (!entrypoint) {\n return;\n }\n\n const entryChunk = entrypoint.getEntrypointChunk();\n const initialChunks = Array.from(entrypoint.chunks);\n const asyncChunks = Array.from(entryChunk.getAllAsyncChunks());\n\n if (initialChunks.length !== 1 || initialChunks[0] !== entryChunk || asyncChunks.length > 0) {\n throw new Error(\n `Full build-assets entrypoint \"${name}\" must be a single self-contained chunk; async chunks are not supported`\n );\n }\n};\n\nconst validateFullMapAssets = (assets: EntrypointAssetsMap, name: string): void => {\n const entrypoint = assets[name];\n\n if (!entrypoint) {\n return;\n }\n\n if (entrypoint.initial.js.length !== 1 || entrypoint.async.js.length > 0) {\n throw new Error(\n `Full build-assets entrypoint \"${name}\" must emit exactly one initial JavaScript file and no async JavaScript files`\n );\n }\n};\n\nconst serializeFilename = (filename: unknown): string => {\n return typeof filename === \"function\" ? filename.toString() : JSON.stringify(filename);\n};\n\nconst collectRuntimeModuleFingerprints = (compilation: Compilation): RuntimeModuleFingerprints => {\n const fingerprints: RuntimeModuleFingerprints = new Map();\n\n compilation.hooks.runtimeModule.tap(PluginName, (runtimeModule, chunk) => {\n if (runtimeModule.identifier().startsWith(\"webpack/runtime/build assets \")) {\n return;\n }\n\n let chunkFingerprints = fingerprints.get(chunk);\n\n if (!chunkFingerprints) {\n chunkFingerprints = new Map();\n fingerprints.set(chunk, chunkFingerprints);\n }\n\n chunkFingerprints.set(`${runtimeModule.stage}:${runtimeModule.identifier()}`, runtimeModule.generate());\n });\n\n return fingerprints;\n};\n\nconst updateBuildAssetsChunkHashes = (\n compilation: Compilation,\n options: Required<BuildAssetsMapPluginOptions>,\n runtimeModuleFingerprints: RuntimeModuleFingerprints,\n runtimes: ReadonlySet<Chunk>\n): void => {\n compilation.hooks.chunkHash.tap(PluginName, (chunk, hash) => {\n if (!runtimes.has(chunk)) {\n return;\n }\n\n const runtimeEntry = Array.from(compilation.entrypoints).find(([, entrypoint]) => {\n return entrypoint.getRuntimeChunk() === chunk;\n });\n\n if (!runtimeEntry) {\n return;\n }\n\n const [runtimeName] = runtimeEntry;\n const fullMap = runtimeName === options.fullMapEntrypoint;\n\n const entries = fullMap\n ? Array.from(compilation.entrypoints).toSorted(([left], [right]) => left.localeCompare(right))\n : [runtimeEntry];\n\n hash.update(`${PluginName}:runtime-map:${runtimeName}`, \"utf8\");\n hash.update(options.buildHashSalt, \"utf8\");\n hash.update(serializeFilename(compilation.outputOptions.filename), \"utf8\");\n hash.update(serializeFilename(compilation.outputOptions.chunkFilename), \"utf8\");\n hash.update(serializeFilename(options.cssFilename), \"utf8\");\n hash.update(serializeFilename(options.cssChunkFilename), \"utf8\");\n\n if (fullMap) {\n hash.update(serializeFilename(compilation.outputOptions.assetModuleFilename), \"utf8\");\n }\n\n for (const [entryName, entrypoint] of entries) {\n hash.update(entryName, \"utf8\");\n\n const entryChunk = entrypoint.getEntrypointChunk();\n const initialChunks = new Set(entrypoint.chunks);\n\n const chunks = Array.from(entryChunk.getAllReferencedChunks()).toSorted((left, right) =>\n getChunkKey(left).localeCompare(getChunkKey(right))\n );\n\n for (const referencedChunk of chunks) {\n const category = initialChunks.has(referencedChunk) ? \"initial\" : \"async\";\n\n hash.update(`${category}:${getChunkKey(referencedChunk)}`, \"utf8\");\n\n const jsFilename =\n referencedChunk === entryChunk\n ? compilation.outputOptions.filename\n : compilation.outputOptions.chunkFilename;\n\n if (jsFilename) {\n const template = resolveFilenameTemplate(\n compilation,\n referencedChunk,\n jsFilename,\n JavaScriptContentHashType\n );\n\n hash.update(`javascript-template:${template}`, \"utf8\");\n }\n\n if (chunkHasCss(compilation, referencedChunk)) {\n const cssFilename = referencedChunk.canBeInitial() ? options.cssFilename : options.cssChunkFilename;\n\n const template = resolveFilenameTemplate(\n compilation,\n referencedChunk,\n cssFilename,\n CssContentHashType\n );\n\n hash.update(`css-template:${template}`, \"utf8\");\n }\n\n const moduleHashes = Array.from(\n compilation.chunkGraph.getChunkModulesIterable(referencedChunk),\n module => {\n return compilation.chunkGraph.getModuleHash(module, new Set(referencedChunk.runtime)) ?? \"\";\n }\n ).toSorted();\n\n moduleHashes.forEach(moduleHash => hash.update(moduleHash, \"utf8\"));\n\n const runtimeFingerprints = runtimeModuleFingerprints.get(referencedChunk);\n\n if (runtimeFingerprints) {\n Array.from(runtimeFingerprints)\n .toSorted(([left], [right]) => left.localeCompare(right))\n .forEach(([identifier, source]) => {\n hash.update(`runtime-module:${identifier}`, \"utf8\");\n hash.update(source, \"utf8\");\n });\n }\n }\n }\n });\n};\n\nclass BuildAssetsRuntimeModule extends RuntimeModule {\n public constructor(\n private readonly fullMap: boolean,\n private readonly runtimeName: string,\n private readonly property: string,\n private readonly cssFilename: Filename,\n private readonly cssChunkFilename: Filename,\n fullHash: boolean\n ) {\n super(`build assets ${fullMap ? \"full\" : \"current\"} ${runtimeName}`, RuntimeModule.STAGE_TRIGGER);\n\n if (!fullMap) {\n this.dependentHash = true;\n this.fullHash = fullHash;\n }\n }\n\n public generate(): string {\n const runtime = RuntimeGlobals.require;\n\n if (this.fullMap) {\n return renderBuildAssetsRuntime({\n require: runtime,\n property: this.property,\n value: FullMapPlaceholder,\n envelope: FullMapEnvelopeKey,\n full: true,\n });\n }\n\n const compilation = this.compilation;\n\n if (!compilation) {\n throw new Error(\"Build assets runtime is not attached to a compilation\");\n }\n\n const current = getEntrypointRuntimeAssets(\n compilation,\n this.runtimeName,\n this.cssFilename,\n this.cssChunkFilename\n );\n\n const envelope = JSON.stringify({[CurrentMapEnvelopeKey]: current});\n\n return renderBuildAssetsRuntime({\n require: runtime,\n property: this.property,\n value: envelope,\n envelope: CurrentMapEnvelopeKey,\n full: false,\n });\n }\n}\n\nconst replaceFullMapPlaceholder = (\n compilation: Compilation,\n runtimeFiles: readonly string[],\n assets: EntrypointAssetsMap\n): void => {\n const placeholder = JSON.stringify(FullMapPlaceholder);\n const replacementValue = JSON.stringify(JSON.stringify({[FullMapEnvelopeKey]: assets}));\n let replacements = 0;\n\n for (const file of runtimeFiles) {\n const asset = compilation.getAsset(file);\n\n if (!asset) {\n continue;\n }\n\n const code = asset.source.source().toString();\n const start = code.indexOf(placeholder);\n\n if (start < 0) {\n continue;\n }\n\n if (code.indexOf(placeholder, start + placeholder.length) >= 0) {\n throw new Error(`Build assets placeholder occurs more than once in \"${file}\"`);\n }\n\n const source = new sources.ReplaceSource(asset.source);\n\n source.replace(start, start + placeholder.length - 1, replacementValue);\n compilation.updateAsset(file, source);\n replacements += 1;\n }\n\n if (replacements !== 1) {\n throw new Error(`Expected one full build-assets runtime, found ${replacements}`);\n }\n};\n\nconst extractEmbeddedEnvelope = <T>(file: string, source: string, key: string): T => {\n const sourceFile = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, false, ts.ScriptKind.JS);\n const values: T[] = [];\n\n const visit = (node: ts.Node): void => {\n if (ts.isStringLiteralLike(node) && node.text.includes(key)) {\n try {\n const envelope = JSON.parse(node.text) as Record<string, T>;\n\n if (Object.prototype.hasOwnProperty.call(envelope, key)) {\n values.push(envelope[key]);\n }\n } catch {}\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n\n if (values.length !== 1) {\n throw new Error(`Expected one embedded build assets value in \"${file}\", found ${values.length}`);\n }\n\n return values[0];\n};\n\nconst extractEmbeddedMap = (file: string, source: string): EntrypointAssetsMap => {\n return extractEmbeddedEnvelope<EntrypointAssetsMap>(file, source, FullMapEnvelopeKey);\n};\n\nconst validateEmbeddedMap = (compilation: Compilation, fullMap: FullMapRuntime, assets: EntrypointAssetsMap): void => {\n const runtimeFiles = getFullMapRuntimeFiles(fullMap, assets);\n\n const runtime = runtimeFiles\n .map(file => ({file, source: compilation.getAsset(file)?.source.source().toString() ?? \"\"}))\n .find(({source}) => source.length > 0);\n\n if (!runtime) {\n throw new Error(\n `Full build-assets runtime for entrypoint \"${fullMap.name}\" is unavailable after asset processing`\n );\n }\n\n const embedded = extractEmbeddedMap(runtime.file, runtime.source);\n\n if (stringify(normalizeAssetsMap(embedded)) !== stringify(assets)) {\n throw new Error(\n \"Build assets changed after the runtime map was embedded; finalize entrypoint assets before processAssets begins\"\n );\n }\n};\n\nconst validateCurrentEntrypointMaps = (\n compilation: Compilation,\n assets: EntrypointAssetsMap,\n fullMapEntrypoint: string,\n runtimes: ReadonlySet<Chunk>\n): void => {\n for (const [name, entrypointAssets] of Object.entries(assets)) {\n if (name === fullMapEntrypoint) {\n continue;\n }\n\n const entrypoint = compilation.entrypoints.get(name);\n\n if (!entrypoint) {\n throw new Error(`Build assets entrypoint \"${name}\" is unavailable`);\n }\n\n if (!runtimes.has(entrypoint.getRuntimeChunk())) {\n continue;\n }\n\n const runtimeFiles = new Set(Array.from(entrypoint.getRuntimeChunk().files, toPosix));\n\n const runtime = entrypointAssets.initial.js\n .filter(file => runtimeFiles.has(file))\n .map(file => ({file, source: compilation.getAsset(file)?.source.source().toString() ?? \"\"}))\n .find(({source}) => source.length > 0);\n\n if (!runtime) {\n throw new Error(`Runtime map for entrypoint \"${name}\" is unavailable after asset processing`);\n }\n\n const runtimeAssets = extractEmbeddedEnvelope<EntrypointAssets>(\n runtime.file,\n runtime.source,\n CurrentMapEnvelopeKey\n );\n\n const finalizedAssets: EntrypointAssets = {\n initial: entrypointAssets.initial,\n async: entrypointAssets.async,\n };\n\n if (stringify(normalizeAssets(runtimeAssets)) !== stringify(finalizedAssets)) {\n throw new Error(\n `Build assets changed after the runtime map for entrypoint \"${name}\" was embedded: ${JSON.stringify({embedded: runtimeAssets, finalized: finalizedAssets})}`\n );\n }\n }\n};\n\nconst finalizeBuildAssets = (\n compilation: Compilation,\n options: Required<BuildAssetsMapPluginOptions>,\n runtimes: ReadonlySet<Chunk>\n): void => {\n const assets = collectBuildAssets(compilation);\n const fullMap = getFullMapRuntime(compilation, options.fullMapEntrypoint, runtimes);\n\n if (fullMap) {\n validateFullMapAssets(assets, options.fullMapEntrypoint);\n validateEmbeddedMap(compilation, fullMap, assets);\n }\n\n validateCurrentEntrypointMaps(compilation, assets, options.fullMapEntrypoint, runtimes);\n\n setCompilationBuildAssets(compilation, assets);\n};\n\nexport default class BuildAssetsMapPlugin {\n private readonly options: Required<BuildAssetsMapPluginOptions>;\n\n public constructor(options: BuildAssetsMapPluginOptions) {\n this.options = {\n ...options,\n buildHashSalt: options.buildHashSalt ?? \"\",\n };\n }\n\n public apply(compiler: Compiler): void {\n const runtimeSelections = new WeakMap<Compilation, ReadonlySet<Chunk>>();\n\n compiler.hooks.thisCompilation.tap({name: PluginName, stage: EmbedStage}, compilation => {\n const injectedRuntimes = new Set<Chunk>();\n runtimeSelections.set(compilation, injectedRuntimes);\n let filenamesValidated = false;\n let selectedRuntimes: Map<Chunk, RuntimeSelection> | undefined;\n const runtimeModuleFingerprints = collectRuntimeModuleFingerprints(compilation);\n const isUsed = trackModuleUsage(compiler, compilation, this.options.module);\n\n updateBuildAssetsChunkHashes(compilation, this.options, runtimeModuleFingerprints, injectedRuntimes);\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(PluginName, (chunk, requirements) => {\n if (!selectedRuntimes) {\n selectedRuntimes = new Map();\n // Select and validate in entrypoint order, independently of runtime hook order.\n for (const [name, entrypoint] of compilation.entrypoints) {\n const runtime = entrypoint.getRuntimeChunk();\n const fullMap = name === this.options.fullMapEntrypoint;\n const delivery = fullMap ? this.options.module.full : this.options.module.current;\n\n if (!isUsed(runtime, delivery.export)) {\n continue;\n }\n\n validateEntrypointRuntime(compilation, name);\n\n if (fullMap) {\n validateFullMapEntrypoint(compilation, name);\n }\n\n selectedRuntimes.set(runtime, {name, fullMap, property: delivery.property});\n }\n }\n\n if (!filenamesValidated) {\n validateAsyncChunkFilenames(compilation, this.options.cssChunkFilename);\n filenamesValidated = true;\n }\n\n const selection = selectedRuntimes.get(chunk);\n\n if (!selection || injectedRuntimes.has(chunk)) {\n return;\n }\n\n requirements.add(RuntimeGlobals.require);\n injectedRuntimes.add(chunk);\n\n compilation.addRuntimeModule(\n chunk,\n new BuildAssetsRuntimeModule(\n selection.fullMap,\n selection.name,\n selection.property,\n this.options.cssFilename,\n this.options.cssChunkFilename,\n entrypointRuntimeUsesFullHash(\n compilation,\n selection.name,\n this.options.cssFilename,\n this.options.cssChunkFilename\n )\n )\n );\n });\n\n compilation.hooks.processAssets.tap(\n {\n name: PluginName,\n stage: EmbedStage,\n },\n () => {\n const assets = collectBuildAssets(compilation);\n const fullMap = getFullMapRuntime(compilation, this.options.fullMapEntrypoint, injectedRuntimes);\n setCompilationBuildAssets(compilation, assets);\n\n if (fullMap) {\n validateFullMapAssets(assets, this.options.fullMapEntrypoint);\n replaceFullMapPlaceholder(compilation, getFullMapRuntimeFiles(fullMap, assets), assets);\n }\n }\n );\n\n compilation.hooks.processAssets.tap(\n {\n name: `${PluginName}:finalize`,\n stage: Compilation.PROCESS_ASSETS_STAGE_ANALYSE,\n },\n () => finalizeBuildAssets(compilation, this.options, injectedRuntimes)\n );\n });\n\n // Register after every afterPlugins callback, then run after ordinary emit taps but before files are written.\n compiler.hooks.afterPlugins.intercept({\n name: `${PluginName}:registerFinalValidation`,\n done: () => {\n compiler.hooks.emit.tap(\n {name: `${PluginName}:finalValidation`, stage: FinalValidationStage},\n compilation => {\n const runtimes = runtimeSelections.get(compilation);\n\n if (runtimes) {\n finalizeBuildAssets(compilation, this.options, runtimes);\n }\n }\n );\n },\n });\n }\n}\n"],"mappings":"AAAA,SAAe,aAAiC,gBAAgB,eAAe,eAAc;AAC7F,OAAO,eAAe;AACtB,OAAO,QAAQ;AAEf,SAAQ,0BAAyB;AACjC,SAAQ,iBAAiB,0BAAyB;AAClD,SAAQ,gCAA+B;AACvC,SAAQ,iCAAgC;AAExC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAQ,eAAc;AAItB,SAAQ,wBAA+D;AAEvE,MAAM,aAAa;AAEnB,MAAM,qBAAqB;AAE3B,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAE9B,MAAM,aAAa,OAAO;AAC1B,MAAM,uBAAuB;AAuB7B,MAAM,8BAA8B,CAAC,aAA0B,qBAAqC;AAChG,QAAM,cAAc,IAAI;AAAA,IACpB,MAAM,KAAK,YAAY,YAAY,OAAO,CAAC,EAAE,QAAQ,gBAAc;AAC/D,aAAO,MAAM,KAAK,WAAW,mBAAmB,EAAE,kBAAkB,CAAC;AAAA,IACzE,CAAC;AAAA,EACL;AAEA,QAAM,WAAW,CACb,UACA,QACA,iBACA,WACA,eACO;AACP,QAAI,OAA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AAA,cACA,UAAU;AAAA,cACV,KAAK,QAAQ;AAAA,cACb,KAAK,QAAQ;AAAA,YACjB;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ,CAAC;AAED,kBAAY,MAAM,cAAc;AAAA,QAC5B;AAAA,UACI,MAAM;AAAA,UACN,OAAO;AAAA,QACX;AAAA,QACA,MAAM;AACF,gBAAM,SAAS,mBAAmB,WAAW;AAC7C,gBAAM,UAAU,kBAAkB,aAAa,KAAK,QAAQ,mBAAmB,gBAAgB;AAC/F,oCAA0B,aAAa,MAAM;AAE7C,cAAI,SAAS;AACT,kCAAsB,QAAQ,KAAK,QAAQ,iBAAiB;AAC5D,sCAA0B,aAAa,uBAAuB,SAAS,MAAM,GAAG,MAAM;AAAA,UAC1F;AAAA,QACJ;AAAA,MACJ;AAEA,kBAAY,MAAM,cAAc;AAAA,QAC5B;AAAA,UACI,MAAM,GAAG,UAAU;AAAA,UACnB,OAAO,YAAY;AAAA,QACvB;AAAA,QACA,MAAM,oBAAoB,aAAa,KAAK,SAAS,gBAAgB;AAAA,MACzE;AAAA,IACJ,CAAC;AAGD,aAAS,MAAM,aAAa,UAAU;AAAA,MAClC,MAAM,GAAG,UAAU;AAAA,MACnB,MAAM,MAAM;AACR,iBAAS,MAAM,KAAK;AAAA,UAChB,EAAC,MAAM,GAAG,UAAU,oBAAoB,OAAO,qBAAoB;AAAA,UACnE,iBAAe;AACX,kBAAM,WAAW,kBAAkB,IAAI,WAAW;AAElD,gBAAI,UAAU;AACV,kCAAoB,aAAa,KAAK,SAAS,QAAQ;AAAA,YAC3D;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { EntrypointAssets, EntrypointAssetsMap } from "../../../../types/entrypoint.js";
2
+ export declare const normalizeAssets: <T extends EntrypointAssets>(assets: T) => T;
3
+ export declare const normalizeAssetsMap: (assets: EntrypointAssetsMap) => EntrypointAssetsMap;
@@ -0,0 +1,24 @@
1
+ const normalizeAssets = (assets) => {
2
+ const initial = {
3
+ js: [...new Set(assets.initial.js)],
4
+ css: [...new Set(assets.initial.css)]
5
+ };
6
+ const initialFiles = /* @__PURE__ */ new Set([...initial.js, ...initial.css]);
7
+ const async = {
8
+ js: [...new Set(assets.async.js)].filter((file) => !initialFiles.has(file)),
9
+ css: [...new Set(assets.async.css)].filter((file) => !initialFiles.has(file))
10
+ };
11
+ return {
12
+ ...assets,
13
+ initial,
14
+ async
15
+ };
16
+ };
17
+ const normalizeAssetsMap = (assets) => {
18
+ return Object.fromEntries(Object.entries(assets).map(([name, entry]) => [name, normalizeAssets(entry)]));
19
+ };
20
+ export {
21
+ normalizeAssets,
22
+ normalizeAssetsMap
23
+ };
24
+ //# sourceMappingURL=normalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/build-assets-map/normalize.ts"],"sourcesContent":["import type {EntrypointAssets, EntrypointAssetsMap} from \"@typing/entrypoint\";\n\n// realContentHash may merge different chunk filenames into one emitted file.\nexport const normalizeAssets = <T extends EntrypointAssets>(assets: T): T => {\n const initial = {\n js: [...new Set(assets.initial.js)],\n css: [...new Set(assets.initial.css)],\n };\n\n const initialFiles = new Set([...initial.js, ...initial.css]);\n\n const async = {\n js: [...new Set(assets.async.js)].filter(file => !initialFiles.has(file)),\n css: [...new Set(assets.async.css)].filter(file => !initialFiles.has(file)),\n };\n\n return {\n ...assets,\n initial,\n async,\n };\n};\n\nexport const normalizeAssetsMap = (assets: EntrypointAssetsMap): EntrypointAssetsMap => {\n return Object.fromEntries(Object.entries(assets).map(([name, entry]) => [name, normalizeAssets(entry)]));\n};\n"],"mappings":"AAGO,MAAM,kBAAkB,CAA6B,WAAiB;AACzE,QAAM,UAAU;AAAA,IACZ,IAAI,CAAC,GAAG,IAAI,IAAI,OAAO,QAAQ,EAAE,CAAC;AAAA,IAClC,KAAK,CAAC,GAAG,IAAI,IAAI,OAAO,QAAQ,GAAG,CAAC;AAAA,EACxC;AAEA,QAAM,eAAe,oBAAI,IAAI,CAAC,GAAG,QAAQ,IAAI,GAAG,QAAQ,GAAG,CAAC;AAE5D,QAAM,QAAQ;AAAA,IACV,IAAI,CAAC,GAAG,IAAI,IAAI,OAAO,MAAM,EAAE,CAAC,EAAE,OAAO,UAAQ,CAAC,aAAa,IAAI,IAAI,CAAC;AAAA,IACxE,KAAK,CAAC,GAAG,IAAI,IAAI,OAAO,MAAM,GAAG,CAAC,EAAE,OAAO,UAAQ,CAAC,aAAa,IAAI,IAAI,CAAC;AAAA,EAC9E;AAEA,SAAO;AAAA,IACH,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACJ;AACJ;AAEO,MAAM,qBAAqB,CAAC,WAAqD;AACpF,SAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,gBAAgB,KAAK,CAAC,CAAC,CAAC;AAC3G;","names":[]}
@@ -0,0 +1,2 @@
1
+ declare var assets: any;
2
+ declare var entries: any[];
@@ -0,0 +1,9 @@
1
+ import type { RuntimePropertyOptions } from "../types.js";
2
+ interface BuildAssetsRuntimeTemplateOptions extends RuntimePropertyOptions {
3
+ readonly require: string;
4
+ readonly value: string;
5
+ readonly envelope: string;
6
+ readonly full: boolean;
7
+ }
8
+ export declare const renderBuildAssetsRuntime: (options: BuildAssetsRuntimeTemplateOptions) => string;
9
+ export {};
@@ -0,0 +1,32 @@
1
+ // raw-loader:/home/runner/work/addon-bone/addon-bone/src/cli/bundler/plugins/build-assets-map/templates/runtime.template.js?raw
2
+ var runtime_template_default = "var assets = JSON.parse(__ADNBN_VALUE__)[__ADNBN_ENVELOPE__];\nvar entries = __ADNBN_FULL_MAP__ ? Object.keys(assets).map(name => assets[name]) : [assets];\n\n// realContentHash can merge multiple chunk filenames into one emitted file.\n// Normalize after those substitutions, preserving the dependency order.\nentries.forEach(entry => {\n entry.initial.js = Array.from(new Set(entry.initial.js));\n entry.initial.css = Array.from(new Set(entry.initial.css));\n var initial = new Set(entry.initial.js.concat(entry.initial.css));\n entry.async.js = Array.from(new Set(entry.async.js)).filter(file => !initial.has(file));\n entry.async.css = Array.from(new Set(entry.async.css)).filter(file => !initial.has(file));\n});\n\n__ADNBN_REQUIRE__[__ADNBN_PROPERTY__] = assets;\n";
3
+
4
+ // src/cli/bundler/plugins/utils/runtime-template.ts
5
+ var PlaceholderPattern = /__ADNBN_[A-Z0-9_]+__/g;
6
+ var renderRuntimeTemplate = (template, values) => {
7
+ for (const placeholder of Object.keys(values)) {
8
+ if (!template.includes(placeholder)) {
9
+ throw new Error(`Runtime template placeholder "${placeholder}" is unavailable`);
10
+ }
11
+ }
12
+ return template.replace(PlaceholderPattern, (placeholder) => {
13
+ if (!Object.hasOwn(values, placeholder)) {
14
+ throw new Error(`Runtime template placeholder "${placeholder}" was not replaced`);
15
+ }
16
+ return values[placeholder];
17
+ }).trim();
18
+ };
19
+
20
+ // src/cli/bundler/plugins/build-assets-map/templates.ts
21
+ var renderBuildAssetsRuntime = (options) => {
22
+ return renderRuntimeTemplate(runtime_template_default, {
23
+ __ADNBN_REQUIRE__: options.require,
24
+ __ADNBN_PROPERTY__: JSON.stringify(options.property),
25
+ __ADNBN_VALUE__: JSON.stringify(options.value),
26
+ __ADNBN_ENVELOPE__: JSON.stringify(options.envelope),
27
+ __ADNBN_FULL_MAP__: JSON.stringify(options.full)
28
+ });
29
+ };
30
+ export {
31
+ renderBuildAssetsRuntime
32
+ };
@@ -1,5 +1,6 @@
1
1
  import _ from "lodash";
2
2
  import path from "path";
3
+ import { DynamicEntryPlugin } from "@rspack/core";
3
4
  import { RspackVirtualModulePlugin as VirtualModulesPlugin } from "rspack-plugin-virtual-module";
4
5
  class EntrypointPlugin {
5
6
  constructor(entries = /* @__PURE__ */ new Map()) {
@@ -55,6 +56,16 @@ class EntrypointPlugin {
55
56
  this.hookEntryOption(entry);
56
57
  });
57
58
  if (this.update) {
59
+ compiler.hooks.afterEnvironment.tap(this.pluginName, () => {
60
+ compiler.hooks.entryOption.tap(`${this.pluginName}:watch`, (context, entry) => {
61
+ compiler.options.entry = entry;
62
+ new DynamicEntryPlugin(context, async () => {
63
+ const entry2 = compiler.options.entry;
64
+ return typeof entry2 === "function" ? entry2() : entry2;
65
+ }).apply(compiler);
66
+ return true;
67
+ });
68
+ });
58
69
  compiler.hooks.watchRun.tapAsync(this.pluginName, (compiler2, callback) => {
59
70
  this.hookWatchRun(compiler2).then(() => callback()).catch(callback);
60
71
  });
@@ -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,MAAM,IAAI;AAC7B,aAAO,KAAK,SAAS;AAAA,IACzB;AAEA,WAAO,KAAK,KAAK,WAAW,IAAI;AAAA,EACpC;AAAA,EAEA,IAAc,SAA+B;AACzC,QAAI,KAAK,SAAS;AACd,aAAO,KAAK;AAAA,IAChB;AAEA,UAAM,UAAU,OAAO,YAAY,KAAK,kBAAkB,KAAK,OAAO,CAAC;AAEvE,WAAQ,KAAK,UAAU,IAAI,qBAAqB,SAAS,YAAY;AAAA,EACzE;AAAA,EAEA,IAAc,UAAwC;AAClD,WAAQ,KAAK,aAAL,KAAK,WAAa,KAAK,cAAc,KAAK,OAAO;AAAA,EAC7D;AAAA,EAEA,IAAc,aAAkC;AAC5C,UAAM,QAAQ,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC,EACzC,QAAQ,aAAW,MAAM,KAAK,QAAQ,KAAK,CAAC,CAAC,EAC7C,OAAO,CAAC,EAAC,SAAQ,MAAM,CAAC,QAAQ,EAChC,IA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AoB;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;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,MAAM,IAAI;AAC7B,aAAO,KAAK,SAAS;AAAA,IACzB;AAEA,WAAO,KAAK,KAAK,WAAW,IAAI;AAAA,EACpC;AAAA,EAEA,IAAc,SAA+B;AACzC,QAAI,KAAK,SAAS;AACd,aAAO,KAAK;AAAA,IAChB;AAEA,UAAM,UAAU,OAAO,YAAY,KAAK,kBAAkB,KAAK,OAAO,CAAC;AAEvE,WAAQ,KAAK,UAAU,IAAI,qBAAqB,SAAS,YAAY;AAAA,EACzE;AAAA,EAEA,IAAc,UAAwC;AAClD,WAAQ,KAAK,aAAL,KAAK,WAAa,K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AED,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":["_","entry","compiler","name","modules"]}
@@ -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. */
@@ -2,7 +2,8 @@ import { RuntimeGlobals, RuntimeModule } from "@rspack/core";
2
2
  import { CssContentHashType, filenameRequiresFullHash, resolveChunkFilename } from "./../../../../cli/bundler/utils/chunk-filename.js";
3
3
  import { getManifestHooks } from "../utils/manifest-hooks.js";
4
4
  import { renderIsolatedStylesCssLoader, renderIsolatedStylesRuntime } from "./templates.js";
5
- import { getIsolatedStylesFiles, isIsolatedStylesChunk } from "./chunks.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 {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 {getIsolatedStylesFiles, isIsolatedStylesChunk} from \"./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, 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`);\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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"]}
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,gB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YAAY;AAChC,oBAAM,cACF,KAAK,QAAQ,KAAK,KAAK,KAAK,sBAAsB,aAAa,SAAS,IAClE,WACA;AAEV,yBAAW,QAAQ,UAAU,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"]}
@@ -1,3 +1,7 @@
1
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. */
2
3
  export declare const isIsolatedStylesChunk: (compilation: Compilation, chunk: Chunk) => boolean;
3
- export declare const getIsolatedStylesFiles: (compilation: Compilation) => ReadonlySet<string>;
4
+ export declare const getStylesFiles: (compilation: Compilation, chunks: Iterable<Chunk>) => {
5
+ document: ReadonlySet<string>;
6
+ defaults: ReadonlySet<string>;
7
+ };