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

Allow a transform's process function to return Promise #8100

Closed
a-student opened this issue Mar 11, 2019 · 2 comments
Closed

Allow a transform's process function to return Promise #8100

a-student opened this issue Mar 11, 2019 · 2 comments

Comments

@a-student
Copy link

🚀 Feature Proposal

Jest expects an exported transform's process function to return a string.
Please, allow it to return a Promise<string | { code: string }> | string | { code: string }.

Motivation

We live in a new era of asynchronous code and, unfortunately, it is not always possible to write synchronous transformations. For example, I implement a transform which uses postcss internally, which in turn is asynchronous all the way. Currently, I unable to use postcss as a dependency for transformations :-(

Example

Somewhere in a transform implementation:

export async function process (
    src: string,
    path: string,
    config: any,
): Promise<string> {

... await ...

    return '';
}
@SimenB
Copy link
Member

SimenB commented Mar 14, 2019

This is not possible as transformers are called at require time, which is synchronous.

Duplicate of #5556 et al

@SimenB SimenB closed this as completed Mar 14, 2019
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants