1+ import { stat } from 'node:fs/promises' ;
12import { join } from 'node:path' ;
23import {
34 ANSIColors ,
@@ -13,7 +14,7 @@ import { writeRemoteDictionary } from './buildIntlayerDictionary/writeRemoteDict
1314import { cleanOutputDir } from './cleanOutputDir' ;
1415import { createDictionaryEntryPoint } from './createDictionaryEntryPoint/createDictionaryEntryPoint' ;
1516import { createModuleAugmentation , createTypes } from './createType/index' ;
16- import { listDictionaries } from './listDictionariesPath' ;
17+ import { listDictionariesWithStats } from './listDictionariesPath' ;
1718import { loadDictionaries } from './loadDictionaries/loadDictionaries' ;
1819import { runOnce } from './utils/runOnce' ;
1920import {
@@ -54,9 +55,17 @@ export const prepareIntlayer = async (
5455
5556 const isConfigSimilar = await isCachedConfigurationUpToDate ( configuration ) ;
5657
58+ const dictionariesWithStats = await listDictionariesWithStats ( configuration ) ;
59+
60+ const sentinelStats = await stat ( sentinelPath ) ;
61+ const isDictionaryChanged = dictionariesWithStats . some (
62+ ( dictionary ) =>
63+ dictionary . stats . mtime . getTime ( ) > sentinelStats . mtime . getTime ( )
64+ ) ;
65+
5766 const { clean, format, forceRun, onIsCached, cacheTimeoutMs } = {
5867 ...DEFAULT_PREPARE_INTLAYER_OPTIONS ,
59- forceRun : ! isCorrectVersion || ! isConfigSimilar ,
68+ forceRun : ! isCorrectVersion || ! isConfigSimilar || isDictionaryChanged ,
6069 ...( options ?? { } ) ,
6170 } ;
6271
@@ -97,9 +106,14 @@ export const prepareIntlayer = async (
97106 }
98107 ) ;
99108
100- const files : string [ ] = await listDictionaries ( configuration ) ;
109+ const contentDeclarationPaths = dictionariesWithStats . map (
110+ ( dictionary ) => dictionary . path
111+ ) ;
101112
102- const dictionaries = await loadDictionaries ( files , configuration ) ;
113+ const dictionaries = await loadDictionaries (
114+ contentDeclarationPaths ,
115+ configuration
116+ ) ;
103117
104118 const dictionariesLoadedTime = Date . now ( ) ;
105119
0 commit comments