@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
@@ -12071,6 +12071,230 @@ const packageCompileEsbuild = async (config, mode = {}) => {
12071
12071
  return nodeErrors + browserErrors + neutralErrors;
12072
12072
  };
12073
12073
  //#endregion
12074
+ //#region src/actions/package/compile/monolithReexport.ts
12075
+ function normalizeReexportTargets(value) {
12076
+ if (value === void 0) return [];
12077
+ return Array.isArray(value) ? value : [value];
12078
+ }
12079
+ /** Package-like specifier: not a hash alias and not a relative/absolute path. */
12080
+ function isPackageLikeSpecifier(spec) {
12081
+ return !spec.startsWith("#") && !spec.startsWith(".") && !spec.startsWith("/");
12082
+ }
12083
+ /** Configured `reexport` targets for a module, if any. */
12084
+ function moduleReexportTargets(mod) {
12085
+ return normalizeReexportTargets(mod.reexport);
12086
+ }
12087
+ function moduleHasReexport(mod) {
12088
+ return moduleReexportTargets(mod).length > 0;
12089
+ }
12090
+ /**
12091
+ * Master-barrel re-export targets for a module: explicit `barrelFrom`, else
12092
+ * `reexport`, else `#<name>`.
12093
+ */
12094
+ function moduleBarrelTargets(mod) {
12095
+ const fromBarrel = normalizeReexportTargets(mod.barrelFrom);
12096
+ if (fromBarrel.length > 0) return fromBarrel;
12097
+ const fromReexport = moduleReexportTargets(mod);
12098
+ if (fromReexport.length > 0) return fromReexport;
12099
+ return [`#${mod.name}`];
12100
+ }
12101
+ /**
12102
+ * Subpath shim re-export targets: explicit `shimFrom`, else `reexport`, else
12103
+ * `#<name>`.
12104
+ */
12105
+ function moduleShimTargets(mod) {
12106
+ const fromShim = normalizeReexportTargets(mod.shimFrom);
12107
+ if (fromShim.length > 0) return fromShim;
12108
+ const fromReexport = moduleReexportTargets(mod);
12109
+ if (fromReexport.length > 0) return fromReexport;
12110
+ return [`#${mod.name}`];
12111
+ }
12112
+ /** Builds a pure star-reexport TypeScript (or mjs) source body (no header). */
12113
+ function buildStarReexportLines(targets, options = {}) {
12114
+ const semi = options.semi === false ? "" : ";";
12115
+ return `${targets.map((target) => `export * from '${target}'${semi}`).join("\n")}\n`;
12116
+ }
12117
+ const starExportLineRe = /^export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?\s*$/;
12118
+ function isSkippableSourceLine(line) {
12119
+ if (line.length === 0) return true;
12120
+ if (line.startsWith("//")) return true;
12121
+ if (line.startsWith("/*") || line.startsWith("*") || line.startsWith("*/")) return true;
12122
+ return false;
12123
+ }
12124
+ /**
12125
+ * If `source` is only star re-exports (plus blank lines / `//` comments /
12126
+ * generated header), returns the targets in order. Otherwise `null`.
12127
+ */
12128
+ function parsePureStarReexports(source) {
12129
+ const targets = [];
12130
+ for (const rawLine of source.split("\n")) {
12131
+ const line = rawLine.trim();
12132
+ if (isSkippableSourceLine(line)) continue;
12133
+ const match = starExportLineRe.exec(line);
12134
+ if (match === null) return null;
12135
+ targets.push(match[1]);
12136
+ }
12137
+ return targets.length > 0 ? targets : null;
12138
+ }
12139
+ function moduleIndexSourcePath(packageDir, moduleName) {
12140
+ return PATH.join(packageDir, "src", "modules", moduleName, "index.ts");
12141
+ }
12142
+ function hashModuleParts(spec) {
12143
+ const [modName, sub] = spec.slice(1).split("/", 2);
12144
+ return {
12145
+ modName,
12146
+ sub
12147
+ };
12148
+ }
12149
+ function resolveHashToModuleFile(packageDir, spec, config) {
12150
+ const { modName, sub } = hashModuleParts(spec);
12151
+ if (config.aliasImports?.[spec] !== void 0) {
12152
+ const alias = config.aliasImports[spec].replace(/^\.\//, "");
12153
+ return PATH.join(packageDir, alias);
12154
+ }
12155
+ if (sub === void 0) return moduleIndexSourcePath(packageDir, modName);
12156
+ if (sub === "model") return PATH.join(packageDir, "src", "modules", modName, "model.ts");
12157
+ return PATH.join(packageDir, "src", "modules", modName, `${sub}.ts`);
12158
+ }
12159
+ function expandNestedSource(file, packageDir, config, seen) {
12160
+ if (!fs.existsSync(file)) return null;
12161
+ const nested = parsePureStarReexports(fs.readFileSync(file, "utf8"));
12162
+ if (nested === null) return null;
12163
+ return expandToPackageReexportTargets(nested, packageDir, config, seen);
12164
+ }
12165
+ function expandHashTarget(target, packageDir, config, seen) {
12166
+ const { modName, sub } = hashModuleParts(target);
12167
+ const mod = config.modules.find((candidate) => candidate.name === modName);
12168
+ if (mod !== void 0 && moduleHasReexport(mod) && sub === void 0) return expandToPackageReexportTargets(moduleReexportTargets(mod), packageDir, config, seen);
12169
+ const file = resolveHashToModuleFile(packageDir, target, config);
12170
+ if (file === null) return null;
12171
+ return expandNestedSource(file, packageDir, config, seen);
12172
+ }
12173
+ function expandRelativeTarget(target, packageDir, config, seen) {
12174
+ const base = PATH.resolve(packageDir, "src", target.replace(/^\.\//, ""));
12175
+ const existing = [
12176
+ base,
12177
+ `${base}.ts`,
12178
+ `${base}.tsx`,
12179
+ PATH.join(base, "index.ts")
12180
+ ].find((candidate) => fs.existsSync(candidate));
12181
+ if (existing === void 0) return null;
12182
+ return expandNestedSource(existing, packageDir, config, seen);
12183
+ }
12184
+ /**
12185
+ * Expands pure star-reexport targets until only package-like specifiers remain.
12186
+ * Returns `null` if any hop has local implementation or unreadable sources.
12187
+ */
12188
+ function expandToPackageReexportTargets(targets, packageDir, config, seen = /* @__PURE__ */ new Set()) {
12189
+ const out = [];
12190
+ for (const target of targets) {
12191
+ if (seen.has(target)) continue;
12192
+ seen.add(target);
12193
+ if (isPackageLikeSpecifier(target)) {
12194
+ out.push(target);
12195
+ continue;
12196
+ }
12197
+ const expanded = target.startsWith("#") ? expandHashTarget(target, packageDir, config, seen) : target.startsWith(".") ? expandRelativeTarget(target, packageDir, config, seen) : null;
12198
+ if (expanded === null) return null;
12199
+ out.push(...expanded);
12200
+ }
12201
+ return out;
12202
+ }
12203
+ /**
12204
+ * Resolves pure package reexport targets for a module from config and/or source.
12205
+ */
12206
+ function resolveModulePackageReexports(mod, packageDir, config) {
12207
+ if (moduleHasReexport(mod)) return expandToPackageReexportTargets(moduleReexportTargets(mod), packageDir, config);
12208
+ const file = moduleIndexSourcePath(packageDir, mod.name);
12209
+ if (!fs.existsSync(file)) return null;
12210
+ const targets = parsePureStarReexports(fs.readFileSync(file, "utf8"));
12211
+ if (targets === null) return null;
12212
+ return expandToPackageReexportTargets(targets, packageDir, config);
12213
+ }
12214
+ function walkMjs$1(dir, out = []) {
12215
+ if (!fs.existsSync(dir)) return out;
12216
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
12217
+ for (const entry of entries) {
12218
+ const fp = PATH.join(dir, entry.name);
12219
+ if (entry.isDirectory()) walkMjs$1(fp, out);
12220
+ else if (entry.name.endsWith(".mjs")) out.push(fp);
12221
+ }
12222
+ return out;
12223
+ }
12224
+ function writePureReexportMjs(filePath, targets) {
12225
+ fs.mkdirSync(PATH.dirname(filePath), { recursive: true });
12226
+ fs.writeFileSync(filePath, buildStarReexportLines(targets, { semi: true }));
12227
+ }
12228
+ function collectPackageTargetsByModule(packageDir, config) {
12229
+ const packageTargetsByModule = /* @__PURE__ */ new Map();
12230
+ for (const mod of config.modules) {
12231
+ if (!(mod.export ?? false) && !(mod.barrel ?? false)) continue;
12232
+ const targets = resolveModulePackageReexports(mod, packageDir, config);
12233
+ if (targets !== null && targets.length > 0) packageTargetsByModule.set(mod.name, targets);
12234
+ }
12235
+ return packageTargetsByModule;
12236
+ }
12237
+ function resolveBarrelModuleTargets(mod, packageDir, config, packageTargetsByModule) {
12238
+ const fromBarrel = normalizeReexportTargets(mod.barrelFrom);
12239
+ if (fromBarrel.length > 0) return expandToPackageReexportTargets(fromBarrel, packageDir, config);
12240
+ return packageTargetsByModule.get(mod.name) ?? null;
12241
+ }
12242
+ function resolveIndexPackageTargets(packageDir, config, packageTargetsByModule) {
12243
+ const barrelModules = config.modules.filter((mod) => mod.barrel ?? false).toSorted((a, b) => a.name.localeCompare(b.name));
12244
+ const indexTargets = [...config.barrelImports ?? []];
12245
+ for (const mod of barrelModules) {
12246
+ const moduleTargets = resolveBarrelModuleTargets(mod, packageDir, config, packageTargetsByModule);
12247
+ if (moduleTargets === null) return null;
12248
+ indexTargets.push(...moduleTargets);
12249
+ }
12250
+ return indexTargets;
12251
+ }
12252
+ function rewriteModuleReexportMjs(distDir, modulesPlatform, packageTargetsByModule) {
12253
+ let rewritten = 0;
12254
+ for (const [name, targets] of packageTargetsByModule) {
12255
+ const file = PATH.join(distDir, modulesPlatform, `${name}.mjs`);
12256
+ if (!fs.existsSync(file)) continue;
12257
+ writePureReexportMjs(file, targets);
12258
+ rewritten++;
12259
+ }
12260
+ return rewritten;
12261
+ }
12262
+ function rewriteIndexReexportMjs(distDir, platforms, indexTargets) {
12263
+ let rewritten = 0;
12264
+ for (const platform of platforms) {
12265
+ const file = PATH.join(distDir, platform, "index.mjs");
12266
+ if (!fs.existsSync(file)) continue;
12267
+ writePureReexportMjs(file, indexTargets);
12268
+ rewritten++;
12269
+ }
12270
+ for (const file of walkMjs$1(distDir)) {
12271
+ const base = PATH.basename(file);
12272
+ if (!base.startsWith("index") || !base.endsWith(".mjs") || base === "index.mjs") continue;
12273
+ writePureReexportMjs(file, indexTargets);
12274
+ rewritten++;
12275
+ }
12276
+ return rewritten;
12277
+ }
12278
+ /**
12279
+ * After esbuild, rewrite known pure package-facade entries to `export * from`
12280
+ * form. esbuild preserves star re-exports only on the entry file; multi-hop
12281
+ * `#module` chains become `__reExport` helpers that break Storybook/Vite
12282
+ * analysis. Returns the number of files rewritten.
12283
+ */
12284
+ function flattenPurePackageReexportMjs(distDir, packageDir, config) {
12285
+ const modulesPlatform = config.modulesPlatform ?? "neutral";
12286
+ const platforms = config.platforms ?? [
12287
+ "neutral",
12288
+ "node",
12289
+ "browser"
12290
+ ];
12291
+ const packageTargetsByModule = collectPackageTargetsByModule(packageDir, config);
12292
+ let rewritten = rewriteModuleReexportMjs(distDir, modulesPlatform, packageTargetsByModule);
12293
+ const indexTargets = resolveIndexPackageTargets(packageDir, config, packageTargetsByModule);
12294
+ if (indexTargets !== null && indexTargets.length > 0) rewritten += rewriteIndexReexportMjs(distDir, platforms, indexTargets);
12295
+ return rewritten;
12296
+ }
12297
+ //#endregion
12074
12298
  //#region src/actions/package/compile/monolithCompileLayout.ts
12075
12299
  /**
12076
12300
  * Layout generation for `compile.mode: 'monolith'` — a 1:1 port of the
@@ -12177,10 +12401,7 @@ function buildIndexTs(modules, config) {
12177
12401
  const hasConditional = Object.keys(config.conditionalImports ?? {}).length > 0;
12178
12402
  const barrelModules = modules.filter((mod) => mod.barrel ?? false).toSorted((a, b) => a.name.localeCompare(b.name));
12179
12403
  const lines = (config.barrelImports ?? []).map((spec) => `export * from '${spec}'`);
12180
- for (const mod of barrelModules) {
12181
- const target = mod.barrelFrom ?? `#${mod.name}`;
12182
- lines.push(`export * from '${target}'`);
12183
- }
12404
+ for (const mod of barrelModules) for (const target of moduleBarrelTargets(mod)) lines.push(`export * from '${target}'`);
12184
12405
  return `${GENERATED_HEADER}${hasConditional ? "/* eslint-disable @typescript-eslint/ban-ts-comment -- conditional package imports */\n// @ts-nocheck\n" : ""}${lines.join("\n")}
12185
12406
  `;
12186
12407
  }
@@ -12190,9 +12411,11 @@ function buildModelTs(modules) {
12190
12411
  `;
12191
12412
  }
12192
12413
  function buildModuleShim(mod) {
12193
- const target = mod.shimFrom ?? `#${mod.name}`;
12194
- return `${GENERATED_HEADER}export * from '${target}'
12195
- `;
12414
+ return `${GENERATED_HEADER}${buildStarReexportLines(moduleShimTargets(mod), { semi: false })}`;
12415
+ }
12416
+ /** Generated module body for facade modules with `reexport` targets. */
12417
+ function buildModuleReexportIndex(mod) {
12418
+ return `${GENERATED_HEADER}${buildStarReexportLines(moduleReexportTargets(mod), { semi: false })}`;
12196
12419
  }
12197
12420
  function buildModelShim(mod) {
12198
12421
  return `${GENERATED_HEADER}export type * from '#${mod.name}/model'
@@ -12254,9 +12477,10 @@ function syncMonolithLayout(packageDir, config, options = {}) {
12254
12477
  paths: buildTsconfigPaths(modules, config)
12255
12478
  };
12256
12479
  writeOrCheck(tsconfigPath, `${JSON.stringify(tsconfig, null, 2)}\n`);
12257
- writeOrCheck(PATH.join(packageDir, "src/index.ts"), buildIndexTs(modules, config));
12480
+ if (!(config.index?.custom ?? false)) writeOrCheck(PATH.join(packageDir, "src/index.ts"), buildIndexTs(modules, config));
12258
12481
  if (monolithHasModelBarrel(config)) writeOrCheck(PATH.join(packageDir, "src/model.ts"), buildModelTs(modules));
12259
12482
  for (const mod of modules) {
12483
+ if (moduleHasReexport(mod)) writeOrCheck(PATH.join(packageDir, "src", "modules", mod.name, "index.ts"), buildModuleReexportIndex(mod));
12260
12484
  if (!(mod.export ?? false)) continue;
12261
12485
  writeOrCheck(PATH.join(packageDir, `src/${mod.name}.ts`), buildModuleShim(mod));
12262
12486
  if (mod.model ?? false) writeOrCheck(PATH.join(packageDir, `src/${mod.name}.model.ts`), buildModelShim(mod));
@@ -12419,15 +12643,14 @@ function moduleShimEntries(mod, isDirectIndex, isExternal) {
12419
12643
  return shims;
12420
12644
  }
12421
12645
  /**
12422
- * Modules-platform entries for one exported module. Conditional modules
12423
- * normally keep the shim entry in external mode: the shim's retained `#`
12424
- * re-export funnels through distImports. But when the conditional's default
12425
- * condition targets the modules-platform file itself, that shim would
12426
- * re-export its own output — compile the default source directly instead.
12646
+ * Prefer compiling `modules/<name>/index.ts` directly when star re-exports
12647
+ * must stay as `export * from` on the entry (esbuild lowers multi-hop stars
12648
+ * into `__reExport` helpers). Used for external linkage, facade `reexport`
12649
+ * modules, and pure package facades that would otherwise hop through shims.
12427
12650
  */
12428
12651
  function modulesPlatformEntries(mod, config, isExternal, modulesPlatform) {
12429
12652
  const conditional = config.conditionalImports?.[mod.name];
12430
- let isDirectIndex = isExternal && conditional === void 0;
12653
+ let isDirectIndex = (isExternal || moduleHasReexport(mod)) && conditional === void 0;
12431
12654
  let directIn = `./modules/${mod.name}/index.ts`;
12432
12655
  if (isExternal && conditional?.distImports?.default === `./dist/${modulesPlatform}/${mod.name}.mjs`) {
12433
12656
  isDirectIndex = true;
@@ -12440,10 +12663,14 @@ function modulesPlatformEntries(mod, config, isExternal, modulesPlatform) {
12440
12663
  };
12441
12664
  return shims;
12442
12665
  }
12666
+ /** Master barrel entry for a platform (`index.entries` override or `./index.ts`). */
12667
+ function masterBarrelEntry(config, platform) {
12668
+ return config.index?.entries?.[platform] ?? "./index.ts";
12669
+ }
12443
12670
  function initialBarrelEntries(config, platforms, modulesPlatform, barrelPlatforms) {
12444
12671
  const entries = {};
12445
- for (const platform of platforms) entries[platform] = barrelPlatforms.has(platform) ? ["./index.ts"] : [];
12446
- entries[modulesPlatform] ??= barrelPlatforms.has(modulesPlatform) ? ["./index.ts"] : [];
12672
+ for (const platform of platforms) entries[platform] = barrelPlatforms.has(platform) ? [masterBarrelEntry(config, platform)] : [];
12673
+ entries[modulesPlatform] ??= barrelPlatforms.has(modulesPlatform) ? [masterBarrelEntry(config, modulesPlatform)] : [];
12447
12674
  if (monolithHasModelBarrel(config)) entries[modulesPlatform].push("./model.ts");
12448
12675
  return entries;
12449
12676
  }
@@ -12461,12 +12688,14 @@ function platformShimEntry(platform, name, target, isExternal) {
12461
12688
  * a conditional `#import` skip the modules-platform entry — the subpath
12462
12689
  * shim already resolves the default condition.
12463
12690
  *
12464
- * With `moduleLinkage: 'external'` the subpath and platform entries bypass
12465
- * the generated one-line shims and target the module files directly via
12466
- * `{in, out}` pairs: esbuild only preserves `export * from '#external'`
12467
- * when it appears in the entry file itself — routed through an intermediate
12468
- * re-export file the star export is silently lost in ESM output. The shims
12469
- * remain the tsc declaration sources for the same dist names.
12691
+ * With `moduleLinkage: 'external'` or module `reexport` facades, subpath
12692
+ * entries bypass the generated one-line shims and target the module files
12693
+ * directly via `{in, out}` pairs: esbuild only preserves
12694
+ * `export * from '…'` when it appears in the entry file itself — routed
12695
+ * through an intermediate re-export the star is lowered to `__reExport`
12696
+ * helpers. Shims remain the tsc declaration sources for the same dist names.
12697
+ * After esbuild, pure package-facade graphs are also flattened in
12698
+ * {@link flattenPurePackageReexportMjs} so multi-hop barrels stay clean.
12470
12699
  */
12471
12700
  function buildMonolithEntries(config) {
12472
12701
  const { conditionalImports = {}, modules, platformEntries = {} } = config;
@@ -12481,7 +12710,7 @@ function buildMonolithEntries(config) {
12481
12710
  entries[modulesPlatform].push(...modulesPlatformEntries(mod, config, isExternal, modulesPlatform));
12482
12711
  }
12483
12712
  for (const [platform, platformEntryMap] of Object.entries(platformEntries)) {
12484
- entries[platform] ??= barrelPlatforms.has(platform) ? ["./index.ts"] : [];
12713
+ entries[platform] ??= barrelPlatforms.has(platform) ? [masterBarrelEntry(config, platform)] : [];
12485
12714
  for (const [name, target] of Object.entries(platformEntryMap)) if (platform !== modulesPlatform || !exportedConditional.has(name)) entries[platform].push(platformShimEntry(platform, name, target, isExternal));
12486
12715
  }
12487
12716
  return entries;
@@ -12574,9 +12803,12 @@ const packageCompileMonolith = async (config, mode = {}) => {
12574
12803
  if (!shouldEmit) return 0;
12575
12804
  const compileResult = await packageCompileEsbuild(deriveEsbuildConfig(config, compile, monolith), { emitOnly: true });
12576
12805
  if (compileResult !== 0) return compileResult;
12577
- const rewritten = fixMonolithDeclarations(PATH.join(packageDir, "dist"), monolith);
12806
+ const distDir = PATH.join(packageDir, "dist");
12807
+ const flattened = flattenPurePackageReexportMjs(distDir, packageDir, monolith);
12808
+ if (isVerbose && flattened > 0) console.log(chalk.gray(`monolith pure reexport flatten: ${flattened} files`));
12809
+ const rewritten = fixMonolithDeclarations(distDir, monolith);
12578
12810
  if (isVerbose) console.log(chalk.gray(`monolith declaration fixups: ${rewritten} files`));
12579
- const specifierProblems = verifyMonolithRuntimeSpecifiers(PATH.join(packageDir, "dist"), monolith);
12811
+ const specifierProblems = verifyMonolithRuntimeSpecifiers(distDir, monolith);
12580
12812
  if (specifierProblems.length > 0) {
12581
12813
  for (const problem of specifierProblems) console.error(chalk.red(problem));
12582
12814
  return 1;