Skip to content

Commit 1240f19

Browse files
committed
refactor: use exported VERSION from rollup
1 parent 768a50f commit 1240f19

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

packages/vite/src/node/publicUtils.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@
55
*/
66
export { VERSION as version } from './constants'
77
export { version as esbuildVersion } from 'esbuild'
8+
export { VERSION as rollupVersion } from 'rollup'
89
export {
910
splitVendorChunkPlugin,
1011
splitVendorChunk,
1112
isCSSRequest,
1213
} from './plugins/splitVendorChunk'
13-
export {
14-
normalizePath,
15-
mergeConfig,
16-
mergeAlias,
17-
createFilter,
18-
rollupVersion,
19-
} from './utils'
14+
export { normalizePath, mergeConfig, mergeAlias, createFilter } from './utils'
2015
export { send } from './server/send'
2116
export { createLogger } from './logger'
2217
export { searchForWorkspaceRoot } from './server/searchRoot'

packages/vite/src/node/server/pluginContainer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import type {
5757
SourceMap,
5858
TransformResult,
5959
} from 'rollup'
60+
import { VERSION as ROLLUP_VERSION } from 'rollup'
6061
import type { RawSourceMap } from '@ampproject/remapping'
6162
import { TraceMap, originalPositionFor } from '@jridgewell/trace-mapping'
6263
import MagicString from 'magic-string'
@@ -73,7 +74,6 @@ import {
7374
normalizePath,
7475
numberToPos,
7576
prettifyUrl,
76-
rollupVersion,
7777
timeFrom,
7878
} from '../utils'
7979
import { FS_PREFIX } from '../constants'
@@ -177,7 +177,7 @@ class EnvironmentPluginContainer {
177177
) {
178178
this.minimalContext = {
179179
meta: {
180-
rollupVersion,
180+
rollupVersion: ROLLUP_VERSION,
181181
watchMode: true,
182182
},
183183
debug: noop,

packages/vite/src/node/utils.ts

-10
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,6 @@ export const deepImportRE = /^([^@][^/]*)\/|^(@[^/]+\/[^/]+)\//
137137
// TODO: use import()
138138
const _require = createRequire(import.meta.url)
139139

140-
export function resolveDependencyVersion(
141-
dep: string,
142-
pkgRelativePath = '../../package.json',
143-
): string {
144-
const pkgPath = path.resolve(_require.resolve(dep), pkgRelativePath)
145-
return JSON.parse(fs.readFileSync(pkgPath, 'utf-8')).version
146-
}
147-
148-
export const rollupVersion = resolveDependencyVersion('rollup')
149-
150140
// set in bin/vite.js
151141
const filter = process.env.VITE_DEBUG_FILTER
152142

0 commit comments

Comments
 (0)