From 685ee12cc07aa084fbeb3a039885038a9b44eb27 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sun, 2 Aug 2026 23:04:14 +0700 Subject: [PATCH] feat(scripts/types): export module namespaces --- scripts/types.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/types.ts b/scripts/types.ts index f50966d..9c0f479 100644 --- a/scripts/types.ts +++ b/scripts/types.ts @@ -102,6 +102,16 @@ export default async function buildTypes(log = true): Promise { await generateIndex(input), ) + const modules = Object.keys(input) + .filter(entry => entry.startsWith(`${PATHS.lib}/`)) + .map(entry => entry.slice(`${PATHS.lib}/`.length)) + .sort() + + await writeFile( + `${PATHS.output}/modules.json`, + `${JSON.stringify(modules, null, 4)}\n`, + ) + // Make dist/types directly publishable await writeFile( `${PATHS.output}/package.json`, @@ -110,8 +120,10 @@ export default async function buildTypes(log = true): Promise { name: TYPES_PACKAGE_NAME, version: pkg.version, types: 'index.d.ts', + files: ['modules.json'], exports: { '.': { types: './index.d.ts' }, + './modules.json': { default: './modules.json' }, }, imports: { '#*': { types: './*.d.ts' }, @@ -411,6 +423,8 @@ async function auditExternalSpecifiers(): Promise { ) for (const [name, path] of undeclared) { + if (name.startsWith('node:')) continue + console.warn( chalk.yellow( `⚠️ "${name}" is imported by ${path} but not declared by the types package`,