adnbn 0.9.0 → 0.11.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 (608) hide show
  1. package/dist/cli/builders/locale/LocaleBuilder.js +2 -11
  2. package/dist/cli/builders/locale/LocaleBuilder.js.map +1 -1
  3. package/dist/cli/builders/locale/index.js +1 -1
  4. package/dist/cli/builders/locale/index.js.map +1 -1
  5. package/dist/cli/builders/manifest/ManifestBase.d.ts +4 -1
  6. package/dist/cli/builders/manifest/ManifestBase.js +35 -6
  7. package/dist/cli/builders/manifest/ManifestBase.js.map +1 -1
  8. package/dist/cli/builders/manifest/ManifestV2.js +1 -1
  9. package/dist/cli/builders/manifest/ManifestV3.js +12 -5
  10. package/dist/cli/builders/manifest/ManifestV3.js.map +1 -1
  11. package/dist/cli/builders/manifest/utils/data-collection-permissions.d.ts +15 -0
  12. package/dist/cli/builders/manifest/utils/data-collection-permissions.js +26 -0
  13. package/dist/cli/builders/manifest/utils/data-collection-permissions.js.map +1 -0
  14. package/dist/cli/builders/manifest/utils/host-patterns.d.ts +1 -0
  15. package/dist/cli/builders/manifest/utils/host-patterns.js +40 -0
  16. package/dist/cli/builders/manifest/utils/host-patterns.js.map +1 -0
  17. package/dist/cli/builders/manifest/utils/index.d.ts +4 -0
  18. package/dist/cli/builders/manifest/utils/index.js +19 -0
  19. package/dist/cli/builders/manifest/utils/index.js.map +1 -0
  20. package/dist/cli/builders/manifest/utils/permissions.d.ts +14 -0
  21. package/dist/cli/builders/manifest/utils/permissions.js +34 -0
  22. package/dist/cli/builders/manifest/utils/permissions.js.map +1 -0
  23. package/dist/cli/builders/manifest/utils/web-accessible-resources.d.ts +2 -0
  24. package/dist/cli/builders/manifest/utils/web-accessible-resources.js +92 -0
  25. package/dist/cli/builders/manifest/utils/web-accessible-resources.js.map +1 -0
  26. package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.d.ts +14 -0
  27. package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js +523 -0
  28. package/dist/cli/bundler/plugins/build-assets-map/BuildAssetsMapPlugin.js.map +1 -0
  29. package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.d.ts +13 -0
  30. package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.js +16 -0
  31. package/dist/cli/bundler/plugins/build-assets-map/entrypoint-module.js.map +1 -0
  32. package/dist/cli/bundler/plugins/build-assets-map/index.d.ts +3 -0
  33. package/dist/cli/bundler/plugins/build-assets-map/index.js +8 -0
  34. package/dist/cli/bundler/plugins/build-assets-map/index.js.map +1 -0
  35. package/dist/cli/bundler/plugins/build-assets-map/usage.d.ts +12 -0
  36. package/dist/cli/bundler/plugins/build-assets-map/usage.js +28 -0
  37. package/dist/cli/bundler/plugins/build-assets-map/usage.js.map +1 -0
  38. package/dist/cli/bundler/plugins/chunk-loader/ChunkLoaderPlugin.d.ts +9 -0
  39. package/dist/cli/bundler/plugins/chunk-loader/ChunkLoaderPlugin.js +43 -0
  40. package/dist/cli/bundler/plugins/chunk-loader/ChunkLoaderPlugin.js.map +1 -0
  41. package/dist/cli/bundler/plugins/chunk-loader/index.d.ts +1 -0
  42. package/dist/cli/bundler/plugins/chunk-loader/index.js +5 -0
  43. package/dist/cli/bundler/plugins/chunk-loader/index.js.map +1 -0
  44. package/dist/cli/bundler/plugins/chunk-loader/templates/runtime.template.d.ts +2 -0
  45. package/dist/cli/bundler/plugins/chunk-loader/templates.d.ts +7 -0
  46. package/dist/cli/bundler/plugins/chunk-loader/templates.js +30 -0
  47. package/dist/cli/bundler/plugins/{EntrypointPlugin.d.ts → entrypoint/EntrypointPlugin.d.ts} +7 -2
  48. package/dist/cli/bundler/plugins/{EntrypointPlugin.js → entrypoint/EntrypointPlugin.js} +46 -26
  49. package/dist/cli/bundler/plugins/entrypoint/EntrypointPlugin.js.map +1 -0
  50. package/dist/cli/bundler/plugins/entrypoint/index.d.ts +1 -0
  51. package/dist/cli/bundler/plugins/entrypoint/index.js +7 -0
  52. package/dist/cli/bundler/plugins/entrypoint/index.js.map +1 -0
  53. package/dist/cli/bundler/plugins/{GenerateJsonPlugin.d.ts → generate-json/GenerateJsonPlugin.d.ts} +1 -0
  54. package/dist/cli/bundler/plugins/generate-json/GenerateJsonPlugin.js +73 -0
  55. package/dist/cli/bundler/plugins/generate-json/GenerateJsonPlugin.js.map +1 -0
  56. package/dist/cli/bundler/plugins/generate-json/index.d.ts +1 -0
  57. package/dist/cli/bundler/plugins/generate-json/index.js +5 -0
  58. package/dist/cli/bundler/plugins/generate-json/index.js.map +1 -0
  59. package/dist/cli/bundler/plugins/generate-module/GenerateModulePlugin.d.ts +23 -0
  60. package/dist/cli/bundler/plugins/generate-module/GenerateModulePlugin.js +88 -0
  61. package/dist/cli/bundler/plugins/generate-module/GenerateModulePlugin.js.map +1 -0
  62. package/dist/cli/bundler/plugins/generate-module/index.d.ts +1 -0
  63. package/dist/cli/bundler/plugins/generate-module/index.js +7 -0
  64. package/dist/cli/bundler/plugins/generate-module/index.js.map +1 -0
  65. package/dist/cli/bundler/plugins/index.d.ts +11 -5
  66. package/dist/cli/bundler/plugins/index.js +32 -10
  67. package/dist/cli/bundler/plugins/index.js.map +1 -1
  68. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.d.ts +21 -0
  69. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js +174 -0
  70. package/dist/cli/bundler/plugins/isolated-styles/IsolatedStylesPlugin.js.map +1 -0
  71. package/dist/cli/bundler/plugins/isolated-styles/index.d.ts +1 -0
  72. package/dist/cli/bundler/plugins/isolated-styles/index.js +5 -0
  73. package/dist/cli/bundler/plugins/isolated-styles/index.js.map +1 -0
  74. package/dist/cli/bundler/plugins/isolated-styles/templates/css-loader.template.d.ts +1 -0
  75. package/dist/cli/bundler/plugins/isolated-styles/templates/runtime.template.d.ts +7 -0
  76. package/dist/cli/bundler/plugins/isolated-styles/templates.d.ts +18 -0
  77. package/dist/cli/bundler/plugins/isolated-styles/templates.js +174 -0
  78. package/dist/cli/bundler/plugins/manifest/ManifestPlugin.d.ts +10 -0
  79. package/dist/cli/bundler/plugins/manifest/ManifestPlugin.js +55 -0
  80. package/dist/cli/bundler/plugins/manifest/ManifestPlugin.js.map +1 -0
  81. package/dist/cli/bundler/plugins/manifest/index.d.ts +1 -0
  82. package/dist/cli/bundler/plugins/manifest/index.js +6 -0
  83. package/dist/cli/bundler/plugins/manifest/index.js.map +1 -0
  84. package/dist/cli/bundler/plugins/replace/ReplacePlugin.js.map +1 -0
  85. package/dist/cli/bundler/plugins/replace/index.d.ts +1 -0
  86. package/dist/cli/bundler/plugins/replace/index.js +5 -0
  87. package/dist/cli/bundler/plugins/replace/index.js.map +1 -0
  88. package/dist/cli/bundler/plugins/resource-access/ResourceAccessPlugin.d.ts +19 -0
  89. package/dist/cli/bundler/plugins/resource-access/ResourceAccessPlugin.js +20 -0
  90. package/dist/cli/bundler/plugins/resource-access/ResourceAccessPlugin.js.map +1 -0
  91. package/dist/cli/bundler/plugins/resource-access/index.d.ts +1 -0
  92. package/dist/cli/bundler/plugins/resource-access/index.js +5 -0
  93. package/dist/cli/bundler/plugins/resource-access/index.js.map +1 -0
  94. package/dist/cli/bundler/plugins/resource-access/utils.d.ts +8 -0
  95. package/dist/cli/bundler/plugins/resource-access/utils.js +42 -0
  96. package/dist/cli/bundler/plugins/resource-access/utils.js.map +1 -0
  97. package/dist/cli/bundler/plugins/types.d.ts +4 -0
  98. package/dist/cli/bundler/plugins/types.js +1 -0
  99. package/dist/cli/bundler/plugins/types.js.map +1 -0
  100. package/dist/cli/bundler/plugins/utils/index.d.ts +3 -0
  101. package/dist/cli/bundler/plugins/utils/index.js +9 -0
  102. package/dist/cli/bundler/plugins/utils/index.js.map +1 -0
  103. package/dist/cli/bundler/plugins/utils/manifest-hooks.d.ts +13 -0
  104. package/dist/cli/bundler/plugins/utils/manifest-hooks.js +17 -0
  105. package/dist/cli/bundler/plugins/utils/manifest-hooks.js.map +1 -0
  106. package/dist/cli/bundler/plugins/utils/runtime-template.d.ts +1 -0
  107. package/dist/cli/bundler/plugins/utils/runtime-template.js +18 -0
  108. package/dist/cli/bundler/plugins/utils/runtime-template.js.map +1 -0
  109. package/dist/cli/bundler/plugins/utils/watch-compilation.d.ts +3 -0
  110. package/dist/cli/bundler/plugins/utils/watch-compilation.js +18 -0
  111. package/dist/cli/bundler/plugins/utils/watch-compilation.js.map +1 -0
  112. package/dist/cli/bundler/plugins/watch/WatchPlugin.js +16 -0
  113. package/dist/cli/bundler/plugins/watch/WatchPlugin.js.map +1 -0
  114. package/dist/cli/bundler/plugins/watch/index.d.ts +1 -0
  115. package/dist/cli/bundler/plugins/watch/index.js +5 -0
  116. package/dist/cli/bundler/plugins/watch/index.js.map +1 -0
  117. package/dist/cli/bundler/utils/chunk-filename.d.ts +6 -0
  118. package/dist/cli/bundler/utils/chunk-filename.js +93 -0
  119. package/dist/cli/bundler/utils/chunk-filename.js.map +1 -0
  120. package/dist/cli/bundler/utils/index.d.ts +2 -0
  121. package/dist/cli/bundler/utils/index.js +2 -0
  122. package/dist/cli/bundler/utils/index.js.map +1 -1
  123. package/dist/cli/bundler/utils/layers.d.ts +4 -0
  124. package/dist/cli/bundler/utils/layers.js +10 -0
  125. package/dist/cli/bundler/utils/layers.js.map +1 -0
  126. package/dist/cli/bundler/utils/output.d.ts +6 -2
  127. package/dist/cli/bundler/utils/output.js +165 -7
  128. package/dist/cli/bundler/utils/output.js.map +1 -1
  129. package/dist/cli/bundler/utils/styles.d.ts +5 -0
  130. package/dist/cli/bundler/utils/styles.js +30 -0
  131. package/dist/cli/bundler/utils/styles.js.map +1 -0
  132. package/dist/cli/entrypoint/file/ExpressionFile.d.ts +4 -1
  133. package/dist/cli/entrypoint/file/ExpressionFile.js +11 -0
  134. package/dist/cli/entrypoint/file/ExpressionFile.js.map +1 -1
  135. package/dist/cli/entrypoint/file/OptionFile.d.ts +4 -2
  136. package/dist/cli/entrypoint/file/OptionFile.js +35 -31
  137. package/dist/cli/entrypoint/file/OptionFile.js.map +1 -1
  138. package/dist/cli/entrypoint/file/SourceFile.d.ts +18 -7
  139. package/dist/cli/entrypoint/file/SourceFile.js +260 -156
  140. package/dist/cli/entrypoint/file/SourceFile.js.map +1 -1
  141. package/dist/cli/entrypoint/file/index.d.ts +2 -0
  142. package/dist/cli/entrypoint/file/index.js +2 -0
  143. package/dist/cli/entrypoint/file/index.js.map +1 -1
  144. package/dist/cli/entrypoint/file/injectors/core.js +22 -1
  145. package/dist/cli/entrypoint/file/injectors/core.js.map +1 -1
  146. package/dist/cli/entrypoint/file/parsers/ExportParser.d.ts +14 -0
  147. package/dist/cli/entrypoint/file/parsers/ExportParser.js +71 -0
  148. package/dist/cli/entrypoint/file/parsers/ExportParser.js.map +1 -0
  149. package/dist/cli/entrypoint/file/parsers/NodeFinder.d.ts +2 -0
  150. package/dist/cli/entrypoint/file/parsers/NodeFinder.js +9 -0
  151. package/dist/cli/entrypoint/file/parsers/NodeFinder.js.map +1 -1
  152. package/dist/cli/entrypoint/file/parsers/ObjectParser.js +5 -1
  153. package/dist/cli/entrypoint/file/parsers/ObjectParser.js.map +1 -1
  154. package/dist/cli/entrypoint/file/parsers/index.d.ts +1 -0
  155. package/dist/cli/entrypoint/file/parsers/index.js +2 -0
  156. package/dist/cli/entrypoint/file/parsers/index.js.map +1 -1
  157. package/dist/cli/entrypoint/file/parsers/types.d.ts +16 -0
  158. package/dist/cli/entrypoint/file/parsers/types.js +13 -0
  159. package/dist/cli/entrypoint/file/parsers/types.js.map +1 -1
  160. package/dist/cli/entrypoint/file/resolvers/ImportResolver.d.ts +1 -0
  161. package/dist/cli/entrypoint/file/resolvers/ImportResolver.js +3 -0
  162. package/dist/cli/entrypoint/file/resolvers/ImportResolver.js.map +1 -1
  163. package/dist/cli/entrypoint/file/types.d.ts +26 -1
  164. package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.d.ts +2 -2
  165. package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.js +2 -2
  166. package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.js.map +1 -1
  167. package/dist/cli/entrypoint/finder/{AbstractOptionsFinder.js → AbstractParsedFinder.js} +3 -3
  168. package/dist/cli/entrypoint/finder/AbstractParsedFinder.js.map +1 -0
  169. package/dist/cli/entrypoint/finder/OptionsFinder.d.ts +13 -0
  170. package/dist/cli/entrypoint/finder/OptionsFinder.js +33 -0
  171. package/dist/cli/entrypoint/finder/OptionsFinder.js.map +1 -0
  172. package/dist/cli/entrypoint/finder/PluginFinder.d.ts +4 -4
  173. package/dist/cli/entrypoint/finder/PluginFinder.js +2 -2
  174. package/dist/cli/entrypoint/finder/PluginFinder.js.map +1 -1
  175. package/dist/cli/entrypoint/finder/index.d.ts +2 -1
  176. package/dist/cli/entrypoint/finder/index.js +20 -18
  177. package/dist/cli/entrypoint/finder/index.js.map +1 -1
  178. package/dist/cli/entrypoint/parser/AbstractParser.d.ts +3 -2
  179. package/dist/cli/entrypoint/parser/AbstractParser.js +6 -3
  180. package/dist/cli/entrypoint/parser/AbstractParser.js.map +1 -1
  181. package/dist/cli/entrypoint/parser/CommandParser.js +1 -1
  182. package/dist/cli/entrypoint/parser/CommandParser.js.map +1 -1
  183. package/dist/cli/entrypoint/parser/ContentParser.d.ts +5 -1
  184. package/dist/cli/entrypoint/parser/ContentParser.js +55 -3
  185. package/dist/cli/entrypoint/parser/ContentParser.js.map +1 -1
  186. package/dist/cli/entrypoint/parser/OptionsParser.d.ts +6 -0
  187. package/dist/cli/entrypoint/parser/OptionsParser.js +16 -0
  188. package/dist/cli/entrypoint/parser/OptionsParser.js.map +1 -0
  189. package/dist/cli/entrypoint/parser/RelayParser.d.ts +21 -2
  190. package/dist/cli/entrypoint/parser/RelayParser.js +4 -0
  191. package/dist/cli/entrypoint/parser/RelayParser.js.map +1 -1
  192. package/dist/cli/entrypoint/parser/index.d.ts +1 -0
  193. package/dist/cli/entrypoint/parser/index.js +16 -14
  194. package/dist/cli/entrypoint/parser/index.js.map +1 -1
  195. package/dist/cli/plugins/asset.js +9 -4
  196. package/dist/cli/plugins/asset.js.map +1 -1
  197. package/dist/cli/plugins/background/index.js +1 -1
  198. package/dist/cli/plugins/background/index.js.map +1 -1
  199. package/dist/cli/plugins/content/Content.d.ts +1 -1
  200. package/dist/cli/plugins/content/Content.js +3 -2
  201. package/dist/cli/plugins/content/Content.js.map +1 -1
  202. package/dist/cli/plugins/content/ContentManager.d.ts +8 -5
  203. package/dist/cli/plugins/content/ContentManager.js +79 -28
  204. package/dist/cli/plugins/content/ContentManager.js.map +1 -1
  205. package/dist/cli/plugins/content/ContentName.d.ts +1 -1
  206. package/dist/cli/plugins/content/ContentName.js +8 -7
  207. package/dist/cli/plugins/content/ContentName.js.map +1 -1
  208. package/dist/cli/plugins/content/Relay.d.ts +1 -1
  209. package/dist/cli/plugins/content/Relay.js +3 -2
  210. package/dist/cli/plugins/content/Relay.js.map +1 -1
  211. package/dist/cli/plugins/content/bundler.d.ts +7 -0
  212. package/dist/cli/plugins/content/bundler.js +47 -0
  213. package/dist/cli/plugins/content/bundler.js.map +1 -0
  214. package/dist/cli/plugins/content/index.js +121 -62
  215. package/dist/cli/plugins/content/index.js.map +1 -1
  216. package/dist/cli/plugins/content/relay-module.d.ts +3 -0
  217. package/dist/cli/plugins/content/relay-module.js +11 -0
  218. package/dist/cli/plugins/content/relay-module.js.map +1 -0
  219. package/dist/cli/plugins/content/types.d.ts +1 -1
  220. package/dist/cli/plugins/content/utils.d.ts +2 -0
  221. package/dist/cli/plugins/content/utils.js +8 -1
  222. package/dist/cli/plugins/content/utils.js.map +1 -1
  223. package/dist/cli/plugins/icon/declaration/IconDeclaration.d.ts +1 -1
  224. package/dist/cli/plugins/icon/declaration/IconDeclaration.js +6 -6
  225. package/dist/cli/plugins/icon/declaration/IconDeclaration.js.map +1 -1
  226. package/dist/cli/plugins/icon/declaration/icon.d.ts +3 -5
  227. package/dist/cli/plugins/icon/icon-module.d.ts +2 -0
  228. package/dist/cli/plugins/icon/icon-module.js +11 -0
  229. package/dist/cli/plugins/icon/icon-module.js.map +1 -0
  230. package/dist/cli/plugins/icon/index.js +5 -3
  231. package/dist/cli/plugins/icon/index.js.map +1 -1
  232. package/dist/cli/plugins/index.d.ts +1 -0
  233. package/dist/cli/plugins/index.js +22 -20
  234. package/dist/cli/plugins/index.js.map +1 -1
  235. package/dist/cli/plugins/locale/Locale.d.ts +9 -2
  236. package/dist/cli/plugins/locale/Locale.js +37 -5
  237. package/dist/cli/plugins/locale/Locale.js.map +1 -1
  238. package/dist/cli/plugins/locale/declaration/locale.d.ts +1 -1
  239. package/dist/cli/plugins/locale/index.js +57 -22
  240. package/dist/cli/plugins/locale/index.js.map +1 -1
  241. package/dist/cli/plugins/locale/locale-module.d.ts +4 -0
  242. package/dist/cli/plugins/locale/locale-module.js +16 -0
  243. package/dist/cli/plugins/locale/locale-module.js.map +1 -0
  244. package/dist/cli/plugins/offscreen/Offscreen.d.ts +2 -3
  245. package/dist/cli/plugins/offscreen/Offscreen.js.map +1 -1
  246. package/dist/cli/plugins/offscreen/index.js +5 -4
  247. package/dist/cli/plugins/offscreen/index.js.map +1 -1
  248. package/dist/cli/plugins/offscreen/offscreen-module.d.ts +3 -0
  249. package/dist/cli/plugins/offscreen/offscreen-module.js +11 -0
  250. package/dist/cli/plugins/offscreen/offscreen-module.js.map +1 -0
  251. package/dist/cli/plugins/options/Options.d.ts +10 -0
  252. package/dist/cli/plugins/options/Options.js +24 -0
  253. package/dist/cli/plugins/options/Options.js.map +1 -0
  254. package/dist/cli/plugins/options/index.d.ts +2 -0
  255. package/dist/cli/plugins/options/index.js +41 -0
  256. package/dist/cli/plugins/options/index.js.map +1 -0
  257. package/dist/cli/plugins/output.js +33 -3
  258. package/dist/cli/plugins/output.js.map +1 -1
  259. package/dist/cli/plugins/page/declaration/PageDeclaration.js +4 -4
  260. package/dist/cli/plugins/page/declaration/PageDeclaration.js.map +1 -1
  261. package/dist/cli/plugins/page/declaration/page.d.ts +3 -3
  262. package/dist/cli/plugins/page/index.js +14 -10
  263. package/dist/cli/plugins/page/index.js.map +1 -1
  264. package/dist/cli/plugins/page/page-module.d.ts +2 -0
  265. package/dist/cli/plugins/page/page-module.js +11 -0
  266. package/dist/cli/plugins/page/page-module.js.map +1 -0
  267. package/dist/cli/plugins/popup/Popup.d.ts +1 -1
  268. package/dist/cli/plugins/popup/Popup.js +2 -2
  269. package/dist/cli/plugins/popup/Popup.js.map +1 -1
  270. package/dist/cli/plugins/popup/declaration/PopupDeclaration.d.ts +1 -1
  271. package/dist/cli/plugins/popup/declaration/PopupDeclaration.js +6 -6
  272. package/dist/cli/plugins/popup/declaration/PopupDeclaration.js.map +1 -1
  273. package/dist/cli/plugins/popup/declaration/popup.d.ts +3 -3
  274. package/dist/cli/plugins/popup/index.js +6 -5
  275. package/dist/cli/plugins/popup/index.js.map +1 -1
  276. package/dist/cli/plugins/popup/popup-module.d.ts +3 -0
  277. package/dist/cli/plugins/popup/popup-module.js +11 -0
  278. package/dist/cli/plugins/popup/popup-module.js.map +1 -0
  279. package/dist/cli/plugins/sandbox/Sandbox.d.ts +1 -2
  280. package/dist/cli/plugins/sandbox/Sandbox.js.map +1 -1
  281. package/dist/cli/plugins/sandbox/index.js +5 -4
  282. package/dist/cli/plugins/sandbox/index.js.map +1 -1
  283. package/dist/cli/plugins/sandbox/sandbox-module.d.ts +3 -0
  284. package/dist/cli/plugins/sandbox/sandbox-module.js +11 -0
  285. package/dist/cli/plugins/sandbox/sandbox-module.js.map +1 -0
  286. package/dist/cli/plugins/sidebar/Sidebar.d.ts +1 -1
  287. package/dist/cli/plugins/sidebar/Sidebar.js +2 -2
  288. package/dist/cli/plugins/sidebar/Sidebar.js.map +1 -1
  289. package/dist/cli/plugins/sidebar/declaration/SidebarDeclaration.d.ts +1 -1
  290. package/dist/cli/plugins/sidebar/declaration/SidebarDeclaration.js +6 -6
  291. package/dist/cli/plugins/sidebar/declaration/SidebarDeclaration.js.map +1 -1
  292. package/dist/cli/plugins/sidebar/declaration/sidebar.d.ts +3 -3
  293. package/dist/cli/plugins/sidebar/index.js +6 -5
  294. package/dist/cli/plugins/sidebar/index.js.map +1 -1
  295. package/dist/cli/plugins/sidebar/sidebar-module.d.ts +3 -0
  296. package/dist/cli/plugins/sidebar/sidebar-module.js +11 -0
  297. package/dist/cli/plugins/sidebar/sidebar-module.js.map +1 -0
  298. package/dist/cli/plugins/style/index.d.ts +2 -1
  299. package/dist/cli/plugins/style/index.js +52 -25
  300. package/dist/cli/plugins/style/index.js.map +1 -1
  301. package/dist/cli/plugins/style/types.d.ts +5 -0
  302. package/dist/cli/plugins/style/types.js +1 -0
  303. package/dist/cli/plugins/style/types.js.map +1 -0
  304. package/dist/cli/plugins/view/index.js +1 -1
  305. package/dist/cli/plugins/view/index.js.map +1 -1
  306. package/dist/cli/raw.d.ts +4 -0
  307. package/dist/cli/resolvers/bundler.js +9 -7
  308. package/dist/cli/resolvers/bundler.js.map +1 -1
  309. package/dist/cli/resolvers/config.js +4 -1
  310. package/dist/cli/resolvers/config.js.map +1 -1
  311. package/dist/cli/virtual/index.d.ts +2 -2
  312. package/dist/cli/virtual/index.js +11 -8
  313. package/dist/cli/virtual/virtual.d.ts +8 -10
  314. package/dist/entry/content/adapters/react/Builder.js +1 -1
  315. package/dist/entry/content/adapters/react/Builder.js.map +1 -1
  316. package/dist/entry/content/adapters/react/Node.d.ts +2 -0
  317. package/dist/entry/content/adapters/react/Node.js +10 -2
  318. package/dist/entry/content/adapters/react/Node.js.map +1 -1
  319. package/dist/entry/content/adapters/vanilla/Builder.js +1 -1
  320. package/dist/entry/content/adapters/vanilla/Builder.js.map +1 -1
  321. package/dist/entry/content/adapters/vanilla/Node.d.ts +2 -1
  322. package/dist/entry/content/adapters/vanilla/Node.js +10 -7
  323. package/dist/entry/content/adapters/vanilla/Node.js.map +1 -1
  324. package/dist/entry/content/core/Builder.d.ts +1 -2
  325. package/dist/entry/content/core/Builder.js +9 -5
  326. package/dist/entry/content/core/Builder.js.map +1 -1
  327. package/dist/entry/content/core/MountBuilder.js +14 -6
  328. package/dist/entry/content/core/MountBuilder.js.map +1 -1
  329. package/dist/entry/content/core/{Context.d.ts → context/Context.d.ts} +2 -1
  330. package/dist/entry/content/core/{Context.js → context/Context.js} +7 -0
  331. package/dist/entry/content/core/context/Context.js.map +1 -0
  332. package/dist/entry/content/core/{EventEmitter.d.ts → context/EventEmitter.d.ts} +1 -1
  333. package/dist/entry/content/core/{EventEmitter.js → context/EventEmitter.js} +1 -1
  334. package/dist/entry/content/core/context/EventEmitter.js.map +1 -0
  335. package/dist/entry/content/core/{ManagedContext.d.ts → context/ManagedContext.d.ts} +1 -1
  336. package/dist/entry/content/core/context/ManagedContext.js.map +1 -0
  337. package/dist/entry/content/core/context/index.d.ts +3 -0
  338. package/dist/entry/content/core/context/index.js +9 -0
  339. package/dist/entry/content/core/context/index.js.map +1 -0
  340. package/dist/entry/content/core/{AbstractMarker.d.ts → markers/AbstractMarker.d.ts} +1 -1
  341. package/dist/entry/content/core/{AbstractMarker.js → markers/AbstractMarker.js} +1 -1
  342. package/dist/entry/content/core/markers/AbstractMarker.js.map +1 -0
  343. package/dist/entry/content/core/{AttributeMarker.d.ts → markers/AttributeMarker.d.ts} +1 -1
  344. package/dist/entry/content/core/markers/AttributeMarker.js.map +1 -0
  345. package/dist/entry/content/core/{WeakMarker.d.ts → markers/WeakMarker.d.ts} +1 -1
  346. package/dist/entry/content/core/markers/WeakMarker.js.map +1 -0
  347. package/dist/entry/content/core/markers/index.d.ts +3 -0
  348. package/dist/entry/content/core/markers/index.js +9 -0
  349. package/dist/entry/content/core/markers/index.js.map +1 -0
  350. package/dist/entry/content/core/{EventNode.d.ts → nodes/EventNode.d.ts} +2 -1
  351. package/dist/entry/content/core/{EventNode.js → nodes/EventNode.js} +3 -0
  352. package/dist/entry/content/core/nodes/EventNode.js.map +1 -0
  353. package/dist/entry/content/core/nodes/FrameNode.d.ts +23 -0
  354. package/dist/entry/content/core/nodes/FrameNode.js +125 -0
  355. package/dist/entry/content/core/nodes/FrameNode.js.map +1 -0
  356. package/dist/entry/content/core/{MarkerNode.d.ts → nodes/MarkerNode.d.ts} +2 -1
  357. package/dist/entry/content/core/{MarkerNode.js → nodes/MarkerNode.js} +3 -0
  358. package/dist/entry/content/core/nodes/MarkerNode.js.map +1 -0
  359. package/dist/entry/content/core/{MountNode.d.ts → nodes/MountNode.d.ts} +2 -1
  360. package/dist/entry/content/core/{MountNode.js → nodes/MountNode.js} +3 -0
  361. package/dist/entry/content/core/nodes/MountNode.js.map +1 -0
  362. package/dist/entry/content/core/{Node.d.ts → nodes/Node.d.ts} +2 -1
  363. package/dist/entry/content/core/{Node.js → nodes/Node.js} +3 -0
  364. package/dist/entry/content/core/nodes/Node.js.map +1 -0
  365. package/dist/entry/content/core/nodes/ShadowNode.d.ts +14 -0
  366. package/dist/entry/content/core/nodes/ShadowNode.js +67 -0
  367. package/dist/entry/content/core/nodes/ShadowNode.js.map +1 -0
  368. package/dist/entry/content/core/nodes/index.d.ts +6 -0
  369. package/dist/entry/content/core/nodes/index.js +15 -0
  370. package/dist/entry/content/core/nodes/index.js.map +1 -0
  371. package/dist/entry/content/core/nodes/isolated-styles.d.ts +2 -0
  372. package/dist/entry/content/core/nodes/isolated-styles.js +14 -0
  373. package/dist/entry/content/core/nodes/isolated-styles.js.map +1 -0
  374. package/dist/entry/content/core/resolvers/watch.js +1 -1
  375. package/dist/entry/content/core/resolvers/watch.js.map +1 -1
  376. package/dist/entry/content/frame/Builder.d.ts +7 -0
  377. package/dist/entry/content/frame/Builder.js +14 -0
  378. package/dist/entry/content/frame/Builder.js.map +1 -0
  379. package/dist/entry/content/frame/index.d.ts +4 -0
  380. package/dist/entry/content/frame/index.js +7 -0
  381. package/dist/entry/content/frame/index.js.map +1 -0
  382. package/dist/entry/relay/Builder.js +5 -1
  383. package/dist/entry/relay/Builder.js.map +1 -1
  384. package/dist/entry/relay/index.d.ts +1 -1
  385. package/dist/locale/adapters/react/ReactLocale.d.ts +18 -0
  386. package/dist/locale/adapters/react/ReactLocale.js +41 -0
  387. package/dist/locale/adapters/react/ReactLocale.js.map +1 -0
  388. package/dist/locale/adapters/react/hooks/use-locale-attributes.d.ts +7 -0
  389. package/dist/locale/adapters/react/hooks/use-locale-attributes.js +30 -0
  390. package/dist/locale/adapters/react/hooks/use-locale-attributes.js.map +1 -0
  391. package/dist/locale/adapters/react/hooks/use-locale.d.ts +3 -0
  392. package/dist/locale/adapters/react/hooks/use-locale.js +17 -0
  393. package/dist/locale/adapters/react/hooks/use-locale.js.map +1 -0
  394. package/dist/locale/adapters/react/hooks/use-native-locale.d.ts +3 -0
  395. package/dist/locale/adapters/react/hooks/use-native-locale.js +10 -0
  396. package/dist/locale/adapters/react/hooks/use-native-locale.js.map +1 -0
  397. package/dist/locale/adapters/react/index.d.ts +4 -2
  398. package/dist/locale/adapters/react/index.js +6 -4
  399. package/dist/locale/adapters/react/index.js.map +1 -1
  400. package/dist/locale/adapters/react/types.d.ts +22 -0
  401. package/dist/locale/adapters/react/types.js +1 -0
  402. package/dist/locale/adapters/react/types.js.map +1 -0
  403. package/dist/locale/helpers.d.ts +4 -5
  404. package/dist/locale/helpers.js +1 -1
  405. package/dist/locale/helpers.js.map +1 -1
  406. package/dist/locale/index.d.ts +2 -1
  407. package/dist/locale/index.js +1 -0
  408. package/dist/locale/index.js.map +1 -1
  409. package/dist/locale/providers/AbstractLocale.d.ts +4 -4
  410. package/dist/locale/providers/AbstractLocale.js +13 -94
  411. package/dist/locale/providers/AbstractLocale.js.map +1 -1
  412. package/dist/locale/providers/CustomLocale.d.ts +3 -3
  413. package/dist/locale/providers/CustomLocale.js +6 -5
  414. package/dist/locale/providers/CustomLocale.js.map +1 -1
  415. package/dist/locale/providers/DynamicLocale.d.ts +18 -11
  416. package/dist/locale/providers/DynamicLocale.js +60 -47
  417. package/dist/locale/providers/DynamicLocale.js.map +1 -1
  418. package/dist/locale/providers/NativeLocale.d.ts +4 -7
  419. package/dist/locale/providers/NativeLocale.js +5 -14
  420. package/dist/locale/providers/NativeLocale.js.map +1 -1
  421. package/dist/locale/providers/ObservableLocale.d.ts +35 -0
  422. package/dist/locale/providers/ObservableLocale.js +179 -0
  423. package/dist/locale/providers/ObservableLocale.js.map +1 -0
  424. package/dist/locale/providers/index.d.ts +2 -1
  425. package/dist/locale/providers/index.js +3 -1
  426. package/dist/locale/providers/index.js.map +1 -1
  427. package/dist/locale/storage/LocaleStorage.d.ts +11 -0
  428. package/dist/locale/storage/LocaleStorage.js +40 -0
  429. package/dist/locale/storage/LocaleStorage.js.map +1 -0
  430. package/dist/locale/storage/index.d.ts +1 -0
  431. package/dist/locale/storage/index.js +5 -0
  432. package/dist/locale/storage/index.js.map +1 -0
  433. package/dist/main/entrypoint.d.ts +4 -0
  434. package/dist/main/entrypoint.js +20 -0
  435. package/dist/main/entrypoint.js.map +1 -0
  436. package/dist/main/icon.d.ts +2 -3
  437. package/dist/main/icon.js +2 -1
  438. package/dist/main/icon.js.map +1 -1
  439. package/dist/main/index.d.ts +2 -0
  440. package/dist/main/index.js +2 -0
  441. package/dist/main/index.js.map +1 -1
  442. package/dist/main/offscreen.d.ts +2 -5
  443. package/dist/main/offscreen.js +5 -2
  444. package/dist/main/offscreen.js.map +1 -1
  445. package/dist/main/options.d.ts +3 -0
  446. package/dist/main/options.js +7 -0
  447. package/dist/main/options.js.map +1 -0
  448. package/dist/main/page.d.ts +2 -4
  449. package/dist/main/page.js +2 -1
  450. package/dist/main/page.js.map +1 -1
  451. package/dist/main/popup.d.ts +2 -5
  452. package/dist/main/popup.js +3 -3
  453. package/dist/main/popup.js.map +1 -1
  454. package/dist/main/relay.d.ts +1 -2
  455. package/dist/main/relay.js +2 -1
  456. package/dist/main/relay.js.map +1 -1
  457. package/dist/main/sandbox.d.ts +1 -4
  458. package/dist/main/sandbox.js +2 -1
  459. package/dist/main/sandbox.js.map +1 -1
  460. package/dist/main/service.d.ts +1 -2
  461. package/dist/main/service.js.map +1 -1
  462. package/dist/main/sidebar.d.ts +2 -5
  463. package/dist/main/sidebar.js +3 -3
  464. package/dist/main/sidebar.js.map +1 -1
  465. package/dist/message/index.d.ts +2 -4
  466. package/dist/message/index.js.map +1 -1
  467. package/dist/offscreen/index.d.ts +2 -6
  468. package/dist/offscreen/index.js.map +1 -1
  469. package/dist/relay/index.d.ts +2 -5
  470. package/dist/relay/index.js.map +1 -1
  471. package/dist/sandbox/index.d.ts +1 -5
  472. package/dist/sandbox/index.js.map +1 -1
  473. package/dist/service/index.d.ts +2 -6
  474. package/dist/service/index.js.map +1 -1
  475. package/dist/shared/content/index.d.ts +1 -0
  476. package/dist/shared/content/index.js +6 -0
  477. package/dist/shared/content/index.js.map +1 -0
  478. package/dist/shared/content/isolation.d.ts +4 -0
  479. package/dist/shared/content/isolation.js +70 -0
  480. package/dist/shared/content/isolation.js.map +1 -0
  481. package/dist/shared/locale/index.d.ts +5 -0
  482. package/dist/shared/locale/index.js +21 -0
  483. package/dist/shared/locale/index.js.map +1 -0
  484. package/dist/shared/locale/keys.d.ts +5 -0
  485. package/dist/shared/locale/keys.js +33 -0
  486. package/dist/shared/locale/keys.js.map +1 -0
  487. package/dist/shared/locale/language.d.ts +4 -0
  488. package/dist/shared/locale/language.js +23 -0
  489. package/dist/shared/locale/language.js.map +1 -0
  490. package/dist/shared/locale/messages.d.ts +3 -0
  491. package/dist/shared/locale/messages.js +9 -0
  492. package/dist/shared/locale/messages.js.map +1 -0
  493. package/dist/shared/locale/plural.d.ts +2 -0
  494. package/dist/shared/locale/plural.js +81 -0
  495. package/dist/shared/locale/plural.js.map +1 -0
  496. package/dist/shared/locale/substitutions.d.ts +10 -0
  497. package/dist/shared/locale/substitutions.js +32 -0
  498. package/dist/shared/locale/substitutions.js.map +1 -0
  499. package/dist/types/background.d.ts +1 -1
  500. package/dist/types/background.js.map +1 -1
  501. package/dist/types/command.d.ts +1 -1
  502. package/dist/types/command.js.map +1 -1
  503. package/dist/types/content.d.ts +120 -31
  504. package/dist/types/content.js +22 -1
  505. package/dist/types/content.js.map +1 -1
  506. package/dist/types/entrypoint.d.ts +20 -0
  507. package/dist/types/entrypoint.js +4 -0
  508. package/dist/types/entrypoint.js.map +1 -1
  509. package/dist/types/icon.d.ts +8 -0
  510. package/dist/types/icon.js.map +1 -1
  511. package/dist/types/language.d.ts +57 -0
  512. package/dist/types/language.js +62 -0
  513. package/dist/types/language.js.map +1 -0
  514. package/dist/types/locale.d.ts +34 -63
  515. package/dist/types/locale.js +62 -119
  516. package/dist/types/locale.js.map +1 -1
  517. package/dist/types/manifest.d.ts +24 -7
  518. package/dist/types/manifest.js.map +1 -1
  519. package/dist/types/message.d.ts +7 -0
  520. package/dist/types/message.js.map +1 -1
  521. package/dist/types/offscreen.d.ts +14 -1
  522. package/dist/types/offscreen.js.map +1 -1
  523. package/dist/types/options.d.ts +9 -0
  524. package/dist/types/options.js +1 -0
  525. package/dist/types/options.js.map +1 -0
  526. package/dist/types/page.d.ts +8 -0
  527. package/dist/types/plugin.d.ts +2 -1
  528. package/dist/types/popup.d.ts +9 -0
  529. package/dist/types/relay.d.ts +16 -7
  530. package/dist/types/relay.js.map +1 -1
  531. package/dist/types/sandbox.d.ts +12 -0
  532. package/dist/types/sandbox.js.map +1 -1
  533. package/dist/types/service.d.ts +10 -1
  534. package/dist/types/service.js.map +1 -1
  535. package/dist/types/sidebar.d.ts +9 -0
  536. package/dist/types/sidebar.js.map +1 -1
  537. package/dist/types/transport.d.ts +4 -0
  538. package/dist/virtual/entrypoint.d.ts +5 -0
  539. package/dist/virtual/entrypoint.js +7 -0
  540. package/dist/virtual/entrypoint.js.map +1 -0
  541. package/dist/virtual/icon.d.ts +2 -0
  542. package/dist/virtual/icon.js +5 -0
  543. package/dist/virtual/icon.js.map +1 -0
  544. package/dist/virtual/locale.d.ts +7 -0
  545. package/dist/virtual/locale.js +13 -0
  546. package/dist/virtual/locale.js.map +1 -0
  547. package/dist/virtual/modules.d.ts +40 -0
  548. package/dist/virtual/offscreen.d.ts +3 -0
  549. package/dist/virtual/offscreen.js +5 -0
  550. package/dist/virtual/offscreen.js.map +1 -0
  551. package/dist/virtual/page.d.ts +2 -0
  552. package/dist/virtual/page.js +5 -0
  553. package/dist/virtual/page.js.map +1 -0
  554. package/dist/virtual/popup.d.ts +3 -0
  555. package/dist/virtual/popup.js +5 -0
  556. package/dist/virtual/popup.js.map +1 -0
  557. package/dist/virtual/relay.d.ts +3 -0
  558. package/dist/virtual/relay.js +5 -0
  559. package/dist/virtual/relay.js.map +1 -0
  560. package/dist/virtual/sandbox.d.ts +3 -0
  561. package/dist/virtual/sandbox.js +5 -0
  562. package/dist/virtual/sandbox.js.map +1 -0
  563. package/dist/virtual/sidebar.d.ts +3 -0
  564. package/dist/virtual/sidebar.js +5 -0
  565. package/dist/virtual/sidebar.js.map +1 -0
  566. package/package.json +31 -10
  567. package/scripts/clean-dist.js +7 -0
  568. package/scripts/copy-dts.js +11 -1
  569. package/types/client.d.ts +15 -0
  570. package/dist/cli/builders/manifest/utils.d.ts +0 -32
  571. package/dist/cli/builders/manifest/utils.js +0 -209
  572. package/dist/cli/builders/manifest/utils.js.map +0 -1
  573. package/dist/cli/bundler/plugins/EntrypointPlugin.js.map +0 -1
  574. package/dist/cli/bundler/plugins/GenerateJsonPlugin.js +0 -40
  575. package/dist/cli/bundler/plugins/GenerateJsonPlugin.js.map +0 -1
  576. package/dist/cli/bundler/plugins/ManifestPlugin.d.ts +0 -10
  577. package/dist/cli/bundler/plugins/ManifestPlugin.js +0 -78
  578. package/dist/cli/bundler/plugins/ManifestPlugin.js.map +0 -1
  579. package/dist/cli/bundler/plugins/ReplacePlugin.js.map +0 -1
  580. package/dist/cli/bundler/plugins/WatchPlugin.js +0 -21
  581. package/dist/cli/bundler/plugins/WatchPlugin.js.map +0 -1
  582. package/dist/cli/entrypoint/finder/AbstractOptionsFinder.js.map +0 -1
  583. package/dist/entry/content/core/AbstractMarker.js.map +0 -1
  584. package/dist/entry/content/core/AttributeMarker.js.map +0 -1
  585. package/dist/entry/content/core/Context.js.map +0 -1
  586. package/dist/entry/content/core/EventEmitter.js.map +0 -1
  587. package/dist/entry/content/core/EventNode.js.map +0 -1
  588. package/dist/entry/content/core/ManagedContext.js.map +0 -1
  589. package/dist/entry/content/core/MarkerNode.js.map +0 -1
  590. package/dist/entry/content/core/MountNode.js.map +0 -1
  591. package/dist/entry/content/core/Node.js.map +0 -1
  592. package/dist/entry/content/core/WeakMarker.js.map +0 -1
  593. package/dist/locale/adapters/react/LocaleProvider.d.ts +0 -7
  594. package/dist/locale/adapters/react/LocaleProvider.js +0 -58
  595. package/dist/locale/adapters/react/LocaleProvider.js.map +0 -1
  596. package/dist/locale/adapters/react/context.d.ts +0 -14
  597. package/dist/locale/adapters/react/context.js +0 -25
  598. package/dist/locale/adapters/react/context.js.map +0 -1
  599. package/dist/locale/utils.d.ts +0 -11
  600. package/dist/locale/utils.js +0 -67
  601. package/dist/locale/utils.js.map +0 -1
  602. /package/dist/cli/bundler/plugins/{ReplacePlugin.d.ts → replace/ReplacePlugin.d.ts} +0 -0
  603. /package/dist/cli/bundler/plugins/{ReplacePlugin.js → replace/ReplacePlugin.js} +0 -0
  604. /package/dist/cli/bundler/plugins/{WatchPlugin.d.ts → watch/WatchPlugin.d.ts} +0 -0
  605. /package/dist/cli/entrypoint/finder/{AbstractOptionsFinder.d.ts → AbstractParsedFinder.d.ts} +0 -0
  606. /package/dist/entry/content/core/{ManagedContext.js → context/ManagedContext.js} +0 -0
  607. /package/dist/entry/content/core/{AttributeMarker.js → markers/AttributeMarker.js} +0 -0
  608. /package/dist/entry/content/core/{WeakMarker.js → markers/WeakMarker.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/build-assets-map/index.ts"],"sourcesContent":["export {default, type BuildAssetsMapPluginOptions} from \"./BuildAssetsMapPlugin\";\nexport {createEntrypointModule, EntrypointAssetsModule} from \"./entrypoint-module\";\nexport type {BuildAssetsMapPluginModuleOptions, BuildAssetsMapPluginExportOptions} from \"./usage\";\n"],"mappings":"AAAA,SAAQ,WAAAA,gBAAgD;AACxD,SAAQ,wBAAwB,8BAA6B;","names":["default"]}
@@ -0,0 +1,12 @@
1
+ import type { Chunk, Compilation, Compiler } from "@rspack/core";
2
+ import type { RuntimePropertyOptions } from "../types.js";
3
+ export interface BuildAssetsMapPluginExportOptions extends RuntimePropertyOptions {
4
+ readonly export: string;
5
+ }
6
+ export interface BuildAssetsMapPluginModuleOptions {
7
+ readonly request: string;
8
+ readonly current: BuildAssetsMapPluginExportOptions;
9
+ readonly full: BuildAssetsMapPluginExportOptions;
10
+ }
11
+ /** Retain every layer's module before concatenation, then inspect export use per runtime. */
12
+ export declare const trackModuleUsage: (compiler: Compiler, compilation: Compilation, options: BuildAssetsMapPluginModuleOptions) => ((chunk: Chunk, name: string) => boolean);
@@ -0,0 +1,28 @@
1
+ const trackModuleUsage = (compiler, compilation, options) => {
2
+ let resource;
3
+ let modules = [];
4
+ compilation.hooks.finishModules.tapPromise("BuildAssetsMapPlugin:resolve", async () => {
5
+ const resolver = compiler.resolverFactory.get("normal", { dependencyType: "esm" });
6
+ resource = await new Promise((resolve, reject) => {
7
+ resolver.resolve({}, compiler.context, options.request, {}, (error, result) => {
8
+ if (error) reject(error);
9
+ else if (typeof result !== "string")
10
+ reject(new Error(`Unable to resolve assets module "${options.request}"`));
11
+ else resolve(result);
12
+ });
13
+ });
14
+ });
15
+ compilation.hooks.afterOptimizeModules.tap("BuildAssetsMapPlugin:usage", (candidates) => {
16
+ modules = Array.from(candidates).filter(
17
+ (module) => module.resource === resource
18
+ );
19
+ });
20
+ return (chunk, name) => {
21
+ const runtime = new Set(chunk.runtime);
22
+ return modules.some((module) => compilation.moduleGraph.getExportsInfo(module).getUsed(name, runtime) !== 0);
23
+ };
24
+ };
25
+ export {
26
+ trackModuleUsage
27
+ };
28
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/build-assets-map/usage.ts"],"sourcesContent":["import type {Chunk, Compilation, Compiler, NormalModule} from \"@rspack/core\";\n\nimport type {RuntimePropertyOptions} from \"../types\";\n\nexport interface BuildAssetsMapPluginExportOptions extends RuntimePropertyOptions {\n readonly export: string;\n}\n\nexport interface BuildAssetsMapPluginModuleOptions {\n readonly request: string;\n readonly current: BuildAssetsMapPluginExportOptions;\n readonly full: BuildAssetsMapPluginExportOptions;\n}\n\n/** Retain every layer's module before concatenation, then inspect export use per runtime. */\nexport const trackModuleUsage = (\n compiler: Compiler,\n compilation: Compilation,\n options: BuildAssetsMapPluginModuleOptions\n): ((chunk: Chunk, name: string) => boolean) => {\n let resource: string | undefined;\n let modules: NormalModule[] = [];\n\n compilation.hooks.finishModules.tapPromise(\"BuildAssetsMapPlugin:resolve\", async () => {\n const resolver = compiler.resolverFactory.get(\"normal\", {dependencyType: \"esm\"});\n resource = await new Promise<string>((resolve, reject) => {\n resolver.resolve({}, compiler.context, options.request, {}, (error, result) => {\n if (error) reject(error);\n else if (typeof result !== \"string\")\n reject(new Error(`Unable to resolve assets module \"${options.request}\"`));\n else resolve(result);\n });\n });\n });\n\n compilation.hooks.afterOptimizeModules.tap(\"BuildAssetsMapPlugin:usage\", candidates => {\n modules = Array.from(candidates).filter(\n module => (module as NormalModule).resource === resource\n ) as NormalModule[];\n });\n\n return (chunk, name) => {\n const runtime = new Set(chunk.runtime);\n return modules.some(module => compilation.moduleGraph.getExportsInfo(module).getUsed(name, runtime) !== 0);\n };\n};\n"],"mappings":"AAeO,MAAM,mBAAmB,CAC5B,UACA,aACA,YAC4C;AAC5C,MAAI;AACJ,MAAI,UAA0B,CAAC;AAE/B,cAAY,MAAM,cAAc,WAAW,gCAAgC,YAAY;AACnF,UAAM,WAAW,SAAS,gBAAgB,IAAI,UAAU,EAAC,gBAAgB,MAAK,CAAC;AAC/E,eAAW,MAAM,IAAI,QAAgB,CAAC,SAAS,WAAW;AACtD,eAAS,QAAQ,CAAC,GAAG,SAAS,SAAS,QAAQ,SAAS,CAAC,GAAG,CAAC,OAAO,WAAW;AAC3E,YAAI,MAAO,QAAO,KAAK;AAAA,iBACd,OAAO,WAAW;AACvB,iBAAO,IAAI,MAAM,oCAAoC,QAAQ,OAAO,GAAG,CAAC;AAAA,YACvE,SAAQ,MAAM;AAAA,MACvB,CAAC;AAAA,IACL,CAAC;AAAA,EACL,CAAC;AAED,cAAY,MAAM,qBAAqB,IAAI,8BAA8B,gBAAc;AACnF,cAAU,MAAM,KAAK,UAAU,EAAE;AAAA,MAC7B,YAAW,OAAwB,aAAa;AAAA,IACpD;AAAA,EACJ,CAAC;AAED,SAAO,CAAC,OAAO,SAAS;AACpB,UAAM,UAAU,IAAI,IAAI,MAAM,OAAO;AACrC,WAAO,QAAQ,KAAK,YAAU,YAAY,YAAY,eAAe,MAAM,EAAE,QAAQ,MAAM,OAAO,MAAM,CAAC;AAAA,EAC7G;AACJ;","names":[]}
@@ -0,0 +1,9 @@
1
+ import { type Compiler } from "@rspack/core";
2
+ export interface ChunkLoaderPluginOptions {
3
+ test: (entry: string) => boolean;
4
+ }
5
+ export default class ChunkLoaderPlugin {
6
+ private readonly options;
7
+ constructor(options: ChunkLoaderPluginOptions);
8
+ apply(compiler: Compiler): void;
9
+ }
@@ -0,0 +1,43 @@
1
+ import { RuntimeGlobals, RuntimeModule } from "@rspack/core";
2
+ import { renderChunkLoaderRuntime } from "./templates.js";
3
+ const PluginName = "ChunkLoaderPlugin";
4
+ class ChunkLoaderRuntimeModule extends RuntimeModule {
5
+ constructor() {
6
+ super("extension native chunk loading", RuntimeModule.STAGE_TRIGGER);
7
+ }
8
+ generate() {
9
+ return renderChunkLoaderRuntime({
10
+ ensureChunk: RuntimeGlobals.ensureChunk,
11
+ loadScript: RuntimeGlobals.loadScript,
12
+ publicPath: RuntimeGlobals.publicPath
13
+ });
14
+ }
15
+ }
16
+ class ChunkLoaderPlugin {
17
+ constructor(options) {
18
+ this.options = options;
19
+ }
20
+ options;
21
+ apply(compiler) {
22
+ compiler.hooks.thisCompilation.tap(PluginName, (compilation) => {
23
+ const injected = /* @__PURE__ */ new Set();
24
+ compilation.hooks.additionalTreeRuntimeRequirements.tap(
25
+ { name: PluginName, stage: 1e4 },
26
+ (chunk, requirements) => {
27
+ if (chunk.name === void 0 || !this.options.test(chunk.name) || chunk.getAllAsyncChunks().length === 0 || injected.has(chunk)) {
28
+ return;
29
+ }
30
+ requirements.add(RuntimeGlobals.loadScript);
31
+ requirements.add(RuntimeGlobals.ensureChunk);
32
+ requirements.add(RuntimeGlobals.publicPath);
33
+ injected.add(chunk);
34
+ compilation.addRuntimeModule(chunk, new ChunkLoaderRuntimeModule());
35
+ }
36
+ );
37
+ });
38
+ }
39
+ }
40
+ export {
41
+ ChunkLoaderPlugin as default
42
+ };
43
+ //# sourceMappingURL=ChunkLoaderPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/chunk-loader/ChunkLoaderPlugin.ts"],"sourcesContent":["import {type Chunk, type Compiler, RuntimeGlobals, RuntimeModule} from \"@rspack/core\";\n\nimport {renderChunkLoaderRuntime} from \"./templates\";\n\nconst PluginName = \"ChunkLoaderPlugin\";\n\nexport interface ChunkLoaderPluginOptions {\n test: (entry: string) => boolean;\n}\n\nclass ChunkLoaderRuntimeModule extends RuntimeModule {\n public constructor() {\n super(\"extension native chunk loading\", RuntimeModule.STAGE_TRIGGER);\n }\n\n public generate(): string {\n return renderChunkLoaderRuntime({\n ensureChunk: RuntimeGlobals.ensureChunk,\n loadScript: RuntimeGlobals.loadScript,\n publicPath: RuntimeGlobals.publicPath,\n });\n }\n}\n\nexport default class ChunkLoaderPlugin {\n public constructor(private readonly options: ChunkLoaderPluginOptions) {}\n\n public apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(PluginName, compilation => {\n const injected = new Set<Chunk>();\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n {name: PluginName, stage: 10_000},\n (chunk, requirements) => {\n if (\n chunk.name === undefined ||\n !this.options.test(chunk.name) ||\n chunk.getAllAsyncChunks().length === 0 ||\n injected.has(chunk)\n ) {\n return;\n }\n\n requirements.add(RuntimeGlobals.loadScript);\n requirements.add(RuntimeGlobals.ensureChunk);\n requirements.add(RuntimeGlobals.publicPath);\n\n injected.add(chunk);\n compilation.addRuntimeModule(chunk, new ChunkLoaderRuntimeModule());\n }\n );\n });\n }\n}\n"],"mappings":"AAAA,SAAmC,gBAAgB,qBAAoB;AAEvE,SAAQ,gCAA+B;AAEvC,MAAM,aAAa;AAMnB,MAAM,iCAAiC,cAAc;AAAA,EAC1C,cAAc;AACjB,UAAM,kCAAkC,cAAc,aAAa;AAAA,EACvE;AAAA,EAEO,WAAmB;AACtB,WAAO,yBAAyB;AAAA,MAC5B,aAAa,eAAe;AAAA,MAC5B,YAAY,eAAe;AAAA,MAC3B,YAAY,eAAe;AAAA,IAC/B,CAAC;AAAA,EACL;AACJ;AAEA,MAAO,kBAAgC;AAAA,EAC5B,YAA6B,SAAmC;AAAnC;AAAA,EAAoC;AAAA,EAApC;AAAA,EAE7B,MAAM,UAA0B;AACnC,aAAS,MAAM,gBAAgB,IAAI,YAAY,iBAAe;AAC1D,YAAM,WAAW,oBAAI,IAAW;AAEhC,kBAAY,MAAM,kCAAkC;AAAA,QAChD,EAAC,MAAM,YAAY,OAAO,IAAM;AAAA,QAChC,CAAC,OAAO,iBAAiB;AACrB,cACI,MAAM,SAAS,UACf,CAAC,KAAK,QAAQ,KAAK,MAAM,IAAI,KAC7B,MAAM,kBAAkB,EAAE,WAAW,KACrC,SAAS,IAAI,KAAK,GACpB;AACE;AAAA,UACJ;AAEA,uBAAa,IAAI,eAAe,UAAU;AAC1C,uBAAa,IAAI,eAAe,WAAW;AAC3C,uBAAa,IAAI,eAAe,UAAU;AAE1C,mBAAS,IAAI,KAAK;AAClB,sBAAY,iBAAiB,OAAO,IAAI,yBAAyB,CAAC;AAAA,QACtE;AAAA,MACJ;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;","names":[]}
@@ -0,0 +1 @@
1
+ export { default, type ChunkLoaderPluginOptions } from "./ChunkLoaderPlugin.js";
@@ -0,0 +1,5 @@
1
+ import { default as default2 } from "./ChunkLoaderPlugin.js";
2
+ export {
3
+ default2 as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/chunk-loader/index.ts"],"sourcesContent":["export {default, type ChunkLoaderPluginOptions} from \"./ChunkLoaderPlugin\";\n"],"mappings":"AAAA,SAAQ,WAAAA,gBAA6C;","names":["default"]}
@@ -0,0 +1,2 @@
1
+ declare function resolveExtensionChunkPublicPath(): Promise<void>;
2
+ declare var ensureExtensionChunk: any;
@@ -0,0 +1,7 @@
1
+ interface ChunkLoaderRuntimeTemplateOptions {
2
+ readonly ensureChunk: string;
3
+ readonly loadScript: string;
4
+ readonly publicPath: string;
5
+ }
6
+ export declare const renderChunkLoaderRuntime: (options: ChunkLoaderRuntimeTemplateOptions) => string;
7
+ export {};
@@ -0,0 +1,30 @@
1
+ // raw-loader:/home/runner/work/addon-bone/addon-bone/src/cli/bundler/plugins/chunk-loader/templates/runtime.template.js?raw
2
+ var runtime_template_default = 'var resolveExtensionChunkPublicPath = function () {\n if (!__ADNBN_PUBLIC_PATH__) {\n var extensionApi =\n globalThis.browser && globalThis.browser.runtime && globalThis.browser.runtime.getURL\n ? globalThis.browser\n : globalThis.chrome;\n\n if (!extensionApi || !extensionApi.runtime || !extensionApi.runtime.getURL) {\n return Promise.reject(new Error("Unable to resolve the extension URL for chunk loading"));\n }\n\n __ADNBN_PUBLIC_PATH__ = extensionApi.runtime.getURL("/");\n }\n\n return Promise.resolve();\n};\n\nvar ensureExtensionChunk = __ADNBN_ENSURE_CHUNK__;\n\n__ADNBN_ENSURE_CHUNK__ = function (chunkId) {\n return resolveExtensionChunkPublicPath().then(function () {\n return ensureExtensionChunk(chunkId);\n });\n};\n\n__ADNBN_LOAD_SCRIPT__ = function (url, done) {\n import(url).then(\n function () {\n done({type: "load", target: {src: url}});\n },\n function (error) {\n done({type: "error", target: {src: url}, error: error});\n }\n );\n};\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/chunk-loader/templates.ts
21
+ var renderChunkLoaderRuntime = (options) => {
22
+ return renderRuntimeTemplate(runtime_template_default, {
23
+ __ADNBN_ENSURE_CHUNK__: options.ensureChunk,
24
+ __ADNBN_LOAD_SCRIPT__: options.loadScript,
25
+ __ADNBN_PUBLIC_PATH__: options.publicPath
26
+ });
27
+ };
28
+ export {
29
+ renderChunkLoaderRuntime
30
+ };
@@ -1,6 +1,6 @@
1
- import { Compiler, EntryNormalized } from "@rspack/core";
1
+ import { Compiler, type EntryDescription, EntryNormalized } from "@rspack/core";
2
2
  import { RspackVirtualModulePlugin as VirtualModulesPlugin } from "rspack-plugin-virtual-module";
3
- import { EntrypointEntries, EntrypointFile } from "../../../types/entrypoint.js";
3
+ import { EntrypointEntries, EntrypointFile } from "../../../../types/entrypoint.js";
4
4
  export type EntrypointPluginTemplate = (file: EntrypointFile) => string;
5
5
  export type EntrypointPluginUpdate = (files: ReadonlySet<string>) => Promise<EntrypointEntries>;
6
6
  export interface EntrypointPluginModule {
@@ -15,11 +15,14 @@ export interface EntrypointPluginModule {
15
15
  }
16
16
  export type EntrypointPluginModules = Map<EntrypointFile, EntrypointPluginModule>;
17
17
  export type EntrypointPluginEntryModules = Map<string, EntrypointPluginModules>;
18
+ export type EntrypointPluginEntryOptions = Omit<EntryDescription, "import">;
19
+ export type EntrypointPluginEntryOptionsResolver = (name: string) => EntrypointPluginEntryOptions;
18
20
  export default class EntrypointPlugin {
19
21
  private readonly entries;
20
22
  private readonly pluginName;
21
23
  private _plugin?;
22
24
  private _modules?;
25
+ private readonly _entryOptions;
23
26
  protected template?: EntrypointPluginTemplate;
24
27
  protected update?: EntrypointPluginUpdate;
25
28
  static filename(file: EntrypointFile): string;
@@ -29,10 +32,12 @@ export default class EntrypointPlugin {
29
32
  static from(entries: EntrypointEntries): EntrypointPlugin;
30
33
  constructor(entries?: EntrypointEntries);
31
34
  virtual(template: EntrypointPluginTemplate): this;
35
+ entryOptions(options: EntrypointPluginEntryOptions | EntrypointPluginEntryOptionsResolver): this;
32
36
  watch(update: EntrypointPluginUpdate): this;
33
37
  apply(compiler: Compiler): void;
34
38
  protected hookEntryOption(entry: EntryNormalized): void;
35
39
  protected hookWatchRun(compiler: Compiler): Promise<void>;
40
+ protected resolveEntryOptions(name: string): EntrypointPluginEntryOptions;
36
41
  protected createModules(entries: EntrypointEntries): EntrypointPluginEntryModules;
37
42
  protected getModuleContents(modules: EntrypointPluginEntryModules): Map<string, string>;
38
43
  }
@@ -9,6 +9,7 @@ class EntrypointPlugin {
9
9
  pluginName = "EntrypointPlugin";
10
10
  _plugin;
11
11
  _modules;
12
+ _entryOptions = [];
12
13
  template;
13
14
  update;
14
15
  static filename(file) {
@@ -40,6 +41,10 @@ class EntrypointPlugin {
40
41
  this.template = template;
41
42
  return this;
42
43
  }
44
+ entryOptions(options) {
45
+ this._entryOptions.push(_.isFunction(options) ? options : () => options);
46
+ return this;
47
+ }
43
48
  watch(update) {
44
49
  this.update = update;
45
50
  return this;
@@ -58,12 +63,17 @@ class EntrypointPlugin {
58
63
  hookEntryOption(entry) {
59
64
  if (_.isPlainObject(entry)) {
60
65
  this.modules.entries().forEach(([name, modules]) => {
61
- let currentFiles = structuredClone(entry[name] ?? []);
66
+ const current = structuredClone(entry[name] ?? []);
67
+ let currentFiles = current;
68
+ let currentOptions = {};
62
69
  if ("import" in currentFiles) {
70
+ currentOptions = currentFiles;
63
71
  currentFiles = currentFiles.import;
64
72
  }
65
73
  currentFiles.push(...Array.from(modules.values(), ({ name: name2 }) => name2));
66
74
  entry[name] = {
75
+ ...currentOptions,
76
+ ...this.resolveEntryOptions(name),
67
77
  import: _.uniq(currentFiles)
68
78
  };
69
79
  });
@@ -73,13 +83,8 @@ class EntrypointPlugin {
73
83
  }
74
84
  async hookWatchRun(compiler) {
75
85
  const { modifiedFiles = /* @__PURE__ */ new Set() } = compiler;
76
- const watchFiles = this.watchFiles;
77
- const needUpdate = Array.from(modifiedFiles).some((file) => {
78
- if (path.isAbsolute(file)) {
79
- file = path.relative(compiler.context, file);
80
- }
81
- return watchFiles.has(file);
82
- });
86
+ const watchFiles = new Set(Array.from(this.watchFiles, (file) => path.resolve(compiler.context, file)));
87
+ const needUpdate = Array.from(modifiedFiles).some((file) => watchFiles.has(path.resolve(compiler.context, file)));
83
88
  if (!needUpdate) {
84
89
  return;
85
90
  }
@@ -88,26 +93,41 @@ class EntrypointPlugin {
88
93
  const currentContents = this.getModuleContents(this.modules);
89
94
  const updatedContents = this.getModuleContents(updatedModules);
90
95
  const removedContents = new Map(Array.from(currentContents).filter((entry) => !updatedContents.has(entry[0])));
91
- const addedContents = new Map(Array.from(updatedContents).filter((entry) => !currentContents.has(entry[0])));
92
- if (removedContents.size > 0 || addedContents.size > 0) {
93
- removedContents.keys().forEach((name) => {
94
- this.plugin.writeModule(name, "");
95
- });
96
- addedContents.forEach((content, name) => {
97
- this.plugin.writeModule(name, content);
98
- });
99
- updatedModules.entries().forEach(([name, modules]) => {
100
- let entry = structuredClone(compiler.options.entry[name]);
101
- if ("import" in entry) {
102
- entry = entry.import;
103
- }
104
- entry = entry.filter((file) => !removedContents.has(file));
105
- entry.push(...Array.from(modules.values(), ({ name: name2 }) => name2));
106
- compiler.options.entry[name] = _.uniq(entry);
107
- });
108
- }
96
+ const changedContents = new Map(
97
+ Array.from(updatedContents).filter(([name, content]) => currentContents.get(name) !== content)
98
+ );
99
+ removedContents.keys().forEach((name) => {
100
+ this.plugin.writeModule(name, "");
101
+ });
102
+ changedContents.forEach((content, name) => {
103
+ this.plugin.writeModule(name, content);
104
+ });
105
+ this.modules.keys().forEach((name) => {
106
+ if (!updatedModules.has(name)) {
107
+ delete compiler.options.entry[name];
108
+ }
109
+ });
110
+ updatedModules.entries().forEach(([name, modules]) => {
111
+ const current = structuredClone(compiler.options.entry[name] ?? []);
112
+ let entry = current;
113
+ let currentOptions = {};
114
+ if ("import" in entry) {
115
+ currentOptions = entry;
116
+ entry = entry.import;
117
+ }
118
+ entry = entry.filter((file) => !removedContents.has(file));
119
+ entry.push(...Array.from(modules.values(), ({ name: name2 }) => name2));
120
+ compiler.options.entry[name] = {
121
+ ...currentOptions,
122
+ ...this.resolveEntryOptions(name),
123
+ import: _.uniq(entry)
124
+ };
125
+ });
109
126
  this._modules = updatedModules;
110
127
  }
128
+ resolveEntryOptions(name) {
129
+ return Object.assign({}, ...this._entryOptions.map((resolve) => resolve(name)));
130
+ }
111
131
  createModules(entries) {
112
132
  const entryModules = /* @__PURE__ */ new Map();
113
133
  for (const [name, files] of entries) {
@@ -0,0 +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,EAE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G,KAAK,cAAc,IAAI,aAAW,QAAQ,IAAI,CAAC,CAAC;AAAA,EAChF;AAAA,EAEU,cAAc,SAA0D;AAC9E,UAAM,eAA6C,oBAAI,IAAI;AAE3D,eAAW,CAAC,MAAM,KAAK,KAAK,SAAS;AACjC,YAAM,UAAmC,oBAAI,IAAI;AAEjD,iBAAW,QAAQ,OAAO;AACtB,gBAAQ,IAAI,MAAM;AAAA,UACd,MAAM,iBAAiB,SAAS,IAAI;AAAA,UACpC,QAAQ,KAAK,WAAW,KAAK,SAAS,IAAI,IAAI;AAAA,QAClD,CAAC;AAAA,MACL;AAEA,mBAAa,IAAI,MAAM,OAAO;AAAA,IAClC;AAEA,WAAO;AAAA,EACX;AAAA,EAEU,kBAAkB,SAA4D;AACpF,UAAM,UAAU,oBAAI,IAAoB;AAExC,YAAQ,OAAO,EAAE,QAAQ,CAAAC,aAAW;AAChC,MAAAA,SAAQ,QAAQ,CAAC,EAAC,MAAM,OAAM,MAAM;AAChC,gBAAQ,IAAI,MAAM,MAAM;AAAA,MAC5B,CAAC;AAAA,IACL,CAAC;AAED,WAAO;AAAA,EACX;AACJ;","names":["_","compiler","name","modules"]}
@@ -0,0 +1 @@
1
+ export { default, type EntrypointPluginEntryOptions, type EntrypointPluginEntryOptionsResolver, type EntrypointPluginModules, type EntrypointPluginModule, type EntrypointPluginEntryModules, type EntrypointPluginTemplate, type EntrypointPluginUpdate, } from "./EntrypointPlugin.js";
@@ -0,0 +1,7 @@
1
+ import {
2
+ default as default2
3
+ } from "./EntrypointPlugin.js";
4
+ export {
5
+ default2 as default
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/entrypoint/index.ts"],"sourcesContent":["export {\n default,\n type EntrypointPluginEntryOptions,\n type EntrypointPluginEntryOptionsResolver,\n type EntrypointPluginModules,\n type EntrypointPluginModule,\n type EntrypointPluginEntryModules,\n type EntrypointPluginTemplate,\n type EntrypointPluginUpdate,\n} from \"./EntrypointPlugin\";\n"],"mappings":"AAAA;AAAA,EACI,WAAAA;AAAA,OAQG;","names":["default"]}
@@ -14,5 +14,6 @@ export default class GenerateJsonPlugin {
14
14
  apply(compiler: Compiler): void;
15
15
  watch(update: GenerateJsonPluginUpdate): this;
16
16
  protected generateFiles(compilation: Compilation): void;
17
+ private removeFile;
17
18
  }
18
19
  export {};
@@ -0,0 +1,73 @@
1
+ import { Compilation, sources } from "@rspack/core";
2
+ import path from "path";
3
+ import { promisify } from "util";
4
+ import { watchCompilation } from "../utils/index.js";
5
+ class GenerateJsonPlugin {
6
+ constructor(data) {
7
+ this.data = data;
8
+ }
9
+ data;
10
+ pluginName = "GenerateJsonPlugin";
11
+ update;
12
+ apply(compiler) {
13
+ let emitted = /* @__PURE__ */ new Set();
14
+ watchCompilation(compiler, this.pluginName, async () => {
15
+ const update = this.update;
16
+ if (update) {
17
+ this.data = await update();
18
+ }
19
+ });
20
+ compiler.hooks.compilation.tap(this.pluginName, (compilation) => {
21
+ compilation.hooks.processAssets.tap(
22
+ {
23
+ name: this.pluginName,
24
+ stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
25
+ },
26
+ () => this.generateFiles(compilation)
27
+ );
28
+ });
29
+ compiler.hooks.afterEmit.tapPromise(this.pluginName, async (compilation) => {
30
+ if (compilation.errors.length) return;
31
+ const current = new Set(Object.keys(this.data));
32
+ for (const filename of emitted) {
33
+ if (!current.has(filename) && !compilation.getAsset(filename)) {
34
+ await this.removeFile(compiler, filename);
35
+ }
36
+ }
37
+ emitted = current;
38
+ });
39
+ }
40
+ watch(update) {
41
+ this.update = update;
42
+ return this;
43
+ }
44
+ generateFiles(compilation) {
45
+ Object.entries(this.data).forEach(([filename, jsonData]) => {
46
+ const json = JSON.stringify(jsonData, null, 2);
47
+ compilation.emitAsset(filename, new sources.RawSource(json));
48
+ });
49
+ }
50
+ async removeFile(compiler, filename) {
51
+ const filesystem = compiler.outputFileSystem;
52
+ const output = compiler.options.output.path;
53
+ const file = path.join(output, filename);
54
+ await promisify(filesystem.unlink.bind(filesystem))(file).catch((error) => {
55
+ if (error.code !== "ENOENT") throw error;
56
+ });
57
+ for (let directory = path.dirname(file); directory.startsWith(output + path.sep); directory = path.dirname(directory)) {
58
+ const removed = await promisify(filesystem.rmdir.bind(filesystem))(directory).then(
59
+ () => true,
60
+ (error) => {
61
+ if (error.code === "ENOENT") return true;
62
+ if (error.code === "ENOTEMPTY" || error.code === "EEXIST") return false;
63
+ throw error;
64
+ }
65
+ );
66
+ if (!removed) break;
67
+ }
68
+ }
69
+ }
70
+ export {
71
+ GenerateJsonPlugin as default
72
+ };
73
+ //# sourceMappingURL=GenerateJsonPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/generate-json/GenerateJsonPlugin.ts"],"sourcesContent":["import {Compilation, Compiler, sources} from \"@rspack/core\";\nimport path from \"path\";\nimport {promisify} from \"util\";\nimport {watchCompilation} from \"../utils\";\n\ntype JsonValue = string | number | boolean | null | JsonObject | JsonArray;\n\ninterface JsonObject {\n [key: string]: JsonValue;\n}\n\ntype JsonArray = JsonValue[];\n\nexport type GenerateJsonPluginData = Record<string, JsonValue>;\n\nexport type GenerateJsonPluginUpdate = () => Promise<GenerateJsonPluginData>;\n\nexport default class GenerateJsonPlugin {\n private readonly pluginName: string = \"GenerateJsonPlugin\";\n\n private update?: GenerateJsonPluginUpdate;\n\n constructor(protected data: GenerateJsonPluginData) {}\n\n public apply(compiler: Compiler): void {\n let emitted = new Set<string>();\n\n watchCompilation(compiler, this.pluginName, async () => {\n const update = this.update;\n\n if (update) {\n this.data = await update();\n }\n });\n\n compiler.hooks.compilation.tap(this.pluginName, (compilation: Compilation) => {\n compilation.hooks.processAssets.tap(\n {\n name: this.pluginName,\n stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,\n },\n () => this.generateFiles(compilation)\n );\n });\n\n compiler.hooks.afterEmit.tapPromise(this.pluginName, async compilation => {\n if (compilation.errors.length) return;\n\n const current = new Set(Object.keys(this.data));\n for (const filename of emitted) {\n if (!current.has(filename) && !compilation.getAsset(filename)) {\n await this.removeFile(compiler, filename);\n }\n }\n emitted = current;\n });\n }\n\n public watch(update: GenerateJsonPluginUpdate): this {\n this.update = update;\n\n return this;\n }\n\n protected generateFiles(compilation: Compilation): void {\n Object.entries(this.data).forEach(([filename, jsonData]) => {\n const json = JSON.stringify(jsonData, null, 2);\n\n compilation.emitAsset(filename, new sources.RawSource(json));\n });\n }\n\n private async removeFile(compiler: Compiler, filename: string): Promise<void> {\n const filesystem = compiler.outputFileSystem!;\n const output = compiler.options.output.path!;\n const file = path.join(output, filename);\n await promisify(filesystem.unlink.bind(filesystem))(file).catch((error: NodeJS.ErrnoException) => {\n if (error.code !== \"ENOENT\") throw error;\n });\n\n // Remove only empty parent directories owned by the removed output, stopping at output.path.\n for (\n let directory = path.dirname(file);\n directory.startsWith(output + path.sep);\n directory = path.dirname(directory)\n ) {\n const removed = await promisify(filesystem.rmdir.bind(filesystem))(directory).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return true;\n if (error.code === \"ENOTEMPTY\" || error.code === \"EEXIST\") return false;\n throw error;\n }\n );\n if (!removed) break;\n }\n }\n}\n"],"mappings":"AAAA,SAAQ,aAAuB,eAAc;AAC7C,OAAO,UAAU;AACjB,SAAQ,iBAAgB;AACxB,SAAQ,wBAAuB;AAc/B,MAAO,mBAAiC;AAAA,EAKpC,YAAsB,MAA8B;AAA9B;AAAA,EAA+B;AAAA,EAA/B;AAAA,EAJL,aAAqB;AAAA,EAE9B;AAAA,EAID,MAAM,UAA0B;AACnC,QAAI,UAAU,oBAAI,IAAY;AAE9B,qBAAiB,UAAU,KAAK,YAAY,YAAY;AACpD,YAAM,SAAS,KAAK;AAEpB,UAAI,QAAQ;AACR,aAAK,OAAO,MAAM,OAAO;AAAA,MAC7B;AAAA,IACJ,CAAC;AAED,aAAS,MAAM,YA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AK,QAAQ,SAAS,GACpC;AACE,YAAM,UAAU,MAAM,UAAU,WAAW,MAAM,KAAK,UAAU,CAAC,EAAE,SAAS,EAAE;AAAA,QAC1E,MAAM;AAAA,QACN,CAAC,UAAiC;AAC9B,cAAI,MAAM,SAAS,SAAU,QAAO;AACpC,cAAI,MAAM,SAAS,eAAe,MAAM,SAAS,SAAU,QAAO;AAClE,gBAAM;AAAA,QACV;AAAA,MACJ;AACA,UAAI,CAAC,QAAS;AAAA,IAClB;AAAA,EACJ;AACJ;","names":[]}
@@ -0,0 +1 @@
1
+ export { default, type GenerateJsonPluginData, type GenerateJsonPluginUpdate } from "./GenerateJsonPlugin.js";
@@ -0,0 +1,5 @@
1
+ import { default as default2 } from "./GenerateJsonPlugin.js";
2
+ export {
3
+ default2 as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/generate-json/index.ts"],"sourcesContent":["export {default, type GenerateJsonPluginData, type GenerateJsonPluginUpdate} from \"./GenerateJsonPlugin\";\n"],"mappings":"AAAA,SAAQ,WAAAA,gBAA0E;","names":["default"]}
@@ -0,0 +1,23 @@
1
+ import { type Compiler, type RuleSetCondition } from "@rspack/core";
2
+ /** JavaScript source keyed by the module's import specifier. */
3
+ export type GenerateModulePluginModules = Record<string, string>;
4
+ /** Returns source updates for the registered modules. */
5
+ export type GenerateModulePluginUpdate = () => Promise<GenerateModulePluginModules>;
6
+ export interface GenerateModulePluginDependencies {
7
+ files?: Iterable<string>;
8
+ directories?: Iterable<string>;
9
+ }
10
+ export type GenerateModulePluginDependenciesResolver = () => Promise<GenerateModulePluginDependencies>;
11
+ export default class GenerateModulePlugin {
12
+ private readonly modules;
13
+ private readonly pluginName;
14
+ private update?;
15
+ private dependencies?;
16
+ private moduleLayer?;
17
+ private issuerLayer?;
18
+ constructor(modules: GenerateModulePluginModules);
19
+ /** Share a module layer for matching issuers; other issuers keep their inherited layer. */
20
+ layer(name: string, issuerLayer?: RuleSetCondition): this;
21
+ watch(update: GenerateModulePluginUpdate, dependencies?: GenerateModulePluginDependenciesResolver): this;
22
+ apply(compiler: Compiler): void;
23
+ }
@@ -0,0 +1,88 @@
1
+ import { existsSync } from "fs";
2
+ import path from "path";
3
+ import { experiments } from "@rspack/core";
4
+ import { watchCompilation } from "../utils/index.js";
5
+ class GenerateModulePlugin {
6
+ constructor(modules) {
7
+ this.modules = modules;
8
+ }
9
+ modules;
10
+ pluginName = "GenerateModulePlugin";
11
+ update;
12
+ dependencies;
13
+ moduleLayer;
14
+ issuerLayer;
15
+ /** Share a module layer for matching issuers; other issuers keep their inherited layer. */
16
+ layer(name, issuerLayer) {
17
+ this.moduleLayer = name;
18
+ this.issuerLayer = issuerLayer;
19
+ return this;
20
+ }
21
+ watch(update, dependencies) {
22
+ this.update = update;
23
+ this.dependencies = dependencies;
24
+ return this;
25
+ }
26
+ apply(compiler) {
27
+ const modules = { ...this.modules };
28
+ let dependencies = {};
29
+ const resources = Object.fromEntries(
30
+ Object.keys(modules).map((name) => [
31
+ name,
32
+ path.resolve(
33
+ compiler.context,
34
+ "node_modules",
35
+ ".adnbn-virtual",
36
+ path.extname(name) ? name : `${name}.js`
37
+ )
38
+ ])
39
+ );
40
+ const plugin = new experiments.VirtualModulesPlugin(
41
+ Object.fromEntries(Object.entries(modules).map(([name, source]) => [resources[name], source]))
42
+ );
43
+ plugin.apply(compiler);
44
+ compiler.options.resolve.alias = { ...compiler.options.resolve.alias, ...resources };
45
+ const pending = /* @__PURE__ */ new Map();
46
+ let initialized = false;
47
+ if (this.moduleLayer !== void 0) {
48
+ compiler.options.module.rules.push({
49
+ include: Object.values(resources),
50
+ layer: this.moduleLayer,
51
+ issuerLayer: this.issuerLayer
52
+ });
53
+ }
54
+ compiler.hooks.compilation.tap(this.pluginName, (compilation) => {
55
+ for (const [name, source] of pending) plugin.writeModule(resources[name], source);
56
+ pending.clear();
57
+ initialized = true;
58
+ for (const file of dependencies.files ?? []) {
59
+ compilation.fileDependencies.add(path.resolve(compiler.context, file));
60
+ }
61
+ for (const directory of dependencies.directories ?? []) {
62
+ const absolute = path.resolve(compiler.context, directory);
63
+ const target = existsSync(absolute) ? compilation.contextDependencies : compilation.missingDependencies;
64
+ target.add(absolute);
65
+ }
66
+ });
67
+ watchCompilation(compiler, this.pluginName, async () => {
68
+ var _a;
69
+ dependencies = await ((_a = this.dependencies) == null ? void 0 : _a.call(this)) ?? {};
70
+ if (!this.update) return;
71
+ for (const [name, source] of Object.entries(await this.update())) {
72
+ if (modules[name] !== source) {
73
+ if (initialized) {
74
+ plugin.writeModule(resources[name], source);
75
+ compiler.modifiedFiles = /* @__PURE__ */ new Set([...compiler.modifiedFiles ?? [], resources[name]]);
76
+ } else {
77
+ pending.set(name, source);
78
+ }
79
+ modules[name] = source;
80
+ }
81
+ }
82
+ });
83
+ }
84
+ }
85
+ export {
86
+ GenerateModulePlugin as default
87
+ };
88
+ //# sourceMappingURL=GenerateModulePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/generate-module/GenerateModulePlugin.ts"],"sourcesContent":["import {existsSync} from \"fs\";\nimport path from \"path\";\nimport {experiments, type Compiler, type RuleSetCondition} from \"@rspack/core\";\nimport {watchCompilation} from \"../utils\";\n\n/** JavaScript source keyed by the module's import specifier. */\nexport type GenerateModulePluginModules = Record<string, string>;\n\n/** Returns source updates for the registered modules. */\nexport type GenerateModulePluginUpdate = () => Promise<GenerateModulePluginModules>;\n\nexport interface GenerateModulePluginDependencies {\n files?: Iterable<string>;\n directories?: Iterable<string>;\n}\n\nexport type GenerateModulePluginDependenciesResolver = () => Promise<GenerateModulePluginDependencies>;\n\nexport default class GenerateModulePlugin {\n private readonly pluginName = \"GenerateModulePlugin\";\n private update?: GenerateModulePluginUpdate;\n private dependencies?: GenerateModulePluginDependenciesResolver;\n private moduleLayer?: string;\n private issuerLayer?: RuleSetCondition;\n\n constructor(private readonly modules: GenerateModulePluginModules) {}\n\n /** Share a module layer for matching issuers; other issuers keep their inherited layer. */\n public layer(name: string, issuerLayer?: RuleSetCondition): this {\n this.moduleLayer = name;\n this.issuerLayer = issuerLayer;\n return this;\n }\n\n public watch(update: GenerateModulePluginUpdate, dependencies?: GenerateModulePluginDependenciesResolver): this {\n this.update = update;\n this.dependencies = dependencies;\n return this;\n }\n\n public apply(compiler: Compiler): void {\n const modules = {...this.modules};\n let dependencies: GenerateModulePluginDependencies = {};\n\n // Stable paths keep module IDs and hashes reproducible. The native store belongs\n // to this compiler, so concurrent builds never share files or cleanup ownership.\n const resources = Object.fromEntries(\n Object.keys(modules).map(name => [\n name,\n path.resolve(\n compiler.context,\n \"node_modules\",\n \".adnbn-virtual\",\n path.extname(name) ? name : `${name}.js`\n ),\n ])\n );\n const plugin = new experiments.VirtualModulesPlugin(\n Object.fromEntries(Object.entries(modules).map(([name, source]) => [resources[name], source]))\n );\n plugin.apply(compiler);\n compiler.options.resolve.alias = {...compiler.options.resolve.alias, ...resources};\n const pending = new Map<string, string>();\n let initialized = false;\n\n if (this.moduleLayer !== undefined) {\n compiler.options.module.rules.push({\n include: Object.values(resources),\n layer: this.moduleLayer,\n issuerLayer: this.issuerLayer,\n });\n }\n\n compiler.hooks.compilation.tap(this.pluginName, compilation => {\n // Native virtual files can be updated only after the Rust compiler exists.\n for (const [name, source] of pending) plugin.writeModule(resources[name], source);\n pending.clear();\n initialized = true;\n\n for (const file of dependencies.files ?? []) {\n compilation.fileDependencies.add(path.resolve(compiler.context, file));\n }\n\n for (const directory of dependencies.directories ?? []) {\n const absolute = path.resolve(compiler.context, directory);\n const target = existsSync(absolute) ? compilation.contextDependencies : compilation.missingDependencies;\n target.add(absolute);\n }\n });\n\n watchCompilation(compiler, this.pluginName, async () => {\n dependencies = (await this.dependencies?.()) ?? {};\n if (!this.update) return;\n\n for (const [name, source] of Object.entries(await this.update())) {\n if (modules[name] !== source) {\n if (initialized) {\n plugin.writeModule(resources[name], source);\n // watchRun precedes native cache invalidation. Include generated changes\n // in this rebuild rather than waiting for a second filesystem event.\n compiler.modifiedFiles = new Set([...(compiler.modifiedFiles ?? []), resources[name]]);\n } else {\n pending.set(name, source);\n }\n modules[name] = source;\n }\n }\n });\n }\n}\n"],"mappings":"AAAA,SAAQ,kBAAiB;AACzB,OAAO,UAAU;AACjB,SAAQ,mBAAwD;AAChE,SAAQ,wBAAuB;AAe/B,MAAO,qBAAmC;AAAA,EAOtC,YAA6B,SAAsC;AAAtC;AAAA,EAAuC;AAAA,EAAvC;AAAA,EANZ,aAAa;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAKD,MAAM,MAAc,aAAsC;AAC7D,SAAK,cAAc;AACnB,SAAK,cAAc;AACnB,WAAO;AAAA,EACX;AAAA,EAEO,MAAM,QAAoC,cAA+D;AAC5G,SAAK,SAAS;AACd,SAAK,eAAe;AACpB,WAAO;AAAA,EACX;AAAA,EAEO,MAAM,UAA0B;AACnC,UAAM,UAAU,EAAC,GAAG,KAAK,QAAO;AAChC,QAAI,eAAiD,CAAC;AAItD,UAAM,YAAY,OAAO;AAAA,MACrB,OAAO,KAAK,OAAO,EAAE,IAAI,UAAQ;AAAA,QAC7B;AAAA,QACA,KAAK;AAAA,UACD,SAAS;AAAA,UACT;AAAA,UACA;AAAA,UACA,KAAK,QAAQ,IAAI,IAAI,OAAO,GAAG,IAAI;AAAA,QACvC;AAAA,MACJ,CAAC;AAAA,IACL;AACA,UAAM,SAAS,IAAI,YAAY;AAAA,MAC3B,OAAO,YAAY,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,MAAM,MAAM,CAAC,UAAU,IAAI,GAAG,MAAM,CAAC,CAAC;AAAA,IACjG;AACA,WAAO,MAAM,QAAQ;AACrB,aAAS,QAAQ,QAAQ,QAAQ,EAAC,GAAG,SAAS,QAAQ,QAAQ,OAAO,GAAG,UAAS;AACjF,UAAM,UAAU,oBAAI,IAAoB;AACxC,QAAI,c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names":[]}
@@ -0,0 +1 @@
1
+ export { default as GenerateModulePlugin, type GenerateModulePluginDependencies, type GenerateModulePluginDependenciesResolver, type GenerateModulePluginModules, type GenerateModulePluginUpdate, } from "./GenerateModulePlugin.js";
@@ -0,0 +1,7 @@
1
+ import {
2
+ default as default2
3
+ } from "./GenerateModulePlugin.js";
4
+ export {
5
+ default2 as GenerateModulePlugin
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/bundler/plugins/generate-module/index.ts"],"sourcesContent":["export {\n default as GenerateModulePlugin,\n type GenerateModulePluginDependencies,\n type GenerateModulePluginDependenciesResolver,\n type GenerateModulePluginModules,\n type GenerateModulePluginUpdate,\n} from \"./GenerateModulePlugin\";\n"],"mappings":"AAAA;AAAA,EACe,WAAXA;AAAA,OAKG;","names":["default"]}