UNPKG

svelte-standalone

Version:

Transform Svelte components in standalone scripts!

34 lines (33 loc) 945 B
import fs from 'fs'; import path from 'path'; import { rootDir } from '../../dir.js'; function getPack() { const packPath = path.join(rootDir, 'package.json'); try { const p = fs.readFileSync(packPath, 'utf-8'); return JSON.parse(p); } catch { return null; } } function includes(dependency) { const pack = getPack(); if (!pack) return false; const { dependencies = {}, devDependencies = {} } = pack; const allDependencies = { ...dependencies, ...devDependencies }; return dependency in allDependencies; } export function includesStorybook() { return includes('@storybook/react') || includes('@storybook/svelte') || includes('storybook'); } export function includesSvelteKit() { return includes('@sveltejs/kit'); } export function includesTypeScript() { return includes('typescript'); } export function includesTailwind() { return includes('tailwindcss'); }