Skip to content

Commit

Permalink
perf: lazy load rollup during dev (#15621)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jan 23, 2024
1 parent 93fce55 commit 6f88a90
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/vite/src/node/publicUtils.ts
Expand Up @@ -5,13 +5,18 @@
*/
export { VERSION as version } from './constants'
export { version as esbuildVersion } from 'esbuild'
export { VERSION as rollupVersion } from 'rollup'
export {
splitVendorChunkPlugin,
splitVendorChunk,
isCSSRequest,
} from './plugins/splitVendorChunk'
export { normalizePath, mergeConfig, mergeAlias, createFilter } from './utils'
export {
normalizePath,
mergeConfig,
mergeAlias,
createFilter,
rollupVersion,
} from './utils'
export { send } from './server/send'
export { createLogger } from './logger'
export { searchForWorkspaceRoot } from './server/searchRoot'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/pluginContainer.ts
Expand Up @@ -32,7 +32,6 @@ SOFTWARE.
import fs from 'node:fs'
import { join } from 'node:path'
import { performance } from 'node:perf_hooks'
import { VERSION as rollupVersion } from 'rollup'
import { parseAst as rollupParseAst } from 'rollup/parseAst'
import type {
AsyncPluginHooks,
Expand Down Expand Up @@ -74,6 +73,7 @@ import {
normalizePath,
numberToPos,
prettifyUrl,
rollupVersion,
timeFrom,
unwrapId,
} from '../utils'
Expand Down
10 changes: 10 additions & 0 deletions packages/vite/src/node/utils.ts
Expand Up @@ -162,6 +162,16 @@ export const deepImportRE = /^([^@][^/]*)\/|^(@[^/]+\/[^/]+)\//
// TODO: use import()
const _require = createRequire(import.meta.url)

export function resolveDependencyVersion(
dep: string,
pkgRelativePath = '../../package.json',
): string {
const pkgPath = path.resolve(_require.resolve(dep), pkgRelativePath)
return JSON.parse(fs.readFileSync(pkgPath, 'utf-8')).version
}

export const rollupVersion = resolveDependencyVersion('rollup')

// set in bin/vite.js
const filter = process.env.VITE_DEBUG_FILTER

Expand Down

0 comments on commit 6f88a90

Please sign in to comment.