chore: migrate ct to vite5 (#29033)
Closes https://github.com/microsoft/playwright/issues/28607
This commit is contained in:
parent
54c57fdebe
commit
71a48c2562
File diff suppressed because it is too large
Load Diff
|
@ -73,8 +73,8 @@
|
||||||
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
||||||
"@typescript-eslint/parser": "^6.13.2",
|
"@typescript-eslint/parser": "^6.13.2",
|
||||||
"@typescript-eslint/utils": "^6.13.2",
|
"@typescript-eslint/utils": "^6.13.2",
|
||||||
"@vitejs/plugin-basic-ssl": "^1.0.1",
|
"@vitejs/plugin-basic-ssl": "^1.1.0",
|
||||||
"@vitejs/plugin-react": "^3.1.0",
|
"@vitejs/plugin-react": "^4.2.1",
|
||||||
"@zip.js/zip.js": "^2.7.29",
|
"@zip.js/zip.js": "^2.7.29",
|
||||||
"chokidar": "^3.5.3",
|
"chokidar": "^3.5.3",
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
"socksv5": "0.0.6",
|
"socksv5": "0.0.6",
|
||||||
"ssim.js": "^3.5.0",
|
"ssim.js": "^3.5.0",
|
||||||
"typescript": "^5.3.2",
|
"typescript": "^5.3.2",
|
||||||
"vite": "^4.4.12",
|
"vite": "^5.0.11",
|
||||||
"ws": "^8.5.0",
|
"ws": "^8.5.0",
|
||||||
"xml2js": "^0.5.0",
|
"xml2js": "^0.5.0",
|
||||||
"yaml": "^2.2.2"
|
"yaml": "^2.2.2"
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"playwright-core": "1.42.0-next",
|
"playwright-core": "1.42.0-next",
|
||||||
"vite": "^4.4.12",
|
"vite": "^5.0.11",
|
||||||
"playwright": "1.42.0-next"
|
"playwright": "1.42.0-next"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
|
@ -16,20 +16,18 @@
|
||||||
|
|
||||||
import type { Suite } from 'playwright/types/testReporter';
|
import type { Suite } from 'playwright/types/testReporter';
|
||||||
import type { PlaywrightTestConfig as BasePlaywrightTestConfig, FullConfig } from 'playwright/test';
|
import type { PlaywrightTestConfig as BasePlaywrightTestConfig, FullConfig } from 'playwright/test';
|
||||||
|
import type http from 'http';
|
||||||
import type { InlineConfig, Plugin, ResolveFn, ResolvedConfig, UserConfig } from 'vite';
|
import type { InlineConfig, Plugin, ResolveFn, ResolvedConfig, UserConfig } from 'vite';
|
||||||
import type { TestRunnerPlugin } from '../../playwright/src/plugins';
|
import type { TestRunnerPlugin } from '../../playwright/src/plugins';
|
||||||
import type { AddressInfo } from 'net';
|
import type { AddressInfo } from 'net';
|
||||||
import type { PluginContext } from 'rollup';
|
import type { PluginContext } from 'rollup';
|
||||||
import { debug } from 'playwright-core/lib/utilsBundle';
|
import { debug } from 'playwright-core/lib/utilsBundle';
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { stoppable } from 'playwright/lib/utilsBundle';
|
import { stoppable } from 'playwright/lib/utilsBundle';
|
||||||
import { assert, calculateSha1 } from 'playwright-core/lib/utils';
|
import { assert, calculateSha1 } from 'playwright-core/lib/utils';
|
||||||
import { getPlaywrightVersion } from 'playwright-core/lib/utils';
|
import { getPlaywrightVersion } from 'playwright-core/lib/utils';
|
||||||
import { getUserData, internalDependenciesForTestFile, setExternalDependencies } from 'playwright/lib/transform/compilationCache';
|
import { getUserData, internalDependenciesForTestFile, setExternalDependencies } from 'playwright/lib/transform/compilationCache';
|
||||||
import { version as viteVersion, build, preview, mergeConfig } from 'vite';
|
|
||||||
import { source as injectedSource } from './generated/indexSource';
|
import { source as injectedSource } from './generated/indexSource';
|
||||||
import type { ImportInfo } from './tsxTransform';
|
import type { ImportInfo } from './tsxTransform';
|
||||||
|
|
||||||
|
@ -90,14 +88,17 @@ export function createPlugin(
|
||||||
outDir: use.ctCacheDir ? path.resolve(configDir, use.ctCacheDir) : path.resolve(templateDir, '.cache')
|
outDir: use.ctCacheDir ? path.resolve(configDir, use.ctCacheDir) : path.resolve(templateDir, '.cache')
|
||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
https: baseURL.protocol.startsWith('https:'),
|
https: baseURL.protocol.startsWith('https:') ? {} : undefined,
|
||||||
host: baseURL.hostname,
|
host: baseURL.hostname,
|
||||||
port: use.ctPort || Number(baseURL.port) || 3100
|
port: use.ctPort || Number(baseURL.port) || 3100
|
||||||
},
|
},
|
||||||
// Vite preview server will otherwise always return the index.html with 200.
|
// Vite preview server will otherwise always return the index.html with 200.
|
||||||
appType: 'custom',
|
appType: 'mpa',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Vite 5 refuses to support CJS.
|
||||||
|
const { version: viteVersion, build, preview, mergeConfig } = await import('vite');
|
||||||
|
|
||||||
// Apply user config on top of the base config. This could have changed root and build.outDir.
|
// Apply user config on top of the base config. This could have changed root and build.outDir.
|
||||||
const userConfig = typeof use.ctViteConfig === 'function' ? await use.ctViteConfig() : (use.ctViteConfig || {});
|
const userConfig = typeof use.ctViteConfig === 'function' ? await use.ctViteConfig() : (use.ctViteConfig || {});
|
||||||
const baseAndUserConfig = mergeConfig(baseConfig, userConfig);
|
const baseAndUserConfig = mergeConfig(baseConfig, userConfig);
|
||||||
|
@ -217,7 +218,7 @@ export function createPlugin(
|
||||||
}
|
}
|
||||||
|
|
||||||
const previewServer = await preview(finalConfig);
|
const previewServer = await preview(finalConfig);
|
||||||
stoppableServer = stoppable(previewServer.httpServer, 0);
|
stoppableServer = stoppable(previewServer.httpServer as http.Server, 0);
|
||||||
const isAddressInfo = (x: any): x is AddressInfo => x?.address;
|
const isAddressInfo = (x: any): x is AddressInfo => x?.address;
|
||||||
const address = previewServer.httpServer.address();
|
const address = previewServer.httpServer.address();
|
||||||
if (isAddressInfo(address)) {
|
if (isAddressInfo(address)) {
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@playwright/experimental-ct-core": "1.42.0-next",
|
"@playwright/experimental-ct-core": "1.42.0-next",
|
||||||
"@vitejs/plugin-react": "^4.0.0"
|
"@vitejs/plugin-react": "^4.2.1"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright": "cli.js"
|
"playwright": "cli.js"
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@playwright/experimental-ct-core": "1.42.0-next",
|
"@playwright/experimental-ct-core": "1.42.0-next",
|
||||||
"@vitejs/plugin-react": "^4.0.0"
|
"@vitejs/plugin-react": "^4.2.1"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"playwright": "cli.js"
|
"playwright": "cli.js"
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^18.0.26",
|
"@types/react": "^18.0.26",
|
||||||
"@types/react-dom": "^18.0.10",
|
"@types/react-dom": "^18.0.10",
|
||||||
"@vitejs/plugin-react": "^3.1.0",
|
"@vitejs/plugin-react": "^4.2.1",
|
||||||
"typescript": "^4.5.4",
|
"typescript": "^4.5.4",
|
||||||
"vite": "^4.2.1"
|
"vite": "^5.0.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^4.7.4",
|
"typescript": "^4.7.4",
|
||||||
"vite": "^4.2.1",
|
"vite": "^5.0.11",
|
||||||
"vite-plugin-solid": "^2.6.1"
|
"vite-plugin-solid": "^2.6.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
"svelte-check": "^3.6.2",
|
"svelte-check": "^3.6.2",
|
||||||
"tslib": "^2.6.2",
|
"tslib": "^2.6.2",
|
||||||
"typescript": "^5.3.3",
|
"typescript": "^5.3.3",
|
||||||
"vite": "^5.0.8"
|
"vite": "^5.0.11"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"svelte": "^4.2.8",
|
"svelte": "^4.2.8",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^4.1.0",
|
"@vitejs/plugin-vue": "^4.1.0",
|
||||||
"@vue/tsconfig": "^0.1.3",
|
"@vue/tsconfig": "^0.1.3",
|
||||||
"vite": "^4.2.1",
|
"vite": "^5.0.11",
|
||||||
"vue-tsc": "^1.0.0"
|
"vue-tsc": "^1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
import { test } from './npmTest';
|
import { test } from './npmTest';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
test.slow();
|
||||||
|
|
||||||
test('pnpm: @playwright/experimental-ct-react should work', async ({ exec, tmpWorkspace, writeFiles }) => {
|
test('pnpm: @playwright/experimental-ct-react should work', async ({ exec, tmpWorkspace, writeFiles }) => {
|
||||||
await exec('pnpm add @playwright/experimental-ct-react react react-dom');
|
await exec('pnpm add @playwright/experimental-ct-react react react-dom');
|
||||||
await exec('pnpm exec playwright install');
|
await exec('pnpm exec playwright install');
|
||||||
|
|
|
@ -346,6 +346,7 @@ const TSCONFIG = {
|
||||||
'rootDir': '.',
|
'rootDir': '.',
|
||||||
'lib': ['esnext', 'dom', 'DOM.Iterable'],
|
'lib': ['esnext', 'dom', 'DOM.Iterable'],
|
||||||
'noEmit': true,
|
'noEmit': true,
|
||||||
|
'skipLibCheck': true,
|
||||||
},
|
},
|
||||||
'exclude': [
|
'exclude': [
|
||||||
'node_modules'
|
'node_modules'
|
||||||
|
|
Loading…
Reference in New Issue