chore: move transform to its own folder (for loader worker) (#23247)

This commit is contained in:
Pavel Feldman 2023-05-23 21:05:33 -07:00 committed by GitHub
parent 2858ca95d8
commit 76b4b9dbaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 47 additions and 29 deletions

View File

@ -15,8 +15,8 @@
*/ */
import path from 'path'; import path from 'path';
import type { T, BabelAPI } from '../../playwright-test/src/common/babelBundle'; import type { T, BabelAPI } from '@playwright/test/src/transform/babelBundle';
import { types, declare, traverse } from '@playwright/test/lib/common/babelBundle'; import { types, declare, traverse } from '@playwright/test/lib/transform/babelBundle';
import { resolveImportSpecifierExtension } from '@playwright/test/lib/util'; import { resolveImportSpecifierExtension } from '@playwright/test/lib/util';
const t: typeof T = types; const t: typeof T = types;

View File

@ -25,11 +25,11 @@ import type { PluginContext } from 'rollup';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { parse, traverse, types as t } from '@playwright/test/lib/common/babelBundle'; import { parse, traverse, types as t } from '@playwright/test/lib/transform/babelBundle';
import { stoppable } from '@playwright/test/lib/utilsBundle'; import { stoppable } from '@playwright/test/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 { setExternalDependencies } from '@playwright/test/lib/common/compilationCache'; import { setExternalDependencies } from '@playwright/test/lib/transform/compilationCache';
import { collectComponentUsages, componentInfo } from './tsxTransform'; import { collectComponentUsages, componentInfo } from './tsxTransform';
let stoppableServer: any; let stoppableServer: any;

View File

@ -3,7 +3,7 @@
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"scripts": { "scripts": {
"esbuild": "esbuild ./src/babelBundleImpl.ts --bundle --outdir=../../lib/common --format=cjs --platform=node --target=ES2019", "esbuild": "esbuild ./src/babelBundleImpl.ts --bundle --outdir=../../lib/transform --format=cjs --platform=node --target=ES2019",
"build": "npm run esbuild -- --minify", "build": "npm run esbuild -- --minify",
"watch": "npm run esbuild -- --watch --sourcemap", "watch": "npm run esbuild -- --watch --sourcemap",
"generate-license": "node ../../../../utils/generate_third_party_notice.js" "generate-license": "node ../../../../utils/generate_third_party_notice.js"

View File

@ -18,8 +18,8 @@
"./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/transform/babelBundle": "./lib/transform/babelBundle.js",
"./lib/common/compilationCache": "./lib/common/compilationCache.js", "./lib/transform/compilationCache": "./lib/transform/compilationCache.js",
"./lib/internalsForTest": "./lib/internalsForTest.js", "./lib/internalsForTest": "./lib/internalsForTest.js",
"./lib/experimentalLoader": "./lib/experimentalLoader.js", "./lib/experimentalLoader": "./lib/experimentalLoader.js",
"./lib/plugins": "./lib/plugins/index.js", "./lib/plugins": "./lib/plugins/index.js",

View File

@ -8,3 +8,9 @@ common/
[index.ts] [index.ts]
@testIsomorphic/** @testIsomorphic/**
[experimentalLoader.ts]
./transform/
[internalsForTest.ts]
**

View File

@ -1,9 +1,8 @@
[*] [*]
../util.ts ../util.ts
../utilsBundle.ts ../utilsBundle.ts
../transform
[transform.ts]
../third_party/tsconfig-loader.ts
[testType.ts] [testType.ts]
../matchers/expect.ts ../matchers/expect.ts

View File

@ -18,7 +18,7 @@ import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import { isRegExp } from 'playwright-core/lib/utils'; import { isRegExp } from 'playwright-core/lib/utils';
import type { ConfigCLIOverrides, SerializedConfig } from './ipc'; import type { ConfigCLIOverrides, SerializedConfig } from './ipc';
import { requireOrImport, setBabelPlugins } from './transform'; import { requireOrImport, setBabelPlugins } from '../transform/transform';
import type { Config, Project } from '../../types/test'; import type { Config, Project } from '../../types/test';
import { errorWithFile } from '../util'; import { errorWithFile } from '../util';
import { setCurrentConfig } from './globals'; import { setCurrentConfig } from './globals';

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { serializeCompilationCache } from './compilationCache'; import { serializeCompilationCache } from '../transform/compilationCache';
import type { FullConfigInternal } from './config'; import type { FullConfigInternal } from './config';
import type { ReporterDescription, TestInfoError, TestStatus } from '../../types/test'; import type { ReporterDescription, TestInfoError, TestStatus } from '../../types/test';

View File

@ -19,9 +19,9 @@ import util from 'util';
import type { TestError } from '../../reporter'; import type { TestError } from '../../reporter';
import { isWorkerProcess, setCurrentlyLoadingFileSuite } from './globals'; import { isWorkerProcess, setCurrentlyLoadingFileSuite } from './globals';
import { Suite } from './test'; import { Suite } from './test';
import { requireOrImport } from './transform'; import { requireOrImport } from '../transform/transform';
import { filterStackTrace } from '../util'; import { filterStackTrace } from '../util';
import { startCollectingFileDeps, stopCollectingFileDeps } from './compilationCache'; import { startCollectingFileDeps, stopCollectingFileDeps } from '../transform/compilationCache';
export const defaultTimeout = 30000; export const defaultTimeout = 30000;

View File

@ -17,7 +17,7 @@
import { expect } from '../matchers/expect'; import { expect } from '../matchers/expect';
import { currentlyLoadingFileSuite, currentTestInfo, setCurrentlyLoadingFileSuite } from './globals'; import { currentlyLoadingFileSuite, currentTestInfo, setCurrentlyLoadingFileSuite } from './globals';
import { TestCase, Suite } from './test'; import { TestCase, Suite } from './test';
import { wrapFunctionWithLocation } from './transform'; import { wrapFunctionWithLocation } from '../transform/transform';
import type { FixturesWithLocation } from './config'; import type { FixturesWithLocation } from './config';
import type { Fixtures, TestType } from '../../types/test'; import type { Fixtures, TestType } from '../../types/test';
import type { Location } from '../../types/testReporter'; import type { Location } from '../../types/testReporter';

View File

@ -16,8 +16,8 @@
import fs from 'fs'; import fs from 'fs';
import url from 'url'; import url from 'url';
import { belongsToNodeModules, currentFileDepsCollector } from './common/compilationCache'; import { belongsToNodeModules, currentFileDepsCollector } from './transform/compilationCache';
import { transformHook, resolveHook } from './common/transform'; import { transformHook, resolveHook } from './transform/transform';
// Node < 18.6: defaultResolve takes 3 arguments. // Node < 18.6: defaultResolve takes 3 arguments.
// Node >= 18.6: nextResolve from the chain takes 2 arguments. // Node >= 18.6: nextResolve from the chain takes 2 arguments.

View File

@ -15,7 +15,7 @@
*/ */
import path from 'path'; import path from 'path';
import { fileDependenciesForTest } from './common/compilationCache'; import { fileDependenciesForTest } from './transform/compilationCache';
export function fileDependencies() { export function fileDependencies() {
return Object.fromEntries([...fileDependenciesForTest().entries()].map(entry => ( return Object.fromEntries([...fileDependenciesForTest().entries()].map(entry => (

View File

@ -1,2 +1,3 @@
[*] [*]
../common/ ../common/
../transform/

View File

@ -20,7 +20,7 @@ import { ProcessRunner } from '../common/process';
import type { FullConfigInternal } from '../common/config'; import type { FullConfigInternal } from '../common/config';
import { loadTestFile } from '../common/testLoader'; import { loadTestFile } from '../common/testLoader';
import type { TestError } from '../../reporter'; import type { TestError } from '../../reporter';
import { addToCompilationCache, serializeCompilationCache } from '../common/compilationCache'; import { addToCompilationCache, serializeCompilationCache } from '../transform/compilationCache';
import { PoolBuilder } from '../common/poolBuilder'; import { PoolBuilder } from '../common/poolBuilder';
export class LoaderMain extends ProcessRunner { export class LoaderMain extends ProcessRunner {

View File

@ -6,3 +6,9 @@
[merge.ts] [merge.ts]
../runner/reporters.ts ../runner/reporters.ts
[internalReporter.ts]
../transform/babelBundle.ts
[raw.ts]
../transform/babelBundle.ts

View File

@ -16,7 +16,7 @@
import fs from 'fs'; import fs from 'fs';
import { colors } from 'playwright-core/lib/utilsBundle'; import { colors } from 'playwright-core/lib/utilsBundle';
import { codeFrameColumns } from '../common/babelBundle'; import { codeFrameColumns } from '../transform/babelBundle';
import type { FullConfig, TestCase, TestError, TestResult, FullResult, TestStep, Reporter } from '../../types/testReporter'; import type { FullConfig, TestCase, TestError, TestResult, FullResult, TestStep, Reporter } from '../../types/testReporter';
import { Suite } from '../common/test'; import { Suite } from '../common/test';
import type { FullConfigInternal } from '../common/config'; import type { FullConfigInternal } from '../common/config';

View File

@ -22,7 +22,7 @@ import { sanitizeForFilePath } from '../util';
import { formatResultFailure } from './base'; import { formatResultFailure } from './base';
import { toPosixPath, serializePatterns } from './json'; import { toPosixPath, serializePatterns } from './json';
import { MultiMap } from 'playwright-core/lib/utils'; import { MultiMap } from 'playwright-core/lib/utils';
import { codeFrameColumns } from '../common/babelBundle'; import { codeFrameColumns } from '../transform/babelBundle';
import type { Metadata } from '../../types/test'; import type { Metadata } from '../../types/test';
import type { SuitePrivate } from '../../types/reporterPrivate'; import type { SuitePrivate } from '../../types/reporterPrivate';

View File

@ -3,6 +3,7 @@
../common/ ../common/
../reporters/ ../reporters/
../third_party/ ../third_party/
../transform/
../plugins/ ../plugins/
../util.ts ../util.ts
../utilsBundle.ts ../utilsBundle.ts

View File

@ -25,10 +25,10 @@ import { createFileMatcherFromArguments, createFileFiltersFromArguments, createT
import type { Matcher, TestFileFilter } from '../util'; import type { Matcher, TestFileFilter } from '../util';
import { buildProjectsClosure, collectFilesForProject, filterProjects } from './projectUtils'; import { buildProjectsClosure, collectFilesForProject, filterProjects } from './projectUtils';
import type { TestRun } from './tasks'; import type { TestRun } from './tasks';
import { requireOrImport } from '../common/transform'; import { requireOrImport } from '../transform/transform';
import { buildFileSuiteForProject, filterByFocusedLine, filterByTestIds, filterOnly, filterTestsRemoveEmptySuites } from '../common/suiteUtils'; import { buildFileSuiteForProject, filterByFocusedLine, filterByTestIds, filterOnly, filterTestsRemoveEmptySuites } from '../common/suiteUtils';
import { createTestGroups, filterForShard, type TestGroup } from './testGroups'; import { createTestGroups, filterForShard, type TestGroup } from './testGroups';
import { dependenciesForTestFile } from '../common/compilationCache'; import { dependenciesForTestFile } from '../transform/compilationCache';
import { sourceMapSupport } from '../utilsBundle'; import { sourceMapSupport } from '../utilsBundle';
import type { RawSourceMap } from 'source-map'; import type { RawSourceMap } from 'source-map';

View File

@ -21,8 +21,8 @@ import { Suite } from '../common/test';
import { loadTestFile } from '../common/testLoader'; import { loadTestFile } from '../common/testLoader';
import type { FullConfigInternal } from '../common/config'; import type { FullConfigInternal } from '../common/config';
import { PoolBuilder } from '../common/poolBuilder'; import { PoolBuilder } from '../common/poolBuilder';
import { addToCompilationCache } from '../common/compilationCache'; import { addToCompilationCache } from '../transform/compilationCache';
import { setBabelPlugins } from '../common/transform'; import { setBabelPlugins } from '../transform/transform';
export class InProcessLoaderHost { export class InProcessLoaderHost {
private _config: FullConfigInternal; private _config: FullConfigInternal;

View File

@ -18,7 +18,7 @@ import { showTraceViewer } from 'playwright-core/lib/server';
import type { Page } from 'playwright-core/lib/server/page'; import type { Page } from 'playwright-core/lib/server/page';
import { isUnderTest, ManualPromise } from 'playwright-core/lib/utils'; import { isUnderTest, ManualPromise } from 'playwright-core/lib/utils';
import type { FullResult } from '../../reporter'; import type { FullResult } from '../../reporter';
import { clearCompilationCache, collectAffectedTestFiles, dependenciesForTestFile } from '../common/compilationCache'; import { clearCompilationCache, collectAffectedTestFiles, dependenciesForTestFile } from '../transform/compilationCache';
import type { FullConfigInternal } from '../common/config'; import type { FullConfigInternal } from '../common/config';
import { InternalReporter } from '../reporters/internalReporter'; import { InternalReporter } from '../reporters/internalReporter';
import { TeleReporterEmitter } from '../reporters/teleEmitter'; import { TeleReporterEmitter } from '../reporters/teleEmitter';

View File

@ -22,7 +22,7 @@ import { createFileMatcher, createFileMatcherFromArguments } from '../util';
import type { Matcher } from '../util'; import type { Matcher } from '../util';
import { TestRun, createTaskRunnerForWatch, createTaskRunnerForWatchSetup } from './tasks'; import { TestRun, createTaskRunnerForWatch, createTaskRunnerForWatchSetup } from './tasks';
import { buildProjectsClosure, filterProjects } from './projectUtils'; import { buildProjectsClosure, filterProjects } from './projectUtils';
import { clearCompilationCache, collectAffectedTestFiles } from '../common/compilationCache'; import { clearCompilationCache, collectAffectedTestFiles } from '../transform/compilationCache';
import type { FullResult } from 'packages/playwright-test/reporter'; import type { FullResult } from 'packages/playwright-test/reporter';
import { chokidar } from '../utilsBundle'; import { chokidar } from '../utilsBundle';
import type { FSWatcher as CFSWatcher } from 'chokidar'; import type { FSWatcher as CFSWatcher } from 'chokidar';

View File

@ -0,0 +1,4 @@
[*]
../util.ts
../utilsBundle.ts
../third_party/tsconfig-loader.ts

View File

@ -19,7 +19,7 @@ export const codeFrameColumns: typeof import('../../bundles/babel/node_modules/@
export const declare: typeof import('../../bundles/babel/node_modules/@types/babel__helper-plugin-utils').declare = require('./babelBundleImpl').declare; export const declare: typeof import('../../bundles/babel/node_modules/@types/babel__helper-plugin-utils').declare = require('./babelBundleImpl').declare;
export const types: typeof import('../../bundles/babel/node_modules/@types/babel__core').types = require('./babelBundleImpl').types; export const types: typeof import('../../bundles/babel/node_modules/@types/babel__core').types = require('./babelBundleImpl').types;
export const parse: typeof import('../../bundles/babel/node_modules/@babel/parser/typings/babel-parser').parse = require('./babelBundleImpl').parse; export const parse: typeof import('../../bundles/babel/node_modules/@babel/parser/typings/babel-parser').parse = require('./babelBundleImpl').parse;
export const traverse: typeof import('../../bundles/babel/node_modules/@types/babel__traverse').default = require('./babelBundleImpl').traverse; export const traverse: typeof import('@babel/traverse').default = require('./babelBundleImpl').traverse;
export type BabelPlugin = [string, any?]; export type BabelPlugin = [string, any?];
export type BabelTransformFunction = (code: string, filename: string, isTypeScript: boolean, isModule: boolean, pluginsPrefix: BabelPlugin[], pluginsSuffix: BabelPlugin[]) => BabelFileResult; export type BabelTransformFunction = (code: string, filename: string, isTypeScript: boolean, isModule: boolean, pluginsPrefix: BabelPlugin[], pluginsSuffix: BabelPlugin[]) => BabelFileResult;
export const babelTransform: BabelTransformFunction = require('./babelBundleImpl').babelTransform; export const babelTransform: BabelTransformFunction = require('./babelBundleImpl').babelTransform;

View File

@ -1,4 +1,5 @@
[*] [*]
../common/ ../common/
../transform/
../util.ts ../util.ts
../utilBundle.ts ../utilBundle.ts

View File

@ -30,7 +30,7 @@ import { ProcessRunner } from '../common/process';
import { loadTestFile } from '../common/testLoader'; import { loadTestFile } from '../common/testLoader';
import { buildFileSuiteForProject, filterTestsRemoveEmptySuites } from '../common/suiteUtils'; import { buildFileSuiteForProject, filterTestsRemoveEmptySuites } from '../common/suiteUtils';
import { PoolBuilder } from '../common/poolBuilder'; import { PoolBuilder } from '../common/poolBuilder';
import { addToCompilationCache } from '../common/compilationCache'; import { addToCompilationCache } from '../transform/compilationCache';
import type { TestInfoError } from '../../types/test'; import type { TestInfoError } from '../../types/test';
const removeFolderAsync = util.promisify(rimraf); const removeFolderAsync = util.promisify(rimraf);