fix: the declarations of the published package import the other declarations by their .js names.
Release / release (push) Successful in 28s

This commit is contained in:
slawek committed 2026-10-28 19:25:09 +01:00
1 parent 4505b37abc
commit 57ac5296cb
4 files changed
+20 -4

No files matched your search

+9 -1
View File
@@ -4,7 +4,7 @@
// the font plugin's virtual module, README.md, CHANGELOG.md and a package.json whose exports name the compiled files.
import { spawnSync } from 'node:child_process';
import { copyFileSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { copyFileSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
const ROOT = import.meta.dirname;
@@ -21,6 +21,14 @@ const tsc = spawnSync(join(ROOT, 'node_modules', '.bin', 'tsc'), ['-p', join(ROO
if (tsc.error) fail(`tsc: ${tsc.error.message}; run npm ci first`);
if (tsc.status !== 0) process.exit(tsc.status ?? 1);
// The declarations import the other declarations by their .js names, as the compiled JavaScript does.
for (const entry of ENTRIES) {
for (const file of readdirSync(join(DIST, entry)).filter((name) => name.endsWith('.d.ts'))) {
const path = join(DIST, entry, file);
writeFileSync(path, readFileSync(path, 'utf8').replace(/(from\s+|import\s+)(['"])(\.{1,2}\/[^'"]+)\.tsx?\2/g, '$1$2$3.js$2'));
}
}
// The compiled renderApp keeps its import of virtual:font, so its declarations reference the module's declaration.
copyFileSync(join(ROOT, 'web', 'virtual-font.d.ts'), join(DIST, 'web', 'virtual-font.d.ts'));
const renderApp = join(DIST, 'web', 'renderApp.d.ts');