Skip to content

Commit

Permalink
Adding transformAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
ychi authored and SimenB committed Mar 13, 2021
1 parent f73d5f6 commit fc92ed8
Show file tree
Hide file tree
Showing 8 changed files with 1,859 additions and 125 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit fc92ed8

Please sign in to comment.