mirror of
https://github.com/withastro/astro.git
synced 2025-02-24 22:46:02 -05:00
refactor: early return
This commit is contained in:
parent
de79f2bba0
commit
e10167f359
1 changed files with 9 additions and 10 deletions
|
@ -40,19 +40,18 @@ export function vitePluginDb(params: VitePluginDBParams): VitePlugin {
|
||||||
name: 'astro:db',
|
name: 'astro:db',
|
||||||
enforce: 'pre',
|
enforce: 'pre',
|
||||||
async resolveId(id, rawImporter) {
|
async resolveId(id, rawImporter) {
|
||||||
if (id === VIRTUAL_MODULE_ID) {
|
if (id !== VIRTUAL_MODULE_ID) return;
|
||||||
if (params.connectToStudio || !params.shouldSeed) return resolvedVirtualModuleId;
|
if (params.connectToStudio || !params.shouldSeed) return resolvedVirtualModuleId;
|
||||||
|
|
||||||
const importer = rawImporter ? await this.resolve(rawImporter) : null;
|
const importer = rawImporter ? await this.resolve(rawImporter) : null;
|
||||||
if (!importer) return resolvedVirtualModuleId;
|
if (!importer) return resolvedVirtualModuleId;
|
||||||
|
|
||||||
if (importer.id.startsWith(srcDirPath)) {
|
if (importer.id.startsWith(srcDirPath)) {
|
||||||
// Seed only if the importer is in the src directory.
|
// Seed only if the importer is in the src directory.
|
||||||
// Otherwise, we may get recursive seed calls (ex. import from db/seed.ts).
|
// Otherwise, we may get recursive seed calls (ex. import from db/seed.ts).
|
||||||
return resolvedSeedVirtualModuleId;
|
return resolvedSeedVirtualModuleId;
|
||||||
}
|
|
||||||
return resolvedVirtualModuleId;
|
|
||||||
}
|
}
|
||||||
|
return resolvedVirtualModuleId;
|
||||||
},
|
},
|
||||||
load(id) {
|
load(id) {
|
||||||
if (id !== resolvedVirtualModuleId && id !== resolvedSeedVirtualModuleId) return;
|
if (id !== resolvedVirtualModuleId && id !== resolvedSeedVirtualModuleId) return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue