mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: move transform to its own folder (for loader worker) (#23247)
This commit is contained in:
parent
2858ca95d8
commit
76b4b9dbaf
@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import type { T, BabelAPI } from '../../playwright-test/src/common/babelBundle';
|
||||
import { types, declare, traverse } from '@playwright/test/lib/common/babelBundle';
|
||||
import type { T, BabelAPI } from '@playwright/test/src/transform/babelBundle';
|
||||
import { types, declare, traverse } from '@playwright/test/lib/transform/babelBundle';
|
||||
import { resolveImportSpecifierExtension } from '@playwright/test/lib/util';
|
||||
const t: typeof T = types;
|
||||
|
||||
|
@ -25,11 +25,11 @@ import type { PluginContext } from 'rollup';
|
||||
|
||||
import fs from 'fs';
|
||||
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 { assert, calculateSha1 } 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';
|
||||
|
||||
let stoppableServer: any;
|
||||
|
@ -3,7 +3,7 @@
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"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",
|
||||
"watch": "npm run esbuild -- --watch --sourcemap",
|
||||
"generate-license": "node ../../../../utils/generate_third_party_notice.js"
|
||||
|
@ -18,8 +18,8 @@
|
||||
"./cli": "./cli.js",
|
||||
"./package.json": "./package.json",
|
||||
"./lib/cli": "./lib/cli.js",
|
||||
"./lib/common/babelBundle": "./lib/common/babelBundle.js",
|
||||
"./lib/common/compilationCache": "./lib/common/compilationCache.js",
|
||||
"./lib/transform/babelBundle": "./lib/transform/babelBundle.js",
|
||||
"./lib/transform/compilationCache": "./lib/transform/compilationCache.js",
|
||||
"./lib/internalsForTest": "./lib/internalsForTest.js",
|
||||
"./lib/experimentalLoader": "./lib/experimentalLoader.js",
|
||||
"./lib/plugins": "./lib/plugins/index.js",
|
||||
|
@ -8,3 +8,9 @@ common/
|
||||
|
||||
[index.ts]
|
||||
@testIsomorphic/**
|
||||
|
||||
[experimentalLoader.ts]
|
||||
./transform/
|
||||
|
||||
[internalsForTest.ts]
|
||||
**
|
||||
|
@ -1,9 +1,8 @@
|
||||
[*]
|
||||
../util.ts
|
||||
../utilsBundle.ts
|
||||
|
||||
[transform.ts]
|
||||
../third_party/tsconfig-loader.ts
|
||||
../transform
|
||||
|
||||
[testType.ts]
|
||||
../matchers/expect.ts
|
||||
|
||||
|
@ -18,7 +18,7 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { isRegExp } from 'playwright-core/lib/utils';
|
||||
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 { errorWithFile } from '../util';
|
||||
import { setCurrentConfig } from './globals';
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { serializeCompilationCache } from './compilationCache';
|
||||
import { serializeCompilationCache } from '../transform/compilationCache';
|
||||
import type { FullConfigInternal } from './config';
|
||||
import type { ReporterDescription, TestInfoError, TestStatus } from '../../types/test';
|
||||
|
||||
|
@ -19,9 +19,9 @@ import util from 'util';
|
||||
import type { TestError } from '../../reporter';
|
||||
import { isWorkerProcess, setCurrentlyLoadingFileSuite } from './globals';
|
||||
import { Suite } from './test';
|
||||
import { requireOrImport } from './transform';
|
||||
import { requireOrImport } from '../transform/transform';
|
||||
import { filterStackTrace } from '../util';
|
||||
import { startCollectingFileDeps, stopCollectingFileDeps } from './compilationCache';
|
||||
import { startCollectingFileDeps, stopCollectingFileDeps } from '../transform/compilationCache';
|
||||
|
||||
export const defaultTimeout = 30000;
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
import { expect } from '../matchers/expect';
|
||||
import { currentlyLoadingFileSuite, currentTestInfo, setCurrentlyLoadingFileSuite } from './globals';
|
||||
import { TestCase, Suite } from './test';
|
||||
import { wrapFunctionWithLocation } from './transform';
|
||||
import { wrapFunctionWithLocation } from '../transform/transform';
|
||||
import type { FixturesWithLocation } from './config';
|
||||
import type { Fixtures, TestType } from '../../types/test';
|
||||
import type { Location } from '../../types/testReporter';
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
import fs from 'fs';
|
||||
import url from 'url';
|
||||
import { belongsToNodeModules, currentFileDepsCollector } from './common/compilationCache';
|
||||
import { transformHook, resolveHook } from './common/transform';
|
||||
import { belongsToNodeModules, currentFileDepsCollector } from './transform/compilationCache';
|
||||
import { transformHook, resolveHook } from './transform/transform';
|
||||
|
||||
// Node < 18.6: defaultResolve takes 3 arguments.
|
||||
// Node >= 18.6: nextResolve from the chain takes 2 arguments.
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import { fileDependenciesForTest } from './common/compilationCache';
|
||||
import { fileDependenciesForTest } from './transform/compilationCache';
|
||||
|
||||
export function fileDependencies() {
|
||||
return Object.fromEntries([...fileDependenciesForTest().entries()].map(entry => (
|
||||
|
@ -1,2 +1,3 @@
|
||||
[*]
|
||||
../common/
|
||||
../transform/
|
@ -20,7 +20,7 @@ import { ProcessRunner } from '../common/process';
|
||||
import type { FullConfigInternal } from '../common/config';
|
||||
import { loadTestFile } from '../common/testLoader';
|
||||
import type { TestError } from '../../reporter';
|
||||
import { addToCompilationCache, serializeCompilationCache } from '../common/compilationCache';
|
||||
import { addToCompilationCache, serializeCompilationCache } from '../transform/compilationCache';
|
||||
import { PoolBuilder } from '../common/poolBuilder';
|
||||
|
||||
export class LoaderMain extends ProcessRunner {
|
||||
|
@ -6,3 +6,9 @@
|
||||
|
||||
[merge.ts]
|
||||
../runner/reporters.ts
|
||||
|
||||
[internalReporter.ts]
|
||||
../transform/babelBundle.ts
|
||||
|
||||
[raw.ts]
|
||||
../transform/babelBundle.ts
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import fs from 'fs';
|
||||
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 { Suite } from '../common/test';
|
||||
import type { FullConfigInternal } from '../common/config';
|
||||
|
@ -22,7 +22,7 @@ import { sanitizeForFilePath } from '../util';
|
||||
import { formatResultFailure } from './base';
|
||||
import { toPosixPath, serializePatterns } from './json';
|
||||
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 { SuitePrivate } from '../../types/reporterPrivate';
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
../common/
|
||||
../reporters/
|
||||
../third_party/
|
||||
../transform/
|
||||
../plugins/
|
||||
../util.ts
|
||||
../utilsBundle.ts
|
||||
|
@ -25,10 +25,10 @@ import { createFileMatcherFromArguments, createFileFiltersFromArguments, createT
|
||||
import type { Matcher, TestFileFilter } from '../util';
|
||||
import { buildProjectsClosure, collectFilesForProject, filterProjects } from './projectUtils';
|
||||
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 { createTestGroups, filterForShard, type TestGroup } from './testGroups';
|
||||
import { dependenciesForTestFile } from '../common/compilationCache';
|
||||
import { dependenciesForTestFile } from '../transform/compilationCache';
|
||||
import { sourceMapSupport } from '../utilsBundle';
|
||||
import type { RawSourceMap } from 'source-map';
|
||||
|
||||
|
@ -21,8 +21,8 @@ import { Suite } from '../common/test';
|
||||
import { loadTestFile } from '../common/testLoader';
|
||||
import type { FullConfigInternal } from '../common/config';
|
||||
import { PoolBuilder } from '../common/poolBuilder';
|
||||
import { addToCompilationCache } from '../common/compilationCache';
|
||||
import { setBabelPlugins } from '../common/transform';
|
||||
import { addToCompilationCache } from '../transform/compilationCache';
|
||||
import { setBabelPlugins } from '../transform/transform';
|
||||
|
||||
export class InProcessLoaderHost {
|
||||
private _config: FullConfigInternal;
|
||||
|
@ -18,7 +18,7 @@ import { showTraceViewer } from 'playwright-core/lib/server';
|
||||
import type { Page } from 'playwright-core/lib/server/page';
|
||||
import { isUnderTest, ManualPromise } from 'playwright-core/lib/utils';
|
||||
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 { InternalReporter } from '../reporters/internalReporter';
|
||||
import { TeleReporterEmitter } from '../reporters/teleEmitter';
|
||||
|
@ -22,7 +22,7 @@ import { createFileMatcher, createFileMatcherFromArguments } from '../util';
|
||||
import type { Matcher } from '../util';
|
||||
import { TestRun, createTaskRunnerForWatch, createTaskRunnerForWatchSetup } from './tasks';
|
||||
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 { chokidar } from '../utilsBundle';
|
||||
import type { FSWatcher as CFSWatcher } from 'chokidar';
|
||||
|
4
packages/playwright-test/src/transform/DEPS.list
Normal file
4
packages/playwright-test/src/transform/DEPS.list
Normal file
@ -0,0 +1,4 @@
|
||||
[*]
|
||||
../util.ts
|
||||
../utilsBundle.ts
|
||||
../third_party/tsconfig-loader.ts
|
@ -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 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 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 BabelTransformFunction = (code: string, filename: string, isTypeScript: boolean, isModule: boolean, pluginsPrefix: BabelPlugin[], pluginsSuffix: BabelPlugin[]) => BabelFileResult;
|
||||
export const babelTransform: BabelTransformFunction = require('./babelBundleImpl').babelTransform;
|
@ -1,4 +1,5 @@
|
||||
[*]
|
||||
../common/
|
||||
../transform/
|
||||
../util.ts
|
||||
../utilBundle.ts
|
||||
|
@ -30,7 +30,7 @@ import { ProcessRunner } from '../common/process';
|
||||
import { loadTestFile } from '../common/testLoader';
|
||||
import { buildFileSuiteForProject, filterTestsRemoveEmptySuites } from '../common/suiteUtils';
|
||||
import { PoolBuilder } from '../common/poolBuilder';
|
||||
import { addToCompilationCache } from '../common/compilationCache';
|
||||
import { addToCompilationCache } from '../transform/compilationCache';
|
||||
import type { TestInfoError } from '../../types/test';
|
||||
|
||||
const removeFolderAsync = util.promisify(rimraf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user