Skip to content

Commit

Permalink
refactor: isolate back compat module graph in its own module
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 22, 2024
1 parent a7a06fe commit 8000e8e
Show file tree
Hide file tree
Showing 8 changed files with 654 additions and 634 deletions.
5 changes: 3 additions & 2 deletions packages/vite/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ export type {
} from './server/ws'
export type { PluginContainer } from './server/pluginContainer'
export type {
ModuleGraph,
ModuleNode,
EnvironmentModuleGraph,
EnvironmentModuleNode,
ResolvedUrl,
Expand Down Expand Up @@ -186,3 +184,6 @@ export type { RollupCommonJSOptions } from 'dep-types/commonjs'
export type { RollupDynamicImportVarsOptions } from 'dep-types/dynamicImportVars'
export type { Matcher, AnymatchPattern, AnymatchFn } from 'dep-types/anymatch'
export type { LightningCSSOptions } from 'dep-types/lightningcss'

// Backward compatibility
export type { ModuleGraph, ModuleNode } from './server/mixedModuleGraph'
3 changes: 2 additions & 1 deletion packages/vite/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export type { PluginContext } from 'rollup'
import type { ConfigEnv, ResolvedConfig, UserConfig } from './config'
import type { ServerHook, ViteDevServer } from './server'
import type { IndexHtmlTransform } from './plugins/html'
import type { EnvironmentModuleNode, ModuleNode } from './server/moduleGraph'
import type { EnvironmentModuleNode } from './server/moduleGraph'
import type { ModuleNode } from './server/mixedModuleGraph'
import type { HmrContext, HotUpdateContext } from './server/hmr'
import type { PreviewServerHook } from './preview'
import type { DevEnvironment } from './server/environment'
Expand Down
5 changes: 3 additions & 2 deletions packages/vite/src/node/server/__tests__/moduleGraph.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest'
import { EnvironmentModuleGraph, ModuleGraph } from '../moduleGraph'
import type { ModuleNode } from '../moduleGraph'
import { EnvironmentModuleGraph } from '../moduleGraph'
import type { ModuleNode } from '../mixedModuleGraph'
import { ModuleGraph } from '../mixedModuleGraph'

describe('moduleGraph', () => {
describe('invalidateModule', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/src/node/server/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { isExplicitImportRequired } from '../plugins/importAnalysis'
import { getEnvFilesForMode } from '../env'
import { withTrailingSlash, wrapId } from '../../shared/utils'
import type { Plugin } from '../plugin'
import type { EnvironmentModuleNode, ModuleNode } from './moduleGraph'
import type { EnvironmentModuleNode } from './moduleGraph'
import type { ModuleNode } from './mixedModuleGraph'
import type { DevEnvironment } from './environment'
import { restartServerWithUrls } from '.'

Expand Down
5 changes: 3 additions & 2 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ import {
serveStaticMiddleware,
} from './middlewares/static'
import { timeMiddleware } from './middlewares/time'
import type { EnvironmentModuleNode, ModuleNode } from './moduleGraph'
import { ModuleGraph } from './moduleGraph'
import type { EnvironmentModuleNode } from './moduleGraph'
import { ModuleGraph } from './mixedModuleGraph'
import type { ModuleNode } from './mixedModuleGraph'
import { notFoundMiddleware } from './middlewares/notFound'
import { errorMiddleware, prepareError } from './middlewares/error'
import type { HMRBroadcaster, HmrOptions, HmrTask } from './hmr'
Expand Down
Loading

0 comments on commit 8000e8e

Please sign in to comment.