diff --git a/packages/api/package.json b/packages/api/package.json index 2e867ee28a..89067c9ca2 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -10,7 +10,7 @@ "main": "dist/index.js", "types": "@types/index.d.ts", "scripts": { - "build": "yarn workspace @actual-app/core exec tsgo && vite build && node scripts/inline-loot-core-types.mjs", + "build": "vite build", "test": "vitest --run", "typecheck": "tsgo -b && tsc-strict" }, diff --git a/packages/api/scripts/inline-loot-core-types.mjs b/packages/api/scripts/inline-loot-core-types.mjs deleted file mode 100644 index 9dd156cf4d..0000000000 --- a/packages/api/scripts/inline-loot-core-types.mjs +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Post-build script: copies loot-core declaration tree into @types/loot-core - * and rewrites index.d.ts to reference it so the published package is self-contained. - * Run after vite build; requires loot-core declarations (yarn workspace @actual-app/core exec tsgo). - */ -import fs from 'fs'; -import path from 'path'; -import { fileURLToPath } from 'url'; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const apiRoot = path.resolve(__dirname, '..'); -const typesDir = path.join(apiRoot, '@types'); -const indexDts = path.join(typesDir, 'index.d.ts'); -const lootCoreDeclRoot = path.resolve(apiRoot, '../loot-core/lib-dist/decl'); -const lootCoreDeclSrc = path.join(lootCoreDeclRoot, 'src'); -const lootCoreDeclTypings = path.join(lootCoreDeclRoot, 'typings'); -const lootCoreTypesDir = path.join(typesDir, 'loot-core'); - -function main() { - if (!fs.existsSync(indexDts)) { - console.error('Missing @types/index.d.ts; run vite build first.'); - process.exit(1); - } - if (!fs.existsSync(lootCoreDeclSrc)) { - console.error( - 'Missing loot-core declarations; run: yarn workspace @actual-app/core exec tsgo', - ); - process.exit(1); - } - - // Remove existing loot-core output (dir or legacy single file) - if (fs.existsSync(lootCoreTypesDir)) { - fs.rmSync(lootCoreTypesDir, { recursive: true }); - } - const legacyDts = path.join(typesDir, 'loot-core.d.ts'); - if (fs.existsSync(legacyDts)) { - fs.rmSync(legacyDts); - } - - // Copy declaration tree: src (main exports) plus emitted typings so no declarations are dropped - fs.cpSync(lootCoreDeclSrc, lootCoreTypesDir, { recursive: true }); - if (fs.existsSync(lootCoreDeclTypings)) { - fs.cpSync(lootCoreDeclTypings, path.join(lootCoreTypesDir, 'typings'), { - recursive: true, - }); - } - - // Rewrite index.d.ts: remove reference, point imports at local ./loot-core/ - let indexContent = fs.readFileSync(indexDts, 'utf8'); - indexContent = indexContent.replace( - /\/\/\/ \n?/, - '', - ); - indexContent = indexContent - .replace(/'loot-core\//g, "'./loot-core/") - .replace(/"loot-core\//g, '"./loot-core/'); - fs.writeFileSync(indexDts, indexContent, 'utf8'); -} - -main(); diff --git a/upcoming-release-notes/7209.md b/upcoming-release-notes/7209.md new file mode 100644 index 0000000000..e9d679db9d --- /dev/null +++ b/upcoming-release-notes/7209.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +api: simplify bundling by removing loot-core type inlining