/** * Ensures .svelte-kit/tsconfig.json exists so the root tsconfig's "extends" resolves. * Storybook's Vite pipeline resolves the root tsconfig; if .svelte-kit is missing (e.g. * svelte-kit sync hasn't run), the build fails. This script writes a minimal fallback * so the root extends succeed. svelte-kit sync will overwrite with the real file. */ const fs = require('fs'); const path = require('path'); const dir = path.join(process.cwd(), '.svelte-kit'); const file = path.join(dir, 'tsconfig.json'); const minimal = { compilerOptions: { module: 'ESNext', moduleResolution: 'Bundler', target: 'ESNext', lib: ['DOM', 'DOM.Iterable', 'ESNext'], strict: true, skipLibCheck: true, noEmit: true, isolatedModules: true, esModuleInterop: true, resolveJsonModule: true, allowJs: true, forceConsistentCasingInFileNames: true, verbatimModuleSyntax: true }, include: [], exclude: [] }; if (!fs.existsSync(dir)) { fs.mkdirSync(dir, { recursive: true }); } if (!fs.existsSync(file)) { fs.writeFileSync(file, JSON.stringify(minimal, null, 2) + '\n', 'utf8'); console.log('Created .svelte-kit/tsconfig.json (minimal fallback for Storybook)'); }