@ariestools/toolchain 8.6.11 → 8.7.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 (103) hide show
  1. package/dist/actions/api-exposure/apiExposure.d.ts.map +1 -1
  2. package/dist/actions/api-exposure/config.d.ts.map +1 -1
  3. package/dist/actions/api-exposure/types.d.ts +3 -0
  4. package/dist/actions/api-exposure/types.d.ts.map +1 -1
  5. package/dist/actions/deplint/packageJsonEditor.d.ts +1 -1
  6. package/dist/actions/deplint/ruleConfig.d.ts.map +1 -1
  7. package/dist/actions/deplint/types.d.ts +1 -1
  8. package/dist/actions/gitlint-fix.d.ts +2 -1
  9. package/dist/actions/gitlint-fix.d.ts.map +1 -1
  10. package/dist/actions/gitlint.d.ts +5 -1
  11. package/dist/actions/gitlint.d.ts.map +1 -1
  12. package/dist/actions/index.d.ts +2 -0
  13. package/dist/actions/index.d.ts.map +1 -1
  14. package/dist/actions/lintlint.d.ts +32 -1
  15. package/dist/actions/lintlint.d.ts.map +1 -1
  16. package/dist/actions/node-lint.d.ts +8 -1
  17. package/dist/actions/node-lint.d.ts.map +1 -1
  18. package/dist/actions/package/compile/ApiExposureConfig.d.ts +9 -2
  19. package/dist/actions/package/compile/ApiExposureConfig.d.ts.map +1 -1
  20. package/dist/actions/package/compile/MonolithConfig.d.ts +46 -4
  21. package/dist/actions/package/compile/MonolithConfig.d.ts.map +1 -1
  22. package/dist/actions/package/compile/PublintConfig.d.ts +43 -0
  23. package/dist/actions/package/compile/PublintConfig.d.ts.map +1 -0
  24. package/dist/actions/package/compile/RuleLevelConfig.d.ts +7 -0
  25. package/dist/actions/package/compile/RuleLevelConfig.d.ts.map +1 -0
  26. package/dist/actions/package/compile/XyConfig.d.ts +45 -38
  27. package/dist/actions/package/compile/XyConfig.d.ts.map +1 -1
  28. package/dist/actions/package/compile/index.d.ts +1 -0
  29. package/dist/actions/package/compile/index.d.ts.map +1 -1
  30. package/dist/actions/package/compile/monolithCompileEntries.d.ts +8 -6
  31. package/dist/actions/package/compile/monolithCompileEntries.d.ts.map +1 -1
  32. package/dist/actions/package/compile/monolithCompileLayout.d.ts +2 -0
  33. package/dist/actions/package/compile/monolithCompileLayout.d.ts.map +1 -1
  34. package/dist/actions/package/compile/monolithReexport.d.ts +45 -0
  35. package/dist/actions/package/compile/monolithReexport.d.ts.map +1 -0
  36. package/dist/actions/package/compile/packageCompileMonolith.d.ts.map +1 -1
  37. package/dist/actions/package/index.d.ts +1 -0
  38. package/dist/actions/package/index.d.ts.map +1 -1
  39. package/dist/actions/package/publint.d.ts +3 -1
  40. package/dist/actions/package/publint.d.ts.map +1 -1
  41. package/dist/actions/package/publintRules.d.ts +13 -0
  42. package/dist/actions/package/publintRules.d.ts.map +1 -0
  43. package/dist/actions/package-lint.d.ts +2 -1
  44. package/dist/actions/package-lint.d.ts.map +1 -1
  45. package/dist/actions/packman/lint.d.ts +16 -1
  46. package/dist/actions/packman/lint.d.ts.map +1 -1
  47. package/dist/actions/publint.d.ts.map +1 -1
  48. package/dist/actions/ruleCatalog.d.ts +42 -0
  49. package/dist/actions/ruleCatalog.d.ts.map +1 -0
  50. package/dist/actions/ruleRunner.d.ts +63 -0
  51. package/dist/actions/ruleRunner.d.ts.map +1 -0
  52. package/dist/actions/skills/lint.d.ts +16 -1
  53. package/dist/actions/skills/lint.d.ts.map +1 -1
  54. package/dist/bin/package/build.mjs +609 -101
  55. package/dist/bin/package/build.mjs.map +1 -1
  56. package/dist/bin/package/compile.mjs +257 -25
  57. package/dist/bin/package/compile.mjs.map +1 -1
  58. package/dist/bin/package/publint.mjs +352 -76
  59. package/dist/bin/package/publint.mjs.map +1 -1
  60. package/dist/bin/package/recompile.mjs +257 -25
  61. package/dist/bin/package/recompile.mjs.map +1 -1
  62. package/dist/bin/package/sync-layout.mjs +48 -8
  63. package/dist/bin/package/sync-layout.mjs.map +1 -1
  64. package/dist/bin/xy.mjs +8326 -836
  65. package/dist/bin/xy.mjs.map +1 -1
  66. package/dist/lib/index.d.ts +1 -0
  67. package/dist/lib/index.d.ts.map +1 -1
  68. package/dist/lib/loadConfig.d.ts +1 -0
  69. package/dist/lib/loadConfig.d.ts.map +1 -1
  70. package/dist/lib/ruleCommandRegistry.d.ts +100 -0
  71. package/dist/lib/ruleCommandRegistry.d.ts.map +1 -0
  72. package/dist/xy/common/checkCommand.d.ts.map +1 -1
  73. package/dist/xy/common/deadCommand.d.ts.map +1 -1
  74. package/dist/xy/common/gitCommand.d.ts +3 -0
  75. package/dist/xy/common/gitCommand.d.ts.map +1 -0
  76. package/dist/xy/common/gitlintCommand.d.ts +2 -0
  77. package/dist/xy/common/gitlintCommand.d.ts.map +1 -1
  78. package/dist/xy/common/index.d.ts.map +1 -1
  79. package/dist/xy/common/packmanCommand.d.ts.map +1 -1
  80. package/dist/xy/common/repo/lintCommand.d.ts.map +1 -1
  81. package/dist/xy/common/skills/index.d.ts.map +1 -1
  82. package/dist/xy/deprecatedCommand.d.ts +2 -0
  83. package/dist/xy/deprecatedCommand.d.ts.map +1 -0
  84. package/dist/xy/lint/apiExposureCommand.d.ts.map +1 -1
  85. package/dist/xy/lint/cycleCommand.d.ts.map +1 -1
  86. package/dist/xy/lint/deplintCommand.d.ts.map +1 -1
  87. package/dist/xy/lint/fixCommand.d.ts.map +1 -1
  88. package/dist/xy/lint/index.d.ts.map +1 -1
  89. package/dist/xy/lint/lint/index.d.ts.map +1 -1
  90. package/dist/xy/lint/lint/runCommand.d.ts.map +1 -1
  91. package/dist/xy/lint/lintlintCommand.d.ts +2 -0
  92. package/dist/xy/lint/lintlintCommand.d.ts.map +1 -1
  93. package/dist/xy/lint/nodeCommand.d.ts +3 -0
  94. package/dist/xy/lint/nodeCommand.d.ts.map +1 -0
  95. package/dist/xy/lint/nodeLintCommand.d.ts +2 -0
  96. package/dist/xy/lint/nodeLintCommand.d.ts.map +1 -1
  97. package/dist/xy/lint/publintCommand.d.ts.map +1 -1
  98. package/dist/xy/lint/relintCommand.d.ts.map +1 -1
  99. package/dist/xy/lint/republintCommand.d.ts.map +1 -1
  100. package/dist/xy/xy.d.ts +3 -10
  101. package/dist/xy/xy.d.ts.map +1 -1
  102. package/dist/xy/xyParseOptions.d.ts.map +1 -1
  103. package/package.json +5 -4
@@ -12143,6 +12143,230 @@ const packageCompileEsbuild = async (config, mode = {}) => {
12143
12143
  return nodeErrors + browserErrors + neutralErrors;
12144
12144
  };
12145
12145
  //#endregion
12146
+ //#region src/actions/package/compile/monolithReexport.ts
12147
+ function normalizeReexportTargets(value) {
12148
+ if (value === void 0) return [];
12149
+ return Array.isArray(value) ? value : [value];
12150
+ }
12151
+ /** Package-like specifier: not a hash alias and not a relative/absolute path. */
12152
+ function isPackageLikeSpecifier(spec) {
12153
+ return !spec.startsWith("#") && !spec.startsWith(".") && !spec.startsWith("/");
12154
+ }
12155
+ /** Configured `reexport` targets for a module, if any. */
12156
+ function moduleReexportTargets(mod) {
12157
+ return normalizeReexportTargets(mod.reexport);
12158
+ }
12159
+ function moduleHasReexport(mod) {
12160
+ return moduleReexportTargets(mod).length > 0;
12161
+ }
12162
+ /**
12163
+ * Master-barrel re-export targets for a module: explicit `barrelFrom`, else
12164
+ * `reexport`, else `#<name>`.
12165
+ */
12166
+ function moduleBarrelTargets(mod) {
12167
+ const fromBarrel = normalizeReexportTargets(mod.barrelFrom);
12168
+ if (fromBarrel.length > 0) return fromBarrel;
12169
+ const fromReexport = moduleReexportTargets(mod);
12170
+ if (fromReexport.length > 0) return fromReexport;
12171
+ return [`#${mod.name}`];
12172
+ }
12173
+ /**
12174
+ * Subpath shim re-export targets: explicit `shimFrom`, else `reexport`, else
12175
+ * `#<name>`.
12176
+ */
12177
+ function moduleShimTargets(mod) {
12178
+ const fromShim = normalizeReexportTargets(mod.shimFrom);
12179
+ if (fromShim.length > 0) return fromShim;
12180
+ const fromReexport = moduleReexportTargets(mod);
12181
+ if (fromReexport.length > 0) return fromReexport;
12182
+ return [`#${mod.name}`];
12183
+ }
12184
+ /** Builds a pure star-reexport TypeScript (or mjs) source body (no header). */
12185
+ function buildStarReexportLines(targets, options = {}) {
12186
+ const semi = options.semi === false ? "" : ";";
12187
+ return `${targets.map((target) => `export * from '${target}'${semi}`).join("\n")}\n`;
12188
+ }
12189
+ const starExportLineRe = /^export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?\s*$/;
12190
+ function isSkippableSourceLine(line) {
12191
+ if (line.length === 0) return true;
12192
+ if (line.startsWith("//")) return true;
12193
+ if (line.startsWith("/*") || line.startsWith("*") || line.startsWith("*/")) return true;
12194
+ return false;
12195
+ }
12196
+ /**
12197
+ * If `source` is only star re-exports (plus blank lines / `//` comments /
12198
+ * generated header), returns the targets in order. Otherwise `null`.
12199
+ */
12200
+ function parsePureStarReexports(source) {
12201
+ const targets = [];
12202
+ for (const rawLine of source.split("\n")) {
12203
+ const line = rawLine.trim();
12204
+ if (isSkippableSourceLine(line)) continue;
12205
+ const match = starExportLineRe.exec(line);
12206
+ if (match === null) return null;
12207
+ targets.push(match[1]);
12208
+ }
12209
+ return targets.length > 0 ? targets : null;
12210
+ }
12211
+ function moduleIndexSourcePath(packageDir, moduleName) {
12212
+ return PATH.join(packageDir, "src", "modules", moduleName, "index.ts");
12213
+ }
12214
+ function hashModuleParts(spec) {
12215
+ const [modName, sub] = spec.slice(1).split("/", 2);
12216
+ return {
12217
+ modName,
12218
+ sub
12219
+ };
12220
+ }
12221
+ function resolveHashToModuleFile(packageDir, spec, config) {
12222
+ const { modName, sub } = hashModuleParts(spec);
12223
+ if (config.aliasImports?.[spec] !== void 0) {
12224
+ const alias = config.aliasImports[spec].replace(/^\.\//, "");
12225
+ return PATH.join(packageDir, alias);
12226
+ }
12227
+ if (sub === void 0) return moduleIndexSourcePath(packageDir, modName);
12228
+ if (sub === "model") return PATH.join(packageDir, "src", "modules", modName, "model.ts");
12229
+ return PATH.join(packageDir, "src", "modules", modName, `${sub}.ts`);
12230
+ }
12231
+ function expandNestedSource(file, packageDir, config, seen) {
12232
+ if (!fs.existsSync(file)) return null;
12233
+ const nested = parsePureStarReexports(fs.readFileSync(file, "utf8"));
12234
+ if (nested === null) return null;
12235
+ return expandToPackageReexportTargets(nested, packageDir, config, seen);
12236
+ }
12237
+ function expandHashTarget(target, packageDir, config, seen) {
12238
+ const { modName, sub } = hashModuleParts(target);
12239
+ const mod = config.modules.find((candidate) => candidate.name === modName);
12240
+ if (mod !== void 0 && moduleHasReexport(mod) && sub === void 0) return expandToPackageReexportTargets(moduleReexportTargets(mod), packageDir, config, seen);
12241
+ const file = resolveHashToModuleFile(packageDir, target, config);
12242
+ if (file === null) return null;
12243
+ return expandNestedSource(file, packageDir, config, seen);
12244
+ }
12245
+ function expandRelativeTarget(target, packageDir, config, seen) {
12246
+ const base = PATH.resolve(packageDir, "src", target.replace(/^\.\//, ""));
12247
+ const existing = [
12248
+ base,
12249
+ `${base}.ts`,
12250
+ `${base}.tsx`,
12251
+ PATH.join(base, "index.ts")
12252
+ ].find((candidate) => fs.existsSync(candidate));
12253
+ if (existing === void 0) return null;
12254
+ return expandNestedSource(existing, packageDir, config, seen);
12255
+ }
12256
+ /**
12257
+ * Expands pure star-reexport targets until only package-like specifiers remain.
12258
+ * Returns `null` if any hop has local implementation or unreadable sources.
12259
+ */
12260
+ function expandToPackageReexportTargets(targets, packageDir, config, seen = /* @__PURE__ */ new Set()) {
12261
+ const out = [];
12262
+ for (const target of targets) {
12263
+ if (seen.has(target)) continue;
12264
+ seen.add(target);
12265
+ if (isPackageLikeSpecifier(target)) {
12266
+ out.push(target);
12267
+ continue;
12268
+ }
12269
+ const expanded = target.startsWith("#") ? expandHashTarget(target, packageDir, config, seen) : target.startsWith(".") ? expandRelativeTarget(target, packageDir, config, seen) : null;
12270
+ if (expanded === null) return null;
12271
+ out.push(...expanded);
12272
+ }
12273
+ return out;
12274
+ }
12275
+ /**
12276
+ * Resolves pure package reexport targets for a module from config and/or source.
12277
+ */
12278
+ function resolveModulePackageReexports(mod, packageDir, config) {
12279
+ if (moduleHasReexport(mod)) return expandToPackageReexportTargets(moduleReexportTargets(mod), packageDir, config);
12280
+ const file = moduleIndexSourcePath(packageDir, mod.name);
12281
+ if (!fs.existsSync(file)) return null;
12282
+ const targets = parsePureStarReexports(fs.readFileSync(file, "utf8"));
12283
+ if (targets === null) return null;
12284
+ return expandToPackageReexportTargets(targets, packageDir, config);
12285
+ }
12286
+ function walkMjs$1(dir, out = []) {
12287
+ if (!fs.existsSync(dir)) return out;
12288
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
12289
+ for (const entry of entries) {
12290
+ const fp = PATH.join(dir, entry.name);
12291
+ if (entry.isDirectory()) walkMjs$1(fp, out);
12292
+ else if (entry.name.endsWith(".mjs")) out.push(fp);
12293
+ }
12294
+ return out;
12295
+ }
12296
+ function writePureReexportMjs(filePath, targets) {
12297
+ fs.mkdirSync(PATH.dirname(filePath), { recursive: true });
12298
+ fs.writeFileSync(filePath, buildStarReexportLines(targets, { semi: true }));
12299
+ }
12300
+ function collectPackageTargetsByModule(packageDir, config) {
12301
+ const packageTargetsByModule = /* @__PURE__ */ new Map();
12302
+ for (const mod of config.modules) {
12303
+ if (!(mod.export ?? false) && !(mod.barrel ?? false)) continue;
12304
+ const targets = resolveModulePackageReexports(mod, packageDir, config);
12305
+ if (targets !== null && targets.length > 0) packageTargetsByModule.set(mod.name, targets);
12306
+ }
12307
+ return packageTargetsByModule;
12308
+ }
12309
+ function resolveBarrelModuleTargets(mod, packageDir, config, packageTargetsByModule) {
12310
+ const fromBarrel = normalizeReexportTargets(mod.barrelFrom);
12311
+ if (fromBarrel.length > 0) return expandToPackageReexportTargets(fromBarrel, packageDir, config);
12312
+ return packageTargetsByModule.get(mod.name) ?? null;
12313
+ }
12314
+ function resolveIndexPackageTargets(packageDir, config, packageTargetsByModule) {
12315
+ const barrelModules = config.modules.filter((mod) => mod.barrel ?? false).toSorted((a, b) => a.name.localeCompare(b.name));
12316
+ const indexTargets = [...config.barrelImports ?? []];
12317
+ for (const mod of barrelModules) {
12318
+ const moduleTargets = resolveBarrelModuleTargets(mod, packageDir, config, packageTargetsByModule);
12319
+ if (moduleTargets === null) return null;
12320
+ indexTargets.push(...moduleTargets);
12321
+ }
12322
+ return indexTargets;
12323
+ }
12324
+ function rewriteModuleReexportMjs(distDir, modulesPlatform, packageTargetsByModule) {
12325
+ let rewritten = 0;
12326
+ for (const [name, targets] of packageTargetsByModule) {
12327
+ const file = PATH.join(distDir, modulesPlatform, `${name}.mjs`);
12328
+ if (!fs.existsSync(file)) continue;
12329
+ writePureReexportMjs(file, targets);
12330
+ rewritten++;
12331
+ }
12332
+ return rewritten;
12333
+ }
12334
+ function rewriteIndexReexportMjs(distDir, platforms, indexTargets) {
12335
+ let rewritten = 0;
12336
+ for (const platform of platforms) {
12337
+ const file = PATH.join(distDir, platform, "index.mjs");
12338
+ if (!fs.existsSync(file)) continue;
12339
+ writePureReexportMjs(file, indexTargets);
12340
+ rewritten++;
12341
+ }
12342
+ for (const file of walkMjs$1(distDir)) {
12343
+ const base = PATH.basename(file);
12344
+ if (!base.startsWith("index") || !base.endsWith(".mjs") || base === "index.mjs") continue;
12345
+ writePureReexportMjs(file, indexTargets);
12346
+ rewritten++;
12347
+ }
12348
+ return rewritten;
12349
+ }
12350
+ /**
12351
+ * After esbuild, rewrite known pure package-facade entries to `export * from`
12352
+ * form. esbuild preserves star re-exports only on the entry file; multi-hop
12353
+ * `#module` chains become `__reExport` helpers that break Storybook/Vite
12354
+ * analysis. Returns the number of files rewritten.
12355
+ */
12356
+ function flattenPurePackageReexportMjs(distDir, packageDir, config) {
12357
+ const modulesPlatform = config.modulesPlatform ?? "neutral";
12358
+ const platforms = config.platforms ?? [
12359
+ "neutral",
12360
+ "node",
12361
+ "browser"
12362
+ ];
12363
+ const packageTargetsByModule = collectPackageTargetsByModule(packageDir, config);
12364
+ let rewritten = rewriteModuleReexportMjs(distDir, modulesPlatform, packageTargetsByModule);
12365
+ const indexTargets = resolveIndexPackageTargets(packageDir, config, packageTargetsByModule);
12366
+ if (indexTargets !== null && indexTargets.length > 0) rewritten += rewriteIndexReexportMjs(distDir, platforms, indexTargets);
12367
+ return rewritten;
12368
+ }
12369
+ //#endregion
12146
12370
  //#region src/actions/package/compile/monolithCompileLayout.ts
12147
12371
  /**
12148
12372
  * Layout generation for `compile.mode: 'monolith'` — a 1:1 port of the
@@ -12249,10 +12473,7 @@ function buildIndexTs(modules, config) {
12249
12473
  const hasConditional = Object.keys(config.conditionalImports ?? {}).length > 0;
12250
12474
  const barrelModules = modules.filter((mod) => mod.barrel ?? false).toSorted((a, b) => a.name.localeCompare(b.name));
12251
12475
  const lines = (config.barrelImports ?? []).map((spec) => `export * from '${spec}'`);
12252
- for (const mod of barrelModules) {
12253
- const target = mod.barrelFrom ?? `#${mod.name}`;
12254
- lines.push(`export * from '${target}'`);
12255
- }
12476
+ for (const mod of barrelModules) for (const target of moduleBarrelTargets(mod)) lines.push(`export * from '${target}'`);
12256
12477
  return `${GENERATED_HEADER}${hasConditional ? "/* eslint-disable @typescript-eslint/ban-ts-comment -- conditional package imports */\n// @ts-nocheck\n" : ""}${lines.join("\n")}
12257
12478
  `;
12258
12479
  }
@@ -12262,9 +12483,11 @@ function buildModelTs(modules) {
12262
12483
  `;
12263
12484
  }
12264
12485
  function buildModuleShim(mod) {
12265
- const target = mod.shimFrom ?? `#${mod.name}`;
12266
- return `${GENERATED_HEADER}export * from '${target}'
12267
- `;
12486
+ return `${GENERATED_HEADER}${buildStarReexportLines(moduleShimTargets(mod), { semi: false })}`;
12487
+ }
12488
+ /** Generated module body for facade modules with `reexport` targets. */
12489
+ function buildModuleReexportIndex(mod) {
12490
+ return `${GENERATED_HEADER}${buildStarReexportLines(moduleReexportTargets(mod), { semi: false })}`;
12268
12491
  }
12269
12492
  function buildModelShim(mod) {
12270
12493
  return `${GENERATED_HEADER}export type * from '#${mod.name}/model'
@@ -12326,9 +12549,10 @@ function syncMonolithLayout(packageDir, config, options = {}) {
12326
12549
  paths: buildTsconfigPaths(modules, config)
12327
12550
  };
12328
12551
  writeOrCheck(tsconfigPath, `${JSON.stringify(tsconfig, null, 2)}\n`);
12329
- writeOrCheck(PATH.join(packageDir, "src/index.ts"), buildIndexTs(modules, config));
12552
+ if (!(config.index?.custom ?? false)) writeOrCheck(PATH.join(packageDir, "src/index.ts"), buildIndexTs(modules, config));
12330
12553
  if (monolithHasModelBarrel(config)) writeOrCheck(PATH.join(packageDir, "src/model.ts"), buildModelTs(modules));
12331
12554
  for (const mod of modules) {
12555
+ if (moduleHasReexport(mod)) writeOrCheck(PATH.join(packageDir, "src", "modules", mod.name, "index.ts"), buildModuleReexportIndex(mod));
12332
12556
  if (!(mod.export ?? false)) continue;
12333
12557
  writeOrCheck(PATH.join(packageDir, `src/${mod.name}.ts`), buildModuleShim(mod));
12334
12558
  if (mod.model ?? false) writeOrCheck(PATH.join(packageDir, `src/${mod.name}.model.ts`), buildModelShim(mod));
@@ -12491,15 +12715,14 @@ function moduleShimEntries(mod, isDirectIndex, isExternal) {
12491
12715
  return shims;
12492
12716
  }
12493
12717
  /**
12494
- * Modules-platform entries for one exported module. Conditional modules
12495
- * normally keep the shim entry in external mode: the shim's retained `#`
12496
- * re-export funnels through distImports. But when the conditional's default
12497
- * condition targets the modules-platform file itself, that shim would
12498
- * re-export its own output — compile the default source directly instead.
12718
+ * Prefer compiling `modules/<name>/index.ts` directly when star re-exports
12719
+ * must stay as `export * from` on the entry (esbuild lowers multi-hop stars
12720
+ * into `__reExport` helpers). Used for external linkage, facade `reexport`
12721
+ * modules, and pure package facades that would otherwise hop through shims.
12499
12722
  */
12500
12723
  function modulesPlatformEntries(mod, config, isExternal, modulesPlatform) {
12501
12724
  const conditional = config.conditionalImports?.[mod.name];
12502
- let isDirectIndex = isExternal && conditional === void 0;
12725
+ let isDirectIndex = (isExternal || moduleHasReexport(mod)) && conditional === void 0;
12503
12726
  let directIn = `./modules/${mod.name}/index.ts`;
12504
12727
  if (isExternal && conditional?.distImports?.default === `./dist/${modulesPlatform}/${mod.name}.mjs`) {
12505
12728
  isDirectIndex = true;
@@ -12512,10 +12735,14 @@ function modulesPlatformEntries(mod, config, isExternal, modulesPlatform) {
12512
12735
  };
12513
12736
  return shims;
12514
12737
  }
12738
+ /** Master barrel entry for a platform (`index.entries` override or `./index.ts`). */
12739
+ function masterBarrelEntry(config, platform) {
12740
+ return config.index?.entries?.[platform] ?? "./index.ts";
12741
+ }
12515
12742
  function initialBarrelEntries(config, platforms, modulesPlatform, barrelPlatforms) {
12516
12743
  const entries = {};
12517
- for (const platform of platforms) entries[platform] = barrelPlatforms.has(platform) ? ["./index.ts"] : [];
12518
- entries[modulesPlatform] ??= barrelPlatforms.has(modulesPlatform) ? ["./index.ts"] : [];
12744
+ for (const platform of platforms) entries[platform] = barrelPlatforms.has(platform) ? [masterBarrelEntry(config, platform)] : [];
12745
+ entries[modulesPlatform] ??= barrelPlatforms.has(modulesPlatform) ? [masterBarrelEntry(config, modulesPlatform)] : [];
12519
12746
  if (monolithHasModelBarrel(config)) entries[modulesPlatform].push("./model.ts");
12520
12747
  return entries;
12521
12748
  }
@@ -12533,12 +12760,14 @@ function platformShimEntry(platform, name, target, isExternal) {
12533
12760
  * a conditional `#import` skip the modules-platform entry — the subpath
12534
12761
  * shim already resolves the default condition.
12535
12762
  *
12536
- * With `moduleLinkage: 'external'` the subpath and platform entries bypass
12537
- * the generated one-line shims and target the module files directly via
12538
- * `{in, out}` pairs: esbuild only preserves `export * from '#external'`
12539
- * when it appears in the entry file itself — routed through an intermediate
12540
- * re-export file the star export is silently lost in ESM output. The shims
12541
- * remain the tsc declaration sources for the same dist names.
12763
+ * With `moduleLinkage: 'external'` or module `reexport` facades, subpath
12764
+ * entries bypass the generated one-line shims and target the module files
12765
+ * directly via `{in, out}` pairs: esbuild only preserves
12766
+ * `export * from '…'` when it appears in the entry file itself — routed
12767
+ * through an intermediate re-export the star is lowered to `__reExport`
12768
+ * helpers. Shims remain the tsc declaration sources for the same dist names.
12769
+ * After esbuild, pure package-facade graphs are also flattened in
12770
+ * {@link flattenPurePackageReexportMjs} so multi-hop barrels stay clean.
12542
12771
  */
12543
12772
  function buildMonolithEntries(config) {
12544
12773
  const { conditionalImports = {}, modules, platformEntries = {} } = config;
@@ -12553,7 +12782,7 @@ function buildMonolithEntries(config) {
12553
12782
  entries[modulesPlatform].push(...modulesPlatformEntries(mod, config, isExternal, modulesPlatform));
12554
12783
  }
12555
12784
  for (const [platform, platformEntryMap] of Object.entries(platformEntries)) {
12556
- entries[platform] ??= barrelPlatforms.has(platform) ? ["./index.ts"] : [];
12785
+ entries[platform] ??= barrelPlatforms.has(platform) ? [masterBarrelEntry(config, platform)] : [];
12557
12786
  for (const [name, target] of Object.entries(platformEntryMap)) if (platform !== modulesPlatform || !exportedConditional.has(name)) entries[platform].push(platformShimEntry(platform, name, target, isExternal));
12558
12787
  }
12559
12788
  return entries;
@@ -12646,9 +12875,12 @@ const packageCompileMonolith = async (config, mode = {}) => {
12646
12875
  if (!shouldEmit) return 0;
12647
12876
  const compileResult = await packageCompileEsbuild(deriveEsbuildConfig(config, compile, monolith), { emitOnly: true });
12648
12877
  if (compileResult !== 0) return compileResult;
12649
- const rewritten = fixMonolithDeclarations(PATH.join(packageDir, "dist"), monolith);
12878
+ const distDir = PATH.join(packageDir, "dist");
12879
+ const flattened = flattenPurePackageReexportMjs(distDir, packageDir, monolith);
12880
+ if (isVerbose && flattened > 0) console.log(chalk.gray(`monolith pure reexport flatten: ${flattened} files`));
12881
+ const rewritten = fixMonolithDeclarations(distDir, monolith);
12650
12882
  if (isVerbose) console.log(chalk.gray(`monolith declaration fixups: ${rewritten} files`));
12651
- const specifierProblems = verifyMonolithRuntimeSpecifiers(PATH.join(packageDir, "dist"), monolith);
12883
+ const specifierProblems = verifyMonolithRuntimeSpecifiers(distDir, monolith);
12652
12884
  if (specifierProblems.length > 0) {
12653
12885
  for (const problem of specifierProblems) console.error(chalk.red(problem));
12654
12886
  return 1;