chore: prefer import over require (#24568)

This commit is contained in:
Ben McCann 2023-08-04 13:21:41 -07:00 committed by GitHub
parent 8fde110c61
commit 6ebee33857
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,7 +75,7 @@ export function createPlugin(
const registerSource = await fs.promises.readFile(registerSourceFile, 'utf-8');
const registerSourceHash = calculateSha1(registerSource);
const { version: viteVersion } = require('vite/package.json');
const { version: viteVersion } = await import('vite');
try {
buildInfo = JSON.parse(await fs.promises.readFile(buildInfoFile, 'utf-8')) as BuildInfo;
assert(buildInfo.version === playwrightVersion);
@ -123,7 +123,7 @@ export function createPlugin(
}
};
}
const { build, preview } = require('vite');
const { build, preview } = await import('vite');
// Build config unconditionally, either build or build & preview will use it.
viteConfig.plugins ??= [];
if (frameworkPluginFactory && !viteConfig.plugins.length)