tailwind-styled-v4 5.1.16 → 5.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atomic.js +16 -4
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +13 -2
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +80 -68
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +77 -66
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +84 -4
- package/dist/compiler.d.ts +84 -4
- package/dist/compiler.js +245 -15
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +240 -14
- package/dist/compiler.mjs.map +1 -1
- package/dist/engine.js +209 -167
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +200 -159
- package/dist/engine.mjs.map +1 -1
- package/dist/index.browser.mjs +0 -3
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -3
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +16 -0
- package/dist/next.d.ts +16 -0
- package/dist/next.js +458 -158
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +454 -154
- package/dist/next.mjs.map +1 -1
- package/dist/runtime.js +0 -3
- package/dist/runtime.js.map +1 -1
- package/dist/runtime.mjs +0 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/shared.js +106 -64
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +101 -60
- package/dist/shared.mjs.map +1 -1
- package/dist/theme.js +0 -3
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +0 -3
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +94 -52
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +92 -51
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +80 -68
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +77 -66
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +172 -130
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +166 -125
- package/dist/vite.mjs.map +1 -1
- package/dist/webpackLoader.js +28 -10
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +26 -9
- package/dist/webpackLoader.mjs.map +1 -1
- package/package.json +1 -1
package/dist/compiler.d.mts
CHANGED
|
@@ -2878,6 +2878,66 @@ declare function validateCssOutput(css: string): string;
|
|
|
2878
2878
|
*/
|
|
2879
2879
|
declare function getCompilerDiagnostics(): string;
|
|
2880
2880
|
|
|
2881
|
+
/**
|
|
2882
|
+
* tailwind-styled-v4 — Route class attribution via static import graph
|
|
2883
|
+
*
|
|
2884
|
+
* Per-route CSS splitting yang sesungguhnya: bukan cuma "semua classes jadi
|
|
2885
|
+
* satu bucket __global", tapi exclusive-per-route classes vs shared classes.
|
|
2886
|
+
*
|
|
2887
|
+
* KENAPA INI BISA DIBANGUN SEKARANG (sebelumnya ditandai "butuh import-graph
|
|
2888
|
+
* tracing yang belum ada"): scanWorkspace() Rust SUDAH balikin classes
|
|
2889
|
+
* per-file (ScannedFile { file, classes, hash }) — yang belum ada cuma
|
|
2890
|
+
* relasi "file A import file B"-nya. Itu yang dibangun di sini, di sisi TS,
|
|
2891
|
+
* pakai static regex-based import extractor + resolusi tsconfig `paths`.
|
|
2892
|
+
* Tidak perlu native binding baru / rebuild Rust.
|
|
2893
|
+
*
|
|
2894
|
+
* ALGORITMA:
|
|
2895
|
+
* 1. Build adjacency list (file -> Set<file yang di-import>), regex-based,
|
|
2896
|
+
* dibatasi ke file yang ada di dalam srcDir saja (bare/node_modules
|
|
2897
|
+
* imports diabaikan — di luar scope atribusi route).
|
|
2898
|
+
* 2. Entry point per route = file yang match `app/.../page.{tsx,ts,jsx,js}`
|
|
2899
|
+
* (sama heuristik dengan fileToRoute() di index.ts).
|
|
2900
|
+
* 3. BFS dari tiap entry -> reachable file set untuk route itu.
|
|
2901
|
+
* 4. Reverse: untuk tiap file, hitung berapa route yang bisa menjangkaunya.
|
|
2902
|
+
* - Tepat 1 route -> classes file itu eksklusif ke route tersebut.
|
|
2903
|
+
* - 0 atau 2+ route (termasuk layout/loading/error/template/
|
|
2904
|
+
* not-found/default, dan file yang gak ke-reach sama sekali —
|
|
2905
|
+
* misal dead code atau import yang gak ke-detect static parser
|
|
2906
|
+
* ini, contoh: import dinamis berbasis variable) -> fallback ke
|
|
2907
|
+
* "__global". Default selalu aman (gak pernah salah atribusi ke
|
|
2908
|
+
* route yang salah), cuma bisa under-split di dynamic-import edge
|
|
2909
|
+
* case.
|
|
2910
|
+
*
|
|
2911
|
+
* KETERBATASAN YANG DISADARI (belum di-handle, scope sengaja dibatasi):
|
|
2912
|
+
* - Nested layout HARUSNYA cuma global utk subtree-nya (bukan whole app),
|
|
2913
|
+
* tapi di sini SEMUA layout/loading/error/template selalu -> __global.
|
|
2914
|
+
* Konservatif (over-share ke global), tidak pernah salah, tapi belum
|
|
2915
|
+
* "true" subtree-scoped splitting.
|
|
2916
|
+
* - Dynamic import dengan path non-literal (`import(someVar)`) tidak bisa
|
|
2917
|
+
* di-resolve static parser ini — file tujuan jadi unreachable -> jatuh
|
|
2918
|
+
* ke __global (aman, tapi gak ke-split).
|
|
2919
|
+
* - Hanya resolve alias dari tsconfig.json/jsconfig.json root project
|
|
2920
|
+
* (compilerOptions.paths + baseUrl). Alias yang didefinisikan di tempat
|
|
2921
|
+
* lain (custom resolver webpack/turbopack) tidak ke-detect.
|
|
2922
|
+
*/
|
|
2923
|
+
interface ScannedFileInput {
|
|
2924
|
+
file: string;
|
|
2925
|
+
classes: string[];
|
|
2926
|
+
}
|
|
2927
|
+
interface RouteClassBuckets {
|
|
2928
|
+
/** route path ("/", "/docs", "/blog/[slug]", ...) -> classes eksklusif route itu */
|
|
2929
|
+
routes: Map<string, Set<string>>;
|
|
2930
|
+
/** classes shared 2+ route, layout/loading/error/template, atau unresolved */
|
|
2931
|
+
global: Set<string>;
|
|
2932
|
+
}
|
|
2933
|
+
/**
|
|
2934
|
+
* Build route -> exclusive-classes map + global fallback bucket, dari hasil
|
|
2935
|
+
* scanWorkspace() (files[].classes) plus static import graph antar file.
|
|
2936
|
+
*/
|
|
2937
|
+
declare function buildRouteClassBuckets(root: string, srcDir: string, files: ScannedFileInput[]): RouteClassBuckets;
|
|
2938
|
+
/** Slugify route path jadi nama file CSS yang aman. "/" -> "root", "/blog/[slug]" -> "blog__slug_". */
|
|
2939
|
+
declare function routeToCssFilename(route: string): string;
|
|
2940
|
+
|
|
2881
2941
|
/**
|
|
2882
2942
|
* tailwind-styled-v5 — Compiler Main Entry Point
|
|
2883
2943
|
*
|
|
@@ -2936,9 +2996,29 @@ declare const runLoaderTransform: (ctx: {
|
|
|
2936
2996
|
declare const shouldSkipFile: (filepath: string) => boolean;
|
|
2937
2997
|
declare const fileToRoute: (filepath: string) => string | null;
|
|
2938
2998
|
declare const getAllRoutes: () => string[];
|
|
2939
|
-
declare const getRouteClasses: (
|
|
2940
|
-
|
|
2941
|
-
|
|
2999
|
+
declare const getRouteClasses: (route: string) => Set<string>;
|
|
3000
|
+
/**
|
|
3001
|
+
* Semua classes yang ke-register dari semua file + registerGlobalClasses(),
|
|
3002
|
+
* tanpa peduli route. TIDAK dipakai untuk manifest per-route (lihat
|
|
3003
|
+
* withTailwindStyled.ts — manifest ditulis dari `result.files` hasil
|
|
3004
|
+
* scanWorkspace() + buildRouteClassBuckets() di ./routeGraph.ts, karena
|
|
3005
|
+
* registry ini baru ke-isi progresif saat bundler benar-benar meng-compile
|
|
3006
|
+
* file, sementara manifest ditulis di config-eval time, sebelum itu).
|
|
3007
|
+
* getRouteClasses()/fileToRoute() di bawah juga TIDAK dipakai jalur itu —
|
|
3008
|
+
* cuma mengenali page.tsx/layout.tsx/loading.tsx/error.tsx secara langsung,
|
|
3009
|
+
* gak ngikutin import transitif. Per-route splitting yang sesungguhnya
|
|
3010
|
+
* (import-graph tracing: file mana di-import transitif oleh route mana)
|
|
3011
|
+
* sudah ada — lihat ./routeGraph.ts (buildRouteClassBuckets), dipanggil
|
|
3012
|
+
* dari withTailwindStyled.ts, bukan dari registry/fungsi di bawah ini.
|
|
3013
|
+
* Fungsi-fungsi di bawah dipertahankan untuk konsumer lain (CLI `tw split`,
|
|
3014
|
+
* dll) yang mungkin masih bergantung pada registry incremental ini.
|
|
3015
|
+
*/
|
|
3016
|
+
declare const getAllRegisteredClasses: () => Set<string>;
|
|
3017
|
+
/** Dipanggil oleh webpackLoader.ts/turbopackLoader.ts setiap file di-transform. */
|
|
3018
|
+
declare const registerFileClasses: (filepath: string, classes: string[]) => void;
|
|
3019
|
+
declare const registerGlobalClasses: (classes: string[]) => void;
|
|
3020
|
+
/** Reset registry — dipakai test, atau awal compilation run kalau perlu state bersih. */
|
|
3021
|
+
declare const resetRouteClassRegistry: () => void;
|
|
2942
3022
|
declare const getIncrementalEngine: () => IncrementalEngine;
|
|
2943
3023
|
declare const resetIncrementalEngine: () => void;
|
|
2944
3024
|
declare class IncrementalEngine {
|
|
@@ -2999,4 +3079,4 @@ declare const extractTwStateConfigs: (source: string, filename: string) => TwSta
|
|
|
2999
3079
|
declare const generateStaticStateCss: (entries: TwStateConfigEntry[], resolvedCssOrThemeConfig?: string | Record<string, unknown>) => GeneratedStateRule[];
|
|
3000
3080
|
declare const extractAndGenerateStateCss: (source: string, filename: string) => GeneratedStateRule[];
|
|
3001
3081
|
|
|
3002
|
-
export { type BatchExtractResult, BucketEngine, type CacheOptimizationHints, type CacheStatistics, type ClassExtractResult, type ClassUsageItem, type ClassifyResult, type CompiledAnimation, type CompiledCssRule, type CompiledTheme, type ComponentMetadata, type ConflictGroupInfo, type ContainerConfig, type CssCompileResult, type DeadCodeResult, type FileChangeEvent, type FileDiff, type FileFingerprint, type GeneratedStateCss, type GeneratedStateRule, type HoistResult, type IncrementalDiffResult, IncrementalEngine, type KeyExpiration, type LoaderOutput, type MemoryRecommendations, type MemoryStats, type MergeResult, type NativeBridge, type NativeRscResult, type NativeTransformResult, type OptimalCacheConfig, type OptimalCacheConfigAnalysis, type PoolInfo, type PrefilterFileResult, type ProcessedCssResult, type ProcessedFileChange, type PruneResult, type PubSubMessage, type RebuildWorkspaceResult, type RedisCacheConfig, type RedisClusterNode, type RedisClusterStatus, type RedisPoolStats, type RegistrySnapshot, type ResolvedClassName, type ResolvedVariantConfig, type ResolverPoolStatsResult, type SafelistCheckResult, type ScanFileResult, type ScanWorkspaceResult, type StateCssConfig, type StateInjectionResult, type StaticStateCssInput, type ThemeCascadeResult, type ThemeValidationResult, type TwMergeOptions, type TwStateConfigEntry, type VariantTableResult, type WatchEvent, type WatchHandle, type WatchStats, type Week6FeaturesStatus, adaptNativeResult, analyzeClassUsageNative, analyzeClasses, analyzeClassesNative, analyzeFile, analyzeRscNative, analyzeVariantUsage, astExtractClasses, atomicRegistrySize, batchExtractClasses, batchExtractClassesNative, bucketSort, buildStyleTag, cachePriority, cacheRead, cacheWrite, checkAgainstSafelist, checkAgainstSafelistNative, classifyAndSortClassesNative, classifyNode, clearAllCaches, clearAtomicRegistry, clearCompileCache, clearCssGenCache, clearParseCache, clearResolveCache, clearResolverPool, clearThemeCache, collectFiles, compileAnimation, compileClass, compileClasses, compileCssFromClasses, compileCssLightning, compileCssNative2, compileKeyframes, compileTheme, compileToCss, compileToCssBatch, compileVariantTableNative, computeIncrementalDiff, createFingerprint, detectConflicts, detectDeadCode, diffClassLists, eliminateDeadCss, eliminateDeadCssNative, emitPluginHook, estimateOptimalCacheConfig, estimateOptimalCacheConfigNative, extractAllClasses, extractAndGenerateStateCss, extractAndGenerateStateCssNative, extractClassesFromSource, extractClassesFromSourceNative, extractComponentUsage, extractContainerCssFromSource, extractTwContainerConfigs, extractTwStateConfigs, extractTwStateConfigsNative, fileToRoute, findDeadVariants, generateAtomicCss, generateCss, generateCssBatch, generateCssForClasses, generateCssNative, generateSafelist, generateStaticStateCss, generateStaticStateCssNative, generateSubComponentTypes, getAllRoutes, getBucketEngine, getCacheOptimizationHints, getCacheStatistics, getCacheStats, getCompilationMetrics, getCompilerDiagnostics, getContentPaths, getIncrementalEngine, getMemoryRecommendationsNative, getMemoryStatsNative, getNativeBridge, getPluginHooks, getResolverPoolStats, getRouteClasses, getWatchStats, getWeek6FeaturesStatus, hasTwUsage, hashContent, hoistComponentsNative, idRegistryActiveCount, idRegistryCreate, idRegistryDestroy, idRegistryExport, idRegistryGenerate, idRegistryImport, idRegistryLookup, idRegistryNext, idRegistryReset, idRegistrySnapshot, injectClientDirective, injectServerOnlyComment, injectStateHash, isAlreadyTransformed, isWatchRunning, layoutClassesToCss, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarationsNative, minifyCss, normalizeAndDedupClasses, normalizeClasses, optimizeCssNative, parseAtomicClass, parseClass, parseClasses, pollWatchEvents, processFileChange, processTailwindCssLightning, propertyIdToString, pruneStaleCacheEntries, rebuildWorkspaceResult, redisCacheClear, redisCacheHitRate, redisCacheKeyCount, redisCacheSize, redisCacheSync, redisClusterStatus, redisDelete, redisDiagnose, redisDisableCacheWarming, redisDisableCluster, redisDisablePersistence, redisEnableCacheWarming, redisEnableCluster, redisEnablePersistence, redisExists, redisExpirationGet, redisExpirationSet, redisFlushAll, redisFlushDb, redisGet, redisGetEvictionPolicy, redisInfo, redisMemoryStats, redisMget, redisMonitor, redisMset, redisOptimizeMemory, redisPing, redisPoolConnect, redisPoolReconnect, redisPoolStats, redisPublish, redisReplicate, redisReplicationStatus, redisSet, redisSetEvictionPolicy, redisSnapshot, redisSubscribe, registerFileClasses, registerGlobalClasses, registerPluginHook, registerPropertyName, registerValueName, resetBucketEngine, resetCacheStats, resetCompilationMetrics, resetIncrementalEngine, resetMemoryStats, resetNativeBridgeCache, resetResolverPoolStats, resolveCascade, resolveClassNames, resolveColorCached, resolveConflictGroup, resolveFontSizeCached, resolveSimpleVariants, resolveSpacingCached, resolveThemeValue, resolveVariants, reverseLookupProperty, reverseLookupValue, runCssPipeline, runElimination, runLoaderTransform, scanCacheOptimizations, scanFile, scanFileNative, scanFilesBatchNative, scanProjectUsage, scanWorkspace, shouldProcess, shouldSkipFile, startWatch, stopWatch, toAtomicClasses, transformSource, twMerge, twMergeMany, twMergeManyWithSeparator, twMergeRaw, twMergeWithSeparator, unregisterPluginHook, validateCssOutput, validateThemeConfig, valueIdToString, walkAndPrefilterSourceFiles, watchAddPattern, watchClearAll, watchEventTypeToString, watchGetActiveHandles, watchPause, watchRemovePattern, watchResume };
|
|
3082
|
+
export { type BatchExtractResult, BucketEngine, type CacheOptimizationHints, type CacheStatistics, type ClassExtractResult, type ClassUsageItem, type ClassifyResult, type CompiledAnimation, type CompiledCssRule, type CompiledTheme, type ComponentMetadata, type ConflictGroupInfo, type ContainerConfig, type CssCompileResult, type DeadCodeResult, type FileChangeEvent, type FileDiff, type FileFingerprint, type GeneratedStateCss, type GeneratedStateRule, type HoistResult, type IncrementalDiffResult, IncrementalEngine, type KeyExpiration, type LoaderOutput, type MemoryRecommendations, type MemoryStats, type MergeResult, type NativeBridge, type NativeRscResult, type NativeTransformResult, type OptimalCacheConfig, type OptimalCacheConfigAnalysis, type PoolInfo, type PrefilterFileResult, type ProcessedCssResult, type ProcessedFileChange, type PruneResult, type PubSubMessage, type RebuildWorkspaceResult, type RedisCacheConfig, type RedisClusterNode, type RedisClusterStatus, type RedisPoolStats, type RegistrySnapshot, type ResolvedClassName, type ResolvedVariantConfig, type ResolverPoolStatsResult, type RouteClassBuckets, type SafelistCheckResult, type ScanFileResult, type ScanWorkspaceResult, type ScannedFileInput, type StateCssConfig, type StateInjectionResult, type StaticStateCssInput, type ThemeCascadeResult, type ThemeValidationResult, type TwMergeOptions, type TwStateConfigEntry, type VariantTableResult, type WatchEvent, type WatchHandle, type WatchStats, type Week6FeaturesStatus, adaptNativeResult, analyzeClassUsageNative, analyzeClasses, analyzeClassesNative, analyzeFile, analyzeRscNative, analyzeVariantUsage, astExtractClasses, atomicRegistrySize, batchExtractClasses, batchExtractClassesNative, bucketSort, buildRouteClassBuckets, buildStyleTag, cachePriority, cacheRead, cacheWrite, checkAgainstSafelist, checkAgainstSafelistNative, classifyAndSortClassesNative, classifyNode, clearAllCaches, clearAtomicRegistry, clearCompileCache, clearCssGenCache, clearParseCache, clearResolveCache, clearResolverPool, clearThemeCache, collectFiles, compileAnimation, compileClass, compileClasses, compileCssFromClasses, compileCssLightning, compileCssNative2, compileKeyframes, compileTheme, compileToCss, compileToCssBatch, compileVariantTableNative, computeIncrementalDiff, createFingerprint, detectConflicts, detectDeadCode, diffClassLists, eliminateDeadCss, eliminateDeadCssNative, emitPluginHook, estimateOptimalCacheConfig, estimateOptimalCacheConfigNative, extractAllClasses, extractAndGenerateStateCss, extractAndGenerateStateCssNative, extractClassesFromSource, extractClassesFromSourceNative, extractComponentUsage, extractContainerCssFromSource, extractTwContainerConfigs, extractTwStateConfigs, extractTwStateConfigsNative, fileToRoute, findDeadVariants, generateAtomicCss, generateCss, generateCssBatch, generateCssForClasses, generateCssNative, generateSafelist, generateStaticStateCss, generateStaticStateCssNative, generateSubComponentTypes, getAllRegisteredClasses, getAllRoutes, getBucketEngine, getCacheOptimizationHints, getCacheStatistics, getCacheStats, getCompilationMetrics, getCompilerDiagnostics, getContentPaths, getIncrementalEngine, getMemoryRecommendationsNative, getMemoryStatsNative, getNativeBridge, getPluginHooks, getResolverPoolStats, getRouteClasses, getWatchStats, getWeek6FeaturesStatus, hasTwUsage, hashContent, hoistComponentsNative, idRegistryActiveCount, idRegistryCreate, idRegistryDestroy, idRegistryExport, idRegistryGenerate, idRegistryImport, idRegistryLookup, idRegistryNext, idRegistryReset, idRegistrySnapshot, injectClientDirective, injectServerOnlyComment, injectStateHash, isAlreadyTransformed, isWatchRunning, layoutClassesToCss, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarationsNative, minifyCss, normalizeAndDedupClasses, normalizeClasses, optimizeCssNative, parseAtomicClass, parseClass, parseClasses, pollWatchEvents, processFileChange, processTailwindCssLightning, propertyIdToString, pruneStaleCacheEntries, rebuildWorkspaceResult, redisCacheClear, redisCacheHitRate, redisCacheKeyCount, redisCacheSize, redisCacheSync, redisClusterStatus, redisDelete, redisDiagnose, redisDisableCacheWarming, redisDisableCluster, redisDisablePersistence, redisEnableCacheWarming, redisEnableCluster, redisEnablePersistence, redisExists, redisExpirationGet, redisExpirationSet, redisFlushAll, redisFlushDb, redisGet, redisGetEvictionPolicy, redisInfo, redisMemoryStats, redisMget, redisMonitor, redisMset, redisOptimizeMemory, redisPing, redisPoolConnect, redisPoolReconnect, redisPoolStats, redisPublish, redisReplicate, redisReplicationStatus, redisSet, redisSetEvictionPolicy, redisSnapshot, redisSubscribe, registerFileClasses, registerGlobalClasses, registerPluginHook, registerPropertyName, registerValueName, resetBucketEngine, resetCacheStats, resetCompilationMetrics, resetIncrementalEngine, resetMemoryStats, resetNativeBridgeCache, resetResolverPoolStats, resetRouteClassRegistry, resolveCascade, resolveClassNames, resolveColorCached, resolveConflictGroup, resolveFontSizeCached, resolveSimpleVariants, resolveSpacingCached, resolveThemeValue, resolveVariants, reverseLookupProperty, reverseLookupValue, routeToCssFilename, runCssPipeline, runElimination, runLoaderTransform, scanCacheOptimizations, scanFile, scanFileNative, scanFilesBatchNative, scanProjectUsage, scanWorkspace, shouldProcess, shouldSkipFile, startWatch, stopWatch, toAtomicClasses, transformSource, twMerge, twMergeMany, twMergeManyWithSeparator, twMergeRaw, twMergeWithSeparator, unregisterPluginHook, validateCssOutput, validateThemeConfig, valueIdToString, walkAndPrefilterSourceFiles, watchAddPattern, watchClearAll, watchEventTypeToString, watchGetActiveHandles, watchPause, watchRemovePattern, watchResume };
|
package/dist/compiler.d.ts
CHANGED
|
@@ -2878,6 +2878,66 @@ declare function validateCssOutput(css: string): string;
|
|
|
2878
2878
|
*/
|
|
2879
2879
|
declare function getCompilerDiagnostics(): string;
|
|
2880
2880
|
|
|
2881
|
+
/**
|
|
2882
|
+
* tailwind-styled-v4 — Route class attribution via static import graph
|
|
2883
|
+
*
|
|
2884
|
+
* Per-route CSS splitting yang sesungguhnya: bukan cuma "semua classes jadi
|
|
2885
|
+
* satu bucket __global", tapi exclusive-per-route classes vs shared classes.
|
|
2886
|
+
*
|
|
2887
|
+
* KENAPA INI BISA DIBANGUN SEKARANG (sebelumnya ditandai "butuh import-graph
|
|
2888
|
+
* tracing yang belum ada"): scanWorkspace() Rust SUDAH balikin classes
|
|
2889
|
+
* per-file (ScannedFile { file, classes, hash }) — yang belum ada cuma
|
|
2890
|
+
* relasi "file A import file B"-nya. Itu yang dibangun di sini, di sisi TS,
|
|
2891
|
+
* pakai static regex-based import extractor + resolusi tsconfig `paths`.
|
|
2892
|
+
* Tidak perlu native binding baru / rebuild Rust.
|
|
2893
|
+
*
|
|
2894
|
+
* ALGORITMA:
|
|
2895
|
+
* 1. Build adjacency list (file -> Set<file yang di-import>), regex-based,
|
|
2896
|
+
* dibatasi ke file yang ada di dalam srcDir saja (bare/node_modules
|
|
2897
|
+
* imports diabaikan — di luar scope atribusi route).
|
|
2898
|
+
* 2. Entry point per route = file yang match `app/.../page.{tsx,ts,jsx,js}`
|
|
2899
|
+
* (sama heuristik dengan fileToRoute() di index.ts).
|
|
2900
|
+
* 3. BFS dari tiap entry -> reachable file set untuk route itu.
|
|
2901
|
+
* 4. Reverse: untuk tiap file, hitung berapa route yang bisa menjangkaunya.
|
|
2902
|
+
* - Tepat 1 route -> classes file itu eksklusif ke route tersebut.
|
|
2903
|
+
* - 0 atau 2+ route (termasuk layout/loading/error/template/
|
|
2904
|
+
* not-found/default, dan file yang gak ke-reach sama sekali —
|
|
2905
|
+
* misal dead code atau import yang gak ke-detect static parser
|
|
2906
|
+
* ini, contoh: import dinamis berbasis variable) -> fallback ke
|
|
2907
|
+
* "__global". Default selalu aman (gak pernah salah atribusi ke
|
|
2908
|
+
* route yang salah), cuma bisa under-split di dynamic-import edge
|
|
2909
|
+
* case.
|
|
2910
|
+
*
|
|
2911
|
+
* KETERBATASAN YANG DISADARI (belum di-handle, scope sengaja dibatasi):
|
|
2912
|
+
* - Nested layout HARUSNYA cuma global utk subtree-nya (bukan whole app),
|
|
2913
|
+
* tapi di sini SEMUA layout/loading/error/template selalu -> __global.
|
|
2914
|
+
* Konservatif (over-share ke global), tidak pernah salah, tapi belum
|
|
2915
|
+
* "true" subtree-scoped splitting.
|
|
2916
|
+
* - Dynamic import dengan path non-literal (`import(someVar)`) tidak bisa
|
|
2917
|
+
* di-resolve static parser ini — file tujuan jadi unreachable -> jatuh
|
|
2918
|
+
* ke __global (aman, tapi gak ke-split).
|
|
2919
|
+
* - Hanya resolve alias dari tsconfig.json/jsconfig.json root project
|
|
2920
|
+
* (compilerOptions.paths + baseUrl). Alias yang didefinisikan di tempat
|
|
2921
|
+
* lain (custom resolver webpack/turbopack) tidak ke-detect.
|
|
2922
|
+
*/
|
|
2923
|
+
interface ScannedFileInput {
|
|
2924
|
+
file: string;
|
|
2925
|
+
classes: string[];
|
|
2926
|
+
}
|
|
2927
|
+
interface RouteClassBuckets {
|
|
2928
|
+
/** route path ("/", "/docs", "/blog/[slug]", ...) -> classes eksklusif route itu */
|
|
2929
|
+
routes: Map<string, Set<string>>;
|
|
2930
|
+
/** classes shared 2+ route, layout/loading/error/template, atau unresolved */
|
|
2931
|
+
global: Set<string>;
|
|
2932
|
+
}
|
|
2933
|
+
/**
|
|
2934
|
+
* Build route -> exclusive-classes map + global fallback bucket, dari hasil
|
|
2935
|
+
* scanWorkspace() (files[].classes) plus static import graph antar file.
|
|
2936
|
+
*/
|
|
2937
|
+
declare function buildRouteClassBuckets(root: string, srcDir: string, files: ScannedFileInput[]): RouteClassBuckets;
|
|
2938
|
+
/** Slugify route path jadi nama file CSS yang aman. "/" -> "root", "/blog/[slug]" -> "blog__slug_". */
|
|
2939
|
+
declare function routeToCssFilename(route: string): string;
|
|
2940
|
+
|
|
2881
2941
|
/**
|
|
2882
2942
|
* tailwind-styled-v5 — Compiler Main Entry Point
|
|
2883
2943
|
*
|
|
@@ -2936,9 +2996,29 @@ declare const runLoaderTransform: (ctx: {
|
|
|
2936
2996
|
declare const shouldSkipFile: (filepath: string) => boolean;
|
|
2937
2997
|
declare const fileToRoute: (filepath: string) => string | null;
|
|
2938
2998
|
declare const getAllRoutes: () => string[];
|
|
2939
|
-
declare const getRouteClasses: (
|
|
2940
|
-
|
|
2941
|
-
|
|
2999
|
+
declare const getRouteClasses: (route: string) => Set<string>;
|
|
3000
|
+
/**
|
|
3001
|
+
* Semua classes yang ke-register dari semua file + registerGlobalClasses(),
|
|
3002
|
+
* tanpa peduli route. TIDAK dipakai untuk manifest per-route (lihat
|
|
3003
|
+
* withTailwindStyled.ts — manifest ditulis dari `result.files` hasil
|
|
3004
|
+
* scanWorkspace() + buildRouteClassBuckets() di ./routeGraph.ts, karena
|
|
3005
|
+
* registry ini baru ke-isi progresif saat bundler benar-benar meng-compile
|
|
3006
|
+
* file, sementara manifest ditulis di config-eval time, sebelum itu).
|
|
3007
|
+
* getRouteClasses()/fileToRoute() di bawah juga TIDAK dipakai jalur itu —
|
|
3008
|
+
* cuma mengenali page.tsx/layout.tsx/loading.tsx/error.tsx secara langsung,
|
|
3009
|
+
* gak ngikutin import transitif. Per-route splitting yang sesungguhnya
|
|
3010
|
+
* (import-graph tracing: file mana di-import transitif oleh route mana)
|
|
3011
|
+
* sudah ada — lihat ./routeGraph.ts (buildRouteClassBuckets), dipanggil
|
|
3012
|
+
* dari withTailwindStyled.ts, bukan dari registry/fungsi di bawah ini.
|
|
3013
|
+
* Fungsi-fungsi di bawah dipertahankan untuk konsumer lain (CLI `tw split`,
|
|
3014
|
+
* dll) yang mungkin masih bergantung pada registry incremental ini.
|
|
3015
|
+
*/
|
|
3016
|
+
declare const getAllRegisteredClasses: () => Set<string>;
|
|
3017
|
+
/** Dipanggil oleh webpackLoader.ts/turbopackLoader.ts setiap file di-transform. */
|
|
3018
|
+
declare const registerFileClasses: (filepath: string, classes: string[]) => void;
|
|
3019
|
+
declare const registerGlobalClasses: (classes: string[]) => void;
|
|
3020
|
+
/** Reset registry — dipakai test, atau awal compilation run kalau perlu state bersih. */
|
|
3021
|
+
declare const resetRouteClassRegistry: () => void;
|
|
2942
3022
|
declare const getIncrementalEngine: () => IncrementalEngine;
|
|
2943
3023
|
declare const resetIncrementalEngine: () => void;
|
|
2944
3024
|
declare class IncrementalEngine {
|
|
@@ -2999,4 +3079,4 @@ declare const extractTwStateConfigs: (source: string, filename: string) => TwSta
|
|
|
2999
3079
|
declare const generateStaticStateCss: (entries: TwStateConfigEntry[], resolvedCssOrThemeConfig?: string | Record<string, unknown>) => GeneratedStateRule[];
|
|
3000
3080
|
declare const extractAndGenerateStateCss: (source: string, filename: string) => GeneratedStateRule[];
|
|
3001
3081
|
|
|
3002
|
-
export { type BatchExtractResult, BucketEngine, type CacheOptimizationHints, type CacheStatistics, type ClassExtractResult, type ClassUsageItem, type ClassifyResult, type CompiledAnimation, type CompiledCssRule, type CompiledTheme, type ComponentMetadata, type ConflictGroupInfo, type ContainerConfig, type CssCompileResult, type DeadCodeResult, type FileChangeEvent, type FileDiff, type FileFingerprint, type GeneratedStateCss, type GeneratedStateRule, type HoistResult, type IncrementalDiffResult, IncrementalEngine, type KeyExpiration, type LoaderOutput, type MemoryRecommendations, type MemoryStats, type MergeResult, type NativeBridge, type NativeRscResult, type NativeTransformResult, type OptimalCacheConfig, type OptimalCacheConfigAnalysis, type PoolInfo, type PrefilterFileResult, type ProcessedCssResult, type ProcessedFileChange, type PruneResult, type PubSubMessage, type RebuildWorkspaceResult, type RedisCacheConfig, type RedisClusterNode, type RedisClusterStatus, type RedisPoolStats, type RegistrySnapshot, type ResolvedClassName, type ResolvedVariantConfig, type ResolverPoolStatsResult, type SafelistCheckResult, type ScanFileResult, type ScanWorkspaceResult, type StateCssConfig, type StateInjectionResult, type StaticStateCssInput, type ThemeCascadeResult, type ThemeValidationResult, type TwMergeOptions, type TwStateConfigEntry, type VariantTableResult, type WatchEvent, type WatchHandle, type WatchStats, type Week6FeaturesStatus, adaptNativeResult, analyzeClassUsageNative, analyzeClasses, analyzeClassesNative, analyzeFile, analyzeRscNative, analyzeVariantUsage, astExtractClasses, atomicRegistrySize, batchExtractClasses, batchExtractClassesNative, bucketSort, buildStyleTag, cachePriority, cacheRead, cacheWrite, checkAgainstSafelist, checkAgainstSafelistNative, classifyAndSortClassesNative, classifyNode, clearAllCaches, clearAtomicRegistry, clearCompileCache, clearCssGenCache, clearParseCache, clearResolveCache, clearResolverPool, clearThemeCache, collectFiles, compileAnimation, compileClass, compileClasses, compileCssFromClasses, compileCssLightning, compileCssNative2, compileKeyframes, compileTheme, compileToCss, compileToCssBatch, compileVariantTableNative, computeIncrementalDiff, createFingerprint, detectConflicts, detectDeadCode, diffClassLists, eliminateDeadCss, eliminateDeadCssNative, emitPluginHook, estimateOptimalCacheConfig, estimateOptimalCacheConfigNative, extractAllClasses, extractAndGenerateStateCss, extractAndGenerateStateCssNative, extractClassesFromSource, extractClassesFromSourceNative, extractComponentUsage, extractContainerCssFromSource, extractTwContainerConfigs, extractTwStateConfigs, extractTwStateConfigsNative, fileToRoute, findDeadVariants, generateAtomicCss, generateCss, generateCssBatch, generateCssForClasses, generateCssNative, generateSafelist, generateStaticStateCss, generateStaticStateCssNative, generateSubComponentTypes, getAllRoutes, getBucketEngine, getCacheOptimizationHints, getCacheStatistics, getCacheStats, getCompilationMetrics, getCompilerDiagnostics, getContentPaths, getIncrementalEngine, getMemoryRecommendationsNative, getMemoryStatsNative, getNativeBridge, getPluginHooks, getResolverPoolStats, getRouteClasses, getWatchStats, getWeek6FeaturesStatus, hasTwUsage, hashContent, hoistComponentsNative, idRegistryActiveCount, idRegistryCreate, idRegistryDestroy, idRegistryExport, idRegistryGenerate, idRegistryImport, idRegistryLookup, idRegistryNext, idRegistryReset, idRegistrySnapshot, injectClientDirective, injectServerOnlyComment, injectStateHash, isAlreadyTransformed, isWatchRunning, layoutClassesToCss, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarationsNative, minifyCss, normalizeAndDedupClasses, normalizeClasses, optimizeCssNative, parseAtomicClass, parseClass, parseClasses, pollWatchEvents, processFileChange, processTailwindCssLightning, propertyIdToString, pruneStaleCacheEntries, rebuildWorkspaceResult, redisCacheClear, redisCacheHitRate, redisCacheKeyCount, redisCacheSize, redisCacheSync, redisClusterStatus, redisDelete, redisDiagnose, redisDisableCacheWarming, redisDisableCluster, redisDisablePersistence, redisEnableCacheWarming, redisEnableCluster, redisEnablePersistence, redisExists, redisExpirationGet, redisExpirationSet, redisFlushAll, redisFlushDb, redisGet, redisGetEvictionPolicy, redisInfo, redisMemoryStats, redisMget, redisMonitor, redisMset, redisOptimizeMemory, redisPing, redisPoolConnect, redisPoolReconnect, redisPoolStats, redisPublish, redisReplicate, redisReplicationStatus, redisSet, redisSetEvictionPolicy, redisSnapshot, redisSubscribe, registerFileClasses, registerGlobalClasses, registerPluginHook, registerPropertyName, registerValueName, resetBucketEngine, resetCacheStats, resetCompilationMetrics, resetIncrementalEngine, resetMemoryStats, resetNativeBridgeCache, resetResolverPoolStats, resolveCascade, resolveClassNames, resolveColorCached, resolveConflictGroup, resolveFontSizeCached, resolveSimpleVariants, resolveSpacingCached, resolveThemeValue, resolveVariants, reverseLookupProperty, reverseLookupValue, runCssPipeline, runElimination, runLoaderTransform, scanCacheOptimizations, scanFile, scanFileNative, scanFilesBatchNative, scanProjectUsage, scanWorkspace, shouldProcess, shouldSkipFile, startWatch, stopWatch, toAtomicClasses, transformSource, twMerge, twMergeMany, twMergeManyWithSeparator, twMergeRaw, twMergeWithSeparator, unregisterPluginHook, validateCssOutput, validateThemeConfig, valueIdToString, walkAndPrefilterSourceFiles, watchAddPattern, watchClearAll, watchEventTypeToString, watchGetActiveHandles, watchPause, watchRemovePattern, watchResume };
|
|
3082
|
+
export { type BatchExtractResult, BucketEngine, type CacheOptimizationHints, type CacheStatistics, type ClassExtractResult, type ClassUsageItem, type ClassifyResult, type CompiledAnimation, type CompiledCssRule, type CompiledTheme, type ComponentMetadata, type ConflictGroupInfo, type ContainerConfig, type CssCompileResult, type DeadCodeResult, type FileChangeEvent, type FileDiff, type FileFingerprint, type GeneratedStateCss, type GeneratedStateRule, type HoistResult, type IncrementalDiffResult, IncrementalEngine, type KeyExpiration, type LoaderOutput, type MemoryRecommendations, type MemoryStats, type MergeResult, type NativeBridge, type NativeRscResult, type NativeTransformResult, type OptimalCacheConfig, type OptimalCacheConfigAnalysis, type PoolInfo, type PrefilterFileResult, type ProcessedCssResult, type ProcessedFileChange, type PruneResult, type PubSubMessage, type RebuildWorkspaceResult, type RedisCacheConfig, type RedisClusterNode, type RedisClusterStatus, type RedisPoolStats, type RegistrySnapshot, type ResolvedClassName, type ResolvedVariantConfig, type ResolverPoolStatsResult, type RouteClassBuckets, type SafelistCheckResult, type ScanFileResult, type ScanWorkspaceResult, type ScannedFileInput, type StateCssConfig, type StateInjectionResult, type StaticStateCssInput, type ThemeCascadeResult, type ThemeValidationResult, type TwMergeOptions, type TwStateConfigEntry, type VariantTableResult, type WatchEvent, type WatchHandle, type WatchStats, type Week6FeaturesStatus, adaptNativeResult, analyzeClassUsageNative, analyzeClasses, analyzeClassesNative, analyzeFile, analyzeRscNative, analyzeVariantUsage, astExtractClasses, atomicRegistrySize, batchExtractClasses, batchExtractClassesNative, bucketSort, buildRouteClassBuckets, buildStyleTag, cachePriority, cacheRead, cacheWrite, checkAgainstSafelist, checkAgainstSafelistNative, classifyAndSortClassesNative, classifyNode, clearAllCaches, clearAtomicRegistry, clearCompileCache, clearCssGenCache, clearParseCache, clearResolveCache, clearResolverPool, clearThemeCache, collectFiles, compileAnimation, compileClass, compileClasses, compileCssFromClasses, compileCssLightning, compileCssNative2, compileKeyframes, compileTheme, compileToCss, compileToCssBatch, compileVariantTableNative, computeIncrementalDiff, createFingerprint, detectConflicts, detectDeadCode, diffClassLists, eliminateDeadCss, eliminateDeadCssNative, emitPluginHook, estimateOptimalCacheConfig, estimateOptimalCacheConfigNative, extractAllClasses, extractAndGenerateStateCss, extractAndGenerateStateCssNative, extractClassesFromSource, extractClassesFromSourceNative, extractComponentUsage, extractContainerCssFromSource, extractTwContainerConfigs, extractTwStateConfigs, extractTwStateConfigsNative, fileToRoute, findDeadVariants, generateAtomicCss, generateCss, generateCssBatch, generateCssForClasses, generateCssNative, generateSafelist, generateStaticStateCss, generateStaticStateCssNative, generateSubComponentTypes, getAllRegisteredClasses, getAllRoutes, getBucketEngine, getCacheOptimizationHints, getCacheStatistics, getCacheStats, getCompilationMetrics, getCompilerDiagnostics, getContentPaths, getIncrementalEngine, getMemoryRecommendationsNative, getMemoryStatsNative, getNativeBridge, getPluginHooks, getResolverPoolStats, getRouteClasses, getWatchStats, getWeek6FeaturesStatus, hasTwUsage, hashContent, hoistComponentsNative, idRegistryActiveCount, idRegistryCreate, idRegistryDestroy, idRegistryExport, idRegistryGenerate, idRegistryImport, idRegistryLookup, idRegistryNext, idRegistryReset, idRegistrySnapshot, injectClientDirective, injectServerOnlyComment, injectStateHash, isAlreadyTransformed, isWatchRunning, layoutClassesToCss, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarationsNative, minifyCss, normalizeAndDedupClasses, normalizeClasses, optimizeCssNative, parseAtomicClass, parseClass, parseClasses, pollWatchEvents, processFileChange, processTailwindCssLightning, propertyIdToString, pruneStaleCacheEntries, rebuildWorkspaceResult, redisCacheClear, redisCacheHitRate, redisCacheKeyCount, redisCacheSize, redisCacheSync, redisClusterStatus, redisDelete, redisDiagnose, redisDisableCacheWarming, redisDisableCluster, redisDisablePersistence, redisEnableCacheWarming, redisEnableCluster, redisEnablePersistence, redisExists, redisExpirationGet, redisExpirationSet, redisFlushAll, redisFlushDb, redisGet, redisGetEvictionPolicy, redisInfo, redisMemoryStats, redisMget, redisMonitor, redisMset, redisOptimizeMemory, redisPing, redisPoolConnect, redisPoolReconnect, redisPoolStats, redisPublish, redisReplicate, redisReplicationStatus, redisSet, redisSetEvictionPolicy, redisSnapshot, redisSubscribe, registerFileClasses, registerGlobalClasses, registerPluginHook, registerPropertyName, registerValueName, resetBucketEngine, resetCacheStats, resetCompilationMetrics, resetIncrementalEngine, resetMemoryStats, resetNativeBridgeCache, resetResolverPoolStats, resetRouteClassRegistry, resolveCascade, resolveClassNames, resolveColorCached, resolveConflictGroup, resolveFontSizeCached, resolveSimpleVariants, resolveSpacingCached, resolveThemeValue, resolveVariants, reverseLookupProperty, reverseLookupValue, routeToCssFilename, runCssPipeline, runElimination, runLoaderTransform, scanCacheOptimizations, scanFile, scanFileNative, scanFilesBatchNative, scanProjectUsage, scanWorkspace, shouldProcess, shouldSkipFile, startWatch, stopWatch, toAtomicClasses, transformSource, twMerge, twMergeMany, twMergeManyWithSeparator, twMergeRaw, twMergeWithSeparator, unregisterPluginHook, validateCssOutput, validateThemeConfig, valueIdToString, walkAndPrefilterSourceFiles, watchAddPattern, watchClearAll, watchEventTypeToString, watchGetActiveHandles, watchPause, watchRemovePattern, watchResume };
|
package/dist/compiler.js
CHANGED
|
@@ -186,7 +186,7 @@ var init_nativeBridge = __esm({
|
|
|
186
186
|
"use strict";
|
|
187
187
|
init_cjs_shims();
|
|
188
188
|
init_src();
|
|
189
|
-
_loadNative = (
|
|
189
|
+
_loadNative = (path5) => require(path5);
|
|
190
190
|
log = (...args) => {
|
|
191
191
|
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
192
192
|
console.log("[compiler:native]", ...args);
|
|
@@ -2031,6 +2031,199 @@ var init_watch = __esm({
|
|
|
2031
2031
|
}
|
|
2032
2032
|
});
|
|
2033
2033
|
|
|
2034
|
+
// packages/domain/compiler/src/routeGraph.ts
|
|
2035
|
+
function deriveRouteFromPageFile(normalizedFile) {
|
|
2036
|
+
const rootMatch = normalizedFile.match(ROOT_PAGE_RE);
|
|
2037
|
+
if (rootMatch) return "/";
|
|
2038
|
+
const match = normalizedFile.match(PAGE_RE);
|
|
2039
|
+
if (!match) return null;
|
|
2040
|
+
const segments = match[1].split("/").filter((s) => !(s.startsWith("(") && s.endsWith(")")));
|
|
2041
|
+
return `/${segments.join("/")}`;
|
|
2042
|
+
}
|
|
2043
|
+
function stripJsonComments(input) {
|
|
2044
|
+
let out = "";
|
|
2045
|
+
let i = 0;
|
|
2046
|
+
let inString = false;
|
|
2047
|
+
let stringChar = "";
|
|
2048
|
+
while (i < input.length) {
|
|
2049
|
+
const ch = input[i];
|
|
2050
|
+
if (inString) {
|
|
2051
|
+
out += ch;
|
|
2052
|
+
if (ch === "\\" && i + 1 < input.length) {
|
|
2053
|
+
out += input[i + 1];
|
|
2054
|
+
i += 2;
|
|
2055
|
+
continue;
|
|
2056
|
+
}
|
|
2057
|
+
if (ch === stringChar) inString = false;
|
|
2058
|
+
i++;
|
|
2059
|
+
continue;
|
|
2060
|
+
}
|
|
2061
|
+
if (ch === '"' || ch === "'") {
|
|
2062
|
+
inString = true;
|
|
2063
|
+
stringChar = ch;
|
|
2064
|
+
out += ch;
|
|
2065
|
+
i++;
|
|
2066
|
+
continue;
|
|
2067
|
+
}
|
|
2068
|
+
if (ch === "/" && input[i + 1] === "/") {
|
|
2069
|
+
while (i < input.length && input[i] !== "\n") i++;
|
|
2070
|
+
continue;
|
|
2071
|
+
}
|
|
2072
|
+
if (ch === "/" && input[i + 1] === "*") {
|
|
2073
|
+
i += 2;
|
|
2074
|
+
while (i < input.length && !(input[i] === "*" && input[i + 1] === "/")) i++;
|
|
2075
|
+
i += 2;
|
|
2076
|
+
continue;
|
|
2077
|
+
}
|
|
2078
|
+
out += ch;
|
|
2079
|
+
i++;
|
|
2080
|
+
}
|
|
2081
|
+
return out;
|
|
2082
|
+
}
|
|
2083
|
+
function loadTsconfigAliases(root) {
|
|
2084
|
+
for (const candidate of ["tsconfig.json", "jsconfig.json"]) {
|
|
2085
|
+
const configPath = import_node_path2.default.join(root, candidate);
|
|
2086
|
+
if (!import_node_fs2.default.existsSync(configPath)) continue;
|
|
2087
|
+
try {
|
|
2088
|
+
const raw = stripJsonComments(import_node_fs2.default.readFileSync(configPath, "utf-8"));
|
|
2089
|
+
const parsed = JSON.parse(raw);
|
|
2090
|
+
const co = parsed.compilerOptions;
|
|
2091
|
+
if (!co?.paths) continue;
|
|
2092
|
+
const baseDir = import_node_path2.default.join(root, co.baseUrl ?? ".");
|
|
2093
|
+
const paths = Object.entries(co.paths).map(([prefix, targets]) => ({
|
|
2094
|
+
prefix: prefix.replace(/\*$/, ""),
|
|
2095
|
+
targets: targets.map((t) => t.replace(/\*$/, ""))
|
|
2096
|
+
}));
|
|
2097
|
+
return { baseDir, paths };
|
|
2098
|
+
} catch {
|
|
2099
|
+
continue;
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
return null;
|
|
2103
|
+
}
|
|
2104
|
+
function resolveSpecifier(specifier, fromFile, aliasInfo) {
|
|
2105
|
+
let candidate = null;
|
|
2106
|
+
if (specifier.startsWith(".")) {
|
|
2107
|
+
candidate = import_node_path2.default.resolve(import_node_path2.default.dirname(fromFile), specifier);
|
|
2108
|
+
} else if (aliasInfo) {
|
|
2109
|
+
for (const { prefix, targets } of aliasInfo.paths) {
|
|
2110
|
+
if (specifier.startsWith(prefix)) {
|
|
2111
|
+
const rest = specifier.slice(prefix.length);
|
|
2112
|
+
candidate = import_node_path2.default.join(aliasInfo.baseDir, targets[0] ?? "", rest);
|
|
2113
|
+
break;
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
if (!candidate) return null;
|
|
2118
|
+
if (/\.(css|scss|sass|less|svg|png|jpe?g|gif|webp|json|woff2?|ttf|eot)$/i.test(candidate)) return null;
|
|
2119
|
+
if (import_node_fs2.default.existsSync(candidate) && import_node_fs2.default.statSync(candidate).isFile()) return candidate;
|
|
2120
|
+
for (const ext of CODE_EXTENSIONS) {
|
|
2121
|
+
if (import_node_fs2.default.existsSync(candidate + ext)) return candidate + ext;
|
|
2122
|
+
}
|
|
2123
|
+
for (const ext of CODE_EXTENSIONS) {
|
|
2124
|
+
const indexPath = import_node_path2.default.join(candidate, `index${ext}`);
|
|
2125
|
+
if (import_node_fs2.default.existsSync(indexPath)) return indexPath;
|
|
2126
|
+
}
|
|
2127
|
+
return null;
|
|
2128
|
+
}
|
|
2129
|
+
function extractImportSpecifiers(source) {
|
|
2130
|
+
const specs = /* @__PURE__ */ new Set();
|
|
2131
|
+
for (const re of [IMPORT_FROM_RE, SIDE_EFFECT_IMPORT_RE, DYNAMIC_IMPORT_RE]) {
|
|
2132
|
+
re.lastIndex = 0;
|
|
2133
|
+
let m;
|
|
2134
|
+
while (m = re.exec(source)) {
|
|
2135
|
+
if (m[1]) specs.add(m[1]);
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
return [...specs];
|
|
2139
|
+
}
|
|
2140
|
+
function buildRouteClassBuckets(root, srcDir, files) {
|
|
2141
|
+
const aliasInfo = loadTsconfigAliases(root);
|
|
2142
|
+
const classesByFile = /* @__PURE__ */ new Map();
|
|
2143
|
+
const adjacency = /* @__PURE__ */ new Map();
|
|
2144
|
+
for (const f of files) {
|
|
2145
|
+
const normalized = import_node_path2.default.normalize(f.file);
|
|
2146
|
+
classesByFile.set(normalized, f.classes);
|
|
2147
|
+
if (!adjacency.has(normalized)) adjacency.set(normalized, /* @__PURE__ */ new Set());
|
|
2148
|
+
}
|
|
2149
|
+
for (const f of files) {
|
|
2150
|
+
const normalized = import_node_path2.default.normalize(f.file);
|
|
2151
|
+
let source;
|
|
2152
|
+
try {
|
|
2153
|
+
source = import_node_fs2.default.readFileSync(normalized, "utf-8");
|
|
2154
|
+
} catch {
|
|
2155
|
+
continue;
|
|
2156
|
+
}
|
|
2157
|
+
const edges = adjacency.get(normalized);
|
|
2158
|
+
for (const spec of extractImportSpecifiers(source)) {
|
|
2159
|
+
const resolved = resolveSpecifier(spec, normalized, aliasInfo);
|
|
2160
|
+
if (resolved && classesByFile.has(resolved)) edges.add(resolved);
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
const routeEntries = [];
|
|
2164
|
+
for (const f of files) {
|
|
2165
|
+
const normalized = import_node_path2.default.normalize(f.file).replace(/\\/g, "/");
|
|
2166
|
+
const route = deriveRouteFromPageFile(normalized);
|
|
2167
|
+
if (route) routeEntries.push({ route, file: import_node_path2.default.normalize(f.file) });
|
|
2168
|
+
}
|
|
2169
|
+
const reachableByRoute = /* @__PURE__ */ new Map();
|
|
2170
|
+
for (const { route, file } of routeEntries) {
|
|
2171
|
+
const visited = /* @__PURE__ */ new Set();
|
|
2172
|
+
const queue = [file];
|
|
2173
|
+
while (queue.length > 0) {
|
|
2174
|
+
const current = queue.shift();
|
|
2175
|
+
if (visited.has(current)) continue;
|
|
2176
|
+
visited.add(current);
|
|
2177
|
+
for (const next of adjacency.get(current) ?? []) {
|
|
2178
|
+
if (!visited.has(next)) queue.push(next);
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
reachableByRoute.set(route, visited);
|
|
2182
|
+
}
|
|
2183
|
+
const routesByFile = /* @__PURE__ */ new Map();
|
|
2184
|
+
for (const [route, fileSet] of reachableByRoute) {
|
|
2185
|
+
for (const file of fileSet) {
|
|
2186
|
+
if (!routesByFile.has(file)) routesByFile.set(file, /* @__PURE__ */ new Set());
|
|
2187
|
+
routesByFile.get(file).add(route);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
const result = { routes: /* @__PURE__ */ new Map(), global: /* @__PURE__ */ new Set() };
|
|
2191
|
+
for (const [file, classes] of classesByFile) {
|
|
2192
|
+
const normalizedSlash = file.replace(/\\/g, "/");
|
|
2193
|
+
const isSharedSegment = SHARED_SEGMENT_RE.test(normalizedSlash);
|
|
2194
|
+
const reachingRoutes = isSharedSegment ? /* @__PURE__ */ new Set() : routesByFile.get(file);
|
|
2195
|
+
if (!isSharedSegment && reachingRoutes && reachingRoutes.size === 1) {
|
|
2196
|
+
const [route] = reachingRoutes;
|
|
2197
|
+
if (!result.routes.has(route)) result.routes.set(route, /* @__PURE__ */ new Set());
|
|
2198
|
+
const bucket = result.routes.get(route);
|
|
2199
|
+
for (const cls of classes) bucket.add(cls);
|
|
2200
|
+
} else {
|
|
2201
|
+
for (const cls of classes) result.global.add(cls);
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
return result;
|
|
2205
|
+
}
|
|
2206
|
+
function routeToCssFilename(route) {
|
|
2207
|
+
const slug = route.replace(/^\/+/, "").replace(/[^a-zA-Z0-9_-]+/g, "_").replace(/^_+|_+$/g, "");
|
|
2208
|
+
return `route_${slug || "root"}.css`;
|
|
2209
|
+
}
|
|
2210
|
+
var import_node_fs2, import_node_path2, CODE_EXTENSIONS, SHARED_SEGMENT_RE, PAGE_RE, ROOT_PAGE_RE, IMPORT_FROM_RE, SIDE_EFFECT_IMPORT_RE, DYNAMIC_IMPORT_RE;
|
|
2211
|
+
var init_routeGraph = __esm({
|
|
2212
|
+
"packages/domain/compiler/src/routeGraph.ts"() {
|
|
2213
|
+
"use strict";
|
|
2214
|
+
init_cjs_shims();
|
|
2215
|
+
import_node_fs2 = __toESM(require("fs"), 1);
|
|
2216
|
+
import_node_path2 = __toESM(require("path"), 1);
|
|
2217
|
+
CODE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs"];
|
|
2218
|
+
SHARED_SEGMENT_RE = /(?:^|[\\/])(layout|loading|error|template|not-found|default)\.(?:tsx|ts|jsx|js)$/;
|
|
2219
|
+
PAGE_RE = /(?:^|[\\/])app[\\/](.*?)[\\/]page\.(?:tsx|ts|jsx|js)$/;
|
|
2220
|
+
ROOT_PAGE_RE = /(?:^|[\\/])app[\\/]page\.(?:tsx|ts|jsx|js)$/;
|
|
2221
|
+
IMPORT_FROM_RE = /(?:import|export)(?:[^'"`;]*?)from\s+["']([^"']+)["']/g;
|
|
2222
|
+
SIDE_EFFECT_IMPORT_RE = /^\s*import\s+["']([^"']+)["']/gm;
|
|
2223
|
+
DYNAMIC_IMPORT_RE = /\bimport\s*\(\s*["']([^"']+)["']\s*\)/g;
|
|
2224
|
+
}
|
|
2225
|
+
});
|
|
2226
|
+
|
|
2034
2227
|
// packages/domain/compiler/src/index.ts
|
|
2035
2228
|
function _layoutClassesToCss(classes) {
|
|
2036
2229
|
const native = getNativeBridge();
|
|
@@ -2066,13 +2259,13 @@ function extractContainerCssFromSource(source) {
|
|
|
2066
2259
|
}
|
|
2067
2260
|
return rules.join("\n");
|
|
2068
2261
|
}
|
|
2069
|
-
var
|
|
2262
|
+
var import_node_fs3, import_node_path3, import_node_module5, _require3, transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, generateCssForClasses, eliminateDeadCss, findDeadVariants, runElimination, scanProjectUsage, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, _fileClassesMap, _globalClasses, getRouteClasses, getAllRegisteredClasses, registerFileClasses, registerGlobalClasses, resetRouteClassRegistry, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, BucketEngine, classifyNode, detectConflicts, bucketSort, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
|
|
2070
2263
|
var init_src2 = __esm({
|
|
2071
2264
|
"packages/domain/compiler/src/index.ts"() {
|
|
2072
2265
|
"use strict";
|
|
2073
2266
|
init_cjs_shims();
|
|
2074
|
-
|
|
2075
|
-
|
|
2267
|
+
import_node_fs3 = __toESM(require("fs"), 1);
|
|
2268
|
+
import_node_path3 = __toESM(require("path"), 1);
|
|
2076
2269
|
import_node_module5 = require("module");
|
|
2077
2270
|
init_nativeBridge();
|
|
2078
2271
|
init_compiler();
|
|
@@ -2081,6 +2274,7 @@ var init_src2 = __esm({
|
|
|
2081
2274
|
init_cache();
|
|
2082
2275
|
init_redis();
|
|
2083
2276
|
init_watch();
|
|
2277
|
+
init_routeGraph();
|
|
2084
2278
|
_require3 = (0, import_node_module5.createRequire)(
|
|
2085
2279
|
typeof require !== "undefined" ? typeof __filename !== "undefined" ? `file://${__filename}` : "file://unknown" : importMetaUrl
|
|
2086
2280
|
);
|
|
@@ -2175,7 +2369,7 @@ var init_src2 = __esm({
|
|
|
2175
2369
|
};
|
|
2176
2370
|
scanProjectUsage = (dirs, cwd) => {
|
|
2177
2371
|
const { batchExtractClasses: batchExtractClasses2 } = _require3("./parser");
|
|
2178
|
-
const files = dirs.map((dir) =>
|
|
2372
|
+
const files = dirs.map((dir) => import_node_path3.default.resolve(cwd, dir));
|
|
2179
2373
|
const results = batchExtractClasses2(files) || [];
|
|
2180
2374
|
const combined = {};
|
|
2181
2375
|
for (const result of results) {
|
|
@@ -2192,13 +2386,13 @@ var init_src2 = __esm({
|
|
|
2192
2386
|
const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
|
|
2193
2387
|
const allClasses = Object.keys(classes).sort();
|
|
2194
2388
|
if (outputPath) {
|
|
2195
|
-
|
|
2389
|
+
import_node_fs3.default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
|
|
2196
2390
|
}
|
|
2197
2391
|
return allClasses;
|
|
2198
2392
|
};
|
|
2199
2393
|
loadSafelist = (safelistPath) => {
|
|
2200
2394
|
try {
|
|
2201
|
-
const content =
|
|
2395
|
+
const content = import_node_fs3.default.readFileSync(safelistPath, "utf-8");
|
|
2202
2396
|
return JSON.parse(content);
|
|
2203
2397
|
} catch {
|
|
2204
2398
|
return [];
|
|
@@ -2212,8 +2406,8 @@ var init_src2 = __esm({
|
|
|
2212
2406
|
"tailwind.config.cjs"
|
|
2213
2407
|
];
|
|
2214
2408
|
for (const file of configFiles) {
|
|
2215
|
-
const fullPath =
|
|
2216
|
-
if (
|
|
2409
|
+
const fullPath = import_node_path3.default.join(cwd, file);
|
|
2410
|
+
if (import_node_fs3.default.existsSync(fullPath)) {
|
|
2217
2411
|
const mod = require(fullPath);
|
|
2218
2412
|
return mod.default || mod;
|
|
2219
2413
|
}
|
|
@@ -2223,9 +2417,9 @@ var init_src2 = __esm({
|
|
|
2223
2417
|
getContentPaths = (cwd = process.cwd()) => {
|
|
2224
2418
|
return {
|
|
2225
2419
|
content: [
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2420
|
+
import_node_path3.default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
|
|
2421
|
+
import_node_path3.default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
|
|
2422
|
+
import_node_path3.default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
|
|
2229
2423
|
]
|
|
2230
2424
|
};
|
|
2231
2425
|
};
|
|
@@ -2296,10 +2490,38 @@ var init_src2 = __esm({
|
|
|
2296
2490
|
}
|
|
2297
2491
|
return ["/", "__global"];
|
|
2298
2492
|
};
|
|
2299
|
-
|
|
2300
|
-
|
|
2493
|
+
_fileClassesMap = /* @__PURE__ */ new Map();
|
|
2494
|
+
_globalClasses = /* @__PURE__ */ new Set();
|
|
2495
|
+
getRouteClasses = (route) => {
|
|
2496
|
+
const result = /* @__PURE__ */ new Set();
|
|
2497
|
+
for (const [filepath, classes] of _fileClassesMap) {
|
|
2498
|
+
const fileRoute = fileToRoute(filepath) ?? "__global";
|
|
2499
|
+
if (fileRoute === route) {
|
|
2500
|
+
for (const cls of classes) result.add(cls);
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
return result;
|
|
2504
|
+
};
|
|
2505
|
+
getAllRegisteredClasses = () => {
|
|
2506
|
+
const result = new Set(_globalClasses);
|
|
2507
|
+
for (const classes of _fileClassesMap.values()) {
|
|
2508
|
+
for (const cls of classes) result.add(cls);
|
|
2509
|
+
}
|
|
2510
|
+
return result;
|
|
2511
|
+
};
|
|
2512
|
+
registerFileClasses = (filepath, classes) => {
|
|
2513
|
+
if (!classes || classes.length === 0) {
|
|
2514
|
+
_fileClassesMap.delete(filepath);
|
|
2515
|
+
return;
|
|
2516
|
+
}
|
|
2517
|
+
_fileClassesMap.set(filepath, new Set(classes));
|
|
2518
|
+
};
|
|
2519
|
+
registerGlobalClasses = (classes) => {
|
|
2520
|
+
for (const cls of classes) _globalClasses.add(cls);
|
|
2301
2521
|
};
|
|
2302
|
-
|
|
2522
|
+
resetRouteClassRegistry = () => {
|
|
2523
|
+
_fileClassesMap.clear();
|
|
2524
|
+
_globalClasses.clear();
|
|
2303
2525
|
};
|
|
2304
2526
|
_incrementalEngineInstance = null;
|
|
2305
2527
|
getIncrementalEngine = () => {
|
|
@@ -2437,6 +2659,7 @@ __export(compiler_exports, {
|
|
|
2437
2659
|
batchExtractClasses: () => batchExtractClasses,
|
|
2438
2660
|
batchExtractClassesNative: () => batchExtractClassesNative,
|
|
2439
2661
|
bucketSort: () => bucketSort,
|
|
2662
|
+
buildRouteClassBuckets: () => buildRouteClassBuckets,
|
|
2440
2663
|
buildStyleTag: () => buildStyleTag,
|
|
2441
2664
|
cachePriority: () => cachePriority,
|
|
2442
2665
|
cacheRead: () => cacheRead,
|
|
@@ -2496,6 +2719,7 @@ __export(compiler_exports, {
|
|
|
2496
2719
|
generateStaticStateCss: () => generateStaticStateCss,
|
|
2497
2720
|
generateStaticStateCssNative: () => generateStaticStateCssNative,
|
|
2498
2721
|
generateSubComponentTypes: () => generateSubComponentTypes,
|
|
2722
|
+
getAllRegisteredClasses: () => getAllRegisteredClasses,
|
|
2499
2723
|
getAllRoutes: () => getAllRoutes,
|
|
2500
2724
|
getBucketEngine: () => getBucketEngine,
|
|
2501
2725
|
getCacheOptimizationHints: () => getCacheOptimizationHints,
|
|
@@ -2599,6 +2823,7 @@ __export(compiler_exports, {
|
|
|
2599
2823
|
resetMemoryStats: () => resetMemoryStats,
|
|
2600
2824
|
resetNativeBridgeCache: () => resetNativeBridgeCache,
|
|
2601
2825
|
resetResolverPoolStats: () => resetResolverPoolStats,
|
|
2826
|
+
resetRouteClassRegistry: () => resetRouteClassRegistry,
|
|
2602
2827
|
resolveCascade: () => resolveCascade,
|
|
2603
2828
|
resolveClassNames: () => resolveClassNames,
|
|
2604
2829
|
resolveColorCached: () => resolveColorCached,
|
|
@@ -2610,6 +2835,7 @@ __export(compiler_exports, {
|
|
|
2610
2835
|
resolveVariants: () => resolveVariants,
|
|
2611
2836
|
reverseLookupProperty: () => reverseLookupProperty,
|
|
2612
2837
|
reverseLookupValue: () => reverseLookupValue,
|
|
2838
|
+
routeToCssFilename: () => routeToCssFilename,
|
|
2613
2839
|
runCssPipeline: () => runCssPipeline,
|
|
2614
2840
|
runElimination: () => runElimination,
|
|
2615
2841
|
runLoaderTransform: () => runLoaderTransform,
|
|
@@ -2662,6 +2888,7 @@ init_src2();
|
|
|
2662
2888
|
batchExtractClasses,
|
|
2663
2889
|
batchExtractClassesNative,
|
|
2664
2890
|
bucketSort,
|
|
2891
|
+
buildRouteClassBuckets,
|
|
2665
2892
|
buildStyleTag,
|
|
2666
2893
|
cachePriority,
|
|
2667
2894
|
cacheRead,
|
|
@@ -2721,6 +2948,7 @@ init_src2();
|
|
|
2721
2948
|
generateStaticStateCss,
|
|
2722
2949
|
generateStaticStateCssNative,
|
|
2723
2950
|
generateSubComponentTypes,
|
|
2951
|
+
getAllRegisteredClasses,
|
|
2724
2952
|
getAllRoutes,
|
|
2725
2953
|
getBucketEngine,
|
|
2726
2954
|
getCacheOptimizationHints,
|
|
@@ -2824,6 +3052,7 @@ init_src2();
|
|
|
2824
3052
|
resetMemoryStats,
|
|
2825
3053
|
resetNativeBridgeCache,
|
|
2826
3054
|
resetResolverPoolStats,
|
|
3055
|
+
resetRouteClassRegistry,
|
|
2827
3056
|
resolveCascade,
|
|
2828
3057
|
resolveClassNames,
|
|
2829
3058
|
resolveColorCached,
|
|
@@ -2835,6 +3064,7 @@ init_src2();
|
|
|
2835
3064
|
resolveVariants,
|
|
2836
3065
|
reverseLookupProperty,
|
|
2837
3066
|
reverseLookupValue,
|
|
3067
|
+
routeToCssFilename,
|
|
2838
3068
|
runCssPipeline,
|
|
2839
3069
|
runElimination,
|
|
2840
3070
|
runLoaderTransform,
|