plgg-bundle 0.0.1

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 (235) hide show
  1. package/README.md +68 -0
  2. package/bin/appAliasHook.mjs +89 -0
  3. package/bin/hook.mjs +94 -0
  4. package/bin/plgg-bundle.mjs +16 -0
  5. package/dist/Dev/fixtures/devPoc.spec.d.ts +2 -0
  6. package/dist/Dev/fixtures/devPoc.spec.d.ts.map +1 -0
  7. package/dist/Dev/fixtures/devPoc.spec.js +145 -0
  8. package/dist/Dev/fixtures/devPoc.spec.js.map +1 -0
  9. package/dist/Dev/model/Fetch.d.ts +20 -0
  10. package/dist/Dev/model/Fetch.d.ts.map +1 -0
  11. package/dist/Dev/model/Fetch.js +8 -0
  12. package/dist/Dev/model/Fetch.js.map +1 -0
  13. package/dist/Dev/model/ModuleGraph.d.ts +27 -0
  14. package/dist/Dev/model/ModuleGraph.d.ts.map +1 -0
  15. package/dist/Dev/model/ModuleGraph.js +2 -0
  16. package/dist/Dev/model/ModuleGraph.js.map +1 -0
  17. package/dist/Dev/model/Protocol.d.ts +22 -0
  18. package/dist/Dev/model/Protocol.d.ts.map +1 -0
  19. package/dist/Dev/model/Protocol.js +31 -0
  20. package/dist/Dev/model/Protocol.js.map +1 -0
  21. package/dist/Dev/node/devServer.d.ts +21 -0
  22. package/dist/Dev/node/devServer.d.ts.map +1 -0
  23. package/dist/Dev/node/devServer.js +298 -0
  24. package/dist/Dev/node/devServer.js.map +1 -0
  25. package/dist/Dev/node/httpAdapter.d.ts +19 -0
  26. package/dist/Dev/node/httpAdapter.d.ts.map +1 -0
  27. package/dist/Dev/node/httpAdapter.js +76 -0
  28. package/dist/Dev/node/httpAdapter.js.map +1 -0
  29. package/dist/Dev/node/scanGraph.d.ts +21 -0
  30. package/dist/Dev/node/scanGraph.d.ts.map +1 -0
  31. package/dist/Dev/node/scanGraph.js +145 -0
  32. package/dist/Dev/node/scanGraph.js.map +1 -0
  33. package/dist/Dev/node/watch.d.ts +10 -0
  34. package/dist/Dev/node/watch.d.ts.map +1 -0
  35. package/dist/Dev/node/watch.js +44 -0
  36. package/dist/Dev/node/watch.js.map +1 -0
  37. package/dist/Dev/usecase/allowedHost.d.ts +16 -0
  38. package/dist/Dev/usecase/allowedHost.d.ts.map +1 -0
  39. package/dist/Dev/usecase/allowedHost.js +33 -0
  40. package/dist/Dev/usecase/allowedHost.js.map +1 -0
  41. package/dist/Dev/usecase/allowedHost.spec.d.ts +2 -0
  42. package/dist/Dev/usecase/allowedHost.spec.d.ts.map +1 -0
  43. package/dist/Dev/usecase/allowedHost.spec.js +13 -0
  44. package/dist/Dev/usecase/allowedHost.spec.js.map +1 -0
  45. package/dist/Dev/usecase/buildGraph.d.ts +12 -0
  46. package/dist/Dev/usecase/buildGraph.d.ts.map +1 -0
  47. package/dist/Dev/usecase/buildGraph.js +24 -0
  48. package/dist/Dev/usecase/buildGraph.js.map +1 -0
  49. package/dist/Dev/usecase/buildGraph.spec.d.ts +2 -0
  50. package/dist/Dev/usecase/buildGraph.spec.d.ts.map +1 -0
  51. package/dist/Dev/usecase/buildGraph.spec.js +16 -0
  52. package/dist/Dev/usecase/buildGraph.spec.js.map +1 -0
  53. package/dist/Dev/usecase/decorateDevHtml.d.ts +12 -0
  54. package/dist/Dev/usecase/decorateDevHtml.d.ts.map +1 -0
  55. package/dist/Dev/usecase/decorateDevHtml.js +15 -0
  56. package/dist/Dev/usecase/decorateDevHtml.js.map +1 -0
  57. package/dist/Dev/usecase/decorateDevHtml.spec.d.ts +2 -0
  58. package/dist/Dev/usecase/decorateDevHtml.spec.d.ts.map +1 -0
  59. package/dist/Dev/usecase/decorateDevHtml.spec.js +19 -0
  60. package/dist/Dev/usecase/decorateDevHtml.spec.js.map +1 -0
  61. package/dist/Dev/usecase/invalidate.d.ts +17 -0
  62. package/dist/Dev/usecase/invalidate.d.ts.map +1 -0
  63. package/dist/Dev/usecase/invalidate.js +57 -0
  64. package/dist/Dev/usecase/invalidate.js.map +1 -0
  65. package/dist/Dev/usecase/invalidate.spec.d.ts +2 -0
  66. package/dist/Dev/usecase/invalidate.spec.d.ts.map +1 -0
  67. package/dist/Dev/usecase/invalidate.spec.js +64 -0
  68. package/dist/Dev/usecase/invalidate.spec.js.map +1 -0
  69. package/dist/Dev/usecase/parseImports.d.ts +24 -0
  70. package/dist/Dev/usecase/parseImports.d.ts.map +1 -0
  71. package/dist/Dev/usecase/parseImports.js +40 -0
  72. package/dist/Dev/usecase/parseImports.js.map +1 -0
  73. package/dist/Dev/usecase/parseImports.spec.d.ts +2 -0
  74. package/dist/Dev/usecase/parseImports.spec.d.ts.map +1 -0
  75. package/dist/Dev/usecase/parseImports.spec.js +24 -0
  76. package/dist/Dev/usecase/parseImports.spec.js.map +1 -0
  77. package/dist/Dev/usecase/reloadDecision.d.ts +20 -0
  78. package/dist/Dev/usecase/reloadDecision.d.ts.map +1 -0
  79. package/dist/Dev/usecase/reloadDecision.js +52 -0
  80. package/dist/Dev/usecase/reloadDecision.js.map +1 -0
  81. package/dist/Dev/usecase/reloadDecision.spec.d.ts +2 -0
  82. package/dist/Dev/usecase/reloadDecision.spec.d.ts.map +1 -0
  83. package/dist/Dev/usecase/reloadDecision.spec.js +17 -0
  84. package/dist/Dev/usecase/reloadDecision.spec.js.map +1 -0
  85. package/dist/domain/model/BundleConfig.d.ts +136 -0
  86. package/dist/domain/model/BundleConfig.d.ts.map +1 -0
  87. package/dist/domain/model/BundleConfig.js +18 -0
  88. package/dist/domain/model/BundleConfig.js.map +1 -0
  89. package/dist/domain/model/BundleConfig.spec.d.ts +2 -0
  90. package/dist/domain/model/BundleConfig.spec.d.ts.map +1 -0
  91. package/dist/domain/model/BundleConfig.spec.js +8 -0
  92. package/dist/domain/model/BundleConfig.spec.js.map +1 -0
  93. package/dist/domain/usecase/asBundleConfig.d.ts +17 -0
  94. package/dist/domain/usecase/asBundleConfig.d.ts.map +1 -0
  95. package/dist/domain/usecase/asBundleConfig.js +179 -0
  96. package/dist/domain/usecase/asBundleConfig.js.map +1 -0
  97. package/dist/domain/usecase/asBundleConfig.spec.d.ts +2 -0
  98. package/dist/domain/usecase/asBundleConfig.spec.d.ts.map +1 -0
  99. package/dist/domain/usecase/asBundleConfig.spec.js +119 -0
  100. package/dist/domain/usecase/asBundleConfig.spec.js.map +1 -0
  101. package/dist/domain/usecase/build.d.ts +14 -0
  102. package/dist/domain/usecase/build.d.ts.map +1 -0
  103. package/dist/domain/usecase/build.js +177 -0
  104. package/dist/domain/usecase/build.js.map +1 -0
  105. package/dist/domain/usecase/collectModules.d.ts +53 -0
  106. package/dist/domain/usecase/collectModules.d.ts.map +1 -0
  107. package/dist/domain/usecase/collectModules.js +118 -0
  108. package/dist/domain/usecase/collectModules.js.map +1 -0
  109. package/dist/domain/usecase/deriveExternal.d.ts +25 -0
  110. package/dist/domain/usecase/deriveExternal.d.ts.map +1 -0
  111. package/dist/domain/usecase/deriveExternal.js +79 -0
  112. package/dist/domain/usecase/deriveExternal.js.map +1 -0
  113. package/dist/domain/usecase/deriveExternal.spec.d.ts +2 -0
  114. package/dist/domain/usecase/deriveExternal.spec.d.ts.map +1 -0
  115. package/dist/domain/usecase/deriveExternal.spec.js +56 -0
  116. package/dist/domain/usecase/deriveExternal.spec.js.map +1 -0
  117. package/dist/domain/usecase/discoverWorkspace.d.ts +27 -0
  118. package/dist/domain/usecase/discoverWorkspace.d.ts.map +1 -0
  119. package/dist/domain/usecase/discoverWorkspace.js +116 -0
  120. package/dist/domain/usecase/discoverWorkspace.js.map +1 -0
  121. package/dist/domain/usecase/discoverWorkspace.spec.d.ts +2 -0
  122. package/dist/domain/usecase/discoverWorkspace.spec.d.ts.map +1 -0
  123. package/dist/domain/usecase/discoverWorkspace.spec.js +23 -0
  124. package/dist/domain/usecase/discoverWorkspace.spec.js.map +1 -0
  125. package/dist/domain/usecase/emitBundle.d.ts +43 -0
  126. package/dist/domain/usecase/emitBundle.d.ts.map +1 -0
  127. package/dist/domain/usecase/emitBundle.js +157 -0
  128. package/dist/domain/usecase/emitBundle.js.map +1 -0
  129. package/dist/domain/usecase/emitBundle.spec.d.ts +2 -0
  130. package/dist/domain/usecase/emitBundle.spec.d.ts.map +1 -0
  131. package/dist/domain/usecase/emitBundle.spec.js +80 -0
  132. package/dist/domain/usecase/emitBundle.spec.js.map +1 -0
  133. package/dist/domain/usecase/emitDts.d.ts +32 -0
  134. package/dist/domain/usecase/emitDts.d.ts.map +1 -0
  135. package/dist/domain/usecase/emitDts.js +99 -0
  136. package/dist/domain/usecase/emitDts.js.map +1 -0
  137. package/dist/domain/usecase/isExternal.d.ts +12 -0
  138. package/dist/domain/usecase/isExternal.d.ts.map +1 -0
  139. package/dist/domain/usecase/isExternal.js +16 -0
  140. package/dist/domain/usecase/isExternal.js.map +1 -0
  141. package/dist/domain/usecase/isExternal.spec.d.ts +2 -0
  142. package/dist/domain/usecase/isExternal.spec.d.ts.map +1 -0
  143. package/dist/domain/usecase/isExternal.spec.js +16 -0
  144. package/dist/domain/usecase/isExternal.spec.js.map +1 -0
  145. package/dist/domain/usecase/resolveSpecifier.d.ts +35 -0
  146. package/dist/domain/usecase/resolveSpecifier.d.ts.map +1 -0
  147. package/dist/domain/usecase/resolveSpecifier.js +83 -0
  148. package/dist/domain/usecase/resolveSpecifier.js.map +1 -0
  149. package/dist/domain/usecase/resolveSpecifier.spec.d.ts +2 -0
  150. package/dist/domain/usecase/resolveSpecifier.spec.d.ts.map +1 -0
  151. package/dist/domain/usecase/resolveSpecifier.spec.js +44 -0
  152. package/dist/domain/usecase/resolveSpecifier.spec.js.map +1 -0
  153. package/dist/domain/usecase/resolveWorkspaceSpecifier.d.ts +29 -0
  154. package/dist/domain/usecase/resolveWorkspaceSpecifier.d.ts.map +1 -0
  155. package/dist/domain/usecase/resolveWorkspaceSpecifier.js +89 -0
  156. package/dist/domain/usecase/resolveWorkspaceSpecifier.js.map +1 -0
  157. package/dist/domain/usecase/resolveWorkspaceSpecifier.spec.d.ts +2 -0
  158. package/dist/domain/usecase/resolveWorkspaceSpecifier.spec.d.ts.map +1 -0
  159. package/dist/domain/usecase/resolveWorkspaceSpecifier.spec.js +27 -0
  160. package/dist/domain/usecase/resolveWorkspaceSpecifier.spec.js.map +1 -0
  161. package/dist/domain/usecase/rewriteDtsAliases.d.ts +25 -0
  162. package/dist/domain/usecase/rewriteDtsAliases.d.ts.map +1 -0
  163. package/dist/domain/usecase/rewriteDtsAliases.js +71 -0
  164. package/dist/domain/usecase/rewriteDtsAliases.js.map +1 -0
  165. package/dist/domain/usecase/rewriteDtsAliases.spec.d.ts +2 -0
  166. package/dist/domain/usecase/rewriteDtsAliases.spec.d.ts.map +1 -0
  167. package/dist/domain/usecase/rewriteDtsAliases.spec.js +35 -0
  168. package/dist/domain/usecase/rewriteDtsAliases.spec.js.map +1 -0
  169. package/dist/entrypoints/cli.d.ts +2 -0
  170. package/dist/entrypoints/cli.d.ts.map +1 -0
  171. package/dist/entrypoints/cli.js +79 -0
  172. package/dist/entrypoints/cli.js.map +1 -0
  173. package/dist/index.d.ts +21 -0
  174. package/dist/index.d.ts.map +1 -0
  175. package/dist/index.js +28 -0
  176. package/dist/index.js.map +1 -0
  177. package/dist/vendors/runner.d.ts +20 -0
  178. package/dist/vendors/runner.d.ts.map +1 -0
  179. package/dist/vendors/runner.js +60 -0
  180. package/dist/vendors/runner.js.map +1 -0
  181. package/dist/vendors/runner.spec.d.ts +2 -0
  182. package/dist/vendors/runner.spec.d.ts.map +1 -0
  183. package/dist/vendors/runner.spec.js +20 -0
  184. package/dist/vendors/runner.spec.js.map +1 -0
  185. package/dist/vendors/transpiler.d.ts +19 -0
  186. package/dist/vendors/transpiler.d.ts.map +1 -0
  187. package/dist/vendors/transpiler.js +42 -0
  188. package/dist/vendors/transpiler.js.map +1 -0
  189. package/package.json +31 -0
  190. package/src/Dev/fixtures/devPoc.spec.ts +235 -0
  191. package/src/Dev/model/Fetch.ts +31 -0
  192. package/src/Dev/model/ModuleGraph.ts +30 -0
  193. package/src/Dev/model/Protocol.ts +35 -0
  194. package/src/Dev/node/devServer.ts +503 -0
  195. package/src/Dev/node/httpAdapter.ts +162 -0
  196. package/src/Dev/node/scanGraph.ts +203 -0
  197. package/src/Dev/node/watch.ts +54 -0
  198. package/src/Dev/usecase/allowedHost.spec.ts +50 -0
  199. package/src/Dev/usecase/allowedHost.ts +39 -0
  200. package/src/Dev/usecase/buildGraph.spec.ts +30 -0
  201. package/src/Dev/usecase/buildGraph.ts +31 -0
  202. package/src/Dev/usecase/decorateDevHtml.spec.ts +39 -0
  203. package/src/Dev/usecase/decorateDevHtml.ts +21 -0
  204. package/src/Dev/usecase/invalidate.spec.ts +88 -0
  205. package/src/Dev/usecase/invalidate.ts +67 -0
  206. package/src/Dev/usecase/parseImports.spec.ts +58 -0
  207. package/src/Dev/usecase/parseImports.ts +50 -0
  208. package/src/Dev/usecase/reloadDecision.spec.ts +50 -0
  209. package/src/Dev/usecase/reloadDecision.ts +65 -0
  210. package/src/domain/model/BundleConfig.spec.ts +35 -0
  211. package/src/domain/model/BundleConfig.ts +162 -0
  212. package/src/domain/usecase/asBundleConfig.spec.ts +230 -0
  213. package/src/domain/usecase/asBundleConfig.ts +257 -0
  214. package/src/domain/usecase/build.ts +259 -0
  215. package/src/domain/usecase/collectModules.ts +226 -0
  216. package/src/domain/usecase/deriveExternal.spec.ts +125 -0
  217. package/src/domain/usecase/deriveExternal.ts +108 -0
  218. package/src/domain/usecase/discoverWorkspace.spec.ts +63 -0
  219. package/src/domain/usecase/discoverWorkspace.ts +183 -0
  220. package/src/domain/usecase/emitBundle.spec.ts +162 -0
  221. package/src/domain/usecase/emitBundle.ts +215 -0
  222. package/src/domain/usecase/emitDts.ts +156 -0
  223. package/src/domain/usecase/isExternal.spec.ts +53 -0
  224. package/src/domain/usecase/isExternal.ts +20 -0
  225. package/src/domain/usecase/resolveSpecifier.spec.ts +112 -0
  226. package/src/domain/usecase/resolveSpecifier.ts +127 -0
  227. package/src/domain/usecase/resolveWorkspaceSpecifier.spec.ts +79 -0
  228. package/src/domain/usecase/resolveWorkspaceSpecifier.ts +120 -0
  229. package/src/domain/usecase/rewriteDtsAliases.spec.ts +123 -0
  230. package/src/domain/usecase/rewriteDtsAliases.ts +133 -0
  231. package/src/entrypoints/cli.ts +105 -0
  232. package/src/index.ts +28 -0
  233. package/src/vendors/runner.spec.ts +50 -0
  234. package/src/vendors/runner.ts +78 -0
  235. package/src/vendors/transpiler.ts +48 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/entrypoints/cli.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,21 @@
1
+ export * from "plgg-bundle/domain/model/BundleConfig";
2
+ export * from "plgg-bundle/domain/usecase/asBundleConfig";
3
+ export * from "plgg-bundle/domain/usecase/build";
4
+ export * from "plgg-bundle/domain/usecase/collectModules";
5
+ export * from "plgg-bundle/domain/usecase/deriveExternal";
6
+ export * from "plgg-bundle/domain/usecase/emitBundle";
7
+ export * from "plgg-bundle/domain/usecase/emitDts";
8
+ export * from "plgg-bundle/domain/usecase/isExternal";
9
+ export * from "plgg-bundle/domain/usecase/resolveSpecifier";
10
+ export * from "plgg-bundle/domain/usecase/rewriteDtsAliases";
11
+ export * from "plgg-bundle/Dev/model/Fetch";
12
+ export * from "plgg-bundle/Dev/model/ModuleGraph";
13
+ export * from "plgg-bundle/Dev/model/Protocol";
14
+ export * from "plgg-bundle/Dev/usecase/parseImports";
15
+ export * from "plgg-bundle/Dev/usecase/buildGraph";
16
+ export * from "plgg-bundle/Dev/usecase/invalidate";
17
+ export * from "plgg-bundle/Dev/usecase/reloadDecision";
18
+ export * from "plgg-bundle/Dev/usecase/decorateDevHtml";
19
+ export * from "plgg-bundle/Dev/usecase/allowedHost";
20
+ export * from "plgg-bundle/Dev/node/devServer";
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,uCAAuC,CAAC;AACtD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,kCAAkC,CAAC;AACjD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8CAA8C,CAAC;AAK7D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ // Public API of the in-house bundler. The CLI
2
+ // (`bin/plgg-bundle.mjs` → `src/entrypoints/cli.ts`) is
3
+ // the usual entry; these exports let other tooling
4
+ // drive the bundler programmatically.
5
+ export * from "plgg-bundle/domain/model/BundleConfig";
6
+ export * from "plgg-bundle/domain/usecase/asBundleConfig";
7
+ export * from "plgg-bundle/domain/usecase/build";
8
+ export * from "plgg-bundle/domain/usecase/collectModules";
9
+ export * from "plgg-bundle/domain/usecase/deriveExternal";
10
+ export * from "plgg-bundle/domain/usecase/emitBundle";
11
+ export * from "plgg-bundle/domain/usecase/emitDts";
12
+ export * from "plgg-bundle/domain/usecase/isExternal";
13
+ export * from "plgg-bundle/domain/usecase/resolveSpecifier";
14
+ export * from "plgg-bundle/domain/usecase/rewriteDtsAliases";
15
+ // Dev server (the `plgg-bundle dev` toolchain half): the
16
+ // app⇄server contract, the pure hot-reload core, and the
17
+ // node-adapter entry point.
18
+ export * from "plgg-bundle/Dev/model/Fetch";
19
+ export * from "plgg-bundle/Dev/model/ModuleGraph";
20
+ export * from "plgg-bundle/Dev/model/Protocol";
21
+ export * from "plgg-bundle/Dev/usecase/parseImports";
22
+ export * from "plgg-bundle/Dev/usecase/buildGraph";
23
+ export * from "plgg-bundle/Dev/usecase/invalidate";
24
+ export * from "plgg-bundle/Dev/usecase/reloadDecision";
25
+ export * from "plgg-bundle/Dev/usecase/decorateDevHtml";
26
+ export * from "plgg-bundle/Dev/usecase/allowedHost";
27
+ export * from "plgg-bundle/Dev/node/devServer";
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,wDAAwD;AACxD,mDAAmD;AACnD,sCAAsC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,kCAAkC,CAAC;AACjD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8CAA8C,CAAC;AAE7D,yDAAyD;AACzD,yDAAyD;AACzD,4BAA4B;AAC5B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Run a self-contained CJS bundle in an isolated VM
3
+ * context and return its `module.exports` enumerable
4
+ * keys (minus `__esModule`), sorted. This is how the
5
+ * ESM emitter learns the exact public surface, since
6
+ * ESM cannot declare exports dynamically. Re-throws
7
+ * with context on failure.
8
+ *
9
+ * `resolveBase` is the TARGET package's root: the
10
+ * bundle's external `require("plgg")` / `require("node:*")`
11
+ * must resolve against the target package's own
12
+ * node_modules (not the bundler's), so the require is
13
+ * rooted there. Upstream dists exist in build order, so
14
+ * the externals resolve.
15
+ *
16
+ * Isolated in `src/vendors/` because executing generated
17
+ * code is an effectful boundary, not domain logic.
18
+ */
19
+ export declare const readExportNames: (cjsCode: string, resolveBase: string) => ReadonlyArray<string>;
20
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/vendors/runner.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,aAAa,MAAM,KAClB,aAAa,CAAC,MAAM,CAYtB,CAAC"}
@@ -0,0 +1,60 @@
1
+ import vm from "node:vm";
2
+ import { createRequire } from "node:module";
3
+ import { join } from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+ /**
6
+ * Run a self-contained CJS bundle in an isolated VM
7
+ * context and return its `module.exports` enumerable
8
+ * keys (minus `__esModule`), sorted. This is how the
9
+ * ESM emitter learns the exact public surface, since
10
+ * ESM cannot declare exports dynamically. Re-throws
11
+ * with context on failure.
12
+ *
13
+ * `resolveBase` is the TARGET package's root: the
14
+ * bundle's external `require("plgg")` / `require("node:*")`
15
+ * must resolve against the target package's own
16
+ * node_modules (not the bundler's), so the require is
17
+ * rooted there. Upstream dists exist in build order, so
18
+ * the externals resolve.
19
+ *
20
+ * Isolated in `src/vendors/` because executing generated
21
+ * code is an effectful boundary, not domain logic.
22
+ */
23
+ export const readExportNames = (cjsCode, resolveBase) => {
24
+ try {
25
+ return keysOf(evalCjs(cjsCode, resolveBase));
26
+ }
27
+ catch (cause) {
28
+ throw new Error(`EvalError: failed to read export surface: ${cause instanceof Error
29
+ ? cause.message
30
+ : String(cause)}`);
31
+ }
32
+ };
33
+ /**
34
+ * Evaluate CJS source in a fresh context with a `require`
35
+ * rooted at the target package, an empty
36
+ * `module`/`exports`, and `console`, returning the
37
+ * populated `module.exports`.
38
+ */
39
+ const evalCjs = (code, resolveBase) => {
40
+ const moduleObj = {
41
+ exports: {},
42
+ };
43
+ const context = vm.createContext({
44
+ module: moduleObj,
45
+ exports: moduleObj.exports,
46
+ require: createRequire(pathToFileURL(join(resolveBase, "package.json"))),
47
+ console,
48
+ });
49
+ vm.runInContext(code, context);
50
+ return moduleObj.exports;
51
+ };
52
+ /**
53
+ * Enumerable own keys of the exports object, dropping
54
+ * the `__esModule` interop marker, sorted for a stable
55
+ * named-export list.
56
+ */
57
+ const keysOf = (exportsObj) => Object.keys(exportsObj)
58
+ .filter((k) => k !== "__esModule")
59
+ .sort();
60
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/vendors/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,OAAe,EACf,WAAmB,EACI,EAAE;IACzB,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,6CACE,KAAK,YAAY,KAAK;YACpB,CAAC,CAAC,KAAK,CAAC,OAAO;YACf,CAAC,CAAC,MAAM,CAAC,KAAK,CAClB,EAAE,CACH,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,OAAO,GAAG,CACd,IAAY,EACZ,WAAmB,EACX,EAAE;IACV,MAAM,SAAS,GAAwB;QACrC,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC;QAC/B,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,OAAO,EAAE,aAAa,CACpB,aAAa,CACX,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAClC,CACF;QACD,OAAO;KACR,CAAC,CAAC;IACH,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,SAAS,CAAC,OAAO,CAAC;AAC3B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,GAAG,CACb,UAAkB,EACK,EAAE,CACzB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;KACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC;KACjC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=runner.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.spec.d.ts","sourceRoot":"","sources":["../../src/vendors/runner.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { test, check, all, toBe, } from "plgg-test";
2
+ import { join } from "node:path";
3
+ import { readExportNames } from "plgg-bundle/vendors/runner";
4
+ // Root createRequire at plgg-bundle's own package so a
5
+ // bundle's external require resolves against real
6
+ // node_modules / node builtins (gap #2: externals-aware
7
+ // export-surface discovery).
8
+ const resolveBase = join(import.meta.dirname, "..", "..");
9
+ test("readExportNames reads a self-contained CJS bundle's keys", () => check(readExportNames("exports.a = 1; exports.b = 2;", resolveBase).join(","), toBe("a,b")));
10
+ test("readExportNames resolves an EXTERNAL require during discovery (gap #2)", () =>
11
+ // The bundle keeps `require("node:path")` as an
12
+ // external; discovery must run it via host require
13
+ // (rooted at the target package) without throwing,
14
+ // and still enumerate the entry's own exports.
15
+ all([
16
+ check(readExportNames('const p = require("node:path"); exports.sep = p.sep; exports.x = 1;', resolveBase).join(","), toBe("sep,x")),
17
+ // __esModule is filtered out of the surface.
18
+ check(readExportNames('Object.defineProperty(exports, "__esModule", { value: true }); exports.only = 1;', resolveBase).join(","), toBe("only")),
19
+ ]));
20
+ //# sourceMappingURL=runner.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.spec.js","sourceRoot":"","sources":["../../src/vendors/runner.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,GAAG,EACH,IAAI,GACL,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,uDAAuD;AACvD,kDAAkD;AAClD,wDAAwD;AACxD,6BAA6B;AAC7B,MAAM,WAAW,GAAG,IAAI,CACtB,MAAM,CAAC,IAAI,CAAC,OAAO,EACnB,IAAI,EACJ,IAAI,CACL,CAAC;AAEF,IAAI,CAAC,0DAA0D,EAAE,GAAG,EAAE,CACpE,KAAK,CACH,eAAe,CACb,+BAA+B,EAC/B,WAAW,CACZ,CAAC,IAAI,CAAC,GAAG,CAAC,EACX,IAAI,CAAC,KAAK,CAAC,CACZ,CAAC,CAAC;AAEL,IAAI,CAAC,wEAAwE,EAAE,GAAG,EAAE;AAClF,gDAAgD;AAChD,mDAAmD;AACnD,mDAAmD;AACnD,+CAA+C;AAC/C,GAAG,CAAC;IACF,KAAK,CACH,eAAe,CACb,qEAAqE,EACrE,WAAW,CACZ,CAAC,IAAI,CAAC,GAAG,CAAC,EACX,IAAI,CAAC,OAAO,CAAC,CACd;IACD,6CAA6C;IAC7C,KAAK,CACH,eAAe,CACb,kFAAkF,EAClF,WAAW,CACZ,CAAC,IAAI,CAAC,GAAG,CAAC,EACX,IAAI,CAAC,MAAM,CAAC,CACb;CACF,CAAC,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Anti-corruption layer over the TypeScript compiler's
3
+ * single-file transpile. Translation + delegation only:
4
+ * TS source in, plain CommonJS JavaScript out; a thrown
5
+ * compiler error is re-thrown with file context. No
6
+ * bundling logic lives here — the graph walk and emit
7
+ * are the in-house domain.
8
+ *
9
+ * CommonJS is the target because the in-house
10
+ * module-registry runtime (domain/usecase/emitBundle)
11
+ * wraps each module body as `(module, exports, require)
12
+ * => {...}`; TS lowers `export`/`import`/`export *` to
13
+ * the `exports.x = ` / `require(...)` forms the runtime
14
+ * rewrites and links. `removeComments` is the free size
15
+ * trim that stands in for a (rejected) minifier
16
+ * dependency.
17
+ */
18
+ export declare const transpileToCjs: (file: string, source: string) => string;
19
+ //# sourceMappingURL=transpiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transpiler.d.ts","sourceRoot":"","sources":["../../src/vendors/transpiler.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EACZ,QAAQ,MAAM,KACb,MAkBF,CAAC"}
@@ -0,0 +1,42 @@
1
+ import ts from "typescript";
2
+ /**
3
+ * Anti-corruption layer over the TypeScript compiler's
4
+ * single-file transpile. Translation + delegation only:
5
+ * TS source in, plain CommonJS JavaScript out; a thrown
6
+ * compiler error is re-thrown with file context. No
7
+ * bundling logic lives here — the graph walk and emit
8
+ * are the in-house domain.
9
+ *
10
+ * CommonJS is the target because the in-house
11
+ * module-registry runtime (domain/usecase/emitBundle)
12
+ * wraps each module body as `(module, exports, require)
13
+ * => {...}`; TS lowers `export`/`import`/`export *` to
14
+ * the `exports.x = ` / `require(...)` forms the runtime
15
+ * rewrites and links. `removeComments` is the free size
16
+ * trim that stands in for a (rejected) minifier
17
+ * dependency.
18
+ */
19
+ export const transpileToCjs = (file, source) => {
20
+ try {
21
+ return ts.transpileModule(source, {
22
+ fileName: file,
23
+ compilerOptions: {
24
+ module: ts.ModuleKind.CommonJS,
25
+ target: ts.ScriptTarget.ES2021,
26
+ esModuleInterop: false,
27
+ isolatedModules: true,
28
+ verbatimModuleSyntax: false,
29
+ removeComments: true,
30
+ },
31
+ }).outputText;
32
+ }
33
+ catch (cause) {
34
+ throw new Error(`TranspileError: ${file}: ${messageOf(cause)}`);
35
+ }
36
+ };
37
+ /**
38
+ * The message of an unknown thrown value, without
39
+ * assuming it is an `Error`.
40
+ */
41
+ const messageOf = (e) => e instanceof Error ? e.message : String(e);
42
+ //# sourceMappingURL=transpiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transpiler.js","sourceRoot":"","sources":["../../src/vendors/transpiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAY,EACZ,MAAc,EACN,EAAE;IACV,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE;YAChC,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE;gBACf,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ;gBAC9B,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;gBAC9B,eAAe,EAAE,KAAK;gBACtB,eAAe,EAAE,IAAI;gBACrB,oBAAoB,EAAE,KAAK;gBAC3B,cAAc,EAAE,IAAI;aACrB;SACF,CAAC,CAAC,UAAU,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,mBAAmB,IAAI,KAAK,SAAS,CAAC,KAAK,CAAC,EAAE,CAC/C,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,SAAS,GAAG,CAAC,CAAU,EAAU,EAAE,CACvC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "plgg-bundle",
3
+ "version": "0.0.1",
4
+ "description": "In-house minimal library bundler for the plgg monorepo (ESM+CJS dual output, per-file .d.ts tree), zero new dependencies — reuses the project's own TypeScript, no native binding.",
5
+ "type": "module",
6
+ "files": [
7
+ "dist",
8
+ "src",
9
+ "bin"
10
+ ],
11
+ "bin": {
12
+ "plgg-bundle": "bin/plgg-bundle.mjs"
13
+ },
14
+ "main": "dist/index.js",
15
+ "types": "dist/index.d.ts",
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "tsc": "tsc --noEmit",
19
+ "test": "tsc --noEmit && plgg-test src",
20
+ "coverage": "tsc --noEmit && plgg-test src --coverage"
21
+ },
22
+ "author": "qmu",
23
+ "license": "MIT",
24
+ "dependencies": {
25
+ "typescript": "^6.0.3"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^25.6.0",
29
+ "plgg-test": "^0.0.2"
30
+ }
31
+ }
@@ -0,0 +1,235 @@
1
+ import {
2
+ test,
3
+ check,
4
+ all,
5
+ toBe,
6
+ } from "plgg-test";
7
+ import { spawn } from "node:child_process";
8
+ import type { ChildProcess } from "node:child_process";
9
+ import {
10
+ mkdtempSync,
11
+ writeFileSync,
12
+ } from "node:fs";
13
+ import { tmpdir } from "node:os";
14
+ import { join } from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+
17
+ // The end-to-end hot-reload PoC (ticket 041500). It runs
18
+ // the REAL toolchain — `node bin/plgg-bundle.mjs dev` on a
19
+ // throwaway fixture app — then edits a *deep* source module
20
+ // mid-run and proves the served output changes with NO
21
+ // process restart, and that the SSE reload channel opens.
22
+ // This is the fidelity oracle for the whole chain: bin +
23
+ // loader-hook version propagation + module-runner re-import
24
+ // + node:http serve + fs.watch + SSE.
25
+
26
+ /** This spec's dir → the package's bin/plgg-bundle.mjs. */
27
+ const BIN = join(
28
+ fileURLToPath(import.meta.url),
29
+ "..",
30
+ "..",
31
+ "..",
32
+ "..",
33
+ "bin",
34
+ "plgg-bundle.mjs",
35
+ );
36
+
37
+ /** A dev entry that renders a deep child's message as HTML. */
38
+ const ENTRY_SRC = [
39
+ `import { message } from "./child.ts";`,
40
+ `export default () =>`,
41
+ ` (_request) =>`,
42
+ ` Promise.resolve(`,
43
+ ` new Response(`,
44
+ ' `<html><body>${message()}</body></html>`,',
45
+ ` { headers: { "content-type": "text/html" } },`,
46
+ ` ),`,
47
+ ` );`,
48
+ ].join("\n");
49
+
50
+ /** The deep child module the edit targets. */
51
+ const childSrc = (word: string): string =>
52
+ `export const message = () => "${word}";\n`;
53
+
54
+ /** A minimal dev-only bundle config for the fixture app. */
55
+ const configSrc = (root: string): string =>
56
+ `export default ${JSON.stringify(
57
+ {
58
+ root,
59
+ rootDir: ".",
60
+ outDir: "dist",
61
+ fileNamePattern: "[name].[format].js",
62
+ entries: [],
63
+ formats: ["es"],
64
+ alias: { prefix: "fixture", srcRoot: "." },
65
+ dev: {
66
+ entry: "entry.ts",
67
+ // Port 0 → ephemeral; the real port is read from
68
+ // the server's ready line.
69
+ port: 0,
70
+ watch: [root],
71
+ allowedHosts: [],
72
+ },
73
+ },
74
+ null,
75
+ 2,
76
+ )};\n`;
77
+
78
+ /** Lay down the fixture app in a fresh temp dir. */
79
+ const writeFixture = (): string => {
80
+ const dir = mkdtempSync(
81
+ join(tmpdir(), "plgg-dev-poc-"),
82
+ );
83
+ writeFileSync(
84
+ join(dir, "child.ts"),
85
+ childSrc("ALPHA"),
86
+ );
87
+ writeFileSync(
88
+ join(dir, "entry.ts"),
89
+ ENTRY_SRC,
90
+ );
91
+ writeFileSync(
92
+ join(dir, "bundle.config.ts"),
93
+ configSrc(dir),
94
+ );
95
+ return dir;
96
+ };
97
+
98
+ /** Sleep (test-only pacing for the watch/reload loop). */
99
+ const wait = (ms: number): Promise<void> =>
100
+ new Promise((r) => setTimeout(r, ms));
101
+
102
+ /**
103
+ * Spawn `plgg-bundle dev` on the fixture and resolve the
104
+ * served URL once the ready line is printed.
105
+ */
106
+ const startDev = (
107
+ dir: string,
108
+ ): Promise<{
109
+ proc: ChildProcess;
110
+ url: string;
111
+ }> =>
112
+ new Promise((resolve, reject) => {
113
+ const proc = spawn(
114
+ process.execPath,
115
+ [BIN, "dev", "bundle.config.ts"],
116
+ { cwd: dir },
117
+ );
118
+ let out = "";
119
+ const onData = (chunk: Buffer): void => {
120
+ out += chunk.toString();
121
+ const m = out.match(
122
+ /http:\/\/localhost:\d+\//,
123
+ );
124
+ if (m) {
125
+ proc.stdout?.off("data", onData);
126
+ resolve({ proc, url: m[0] });
127
+ }
128
+ };
129
+ proc.stdout?.on("data", onData);
130
+ proc.on("error", reject);
131
+ setTimeout(
132
+ () =>
133
+ reject(
134
+ new Error(
135
+ `dev server did not start; output:\n${out}`,
136
+ ),
137
+ ),
138
+ 8000,
139
+ );
140
+ });
141
+
142
+ /** Fetch a URL's body text. */
143
+ const body = (url: string): Promise<string> =>
144
+ fetch(url).then((r) => r.text());
145
+
146
+ /**
147
+ * Poll `body(url)` until it contains `needle`, or throw on
148
+ * timeout. Proves the served output actually changed after
149
+ * the edit (not a fixed sleep guess).
150
+ */
151
+ const pollFor = async (
152
+ url: string,
153
+ needle: string,
154
+ ): Promise<boolean> => {
155
+ const deadline = 6000;
156
+ const step = 60;
157
+ for (let waited = 0; waited < deadline; ) {
158
+ if ((await body(url)).includes(needle)) {
159
+ return true;
160
+ }
161
+ await wait(step);
162
+ waited += step;
163
+ }
164
+ return false;
165
+ };
166
+
167
+ test("plgg-bundle dev hot-reloads a deep source edit with no restart", async () => {
168
+ const dir = writeFixture();
169
+ const { proc, url } = await startDev(dir);
170
+ try {
171
+ const first = await body(url);
172
+ // Rewrite the DEEP child (not the entry) mid-run.
173
+ writeFileSync(
174
+ join(dir, "child.ts"),
175
+ childSrc("BETA"),
176
+ );
177
+ const reloaded = await pollFor(url, "BETA");
178
+ const stillAlive = proc.exitCode === null;
179
+ return all([
180
+ // Initial render came from the child module.
181
+ check(
182
+ first.includes("ALPHA"),
183
+ toBe(true),
184
+ ),
185
+ // The dev server injected its live-reload client.
186
+ check(
187
+ first.includes("EventSource"),
188
+ toBe(true),
189
+ ),
190
+ // The deep edit re-evaluated and is now served …
191
+ check(reloaded, toBe(true)),
192
+ // … by the SAME process (no restart).
193
+ check(stillAlive, toBe(true)),
194
+ ]);
195
+ } finally {
196
+ proc.kill();
197
+ }
198
+ });
199
+
200
+ test("plgg-bundle dev opens an SSE reload channel", async () => {
201
+ const dir = writeFixture();
202
+ const { proc, url } = await startDev(dir);
203
+ try {
204
+ const res = await fetch(
205
+ `${url}__plgg_reload`,
206
+ );
207
+ const contentType =
208
+ res.headers.get("content-type") ?? "";
209
+ // Read the opener frame, then release the stream.
210
+ const reader = res.body?.getReader();
211
+ const firstChunk = reader
212
+ ? await reader.read()
213
+ : { value: undefined };
214
+ await reader?.cancel();
215
+ const text = firstChunk.value
216
+ ? new TextDecoder().decode(
217
+ firstChunk.value,
218
+ )
219
+ : "";
220
+ return all([
221
+ check(
222
+ contentType.includes(
223
+ "text/event-stream",
224
+ ),
225
+ toBe(true),
226
+ ),
227
+ check(
228
+ text.includes("connected"),
229
+ toBe(true),
230
+ ),
231
+ ]);
232
+ } finally {
233
+ proc.kill();
234
+ }
235
+ });
@@ -0,0 +1,31 @@
1
+ // Plain-TS build tool: plgg-bundle is a foundation
2
+ // bundler and must not depend on the libraries it builds
3
+ // (plgg / plgg-server). So the dev server speaks the
4
+ // Web-standard request/response contract directly rather
5
+ // than plgg-server's branded `Fetch`. See the package
6
+ // README and the ticket's hard constraints.
7
+
8
+ /**
9
+ * The Web-standard request handler an app hands the dev
10
+ * server: `Request => Promise<Response>`. This is the same
11
+ * shape plgg-server's `toFetch` produces, reproduced here
12
+ * as a bare structural type so the toolchain never imports
13
+ * a plgg package.
14
+ */
15
+ export type Fetch = (
16
+ request: Request,
17
+ ) => Promise<Response>;
18
+
19
+ /**
20
+ * The app⇄dev-server contract. An app's **dev entry**
21
+ * module default-exports a factory that builds its
22
+ * {@link Fetch}. The dev server calls it once on start and
23
+ * again after every hot-reload — a cache-busted re-import
24
+ * of the entry re-runs the factory over freshly
25
+ * re-evaluated source, which is how a code edit takes
26
+ * effect with no process restart. The factory may be
27
+ * async (config load, route discovery).
28
+ */
29
+ export type FetchFactory = () =>
30
+ | Fetch
31
+ | Promise<Fetch>;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The dev server's view of the app's local module graph:
3
+ * a map from each source file (absolute path) to the
4
+ * absolute paths of the local files it imports. Only
5
+ * workspace-local edges are recorded — `node:*` and
6
+ * `node_modules` specifiers are not part of the watched
7
+ * graph (they do not change during a dev session).
8
+ *
9
+ * Built fresh from disk on each change by the node adapter
10
+ * (scan → resolve), then consumed by the pure
11
+ * {@link transitiveImporters} / reload-decision logic. The
12
+ * graph is what lets the server ignore a save to a file
13
+ * the app does not import, and report exactly which
14
+ * modules a change invalidates.
15
+ */
16
+ export type ModuleGraph = ReadonlyMap<
17
+ string,
18
+ ReadonlyArray<string>
19
+ >;
20
+
21
+ /**
22
+ * One resolved import edge: `from` imports `to` (both
23
+ * absolute paths). The adapter produces these by scanning
24
+ * a file's import specifiers and resolving the local ones;
25
+ * {@link buildGraph} folds them into a {@link ModuleGraph}.
26
+ */
27
+ export type Edge = Readonly<{
28
+ from: string;
29
+ to: string;
30
+ }>;
@@ -0,0 +1,35 @@
1
+ // The dev-only live-reload wire protocol: the SSE route
2
+ // the injected client script connects to, and the frames
3
+ // pushed over it. Kept as pure constants/string builders
4
+ // (no `node:*`, no sockets) so the transport shape is
5
+ // unit-testable and the node adapter only owns the socket
6
+ // registry. Mirrors plggpress's hand-rolled SSE reload,
7
+ // reproduced here plgg-free in the toolchain.
8
+
9
+ /** The dev-only Server-Sent-Events live-reload route. */
10
+ export const RELOAD_PATH = "/__plgg_reload";
11
+
12
+ /**
13
+ * The SSE opener frame. A comment line keeps the stream
14
+ * from idling before the first reload is pushed.
15
+ */
16
+ export const SSE_PRELUDE = ": connected\n\n";
17
+
18
+ /**
19
+ * A default-event SSE frame the injected client's
20
+ * `onmessage` handler reacts to by reloading the page.
21
+ */
22
+ export const RELOAD_FRAME = "data: reload\n\n";
23
+
24
+ /**
25
+ * The dev-only live-reload client: a constant `<script>`
26
+ * opening an `EventSource` to {@link RELOAD_PATH} that
27
+ * reloads the page on every pushed frame. This literal is
28
+ * string-appended onto rendered HTML output ONLY (see
29
+ * `decorateDevHtml`) — it never enters a typed render
30
+ * tree, so a production build can never emit it.
31
+ */
32
+ export const LIVE_RELOAD_SCRIPT =
33
+ "<script>new EventSource('" +
34
+ RELOAD_PATH +
35
+ "').onmessage=()=>location.reload();</script>";