Skip to content

Commit

Permalink
Merge pull request #532 from cspotcode/import-babel-on-demand
Browse files Browse the repository at this point in the history
Import babel deps on-demand, skipping if skipBabel is true
  • Loading branch information
kulshekhar authored May 22, 2018
2 parents 6e530aa + fdebcd9 commit 2af6d2a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/postprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
* Postprocess step. Based on babel-jest: https://github.com/facebook/jest/blob/master/packages/babel-jest/src/index.js
* https://github.com/facebook/jest/blob/9b157c3a7c325c3971b2aabbe4c8ab4ce0b0c56d/packages/babel-jest/src/index.js
*/
import * as babel from 'babel-core';
import istanbulPlugin from 'babel-plugin-istanbul';
import * as jestPreset from 'babel-preset-jest';
import * as __types__babel from 'babel-core';
import __types__istanbulPlugin from 'babel-plugin-istanbul';
import * as __types__jestPreset from 'babel-preset-jest';
let babel: typeof __types__babel;
let istanbulPlugin: typeof __types__istanbulPlugin;
let jestPreset: typeof __types__jestPreset;
function importBabelDeps() {
if (babel) {
return;
}
babel = require('babel-core');
istanbulPlugin = require('babel-plugin-istanbul').default;
jestPreset = require('babel-preset-jest');
}
import { CompilerOptions } from 'typescript/lib/typescript';
import {
BabelTransformOptions,
Expand Down Expand Up @@ -37,6 +48,7 @@ export function postProcessCode(
function createBabelTransformer(
options: BabelTransformOptions,
): PostProcessHook {
importBabelDeps();
options = {
...options,
plugins: options.plugins || [],
Expand Down

0 comments on commit 2af6d2a

Please sign in to comment.