@@ -750,15 +750,17 @@ class CodeInjector implements ICodeInjector {
750
750
751
751
async computeSourcesHash ( folderPath : string = this . spaTmpPath ( ) , allFiles : string [ ] = [ ] ) {
752
752
const files = await fs . promises . readdir ( folderPath , { withFileTypes : true } ) ;
753
- allFiles . push ( ...files . map ( ( file ) => path . join ( folderPath , file . name ) ) ) ;
754
753
const hashes = await Promise . all (
755
754
files . map ( async ( file ) => {
756
755
const filePath = path . join ( folderPath , file . name ) ;
757
756
758
- // 🚫 Skip node_modules
759
- if ( file . name === 'node_modules' || file . name === 'dist' ) {
757
+ // 🚫 Skip big files or files which might be dynamic
758
+ if ( file . name === 'node_modules' || file . name === 'dist' ||
759
+ file . name === 'i18n-messages.json' || file . name === 'i18n-empty.json' ) {
760
760
return '' ;
761
761
}
762
+
763
+ allFiles . push ( filePath ) ;
762
764
763
765
if ( file . isDirectory ( ) ) {
764
766
return this . computeSourcesHash ( filePath , allFiles ) ;
@@ -795,7 +797,8 @@ class CodeInjector implements ICodeInjector {
795
797
796
798
const allFiles = [ ] ;
797
799
const sourcesHash = await this . computeSourcesHash ( this . spaTmpPath ( ) , allFiles ) ;
798
- process . env . VERY_HEAVY_DEBUG && console . log ( '🪲🪲 allFiles:' , JSON . stringify ( allFiles . sort ( ( a , b ) => a . localeCompare ( b ) ) , null , 1 ) )
800
+ process . env . VERY_HEAVY_DEBUG && console . log ( '🪲🪲 allFiles:' , JSON . stringify (
801
+ allFiles . sort ( ( a , b ) => a . localeCompare ( b ) ) , null , 1 ) )
799
802
800
803
const buildHash = await this . tryReadFile ( path . join ( serveDir , '.adminforth_build_hash' ) ) ;
801
804
const messagesHash = await this . tryReadFile ( path . join ( serveDir , '.adminforth_messages_hash' ) ) ;
@@ -828,10 +831,6 @@ class CodeInjector implements ICodeInjector {
828
831
// copy i18n messages to serve dir
829
832
await fsExtra . copy ( path . join ( cwd , 'i18n-messages.json' ) , path . join ( serveDir , 'i18n-messages.json' ) ) ;
830
833
831
- // rm i18n-messages.json and i18n-empty.json from spa tmp, or they will affect hash
832
- await fs . promises . rm ( path . join ( cwd , 'i18n-messages.json' ) , { force : true } ) ;
833
- await fs . promises . rm ( path . join ( cwd , 'i18n-empty.json' ) , { force : true } ) ;
834
-
835
834
// save hash
836
835
await fs . promises . writeFile ( path . join ( serveDir , '.adminforth_messages_hash' ) , sourcesHash ) ;
837
836
} else {
0 commit comments