File tree Expand file tree Collapse file tree
libs/native-federation-core/src/lib/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,8 +38,6 @@ export async function bundleShared(
3838 ? path . dirname ( fedOptions . packageJson )
3939 : fedOptions . workspaceRoot ;
4040
41- fs . mkdirSync ( cache . pathToCache , { recursive : true } ) ;
42-
4341 const sharedPackageInfoCache = getCachedMetadata (
4442 cache . pathToCache ,
4543 cache . metaDataFile ,
@@ -59,6 +57,7 @@ export async function bundleShared(
5957 }
6058
6159 purgeCacheFolder ( cache . pathToCache , cache . metaDataFile ) ;
60+ fs . mkdirSync ( cache . pathToCache , { recursive : true } ) ;
6261
6362 const inferredPackageInfos = Object . keys ( sharedBundles )
6463 . filter ( ( packageName ) => ! sharedBundles [ packageName ] . packageInfo )
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ export const getCachedMetadata = (
3131 checksum : string
3232) : SharedInfo [ ] | false => {
3333 const metadataFile = path . join ( pathToCache , file ) ;
34- if ( ! fs . existsSync ( metadataFile ) ) return false ;
34+ if ( ! fs . existsSync ( pathToCache ) || ! fs . existsSync ( metadataFile ) ) return false ;
3535
3636 const cachedResult : {
3737 checksum : string ;
@@ -85,10 +85,14 @@ export const copyCacheToDist = (
8585
8686export const purgeCacheFolder = ( pathToCache : string , file : string ) => {
8787 const metadataFile = path . join ( pathToCache , file ) ;
88+ if ( ! fs . existsSync ( pathToCache ) ) {
89+ return ;
90+ }
8891 if ( ! fs . existsSync ( metadataFile ) ) {
8992 logger . warn (
9093 `Could not purge cache, metadata file '${ file } ' could not be found.`
9194 ) ;
95+ return ;
9296 }
9397
9498 const cachedResult : {
You can’t perform that action at this time.
0 commit comments