rwsdk
Version:
Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime
54 lines (53 loc) • 2.33 kB
text/typescript
type OptimizeDepsConfig = {
optimizeDeps?: {
exclude?: string[];
};
environments?: Record<string, {
optimizeDeps?: {
exclude?: string[];
};
}>;
};
/**
* Collect `optimizeDeps.exclude` patterns from the root config and from every
* environment config into a single, deduplicated list.
*/
export declare function getOptimizeDepsExcludePatterns(config: OptimizeDepsConfig): string[];
/**
* Collect `optimizeDeps.exclude` patterns grouped by Vite environment.
*
* Root-level excludes apply to every environment. Per-environment excludes
* apply only to that environment. When no environments are configured (e.g.
* Vite 7), the known RedwoodSDK environments (`client`, `ssr`, `worker`) are
* populated with the root-level patterns.
*/
export declare function getOptimizeDepsExcludePatternsByEnv(config: OptimizeDepsConfig): Record<string, string[]>;
/**
* Resolve per-environment `optimizeDeps.exclude` patterns into absolute
* filesystem roots. Each environment is resolved with the environment-aware
* resolver that matches its execution context.
*/
export declare function resolveOptimizeDepsExcludesByEnv(patternsByEnv: Record<string, string[]>, projectRootDir: string): Record<string, string[]>;
/**
* Resolve entries from Vite's `optimizeDeps.exclude` into absolute filesystem
* roots that can be matched against discovered directive files.
*
* Supports:
* - Bare package names (`my-ui-lib`)
* - Scoped packages (`@scope/pkg`)
* - Package subpaths (`my-ui-lib/components`)
* - Relative paths (`./packages/my-ui-lib`)
* - Absolute paths
*
* Symlinked packages (e.g. `file:./packages/my-ui-lib`) are resolved to their
* real location on disk, so source files are matched even though the import
* specifier goes through `node_modules`.
*
* Each pattern is resolved through RedwoodSDK's environment-aware resolvers so
* that packages with environment-specific exports are located correctly for the
* client, SSR, and worker environments. The resolved roots from all
* environments are unioned together.
*/
export declare function resolveOptimizeDepsExcludes(excludes: string[], projectRootDir: string): string[];
export declare function isExcludedFromOptimization(file: string, excludedRoots: string[], projectRootDir?: string): boolean;
export {};