From efa03a440f1ba8feeeb9892becc58ed27014e8db Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Thu, 17 Nov 2022 18:21:58 +0900 Subject: [PATCH] refactor: import version from rollup --- packages/vite/src/node/server/pluginContainer.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts index a5771abc719517..4c4d7ffb1f1a13 100644 --- a/packages/vite/src/node/server/pluginContainer.ts +++ b/packages/vite/src/node/server/pluginContainer.ts @@ -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, @@ -173,18 +173,9 @@ export async function createPluginContainer( const watchFiles = new Set() - // 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 } }