Skip to content

Commit

Permalink
feat: export resolvePackageData and resolvePackageEntry helpers (#…
Browse files Browse the repository at this point in the history
…1307)

* feat: export `resolvePackageData` and `resolvePackageEntry` helpers

These functions can be useful to plugins.

  - `resolvePackageData` provides cache reuse
  - `resolvePackageEntry` is complicated enough to be burdensome to reimplement for a plugin to achieve the same behavior

* feat: export `PackageData` type
  • Loading branch information
aleclarson committed Jan 3, 2021
1 parent ec2bf6c commit 38b9613
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/vite/src/node/index.ts
Expand Up @@ -4,6 +4,7 @@ export * from './optimizer'
export * from './config'
export { send } from './server/send'
export { createLogger } from './logger'
export { resolvePackageData, resolvePackageEntry } from './plugins/resolve'

// additional types
export type { Plugin } from './plugin'
Expand All @@ -23,6 +24,7 @@ export type {
} from './plugins/html'
export type { CSSOptions, CSSModulesOptions } from './plugins/css'
export type { EsbuildTransformResult } from './plugins/esbuild'
export type { PackageData } from './plugins/resolve'
export type { WebSocketServer } from './server/ws'
export type { PluginContainer } from './server/pluginContainer'
export type { ModuleGraph, ModuleNode } from './server/moduleGraph'
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/resolve.ts
Expand Up @@ -272,7 +272,7 @@ function tryOptimizedResolve(
}
}

interface PackageData {
export interface PackageData {
dir: string
hasSideEffects: (id: string) => boolean
data: {
Expand All @@ -285,7 +285,7 @@ interface PackageData {

const packageCache = new Map<string, PackageData>()

function resolvePackageData(
export function resolvePackageData(
id: string,
basedir: string
): PackageData | undefined {
Expand Down

0 comments on commit 38b9613

Please sign in to comment.