Skip to content

Commit

Permalink
More gensync
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Sep 27, 2019
1 parent d6a7280 commit 0da4f7e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/babel-core/src/transformation/index.js
Expand Up @@ -26,7 +26,6 @@ export type FileResult = {
map: SourceMap | null,
};

// eslint-disable-next-line require-yield
export function* run(
config: ResolvedConfig,
code: string,
Expand All @@ -39,7 +38,7 @@ export function* run(
ast,
);

transformFile(file, config.passes);
yield* transformFile(file, config.passes);

const opts = file.opts;
const { outputCode, outputMap } =
Expand All @@ -55,7 +54,8 @@ export function* run(
};
}

function transformFile(file: File, pluginPasses: PluginPasses): void {
// eslint-disable-next-line require-yield
function* transformFile(file: File, pluginPasses: PluginPasses): Handler<void> {
for (const pluginPairs of pluginPasses) {
const passPairs = [];
const passes = [];
Expand All @@ -74,6 +74,7 @@ function transformFile(file: File, pluginPasses: PluginPasses): void {
if (fn) {
const result = fn.call(pass, file);

// ASYNC, if we want to allow async .pre
if (isThenable(result)) {
throw new Error(
`You appear to be using an plugin with an async .pre, ` +
Expand All @@ -98,6 +99,7 @@ function transformFile(file: File, pluginPasses: PluginPasses): void {
if (fn) {
const result = fn.call(pass, file);

// ASYNC, if we want to allow async .post
if (isThenable(result)) {
throw new Error(
`You appear to be using an plugin with an async .post, ` +
Expand Down

0 comments on commit 0da4f7e

Please sign in to comment.