|
1 | 1 | import type { DevEnvironment, FetchResult } from 'vite' |
2 | 2 | import type { Vitest } from '../core' |
3 | | -import type { VitestResolver } from '../resolver' |
4 | 3 | import type { ResolvedConfig } from '../types/config' |
5 | 4 | import fs, { existsSync, mkdirSync, readFileSync } from 'node:fs' |
6 | 5 | import { readFile, rename, rm, stat, unlink, writeFile } from 'node:fs/promises' |
@@ -92,7 +91,7 @@ export class FileSystemModuleCache { |
92 | 91 | | undefined |
93 | 92 | > { |
94 | 93 | if (!existsSync(cachedFilePath)) { |
95 | | - debugFs?.(`${c.red('[empty]')} ${cachedFilePath} doesn't exist, transforming by vite instead`) |
| 94 | + debugFs?.(`${c.red('[empty]')} ${cachedFilePath} doesn't exist, transforming by vite first`) |
96 | 95 | return |
97 | 96 | } |
98 | 97 |
|
@@ -176,15 +175,14 @@ export class FileSystemModuleCache { |
176 | 175 | generateCachePath( |
177 | 176 | vitestConfig: ResolvedConfig, |
178 | 177 | environment: DevEnvironment, |
179 | | - resolver: VitestResolver, |
180 | 178 | id: string, |
181 | 179 | fileContent: string, |
182 | 180 | ): string | null { |
183 | 181 | // bail out if file has import.meta.glob because it depends on other files |
184 | 182 | // TODO: figure out a way to still support it |
185 | 183 | if (fileContent.includes('import.meta.glob(')) { |
186 | 184 | this.saveMemoryCache(environment, id, null) |
187 | | - debugMemory?.(`${c.yellow('[write]')} ${id} was bailed out`) |
| 185 | + debugMemory?.(`${c.yellow('[write]')} ${id} was bailed out because it has "import.meta.glob"`) |
188 | 186 | return null |
189 | 187 | } |
190 | 188 |
|
@@ -218,7 +216,9 @@ export class FileSystemModuleCache { |
218 | 216 | resolve: config.resolve, |
219 | 217 | // plugins can have different options, so this is not the best key, |
220 | 218 | // but we canot access the options because there is no standard API for it |
221 | | - plugins: config.plugins.map(p => p.name), |
| 219 | + plugins: config.plugins |
| 220 | + .filter(p => p.api?.vitest?.experimental?.ignoreFsModuleCache !== true) |
| 221 | + .map(p => p.name), |
222 | 222 | // in case local plugins change |
223 | 223 | // configFileDependencies also includes configFile |
224 | 224 | configFileDependencies: config.configFileDependencies.map(file => tryReadFileSync(file)), |
@@ -248,6 +248,7 @@ export class FileSystemModuleCache { |
248 | 248 | let cacheRoot = this.fsCacheRoots.get(vitestConfig) |
249 | 249 | if (cacheRoot == null) { |
250 | 250 | cacheRoot = vitestConfig.experimental.fsModuleCachePath || this.rootCache |
| 251 | + this.fsCacheRoots.set(vitestConfig, cacheRoot) |
251 | 252 | if (!existsSync(cacheRoot)) { |
252 | 253 | mkdirSync(cacheRoot, { recursive: true }) |
253 | 254 | } |
|
0 commit comments