Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Use babel.transformAsync (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Dec 2, 2019
1 parent 3cda4c8 commit 208e275
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/transformCode.js
Expand Up @@ -14,21 +14,25 @@ export default function(code, babelOptions, overrides, customOptions, ctx, final
code,
customOptions,
}),
).then(transformOptions => {
if (finalizeOptions) {
transformOptions = finalizeOptions(transformOptions);
}
const result = babel.transformSync(code, transformOptions);
)
.then(transformOptions => {
if (finalizeOptions) {
transformOptions = finalizeOptions(transformOptions);
}

return Promise.resolve(
!overrides.result
? result
: overrides.result.call(ctx, result, {
code,
customOptions,
config,
transformOptions,
}),
).then(({ code, map }) => ({ code, map }));
});
const resultP = babel.transformAsync(code, transformOptions);

if (!overrides.result) {
return resultP;
}
return resultP.then(result =>
overrides.result.call(ctx, result, {
code,
customOptions,
config,
transformOptions,
}),
);
})
.then(({ code, map }) => ({ code, map }));
}

0 comments on commit 208e275

Please sign in to comment.