Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transformer): async code transformation #9889

Merged
merged 1 commit into from Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -24,6 +24,7 @@
- `[jest-transform]` Pass config options defined in Jest's config to transformer's `process` and `getCacheKey` functions ([#10926](https://github.com/facebook/jest/pull/10926))
- `[jest-transform]` Add support for transformers written in ESM ([#11163](https://github.com/facebook/jest/pull/11163))
- `[jest-transform]` [**BREAKING**] Do not export `ScriptTransformer` class, instead export the async function `createScriptTransformer` ([#11163](https://github.com/facebook/jest/pull/11163))
- `[jest-transform]` Async code transformations ([#9889](https://github.com/facebook/jest/pull/9889))
- `[jest-worker]` Add support for custom task queues and adds a `PriorityQueue` implementation. ([#10921](https://github.com/facebook/jest/pull/10921))
- `[jest-worker]` Add in-order scheduling policy to jest worker ([10902](https://github.com/facebook/jest/pull/10902))

Expand Down
6 changes: 3 additions & 3 deletions packages/babel-jest/src/index.ts
Expand Up @@ -17,7 +17,7 @@ import * as fs from 'graceful-fs';
import slash = require('slash');
import type {
TransformOptions as JestTransformOptions,
Transformer,
SyncTransformer,
} from '@jest/transform';
import type {Config} from '@jest/types';
import {loadPartialConfig} from './loadBabelConfig';
Expand All @@ -26,7 +26,7 @@ const THIS_FILE = fs.readFileSync(__filename);
const jestPresetPath = require.resolve('babel-preset-jest');
const babelIstanbulPlugin = require.resolve('babel-plugin-istanbul');

type CreateTransformer = Transformer<TransformOptions>['createTransformer'];
type CreateTransformer = SyncTransformer<TransformOptions>['createTransformer'];

const createTransformer: CreateTransformer = userOptions => {
const inputOptions = userOptions ?? {};
Expand Down Expand Up @@ -160,7 +160,7 @@ const createTransformer: CreateTransformer = userOptions => {
};
};

const transformer: Transformer<TransformOptions> = {
const transformer: SyncTransformer<TransformOptions> = {
...createTransformer(),
// Assigned here so only the exported transformer has `createTransformer`,
// instead of all created transformers by the function
Expand Down
5 changes: 3 additions & 2 deletions packages/jest-repl/src/cli/repl.ts
Expand Up @@ -11,10 +11,11 @@ declare const jestProjectConfig: Config.ProjectConfig;
import * as path from 'path';
import * as repl from 'repl';
import {runInThisContext} from 'vm';
import type {Transformer} from '@jest/transform';
import type {SyncTransformer} from '@jest/transform';
import type {Config} from '@jest/types';

let transformer: Transformer;
// TODO: support async as well
let transformer: SyncTransformer;
let transformerConfig: unknown;

const evalCommand: repl.REPLEval = (
Expand Down