Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: plugin container #17288

Merged
merged 6 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import {
} from '../utils'
import type { Logger } from '../logger'
import { cleanUrl, slash } from '../../shared/utils'
import type { TransformPluginContext } from '../server/pluginContainer'
import { addToHTMLProxyTransformResult } from './html'
import {
assetUrlRE,
Expand Down Expand Up @@ -965,9 +966,8 @@ export function cssAnalysisPlugin(config: ResolvedConfig): Plugin {
!inlineRE.test(id) &&
!htmlProxyRE.test(id)
// attached by pluginContainer.addWatchFile
const pluginImports = (this as any)._addedImports as
| Set<string>
| undefined
const pluginImports = (this as unknown as TransformPluginContext)
._addedImports
if (pluginImports) {
// record deps in the module graph so edits to @import css can trigger
// main import to hot update
Expand Down
11 changes: 7 additions & 4 deletions packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import {
withTrailingSlash,
wrapId,
} from '../../shared/utils'
import type { TransformPluginContext } from '../server/pluginContainer'
import { throwOutdatedRequest } from './optimizedDeps'
import { isCSSRequest, isDirectCSSRequest } from './css'
import { browserExternalId } from './resolve'
Expand Down Expand Up @@ -253,7 +254,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
throwOutdatedRequest(importer)
}

if (!imports.length && !(this as any)._addedImports) {
if (
!imports.length &&
!(this as unknown as TransformPluginContext)._addedImports
) {
importerModule.isSelfAccepting = false
debug?.(
`${timeFrom(msAtStart)} ${colors.dim(
Expand Down Expand Up @@ -747,9 +751,8 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
// note that we want to handle .css?raw and .css?url here
if (!isCSSRequest(importer) || SPECIAL_QUERY_RE.test(importer)) {
// attached by pluginContainer.addWatchFile
const pluginImports = (this as any)._addedImports as
| Set<string>
| undefined
const pluginImports = (this as unknown as TransformPluginContext)
._addedImports
if (pluginImports) {
;(
await Promise.all(
Expand Down
Loading