chore: introduce ct-core to hard-depend on vite (#22437)

Fixes https://github.com/microsoft/playwright/issues/22233
This commit is contained in:
Pavel Feldman 2023-04-17 19:19:21 -04:00 committed by GitHub
parent 5b48df36b3
commit 8d69fbacf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 155 additions and 79 deletions

79
package-lock.json generated
View file

@ -1342,6 +1342,10 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/@playwright/experimental-ct-core": {
"resolved": "packages/playwright-ct-core",
"link": true
},
"node_modules/@playwright/experimental-ct-react": { "node_modules/@playwright/experimental-ct-react": {
"resolved": "packages/playwright-ct-react", "resolved": "packages/playwright-ct-react",
"link": true "link": true
@ -6194,14 +6198,27 @@
"node": ">=14" "node": ">=14"
} }
}, },
"packages/playwright-ct-core": {
"version": "1.33.0-next",
"license": "Apache-2.0",
"dependencies": {
"@playwright/test": "1.33.0-next",
"vite": "^4.2.1"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=14"
}
},
"packages/playwright-ct-react": { "packages/playwright-ct-react": {
"name": "@playwright/experimental-ct-react", "name": "@playwright/experimental-ct-react",
"version": "1.33.0-next", "version": "1.33.0-next",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@vitejs/plugin-react": "^3.1.0", "@vitejs/plugin-react": "^3.1.0"
"vite": "^4.2.1"
}, },
"bin": { "bin": {
"playwright": "cli.js" "playwright": "cli.js"
@ -6215,9 +6232,8 @@
"version": "1.33.0-next", "version": "1.33.0-next",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@vitejs/plugin-react": "^3.1.0", "@vitejs/plugin-react": "^3.1.0"
"vite": "^4.2.1"
}, },
"bin": { "bin": {
"playwright": "cli.js" "playwright": "cli.js"
@ -6231,8 +6247,7 @@
"version": "1.33.0-next", "version": "1.33.0-next",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"vite": "^4.2.1",
"vite-plugin-solid": "^2.6.1" "vite-plugin-solid": "^2.6.1"
}, },
"bin": { "bin": {
@ -6250,9 +6265,8 @@
"version": "1.33.0-next", "version": "1.33.0-next",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@sveltejs/vite-plugin-svelte": "^2.0.3", "@sveltejs/vite-plugin-svelte": "^2.0.3"
"vite": "^4.2.1"
}, },
"bin": { "bin": {
"playwright": "cli.js" "playwright": "cli.js"
@ -6269,9 +6283,8 @@
"version": "1.33.0-next", "version": "1.33.0-next",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@vitejs/plugin-vue": "^4.1.0", "@vitejs/plugin-vue": "^4.1.0"
"vite": "^4.2.1"
}, },
"bin": { "bin": {
"playwright": "cli.js" "playwright": "cli.js"
@ -6321,9 +6334,8 @@
"version": "1.33.0-next", "version": "1.33.0-next",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@vitejs/plugin-vue2": "^2.2.0", "@vitejs/plugin-vue2": "^2.2.0"
"vite": "^4.2.1"
}, },
"bin": { "bin": {
"playwright": "cli.js" "playwright": "cli.js"
@ -7163,46 +7175,48 @@
"fastq": "^1.6.0" "fastq": "^1.6.0"
} }
}, },
"@playwright/experimental-ct-core": {
"version": "file:packages/playwright-ct-core",
"requires": {
"@playwright/test": "1.33.0-next",
"vite": "^4.2.1"
}
},
"@playwright/experimental-ct-react": { "@playwright/experimental-ct-react": {
"version": "file:packages/playwright-ct-react", "version": "file:packages/playwright-ct-react",
"requires": { "requires": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@vitejs/plugin-react": "^3.1.0", "@vitejs/plugin-react": "^3.1.0"
"vite": "^4.2.1"
} }
}, },
"@playwright/experimental-ct-react17": { "@playwright/experimental-ct-react17": {
"version": "file:packages/playwright-ct-react17", "version": "file:packages/playwright-ct-react17",
"requires": { "requires": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@vitejs/plugin-react": "^3.1.0", "@vitejs/plugin-react": "^3.1.0"
"vite": "^4.2.1"
} }
}, },
"@playwright/experimental-ct-solid": { "@playwright/experimental-ct-solid": {
"version": "file:packages/playwright-ct-solid", "version": "file:packages/playwright-ct-solid",
"requires": { "requires": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"solid-js": "^1.7.0", "solid-js": "^1.7.0",
"vite": "^4.2.1",
"vite-plugin-solid": "^2.6.1" "vite-plugin-solid": "^2.6.1"
} }
}, },
"@playwright/experimental-ct-svelte": { "@playwright/experimental-ct-svelte": {
"version": "file:packages/playwright-ct-svelte", "version": "file:packages/playwright-ct-svelte",
"requires": { "requires": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@sveltejs/vite-plugin-svelte": "^2.0.3", "@sveltejs/vite-plugin-svelte": "^2.0.3",
"svelte": "^3.55.1", "svelte": "^3.55.1"
"vite": "^4.2.1"
} }
}, },
"@playwright/experimental-ct-vue": { "@playwright/experimental-ct-vue": {
"version": "file:packages/playwright-ct-vue", "version": "file:packages/playwright-ct-vue",
"requires": { "requires": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@vitejs/plugin-vue": "^4.1.0", "@vitejs/plugin-vue": "^4.1.0"
"vite": "^4.2.1"
}, },
"dependencies": { "dependencies": {
"@vitejs/plugin-vue": { "@vitejs/plugin-vue": {
@ -7235,9 +7249,8 @@
"@playwright/experimental-ct-vue2": { "@playwright/experimental-ct-vue2": {
"version": "file:packages/playwright-ct-vue2", "version": "file:packages/playwright-ct-vue2",
"requires": { "requires": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@vitejs/plugin-vue2": "^2.2.0", "@vitejs/plugin-vue2": "^2.2.0",
"vite": "^4.2.1",
"vue": "^2.7.14" "vue": "^2.7.14"
} }
}, },

View file

@ -0,0 +1,6 @@
**/*
!README.md
!LICENSE
!cli.js
!lib/**

View file

@ -0,0 +1,3 @@
> **BEWARE** This package is EXPERIMENTAL and does not respect semver.
Read more at https://playwright.dev/docs/test-components

View file

@ -0,0 +1,17 @@
#!/usr/bin/env node
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('@playwright/test/cli');

View file

@ -0,0 +1,25 @@
{
"name": "@playwright/experimental-ct-core",
"version": "1.33.0-next",
"description": "Playwright Component Testing Helpers",
"repository": "github:Microsoft/playwright",
"homepage": "https://playwright.dev",
"engines": {
"node": ">=14"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"exports": {
"./cli": "./cli.js",
"./lib/vitePlugin": "./lib/vitePlugin.js"
},
"dependencies": {
"vite": "^4.2.1",
"@playwright/test": "1.33.0-next"
},
"bin": {
"playwright": "./cli.js"
}
}

View file

@ -14,21 +14,23 @@
* limitations under the License. * limitations under the License.
*/ */
import fs from 'fs'; import type { Suite } from '@playwright/test/reporter';
import type { Suite } from '../../types/testReporter';
import path from 'path';
import type { InlineConfig, Plugin, ResolveFn, ResolvedConfig } from 'vite';
import type { TestRunnerPlugin } from '.';
import { parse, traverse, types as t } from '../common/babelBundle';
import { stoppable } from '../utilsBundle';
import type { ComponentInfo } from '../common/tsxTransform';
import { collectComponentUsages, componentInfo } from '../common/tsxTransform';
import { assert, calculateSha1 } from 'playwright-core/lib/utils';
import type { AddressInfo } from 'net';
import { getPlaywrightVersion } from 'playwright-core/lib/utils';
import type { PlaywrightTestConfig as BasePlaywrightTestConfig, FullConfig } from '@playwright/test'; import type { PlaywrightTestConfig as BasePlaywrightTestConfig, FullConfig } from '@playwright/test';
import type { InlineConfig, Plugin, ResolveFn, ResolvedConfig } from 'vite';
import type { TestRunnerPlugin } from '../../playwright-test/src/plugins';
import type { ComponentInfo } from '../../playwright-test/src/common/tsxTransform';
import type { AddressInfo } from 'net';
import type { PluginContext } from 'rollup'; import type { PluginContext } from 'rollup';
import { setExternalDependencies } from '../common/compilationCache';
import fs from 'fs';
import path from 'path';
import { parse, traverse, types as t } from '@playwright/test/lib/common/babelBundle';
import { stoppable } from '@playwright/test/lib/utilsBundle';
import { collectComponentUsages, componentInfo } from '@playwright/test/lib/common/tsxTransform';
import { assert, calculateSha1 } from 'playwright-core/lib/utils';
import { getPlaywrightVersion } from 'playwright-core/lib/utils';
import { setExternalDependencies } from '@playwright/test/lib/common/compilationCache';
let stoppableServer: any; let stoppableServer: any;
const playwrightVersion = getPlaywrightVersion(); const playwrightVersion = getPlaywrightVersion();

View file

@ -14,4 +14,4 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
module.exports = require('@playwright/test/cli'); module.exports = require('@playwright/experimental-ct-core/cli');

View file

@ -20,7 +20,7 @@ const path = require('path');
const plugin = () => { const plugin = () => {
// Only fetch upon request to avoid resolution in workers. // Only fetch upon request to avoid resolution in workers.
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin'); const { createPlugin } = require('@playwright/experimental-ct-core/lib/vitePlugin');
return createPlugin( return createPlugin(
path.join(__dirname, 'registerSource.mjs'), path.join(__dirname, 'registerSource.mjs'),
() => import('@vitejs/plugin-react').then(plugin => plugin.default())); () => import('@vitejs/plugin-react').then(plugin => plugin.default()));

View file

@ -26,9 +26,8 @@
} }
}, },
"dependencies": { "dependencies": {
"@vitejs/plugin-react": "^3.1.0", "@playwright/experimental-ct-core": "1.33.0-next",
"@playwright/test": "1.33.0-next", "@vitejs/plugin-react": "^3.1.0"
"vite": "^4.2.1"
}, },
"bin": { "bin": {
"playwright": "./cli.js" "playwright": "./cli.js"

View file

@ -14,4 +14,4 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
module.exports = require('playwright-core/cli'); module.exports = require('@playwright/experimental-ct-core/cli');

View file

@ -20,7 +20,7 @@ const path = require('path');
const plugin = () => { const plugin = () => {
// Only fetch upon request to avoid resolution in workers. // Only fetch upon request to avoid resolution in workers.
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin'); const { createPlugin } = require('@playwright/experimental-ct-core/lib/vitePlugin');
return createPlugin( return createPlugin(
path.join(__dirname, 'registerSource.mjs'), path.join(__dirname, 'registerSource.mjs'),
() => import('@vitejs/plugin-react').then(plugin => plugin.default())); () => import('@vitejs/plugin-react').then(plugin => plugin.default()));

View file

@ -26,9 +26,8 @@
} }
}, },
"dependencies": { "dependencies": {
"@vitejs/plugin-react": "^3.1.0", "@playwright/experimental-ct-core": "1.33.0-next",
"@playwright/test": "1.33.0-next", "@vitejs/plugin-react": "^3.1.0"
"vite": "^4.2.1"
}, },
"bin": { "bin": {
"playwright": "./cli.js" "playwright": "./cli.js"

View file

@ -14,4 +14,4 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
module.exports = require('@playwright/test/cli'); module.exports = require('@playwright/experimental-ct-core/cli');

View file

@ -20,7 +20,7 @@ const path = require('path');
const plugin = () => { const plugin = () => {
// Only fetch upon request to avoid resolution in workers. // Only fetch upon request to avoid resolution in workers.
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin'); const { createPlugin } = require('@playwright/experimental-ct-core/lib/vitePlugin');
return createPlugin( return createPlugin(
path.join(__dirname, 'registerSource.mjs'), path.join(__dirname, 'registerSource.mjs'),
() => import('vite-plugin-solid').then(plugin => plugin.default())); () => import('vite-plugin-solid').then(plugin => plugin.default()));

View file

@ -26,9 +26,8 @@
} }
}, },
"dependencies": { "dependencies": {
"vite": "^4.2.1", "@playwright/experimental-ct-core": "1.33.0-next",
"vite-plugin-solid": "^2.6.1", "vite-plugin-solid": "^2.6.1"
"@playwright/test": "1.33.0-next"
}, },
"devDependencies": { "devDependencies": {
"solid-js": "^1.7.0" "solid-js": "^1.7.0"

View file

@ -14,4 +14,4 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
module.exports = require('@playwright/test/cli'); module.exports = require('@playwright/experimental-ct-core/cli');

View file

@ -20,7 +20,7 @@ const path = require('path');
const plugin = () => { const plugin = () => {
// Only fetch upon request to avoid resolution in workers. // Only fetch upon request to avoid resolution in workers.
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin'); const { createPlugin } = require('@playwright/experimental-ct-core/lib/vitePlugin');
return createPlugin( return createPlugin(
path.join(__dirname, 'registerSource.mjs'), path.join(__dirname, 'registerSource.mjs'),
() => import('@sveltejs/vite-plugin-svelte').then(plugin => plugin.svelte())); () => import('@sveltejs/vite-plugin-svelte').then(plugin => plugin.svelte()));

View file

@ -26,9 +26,8 @@
} }
}, },
"dependencies": { "dependencies": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@sveltejs/vite-plugin-svelte": "^2.0.3", "@sveltejs/vite-plugin-svelte": "^2.0.3"
"vite": "^4.2.1"
}, },
"devDependencies": { "devDependencies": {
"svelte": "^3.55.1" "svelte": "^3.55.1"

View file

@ -14,4 +14,4 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
module.exports = require('@playwright/test/cli'); module.exports = require('@playwright/experimental-ct-core/cli');

View file

@ -20,7 +20,7 @@ const path = require('path');
const plugin = () => { const plugin = () => {
// Only fetch upon request to avoid resolution in workers. // Only fetch upon request to avoid resolution in workers.
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin'); const { createPlugin } = require('@playwright/experimental-ct-core/lib/vitePlugin');
return createPlugin( return createPlugin(
path.join(__dirname, 'registerSource.mjs'), path.join(__dirname, 'registerSource.mjs'),
() => import('@vitejs/plugin-vue').then(plugin => plugin.default())); () => import('@vitejs/plugin-vue').then(plugin => plugin.default()));

View file

@ -26,9 +26,8 @@
} }
}, },
"dependencies": { "dependencies": {
"@vitejs/plugin-vue": "^4.1.0", "@playwright/experimental-ct-core": "1.33.0-next",
"@playwright/test": "1.33.0-next", "@vitejs/plugin-vue": "^4.1.0"
"vite": "^4.2.1"
}, },
"bin": { "bin": {
"playwright": "./cli.js" "playwright": "./cli.js"

View file

@ -14,4 +14,4 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
module.exports = require('@playwright/test/cli'); module.exports = require('@playwright/experimental-ct-core/cli');

View file

@ -20,7 +20,7 @@ const path = require('path');
const plugin = () => { const plugin = () => {
// Only fetch upon request to avoid resolution in workers. // Only fetch upon request to avoid resolution in workers.
const { createPlugin } = require('@playwright/test/lib/plugins/vitePlugin'); const { createPlugin } = require('@playwright/experimental-ct-core/lib/vitePlugin');
return createPlugin( return createPlugin(
path.join(__dirname, 'registerSource.mjs'), path.join(__dirname, 'registerSource.mjs'),
() => import('@vitejs/plugin-vue2').then(plugin => plugin.default())); () => import('@vitejs/plugin-vue2').then(plugin => plugin.default()));

View file

@ -26,9 +26,8 @@
} }
}, },
"dependencies": { "dependencies": {
"@playwright/test": "1.33.0-next", "@playwright/experimental-ct-core": "1.33.0-next",
"@vitejs/plugin-vue2": "^2.2.0", "@vitejs/plugin-vue2": "^2.2.0"
"vite": "^4.2.1"
}, },
"devDependencies": { "devDependencies": {
"vue": "^2.7.14" "vue": "^2.7.14"

View file

@ -18,11 +18,14 @@
"./cli": "./cli.js", "./cli": "./cli.js",
"./package.json": "./package.json", "./package.json": "./package.json",
"./lib/cli": "./lib/cli.js", "./lib/cli": "./lib/cli.js",
"./lib/common/babelBundle": "./lib/common/babelBundle.js",
"./lib/common/compilationCache": "./lib/common/compilationCache.js",
"./lib/common/tsxTransform": "./lib/common/tsxTransform.js",
"./lib/internalsForTest": "./lib/internalsForTest.js", "./lib/internalsForTest": "./lib/internalsForTest.js",
"./lib/experimentalLoader": "./lib/experimentalLoader.js", "./lib/experimentalLoader": "./lib/experimentalLoader.js",
"./lib/mount": "./lib/mount.js", "./lib/mount": "./lib/mount.js",
"./lib/plugins": "./lib/plugins/index.js", "./lib/plugins": "./lib/plugins/index.js",
"./lib/plugins/vitePlugin": "./lib/plugins/vitePlugin.js", "./lib/utilsBundle": "./lib/utilsBundle.js",
"./reporter": "./reporter.js" "./reporter": "./reporter.js"
}, },
"bin": { "bin": {

View file

@ -67,6 +67,13 @@ export async function writeFiles(testInfo: TestInfo, files: Files, initial: bool
}; };
} }
if (initial && !Object.keys(files).some(name => name.includes('tsconfig.json') || name.includes('jsconfig.json'))) {
files = {
...files,
'tsconfig.json': `{}`,
};
}
await Promise.all(Object.keys(files).map(async name => { await Promise.all(Object.keys(files).map(async name => {
const fullName = path.join(baseDir, name); const fullName = path.join(baseDir, name);
await fs.promises.mkdir(path.dirname(fullName), { recursive: true }); await fs.promises.mkdir(path.dirname(fullName), { recursive: true });

View file

@ -7,8 +7,8 @@
"paths": { "paths": {
/* /*
The following two serve different purposes: The following two serve different purposes:
- @foo is for importing types only, - @foo/* is for importing types only,
- foo/lib means require dependency - .../lib/* means require dependency
*/ */
"@html-reporter/*": ["./packages/html-reporter/src/*"], "@html-reporter/*": ["./packages/html-reporter/src/*"],
"@injected/*": ["./packages/playwright-core/src/server/injected/*"], "@injected/*": ["./packages/playwright-core/src/server/injected/*"],
@ -19,6 +19,7 @@
"@trace/*": ["./packages/trace/src/*"], "@trace/*": ["./packages/trace/src/*"],
"@web/*": ["./packages/web/src/*"], "@web/*": ["./packages/web/src/*"],
"playwright-core/lib/*": ["./packages/playwright-core/src/*"], "playwright-core/lib/*": ["./packages/playwright-core/src/*"],
"@playwright/test/lib/*": ["./packages/playwright-test/src/*"],
}, },
"esModuleInterop": true, "esModuleInterop": true,
"strict": true, "strict": true,

View file

@ -173,6 +173,11 @@ const workspace = new Workspace(ROOT_PATH, [
path: path.join(ROOT_PATH, 'packages', 'playwright-chromium'), path: path.join(ROOT_PATH, 'packages', 'playwright-chromium'),
files: LICENCE_FILES, files: LICENCE_FILES,
}), }),
new PWPackage({
name: '@playwright/experimental-ct-core',
path: path.join(ROOT_PATH, 'packages', 'playwright-ct-core'),
files: ['LICENSE'],
}),
new PWPackage({ new PWPackage({
name: '@playwright/experimental-ct-react', name: '@playwright/experimental-ct-react',
path: path.join(ROOT_PATH, 'packages', 'playwright-ct-react'), path: path.join(ROOT_PATH, 'packages', 'playwright-ct-react'),