Skip to content

Commit

Permalink
fix: set isSelfAccepting to false for any asset not processed by …
Browse files Browse the repository at this point in the history
…importAnalysis (#7898)
  • Loading branch information
brillout committed Apr 25, 2022
1 parent 54728e3 commit 0d2089c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/vite/src/node/plugins/importAnalysis.ts
Expand Up @@ -59,7 +59,8 @@ const debug = createDebugger('vite:import-analysis')
const clientDir = normalizePath(CLIENT_DIR)

const skipRE = /\.(map|json)$/
const canSkip = (id: string) => skipRE.test(id) || isDirectCSSRequest(id)
export const canSkipImportAnalysis = (id: string) =>
skipRE.test(id) || isDirectCSSRequest(id)

const optimizedDepChunkRE = /\/chunk-[A-Z0-9]{8}\.js/
const optimizedDepDynamicRE = /-[A-Z0-9]{8}\.js/
Expand Down Expand Up @@ -131,7 +132,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
const ssr = options?.ssr === true
const prettyImporter = prettifyUrl(importer, root)

if (canSkip(importer)) {
if (canSkipImportAnalysis(importer)) {
isDebug && debug(colors.dim(`[skipped] ${prettyImporter}`))
return null
}
Expand Down
5 changes: 3 additions & 2 deletions packages/vite/src/node/server/moduleGraph.ts
Expand Up @@ -11,6 +11,7 @@ import {
} from '../utils'
import { FS_PREFIX } from '../constants'
import type { TransformResult } from './transformRequest'
import { canSkipImportAnalysis } from '../plugins/importAnalysis'

export class ModuleNode {
/**
Expand Down Expand Up @@ -39,9 +40,9 @@ export class ModuleNode {
this.url = url
this.type = isDirectCSSRequest(url) ? 'css' : 'js'
// #7870
// The `isSelfAccepting` value is set by importAnalysis, but HTML
// The `isSelfAccepting` value is set by importAnalysis, but some
// assets don't go through importAnalysis.
if (isHTMLRequest(url)) {
if (isHTMLRequest(url) || canSkipImportAnalysis(url)) {
this.isSelfAccepting = false
}
}
Expand Down

0 comments on commit 0d2089c

Please sign in to comment.