Skip to content

Commit

Permalink
refactor: import version from rollup (#10964)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Nov 17, 2022
1 parent 411cc3d commit 9f54c6a
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions packages/vite/src/node/server/pluginContainer.ts
Expand Up @@ -30,9 +30,9 @@ SOFTWARE.
*/

import fs from 'node:fs'
import { join, resolve } from 'node:path'
import { join } from 'node:path'
import { performance } from 'node:perf_hooks'
import { createRequire } from 'node:module'
import { VERSION as rollupVersion } from 'rollup'
import type {
AsyncPluginHooks,
CustomPluginOptions,
Expand Down Expand Up @@ -173,18 +173,9 @@ export async function createPluginContainer(

const watchFiles = new Set<string>()

// TODO: use import()
const _require = createRequire(import.meta.url)

// get rollup version
const rollupPkgPath = resolve(
_require.resolve('rollup'),
'../../package.json'
)
const minimalContext: MinimalPluginContext = {
meta: {
rollupVersion: JSON.parse(fs.readFileSync(rollupPkgPath, 'utf-8'))
.version,
rollupVersion,
watchMode: true
}
}
Expand Down

0 comments on commit 9f54c6a

Please sign in to comment.