{"id":20691,"library":"vitefu","title":"vitefu","description":"vitefu provides utilities for building frameworks with Vite, including `crawlFrameworkPkgs` to scan dependencies and `isDepExternaled` to check externalization status. Current stable version is 1.1.3, released in March 2025. It supports Vite 3–8 as peer dependencies and is updated regularly (multiple releases per year). Key differentiators: wraps Vite's internal logic for framework authors, handles workspace crawling, and is used by SvelteKit and Astro. It ships TypeScript types and ESM/CJS exports.","status":"active","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/svitejs/vitefu","tags":["javascript","vite","framework","utilities","typescript"],"install":[{"cmd":"npm install vitefu","lang":"bash","label":"npm"},{"cmd":"yarn add vitefu","lang":"bash","label":"yarn"},{"cmd":"pnpm add vitefu","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; all utilities rely on Vite's internal APIs for dependency crawling and externalization checks.","package":"vite","optional":false}],"imports":[{"note":"Named export; default export does not exist. Works in both ESM and CJS.","wrong":"import crawlFrameworkPkgs from 'vitefu'","symbol":"crawlFrameworkPkgs","correct":"import { crawlFrameworkPkgs } from 'vitefu'"},{"note":"CJS require is deprecated; use ESM imports. Named export only.","wrong":"const isDepExternaled = require('vitefu').isDepExternaled","symbol":"isDepExternaled","correct":"import { isDepExternaled } from 'vitefu'"},{"note":"Function name is findDepPkgJsonPath, not findAllPkgJsonPaths. Use named import.","wrong":"import { findAllPkgJsonPaths } from 'vitefu'","symbol":"findDepPkgJsonPath","correct":"import { findDepPkgJsonPath } from 'vitefu'"}],"quickstart":{"code":"import { crawlFrameworkPkgs } from 'vitefu';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  optimizeDeps: {\n    include: [],\n  },\n  ssr: {\n    external: [],\n  },\n  async configResolved(config) {\n    const { optimizedDeps, ssr } = await crawlFrameworkPkgs({\n      root: __dirname,\n      viteConfig: config,\n      frameworkPkg: 'my-framework',\n    });\n    config.optimizeDeps.include = optimizedDeps;\n    config.ssr.external = ssr.external;\n  },\n});","lang":"typescript","description":"Demonstrates using crawlFrameworkPkgs to include framework dependencies for optimization and SSR externalization in a Vite config."},"warnings":[{"fix":"Upgrade to v1.1.3 or later, or sort arrays manually.","message":"crawlFrameworkPkgs result arrays are sorted deterministically only since v1.1.3; earlier versions may produce non-deterministic order.","severity":"gotcha","affected_versions":"<1.1.3"},{"fix":"Ensure workspaceRoot points to the root of your monorepo and that private packages have package.json with devDependencies.","message":"workspaceRoot option in crawlFrameworkPkgs introduced in v1.1.0; it enables crawling devDependencies of local workspace private packages, but may require proper workspace configuration.","severity":"gotcha","affected_versions":">=1.1.0"},{"fix":"Upgrade to v1.0.6 or later, or convert boolean ssr.external to array manually.","message":"isDepExternaled may not handle ssr.external: true (boolean) correctly before v1.0.6; it expects an array of strings.","severity":"gotcha","affected_versions":"<1.0.6"},{"fix":"Wrap initialization in async function if you need top-level await.","message":"v1.0.0 removed top-level await to allow future compatibility with require() of ESM code. If you depend on top-level await, this breaks.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade to v0.2.5 or later.","message":"findDepPkgJsonPath implementation changed in v0.2.5 to align with Vite; older versions may return inconsistent paths compared to Vite's own resolution.","severity":"gotcha","affected_versions":"<0.2.5"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Move the call inside the 'configResolved' hook as shown in the quickstart.","cause":"crawlFrameworkPkgs called before Vite config is resolved (e.g., in config instead of configResolved hook).","error":"TypeError: Cannot destructure property 'optimizedDeps' of (intermediate value) as it is undefined."},{"fix":"Upgrade to v1.0.6+ which gracefully handles missing package.json, or ensure root has a package.json.","cause":"crawlFrameworkPkgs expects a package.json at the root; before v1.0.6, missing package.json caused an error.","error":"Error: Failed to crawl framework packages: ENOENT: no such file or directory, open '.../package.json'."},{"fix":"Run npm install vitefu (or yarn/pnpm add vitefu). It requires Vite as a peer dependency.","cause":"vitefu is not installed or not in node_modules.","error":"Module not found: Can't resolve 'vitefu'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}