@@ -13,6 +13,7 @@ import {
1313 initJsxFilePath ,
1414} from "../consts" ;
1515import { buildClassList } from "../utils/build-class-list" ;
16+ import { createInitLogger } from "../utils/create-init-logger" ;
1617import { extractComponentImports } from "../utils/extract-component-imports" ;
1718import { findFiles } from "../utils/find-files" ;
1819import { getClassList } from "../utils/get-class-list" ;
@@ -25,6 +26,7 @@ export async function dev() {
2526 await setupOutputDirectory ( ) ;
2627 let config = await getConfig ( ) ;
2728 await setupInit ( config ) ;
29+ const initLogger = createInitLogger ( config ) ;
2830
2931 if ( config . components . length ) {
3032 console . warn ( automaticClassGenerationMessage ) ;
@@ -42,12 +44,15 @@ export async function dev() {
4244 for ( const file of files ) {
4345 const content = await fs . readFile ( file , "utf-8" ) ;
4446 const componentImports = extractComponentImports ( content ) ;
47+ initLogger . check ( file , content ) ;
4548
4649 if ( componentImports . length ) {
4750 importedComponentsMap [ file ] = componentImports ;
4851 }
4952 }
5053
54+ initLogger . log ( ) ;
55+
5156 const newImportedComponents = [ ...new Set ( Object . values ( importedComponentsMap ) . flat ( ) ) ] ;
5257 const newClassList = buildClassList ( {
5358 components : config . components . length ? config . components : newImportedComponents ,
@@ -63,9 +68,19 @@ export async function dev() {
6368
6469 // watch for changes
6570 async function handleChange ( path : string , eventName : "change" | "unlink" ) {
71+ if ( [ configFilePath , initFilePath , initJsxFilePath ] . includes ( path ) ) {
72+ config = await getConfig ( ) ;
73+ await setupInit ( config ) ;
74+ initLogger . config = config ;
75+ }
76+ if ( path === gitIgnoreFilePath ) {
77+ await setupGitIgnore ( ) ;
78+ }
79+
6680 if ( eventName === "change" ) {
6781 const content = await fs . readFile ( path , "utf-8" ) ;
6882 const componentImports = extractComponentImports ( content ) ;
83+ initLogger . check ( path , content ) ;
6984
7085 if ( componentImports . length ) {
7186 importedComponentsMap [ path ] = componentImports ;
@@ -75,17 +90,12 @@ export async function dev() {
7590 }
7691 if ( eventName === "unlink" ) {
7792 delete importedComponentsMap [ path ] ;
93+ initLogger . checkedMap . delete ( path ) ;
7894 }
7995
80- const newImportedComponents = [ ... new Set ( Object . values ( importedComponentsMap ) . flat ( ) ) ] ;
96+ initLogger . log ( ) ;
8197
82- if ( [ configFilePath , initFilePath , initJsxFilePath ] . includes ( path ) ) {
83- config = await getConfig ( ) ;
84- await setupInit ( config ) ;
85- }
86- if ( path === gitIgnoreFilePath ) {
87- await setupGitIgnore ( ) ;
88- }
98+ const newImportedComponents = [ ...new Set ( Object . values ( importedComponentsMap ) . flat ( ) ) ] ;
8999
90100 const newClassList = buildClassList ( {
91101 components : config . components . length ? config . components : newImportedComponents ,
0 commit comments