Skip to content

Commit 9f54c6a

Browse files
authored
refactor: import version from rollup (#10964)
1 parent 411cc3d commit 9f54c6a

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ SOFTWARE.
3030
*/
3131

3232
import fs from 'node:fs'
33-
import { join, resolve } from 'node:path'
33+
import { join } from 'node:path'
3434
import { performance } from 'node:perf_hooks'
35-
import { createRequire } from 'node:module'
35+
import { VERSION as rollupVersion } from 'rollup'
3636
import type {
3737
AsyncPluginHooks,
3838
CustomPluginOptions,
@@ -173,18 +173,9 @@ export async function createPluginContainer(
173173

174174
const watchFiles = new Set<string>()
175175

176-
// TODO: use import()
177-
const _require = createRequire(import.meta.url)
178-
179-
// get rollup version
180-
const rollupPkgPath = resolve(
181-
_require.resolve('rollup'),
182-
'../../package.json'
183-
)
184176
const minimalContext: MinimalPluginContext = {
185177
meta: {
186-
rollupVersion: JSON.parse(fs.readFileSync(rollupPkgPath, 'utf-8'))
187-
.version,
178+
rollupVersion,
188179
watchMode: true
189180
}
190181
}

0 commit comments

Comments
 (0)