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

perf: lazy load rollup during dev #15621

Merged
merged 7 commits into from Jan 23, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'
bluwy marked this conversation as resolved.
Show resolved Hide resolved
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)
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved
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