Skip to content

Commit 89b1a6c

Browse files
committed
fix: create empty virtual files
1 parent 97e4538 commit 89b1a6c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/uniwind/src/metro/withUniwindConfig.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import { nativeResolver, webResolver } from './resolvers'
1010
import { DeepMutable, ExtendedBundler, ExtendedFileSystem, FileChangeEvent, Platform, UniwindConfig } from './types'
1111
import { areSetsEqual, uniq } from './utils'
1212

13-
const getVirtualPath = (platform: string) => `${platform}.uniwind.${platform === Platform.Web ? 'css' : 'js'}`
13+
const cacheDir = path.join(__dirname, '.cache')
14+
const getVirtualPath = (platform: string) => path.join(cacheDir, `${platform}.uniwind.${platform === Platform.Web ? 'css' : 'js'}`)
1415
const getPlatformFromVirtualPath = (path: string) => {
15-
const [, platform] = path.match(/^(\w+)\.uniwind\./) ?? []
16+
const [, platform] = path.match(/(\w+)\.uniwind\./) ?? []
1617

1718
return platform as Platform | undefined
1819
}
@@ -23,6 +24,11 @@ export const withUniwindConfig = (
2324
config: DeepMutable<MetroConfig>,
2425
uniwindConfig: UniwindConfig,
2526
) => {
27+
if (!fs.existsSync(cacheDir)) {
28+
fs.mkdirSync(cacheDir)
29+
}
30+
31+
platforms.forEach(platform => fs.writeFileSync(getVirtualPath(platform), ''))
2632
uniwindConfig.themes = uniq([
2733
'light',
2834
'dark',

0 commit comments

Comments
 (0)