Fix check CLI fs load fallback behaviour (#6811)
This commit is contained in:
parent
c12ca5ece3
commit
60c16db6ff
3 changed files with 12 additions and 10 deletions
5
.changeset/angry-experts-compete.md
Normal file
5
.changeset/angry-experts-compete.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix check CLI fs load fallback behaviour
|
|
@ -6,7 +6,7 @@ import {
|
||||||
} from '@astrojs/language-server';
|
} from '@astrojs/language-server';
|
||||||
import type { FSWatcher } from 'chokidar';
|
import type { FSWatcher } from 'chokidar';
|
||||||
import glob from 'fast-glob';
|
import glob from 'fast-glob';
|
||||||
import fsMod, * as fs from 'fs';
|
import fs from 'fs';
|
||||||
import { bold, dim, red, yellow } from 'kleur/colors';
|
import { bold, dim, red, yellow } from 'kleur/colors';
|
||||||
import { createRequire } from 'module';
|
import { createRequire } from 'module';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
|
@ -136,7 +136,7 @@ type CheckerConstructor = {
|
||||||
|
|
||||||
logging: Readonly<LogOptions>;
|
logging: Readonly<LogOptions>;
|
||||||
|
|
||||||
fileSystem: typeof fsMod;
|
fileSystem: typeof fs;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -153,7 +153,7 @@ export class AstroChecker {
|
||||||
readonly #settings: AstroSettings;
|
readonly #settings: AstroSettings;
|
||||||
|
|
||||||
readonly #logging: LogOptions;
|
readonly #logging: LogOptions;
|
||||||
readonly #fs: typeof fsMod;
|
readonly #fs: typeof fs;
|
||||||
#watcher?: FSWatcher;
|
#watcher?: FSWatcher;
|
||||||
|
|
||||||
#filesCount: number;
|
#filesCount: number;
|
||||||
|
|
|
@ -15,7 +15,10 @@ export default function loadFallbackPlugin({
|
||||||
root,
|
root,
|
||||||
}: LoadFallbackPluginParams): vite.Plugin[] | false {
|
}: LoadFallbackPluginParams): vite.Plugin[] | false {
|
||||||
// Only add this plugin if a custom fs implementation is provided.
|
// Only add this plugin if a custom fs implementation is provided.
|
||||||
if (!fs || fs === nodeFs) {
|
// Also check for `fs.default` because `import * as fs from 'fs'` will
|
||||||
|
// export as so, which only it's `.default` would === `nodeFs`.
|
||||||
|
// @ts-expect-error check default
|
||||||
|
if (!fs || fs === nodeFs || fs.default === nodeFs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,12 +56,6 @@ export default function loadFallbackPlugin({
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let resolved = await this.resolve(id, parent, { skipSelf: true });
|
|
||||||
if (resolved) {
|
|
||||||
return resolved.id;
|
|
||||||
}
|
|
||||||
return slashify(id);
|
|
||||||
},
|
},
|
||||||
async load(id) {
|
async load(id) {
|
||||||
const source = await tryLoadModule(id);
|
const source = await tryLoadModule(id);
|
||||||
|
|
Loading…
Add table
Reference in a new issue