Skip to content

Commit

Permalink
fix(scan): ignore virtual entries during scan
Browse files Browse the repository at this point in the history
close #2047
  • Loading branch information
yyx990803 committed Feb 16, 2021
1 parent ad50060 commit 6863aec
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/vite/src/node/optimizer/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import {
externalRE,
dataUrlRE
} from '../utils'
import {
createPluginContainer,
PluginContainer
} from '../server/pluginContainer'
import { PluginContainer } from '../server/pluginContainer'
import { init, parse } from 'es-module-lexer'
import MagicString from 'magic-string'
import { transformImportGlob } from '../importGlob'
Expand Down Expand Up @@ -56,9 +53,12 @@ export async function scanImports(
entries = await globEntries('**/*.html', config)
}

// Non-supported entry file types should not be scanned for dependencies.
// Non-supported entry file types and virtual files should not be scanned for
// dependencies.
entries = entries.filter(
(entry) => JS_TYPES_RE.test(entry) || htmlTypesRE.test(entry)
(entry) =>
(JS_TYPES_RE.test(entry) || htmlTypesRE.test(entry)) &&
fs.existsSync(entry)
)

if (!entries.length) {
Expand All @@ -71,7 +71,6 @@ export async function scanImports(
const tempDir = path.join(config.optimizeCacheDir!, 'temp')
const deps: Record<string, string> = {}
const missing: Record<string, string> = {}
const container = await createPluginContainer(config)
const plugin = esbuildScanPlugin(config, container, deps, missing, entries)

const esbuildService = await ensureService()
Expand Down

0 comments on commit 6863aec

Please sign in to comment.