Skip to content

Commit 6049b37

Browse files
committed
feat(exports): expose llms.txt through the exports map
Takes the generator rule from socket-wheelhouse (byte-identical fleet mirror) and regenerates: 616 entries, the new one being "./llms.txt": "./llms.txt". The file was already published in files[] but unreachable through exports — require.resolve('@socketsecurity/lib/llms.txt') now resolves, which is the point of shipping an llms.txt at all. public-files-are-exported passes.
1 parent 7a18528 commit 6049b37

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3515,7 +3515,8 @@
35153515
"default": "./dist/words/types.js"
35163516
},
35173517
"./data/extensions.json": "./data/extensions.json",
3518-
"./package.json": "./package.json"
3518+
"./package.json": "./package.json",
3519+
"./llms.txt": "./llms.txt"
35193520
},
35203521
"publishConfig": {
35213522
"access": "public",

scripts/fleet/gen/package-exports.mts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* `scripts/fleet/check/public-files-are-exported.mts`.
1717
*/
1818

19-
import { promises as fs, readFileSync } from 'node:fs'
19+
import { existsSync, promises as fs, readFileSync } from 'node:fs'
2020
import { builtinModules } from 'node:module'
2121
import path from 'node:path'
2222
import process from 'node:process'
@@ -211,6 +211,7 @@ export function buildExportsMap(
211211
const { outDir } = config
212212
const map: Record<string, ExportConditions | string> = {}
213213

214+
214215
for (let i = 0, { length } = publicFiles; i < length; i += 1) {
215216
const rel = normalizePath(publicFiles[i]!)
216217
if (isPrivatePath(rel, config.privateSegments)) {
@@ -596,6 +597,14 @@ export async function runGenerator(): Promise<void> {
596597
)
597598

598599
const exports = buildExportsMap(config, publicFiles, srcFiles, declFiles)
600+
// llms.txt at the package root auto-exports as `./llms.txt`, the same
601+
// treatment `./package.json` gets: a plain-text asset agents resolve through
602+
// the exports map. The generator owns the entry so a repo cannot ship the
603+
// file in `files[]` while leaving it unreachable via `exports` — the exact
604+
// drift socket-lib had (published but unexported).
605+
if (existsSync(path.join(packageDir, 'llms.txt'))) {
606+
exports['./llms.txt'] = './llms.txt'
607+
}
599608
pkgJson['exports'] = exports
600609
// A declared browser-safe surface implies the package targets the browser, so
601610
// a downstream browser bundle will traverse its `node:*` imports — stub every

0 commit comments

Comments
 (0)