feat(scripts/types): export module namespaces

This commit is contained in:
PalmDevs 2026-08-02 23:04:14 +07:00
parent 54f5d94205
commit 685ee12cc0
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

@ -102,6 +102,16 @@ export default async function buildTypes(log = true): Promise<void> {
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<void> {
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<void> {
)
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`,