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,177 @@
1
+ import { writeFileSync, mkdirSync, rmSync, renameSync, existsSync, } from "node:fs";
2
+ import { join, dirname } from "node:path";
3
+ import { applyFileName, } from "plgg-bundle/domain/model/BundleConfig";
4
+ import { collectModules, } from "plgg-bundle/domain/usecase/collectModules";
5
+ import { emitCjsBundle, emitEsmBundle, } from "plgg-bundle/domain/usecase/emitBundle";
6
+ import { emitDts } from "plgg-bundle/domain/usecase/emitDts";
7
+ import { deriveExternal } from "plgg-bundle/domain/usecase/deriveExternal";
8
+ import { readExportNames } from "plgg-bundle/vendors/runner";
9
+ import { discoverWorkspace } from "plgg-bundle/domain/usecase/discoverWorkspace";
10
+ import { resolveWorkspaceSpecifier } from "plgg-bundle/domain/usecase/resolveWorkspaceSpecifier";
11
+ /**
12
+ * Build one package's `dist` from its
13
+ * {@link BundleConfig}. Dispatches on the config
14
+ * `target`: a `"library"` (dual `es`/`cjs` per entry +
15
+ * per-file `.d.ts`, deps external) or the `"app"` leaf (a
16
+ * single self-contained `es` bundle, siblings inlined, no
17
+ * `.d.ts`). Both build into a private staging dir and
18
+ * publish with one atomic swap. Returns the relative
19
+ * paths written. Throws on the first failure (caught at
20
+ * the bin boundary). Fully synchronous.
21
+ */
22
+ export const build = (config) => {
23
+ const outDir = join(config.root, config.outDir);
24
+ // Build into a PRIVATE staging dir, then swap it into
25
+ // place as the final step (see swapIntoPlace). The live
26
+ // `dist` must never be observed half-built: it is read
27
+ // concurrently — by a downstream package's `tsc`/runner
28
+ // resolving this package as a dependency, and by any
29
+ // overlapping build invocation. The old emptyDir-on-live
30
+ // pattern left a multi-second window where `dist` was
31
+ // missing or partial; a reader hitting it resolved the
32
+ // dependency to its `.js` (TS7016 implicit-any), to a
33
+ // not-yet-complete barrel (TS2305 "no exported member"),
34
+ // or found no `index.cjs.js` at all — the
35
+ // non-deterministic dts-emit flake. Staging shrinks that
36
+ // window from the whole build to a single rename.
37
+ const stageDir = `${outDir}.stage`;
38
+ emptyDir(stageDir);
39
+ const written = config.target === "app"
40
+ ? buildApp(config, stageDir)
41
+ : buildLibrary(config, stageDir);
42
+ swapIntoPlace(stageDir, outDir);
43
+ return written;
44
+ };
45
+ /**
46
+ * Library build: per entry, emit the dual `es`/`cjs`
47
+ * bundle (CJS first so its runtime keys give ESM its
48
+ * export surface), then the per-file `.d.ts` tree once.
49
+ * Deps are external (ruling B), derived from the
50
+ * package's declared dependency graph (+ `node:*`) so a
51
+ * bundle stays faithful to its manifest and an undeclared
52
+ * import fails loudly.
53
+ */
54
+ const buildLibrary = (config, stageDir) => {
55
+ const external = deriveExternal(config.root);
56
+ const written = [];
57
+ for (const entry of config.entries) {
58
+ const graph = collectModules({
59
+ entryFile: join(config.root, config.rootDir, entry.input),
60
+ root: config.root,
61
+ aliasPrefix: config.alias.prefix,
62
+ aliasSrcRoot: join(config.root, config.alias.srcRoot),
63
+ external,
64
+ });
65
+ written.push(...buildEntry(config, entry, graph, stageDir));
66
+ }
67
+ emitDts({
68
+ root: config.root,
69
+ rootDir: config.rootDir,
70
+ outDir: stageDir,
71
+ aliasPrefix: config.alias.prefix,
72
+ });
73
+ return written;
74
+ };
75
+ /**
76
+ * App build: a single self-contained `es` bundle per
77
+ * entry with every workspace sibling INLINED from source
78
+ * (the mirror of the library externalization — a browser
79
+ * cannot resolve a bare `import "plgg"`). Only `node:*`
80
+ * stays external. No CJS, no export-surface discovery
81
+ * (an app entry has side effects and no exports, and the
82
+ * vm sandbox has no DOM to run it), and no `.d.ts`
83
+ * (nothing consumes the app).
84
+ */
85
+ const buildApp = (config, stageDir) => {
86
+ const packages = discoverWorkspace(config.root);
87
+ const written = [];
88
+ for (const entry of config.entries) {
89
+ const graph = collectModules({
90
+ entryFile: join(config.root, config.rootDir, entry.input),
91
+ root: config.root,
92
+ aliasPrefix: config.alias.prefix,
93
+ aliasSrcRoot: join(config.root, config.alias.srcRoot),
94
+ external: NODE_EXTERNAL,
95
+ resolve: (specifier, fromFile) => resolveWorkspaceSpecifier({
96
+ specifier,
97
+ fromFile,
98
+ packages,
99
+ }),
100
+ });
101
+ const rel = applyFileName(config.fileNamePattern, entry.name, "es");
102
+ writeOut(join(stageDir, rel), emitEsmBundle(graph, []));
103
+ written.push(rel);
104
+ }
105
+ return written;
106
+ };
107
+ /**
108
+ * The app's only external: Node built-ins. Everything
109
+ * else (plgg + siblings) is inlined.
110
+ */
111
+ const NODE_EXTERNAL = /^node:/;
112
+ /**
113
+ * Replace `outDir` with the freshly-built `stageDir` in a
114
+ * single rename, so a concurrent reader sees only a
115
+ * complete `dist` (old or new) — never a torn one. The
116
+ * destructive window is one `rename`, not the whole build.
117
+ */
118
+ const swapIntoPlace = (stageDir, outDir) => {
119
+ const backup = `${outDir}.old`;
120
+ rmSync(backup, {
121
+ recursive: true,
122
+ force: true,
123
+ });
124
+ if (existsSync(outDir)) {
125
+ renameSync(outDir, backup);
126
+ }
127
+ renameSync(stageDir, outDir);
128
+ rmSync(backup, {
129
+ recursive: true,
130
+ force: true,
131
+ });
132
+ };
133
+ /**
134
+ * Build every configured format for one entry, returning
135
+ * the relative paths written.
136
+ */
137
+ const buildEntry = (config, entry, graph, destDir) => {
138
+ const cjs = emitCjsBundle(graph);
139
+ // Discover the exact export surface by running the CJS
140
+ // bundle and reading its keys — ESM cannot declare
141
+ // exports dynamically. The bundle's external requires
142
+ // resolve against the target package's node_modules.
143
+ const esm = emitEsmBundle(graph, readExportNames(cjs, config.root));
144
+ const written = [];
145
+ for (const format of config.formats) {
146
+ const code = format === "es" ? esm : cjs;
147
+ const rel = applyFileName(config.fileNamePattern, entry.name, format);
148
+ writeOut(join(destDir, rel), code);
149
+ written.push(rel);
150
+ }
151
+ return written;
152
+ };
153
+ /**
154
+ * Empty (and recreate) the output directory. The
155
+ * recursive remove is the bundler's own build output —
156
+ * `force` tolerates a not-yet-existing dir.
157
+ */
158
+ const emptyDir = (dir) => {
159
+ rmSync(dir, { recursive: true, force: true });
160
+ mkdirSync(dir, { recursive: true });
161
+ };
162
+ /**
163
+ * Write a file, creating parent dirs; re-throws with
164
+ * context on failure.
165
+ */
166
+ const writeOut = (path, code) => {
167
+ try {
168
+ mkdirSync(dirname(path), { recursive: true });
169
+ writeFileSync(path, code, "utf8");
170
+ }
171
+ catch (cause) {
172
+ throw new Error(`IoError: cannot write ${path}: ${cause instanceof Error
173
+ ? cause.message
174
+ : String(cause)}`);
175
+ }
176
+ };
177
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/domain/usecase/build.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAGL,aAAa,GACd,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,cAAc,GAEf,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,aAAa,EACb,aAAa,GACd,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAC;AAEjG;;;;;;;;;;GAUG;AACH,M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,GAAG,aAAa,CACvB,MAAM,CAAC,eAAe,EACtB,KAAK,CAAC,IAAI,EACV,MAAM,CACP,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAQ,EAAE;IACrC,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAG,CACf,IAAY,EACZ,IAAY,EACN,EAAE;IACR,IAAI,CAAC;QACH,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,yBAAyB,IAAI,KAC3B,KAAK,YAAY,KAAK;YACpB,CAAC,CAAC,KAAK,CAAC,OAAO;YACf,CAAC,CAAC,MAAM,CAAC,KAAK,CAClB,EAAE,CACH,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { type External } from "plgg-bundle/domain/model/BundleConfig";
2
+ /**
3
+ * One bundled module: its stable id (path relative to
4
+ * the package root, the same string the runtime keys
5
+ * on), its transpiled-and-rewritten CJS body, and the
6
+ * external specifiers it still requires at runtime.
7
+ */
8
+ export type Module = Readonly<{
9
+ id: string;
10
+ code: string;
11
+ externals: ReadonlyArray<string>;
12
+ }>;
13
+ /**
14
+ * The module graph reachable from an entry — the set of
15
+ * reachable modules plus the entry's own id. Dependency
16
+ * order is not required: the registry runtime links
17
+ * lazily by id.
18
+ */
19
+ export type Graph = Readonly<{
20
+ entryId: string;
21
+ modules: ReadonlyArray<Module>;
22
+ }>;
23
+ /**
24
+ * Walk the import graph from `entryFile`, transpiling
25
+ * each `.ts` to CJS, resolving every `require(...)`
26
+ * specifier to either an intra-bundle module id (to
27
+ * inline) or an external (to keep as a runtime
28
+ * require), and rewriting the inlined `require("spec")`
29
+ * calls to `require("<id>")`. Pure in-house graph logic;
30
+ * only the per-file TS→JS step is vendored. Throws on an
31
+ * unresolvable import or a read failure.
32
+ */
33
+ export declare const collectModules: (args: {
34
+ entryFile: string;
35
+ root: string;
36
+ aliasPrefix: string;
37
+ aliasSrcRoot: string;
38
+ external: External;
39
+ /**
40
+ * App-mode override: resolve a specifier to a source
41
+ * file (inlining workspace siblings). When absent, the
42
+ * library default resolves only relative imports and
43
+ * the package's own self-alias.
44
+ */
45
+ resolve?: Resolve;
46
+ }) => Graph;
47
+ /**
48
+ * Resolve an import specifier (from `fromFile`) to an
49
+ * absolute source file, or `undefined` if it is not a
50
+ * bundled module (external / unresolvable).
51
+ */
52
+ export type Resolve = (specifier: string, fromFile: string) => string | undefined;
53
+ //# sourceMappingURL=collectModules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectModules.d.ts","sourceRoot":"","sources":["../../../src/domain/usecase/collectModules.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAKtE;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAClC,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAChC,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,KAAG,KAoBH,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,CACpB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,KACb,MAAM,GAAG,SAAS,CAAC"}
@@ -0,0 +1,118 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { relative } from "node:path";
3
+ import {} from "plgg-bundle/domain/model/BundleConfig";
4
+ import { resolveSpecifier } from "plgg-bundle/domain/usecase/resolveSpecifier";
5
+ import { isExternal } from "plgg-bundle/domain/usecase/isExternal";
6
+ import { transpileToCjs } from "plgg-bundle/vendors/transpiler";
7
+ /**
8
+ * Walk the import graph from `entryFile`, transpiling
9
+ * each `.ts` to CJS, resolving every `require(...)`
10
+ * specifier to either an intra-bundle module id (to
11
+ * inline) or an external (to keep as a runtime
12
+ * require), and rewriting the inlined `require("spec")`
13
+ * calls to `require("<id>")`. Pure in-house graph logic;
14
+ * only the per-file TS→JS step is vendored. Throws on an
15
+ * unresolvable import or a read failure.
16
+ */
17
+ export const collectModules = (args) => {
18
+ const ctx = {
19
+ root: args.root,
20
+ external: args.external,
21
+ resolve: args.resolve ??
22
+ ((specifier, fromFile) => resolveSpecifier({
23
+ specifier,
24
+ fromFile,
25
+ aliasPrefix: args.aliasPrefix,
26
+ aliasSrcRoot: args.aliasSrcRoot,
27
+ })),
28
+ };
29
+ const acc = new Map();
30
+ walk(ctx, args.entryFile, acc);
31
+ return {
32
+ entryId: idOf(args.root, args.entryFile),
33
+ modules: [...acc.values()],
34
+ };
35
+ };
36
+ /**
37
+ * Depth-first accumulation into a Map keyed by id, so a
38
+ * diamond import is transpiled once. Mutates `acc`.
39
+ */
40
+ const walk = (ctx, file, acc) => {
41
+ const id = idOf(ctx.root, file);
42
+ if (acc.has(id)) {
43
+ return;
44
+ }
45
+ const cjs = transpileToCjs(file, readSource(file));
46
+ const deps = linkModule(ctx, file, id, cjs, acc);
47
+ for (const depFile of deps) {
48
+ walk(ctx, depFile, acc);
49
+ }
50
+ };
51
+ /**
52
+ * Resolve and rewrite every `require(...)` in a
53
+ * transpiled module, register it in `acc`, and return
54
+ * the resolved file paths of its intra-bundle deps.
55
+ * Throws on an unresolvable (non-external) specifier.
56
+ */
57
+ const linkModule = (ctx, file, id, cjs, acc) => {
58
+ const specifiers = requireSpecifiers(cjs);
59
+ const externals = [];
60
+ const deps = [];
61
+ let rewritten = cjs;
62
+ for (const spec of specifiers) {
63
+ if (isExternal(ctx.external, spec)) {
64
+ externals.push(spec);
65
+ continue;
66
+ }
67
+ const resolved = ctx.resolve(spec, file);
68
+ if (resolved === undefined) {
69
+ throw new Error(`ResolveError: cannot resolve "${spec}" from ${id}`);
70
+ }
71
+ deps.push(resolved);
72
+ rewritten = replaceRequire(rewritten, spec, idOf(ctx.root, resolved));
73
+ }
74
+ acc.set(id, {
75
+ id,
76
+ code: rewritten,
77
+ externals,
78
+ });
79
+ return deps;
80
+ };
81
+ /**
82
+ * Read a source file, re-throwing with context.
83
+ */
84
+ const readSource = (file) => {
85
+ try {
86
+ return readFileSync(file, "utf8");
87
+ }
88
+ catch (cause) {
89
+ throw new Error(`IoError: cannot read ${file}: ${cause instanceof Error
90
+ ? cause.message
91
+ : String(cause)}`);
92
+ }
93
+ };
94
+ /**
95
+ * A module's stable id: its path relative to the
96
+ * package root, POSIX-normalized. The runtime keys on
97
+ * exactly this string.
98
+ */
99
+ const idOf = (root, file) => relative(root, file).split("\\").join("/");
100
+ /**
101
+ * Extract the literal string specifiers of all
102
+ * top-level `require("...")` / `require('...')` calls
103
+ * a transpiled CJS module makes.
104
+ */
105
+ const requireSpecifiers = (cjs) => [
106
+ ...cjs.matchAll(/require\(\s*["']([^"']+)["']\s*\)/g),
107
+ ].flatMap((m) => m[1] === undefined ? [] : [m[1]]);
108
+ /**
109
+ * Rewrite every `require("spec")` occurrence to
110
+ * `require("id")`. Operates on the exact specifier
111
+ * string so distinct specifiers do not interfere.
112
+ */
113
+ const replaceRequire = (cjs, spec, id) => cjs
114
+ .split(`require("${spec}")`)
115
+ .join(`require("${id}")`)
116
+ .split(`require('${spec}')`)
117
+ .join(`require("${id}")`);
118
+ //# sourceMappingURL=collectModules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectModules.js","sourceRoot":"","sources":["../../../src/domain/usecase/collectModules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAiB,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAyBhE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAa9B,EAAS,EAAE;IACV,MAAM,GAAG,GAAQ;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,OAAO,EACL,IAAI,CAAC,OAAO;YACZ,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,CACvB,gBAAgB,CAAC;gBACf,SAAS;gBACT,QAAQ;gBACR,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,YAAY,EAAE,IAAI,CA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;AACH,MAAM,iBAAiB,GAAG,CACxB,GAAW,EACY,EAAE,CACzB;IACE,GAAG,GAAG,CAAC,QAAQ,CACb,oCAAoC,CACrC;CACF,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CACd,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACjC,CAAC;AAEJ;;;;GAIG;AACH,MAAM,cAAc,GAAG,CACrB,GAAW,EACX,IAAY,EACZ,EAAU,EACF,EAAE,CACV,GAAG;KACA,KAAK,CAAC,YAAY,IAAI,IAAI,CAAC;KAC3B,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;KACxB,KAAK,CAAC,YAAY,IAAI,IAAI,CAAC;KAC3B,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { type External } from "plgg-bundle/domain/model/BundleConfig";
2
+ /**
3
+ * Derive a package's externals from its `package.json`
4
+ * (the declared dependency graph) plus Node builtins —
5
+ * the ruling-B rule, so externals cannot drift from what
6
+ * the manifest says the package depends on. Anything a
7
+ * module imports that is neither the package's own
8
+ * source (self-alias / relative) nor a declared
9
+ * dependency nor `node:*` is an *undeclared* dependency
10
+ * and the graph walk fails loudly rather than silently
11
+ * inlining or externalizing it.
12
+ *
13
+ * Declared = keys of `dependencies` + `peerDependencies`
14
+ * + `optionalDependencies`. A specifier is external when
15
+ * it is a declared dep exactly (`plgg-view`) OR a PUBLIC
16
+ * SUBPATH export of one (`plgg-view/style`,
17
+ * `plgg-server/ssg`) — the consumer resolves the subpath
18
+ * at runtime via the dep's own `exports` map, so a library
19
+ * bundle must never inline it. `node:*` is matched by
20
+ * prefix. An undeclared specifier (neither a dep nor a
21
+ * dep subpath nor `node:*`) still fails the graph walk
22
+ * loudly.
23
+ */
24
+ export declare const deriveExternal: (root: string) => External;
25
+ //# sourceMappingURL=deriveExternal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deriveExternal.d.ts","sourceRoot":"","sources":["../../../src/domain/usecase/deriveExternal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,KACX,QAQF,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import {} from "plgg-bundle/domain/model/BundleConfig";
4
+ /**
5
+ * Derive a package's externals from its `package.json`
6
+ * (the declared dependency graph) plus Node builtins —
7
+ * the ruling-B rule, so externals cannot drift from what
8
+ * the manifest says the package depends on. Anything a
9
+ * module imports that is neither the package's own
10
+ * source (self-alias / relative) nor a declared
11
+ * dependency nor `node:*` is an *undeclared* dependency
12
+ * and the graph walk fails loudly rather than silently
13
+ * inlining or externalizing it.
14
+ *
15
+ * Declared = keys of `dependencies` + `peerDependencies`
16
+ * + `optionalDependencies`. A specifier is external when
17
+ * it is a declared dep exactly (`plgg-view`) OR a PUBLIC
18
+ * SUBPATH export of one (`plgg-view/style`,
19
+ * `plgg-server/ssg`) — the consumer resolves the subpath
20
+ * at runtime via the dep's own `exports` map, so a library
21
+ * bundle must never inline it. `node:*` is matched by
22
+ * prefix. An undeclared specifier (neither a dep nor a
23
+ * dep subpath nor `node:*`) still fails the graph walk
24
+ * loudly.
25
+ */
26
+ export const deriveExternal = (root) => {
27
+ const declared = declaredDeps(root);
28
+ return (specifier) => declared.has(specifier) ||
29
+ [...declared].some((dep) => specifier.startsWith(`${dep}/`)) ||
30
+ specifier.startsWith("node:");
31
+ };
32
+ /**
33
+ * The set of declared dependency names from a package's
34
+ * `package.json`. Throws (re-thrown with context) if the
35
+ * manifest is missing or unparseable.
36
+ */
37
+ const declaredDeps = (root) => {
38
+ const path = join(root, "package.json");
39
+ const parsed = parse(path, read(path));
40
+ return new Set([
41
+ ...keysOf(parsed, "dependencies"),
42
+ ...keysOf(parsed, "peerDependencies"),
43
+ ...keysOf(parsed, "optionalDependencies"),
44
+ ]);
45
+ };
46
+ const read = (path) => {
47
+ try {
48
+ return readFileSync(path, "utf8");
49
+ }
50
+ catch (cause) {
51
+ throw new Error(`IoError: cannot read ${path}: ${messageOf(cause)}`);
52
+ }
53
+ };
54
+ const parse = (path, text) => {
55
+ try {
56
+ return JSON.parse(text);
57
+ }
58
+ catch (cause) {
59
+ throw new Error(`ConfigError: ${path} is not valid JSON: ${messageOf(cause)}`);
60
+ }
61
+ };
62
+ /**
63
+ * The keys of one dependency map on a parsed
64
+ * package.json, narrowing at the `unknown` boundary.
65
+ */
66
+ const keysOf = (pkg, field) => {
67
+ if (!isRecord(pkg)) {
68
+ return [];
69
+ }
70
+ const map = pkg[field];
71
+ return isRecord(map) ? Object.keys(map) : [];
72
+ };
73
+ /**
74
+ * Whether a value is a non-null object (records the
75
+ * narrowing for property reads).
76
+ */
77
+ const isRecord = (v) => typeof v === "object" && v !== null;
78
+ const messageOf = (e) => e instanceof Error ? e.message : String(e);
79
+ //# sourceMappingURL=deriveExternal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deriveExternal.js","sourceRoot":"","sources":["../../../src/domain/usecase/deriveExternal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAiB,MAAM,uCAAuC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAY,EACF,EAAE;IACZ,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,CAAC,SAAiB,EAAW,EAAE,CACpC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC;QACvB,CAAC,GAAG,QAAQ,CAAC,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AAE;IACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/C,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAG,CACf,CAAU,EACoB,EAAE,CAChC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC;AAEtC,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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=deriveExternal.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deriveExternal.spec.d.ts","sourceRoot":"","sources":["../../../src/domain/usecase/deriveExternal.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,56 @@
1
+ import { test, check, all, toBe, } from "plgg-test";
2
+ import { join } from "node:path";
3
+ import { mkdtempSync, writeFileSync, } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { deriveExternal } from "plgg-bundle/domain/usecase/deriveExternal";
6
+ import { isExternal } from "plgg-bundle/domain/usecase/isExternal";
7
+ /** True when `deriveExternal(root)` throws an Error. */
8
+ const rejects = (root) => {
9
+ try {
10
+ deriveExternal(root);
11
+ return false;
12
+ }
13
+ catch (e) {
14
+ return e instanceof Error;
15
+ }
16
+ };
17
+ /** A temp dir carrying a specific package.json body. */
18
+ const withManifest = (body) => {
19
+ const dir = mkdtempSync(join(tmpdir(), "plgg-derive-"));
20
+ writeFileSync(join(dir, "package.json"), body);
21
+ return dir;
22
+ };
23
+ // plgg-bundle's own root: its package.json declares
24
+ // `typescript` as the sole dependency.
25
+ const root = join(import.meta.dirname, "..", "..", "..");
26
+ const external = deriveExternal(root);
27
+ test("deriveExternal externalizes declared deps and node builtins", () => all([
28
+ check(isExternal(external, "typescript"), toBe(true)),
29
+ check(isExternal(external, "node:fs"), toBe(true)),
30
+ check(isExternal(external, "node:child_process"), toBe(true)),
31
+ ]));
32
+ test("deriveExternal externalizes a PUBLIC SUBPATH of a declared dep", () =>
33
+ // `typescript/lib/...` is a subpath of the declared
34
+ // `typescript` dep → external (resolved at runtime via
35
+ // the dep's own exports), mirroring `plgg-server/ssg`.
36
+ check(isExternal(external, "typescript/lib/typescript"), toBe(true)));
37
+ test("deriveExternal does NOT externalize undeclared / own-source specifiers", () => all([
38
+ // plgg is not a dependency of plgg-bundle → not
39
+ // external (an import of it would fail loudly).
40
+ check(isExternal(external, "plgg"), toBe(false)),
41
+ check(isExternal(external, "./resolveSpecifier"), toBe(false)),
42
+ check(isExternal(external, "plgg-bundle/domain/model/BundleConfig"), toBe(false)),
43
+ ]));
44
+ test("deriveExternal throws when package.json is missing", () => check(rejects(join(tmpdir(), "plgg-derive-missing-xyz")), toBe(true)));
45
+ test("deriveExternal throws on an unparseable package.json", () => check(rejects(withManifest("{ not valid json")), toBe(true)));
46
+ test("deriveExternal treats a non-object manifest as zero declared deps", () => {
47
+ const ext = deriveExternal(withManifest(`"just a string"`));
48
+ return all([
49
+ // node:* is still external by prefix …
50
+ check(isExternal(ext, "node:fs"), toBe(true)),
51
+ // … but nothing is declared, so any package specifier
52
+ // is undeclared (not external).
53
+ check(isExternal(ext, "whatever"), toBe(false)),
54
+ ]);
55
+ });
56
+ //# sourceMappingURL=deriveExternal.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deriveExternal.spec.js","sourceRoot":"","sources":["../../../src/domain/usecase/deriveExternal.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,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SAAS,CAAC,EAC1B,IAAI,CAAC,IAAI,CAAC,CACX;QACD,sDAAsD;QACtD,gCAAgC;QAChC,KAAK,CACH,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,EAC3B,IAAI,CAAC,KAAK,CAAC,CACZ;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A workspace sibling the app bundler can INLINE from
3
+ * source: its package `name`, its `dir`, and the map from
4
+ * each public export subpath (`"."`, `"./client"`, …) to
5
+ * the `import.default` dist path declared in its
6
+ * `package.json` `exports`. The app resolver reverses
7
+ * that dist path to the entry's source file (so the
8
+ * `./style` → `dist/styleEntry.es.js` → `src/styleEntry`
9
+ * rename is honoured), and falls back to a self-alias
10
+ * `name/<path>` → `src/<path>` for non-export internal
11
+ * imports.
12
+ */
13
+ export type WorkspacePackage = Readonly<{
14
+ name: string;
15
+ dir: string;
16
+ /** export subpath (`"."` | `"./x"`) → dist default. */
17
+ exports: ReadonlyMap<string, string>;
18
+ }>;
19
+ /**
20
+ * Discover every sibling package under the directory that
21
+ * holds `packageRoot` (the monorepo `packages/` dir) —
22
+ * each entry that has a `package.json` with a `name`.
23
+ * Sorted longest-name-first so a later prefix match picks
24
+ * `plgg-view` over `plgg`. Throws on a read/parse failure.
25
+ */
26
+ export declare const discoverWorkspace: (packageRoot: string) => ReadonlyArray<WorkspacePackage>;
27
+ //# sourceMappingURL=discoverWorkspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discoverWorkspace.d.ts","sourceRoot":"","sources":["../../../src/domain/usecase/discoverWorkspace.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,uDAAuD;IACvD,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,aAAa,MAAM,KAClB,aAAa,CAAC,gBAAgB,CAUhC,CAAC"}