cherry-pick(#17367): chore: rebuild components on new vite
This commit is contained in:
parent
e1681a3a89
commit
8a8c89bea8
|
|
@ -75,7 +75,7 @@ export function getClientLanguage(): { langName: string, langVersion: string } {
|
||||||
return { langName, langVersion };
|
return { langName, langVersion };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPlaywrightVersion(majorMinorOnly = false) {
|
export function getPlaywrightVersion(majorMinorOnly = false): string {
|
||||||
const packageJson = require('./../../package.json');
|
const packageJson = require('./../../package.json');
|
||||||
return majorMinorOnly ? packageJson.version.split('.').slice(0, 2).join('.') : packageJson.version;
|
return majorMinorOnly ? packageJson.version.split('.').slice(0, 2).join('.') : packageJson.version;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,10 @@ import { collectComponentUsages, componentInfo } from '../tsxTransform';
|
||||||
import type { FullConfig } from '../types';
|
import type { FullConfig } from '../types';
|
||||||
import { assert, calculateSha1 } from 'playwright-core/lib/utils';
|
import { assert, calculateSha1 } from 'playwright-core/lib/utils';
|
||||||
import type { AddressInfo } from 'net';
|
import type { AddressInfo } from 'net';
|
||||||
|
import { getPlaywrightVersion } from 'playwright-core/lib/common/userAgent';
|
||||||
|
|
||||||
let stoppableServer: any;
|
let stoppableServer: any;
|
||||||
const VERSION = 6;
|
const playwrightVersion = getPlaywrightVersion();
|
||||||
|
|
||||||
type CtConfig = {
|
type CtConfig = {
|
||||||
ctPort?: number;
|
ctPort?: number;
|
||||||
|
|
@ -65,14 +66,17 @@ export function createPlugin(
|
||||||
const registerSource = await fs.promises.readFile(registerSourceFile, 'utf-8');
|
const registerSource = await fs.promises.readFile(registerSourceFile, 'utf-8');
|
||||||
const registerSourceHash = calculateSha1(registerSource);
|
const registerSourceHash = calculateSha1(registerSource);
|
||||||
|
|
||||||
|
const { version: viteVersion } = require('vite/package.json');
|
||||||
try {
|
try {
|
||||||
buildInfo = JSON.parse(await fs.promises.readFile(buildInfoFile, 'utf-8')) as BuildInfo;
|
buildInfo = JSON.parse(await fs.promises.readFile(buildInfoFile, 'utf-8')) as BuildInfo;
|
||||||
assert(buildInfo.version === VERSION);
|
assert(buildInfo.version === playwrightVersion);
|
||||||
|
assert(buildInfo.viteVersion === viteVersion);
|
||||||
assert(buildInfo.registerSourceHash === registerSourceHash);
|
assert(buildInfo.registerSourceHash === registerSourceHash);
|
||||||
buildExists = true;
|
buildExists = true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
buildInfo = {
|
buildInfo = {
|
||||||
version: VERSION,
|
version: playwrightVersion,
|
||||||
|
viteVersion,
|
||||||
registerSourceHash,
|
registerSourceHash,
|
||||||
components: [],
|
components: [],
|
||||||
tests: {},
|
tests: {},
|
||||||
|
|
@ -156,7 +160,8 @@ export function createPlugin(
|
||||||
}
|
}
|
||||||
|
|
||||||
type BuildInfo = {
|
type BuildInfo = {
|
||||||
version: number,
|
version: string,
|
||||||
|
viteVersion: string,
|
||||||
registerSourceHash: string,
|
registerSourceHash: string,
|
||||||
sources: {
|
sources: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ test('should work with the empty component list', async ({ runInlineTest }, test
|
||||||
expect(output.replace(/\\+/g, '/')).toContain('playwright/.cache/playwright/index.html');
|
expect(output.replace(/\\+/g, '/')).toContain('playwright/.cache/playwright/index.html');
|
||||||
|
|
||||||
const metainfo = JSON.parse(fs.readFileSync(testInfo.outputPath('playwright/.cache/metainfo.json'), 'utf-8'));
|
const metainfo = JSON.parse(fs.readFileSync(testInfo.outputPath('playwright/.cache/metainfo.json'), 'utf-8'));
|
||||||
expect(metainfo.version).toEqual(expect.any(Number));
|
expect(metainfo.version).toEqual(require('playwright-core/package.json').version);
|
||||||
|
expect(metainfo.viteVersion).toEqual(require('vite/package.json').version);
|
||||||
expect(Object.entries(metainfo.tests)).toHaveLength(1);
|
expect(Object.entries(metainfo.tests)).toHaveLength(1);
|
||||||
expect(Object.entries(metainfo.sources)).toHaveLength(8);
|
expect(Object.entries(metainfo.sources)).toHaveLength(8);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue