Skip to content

Commit

Permalink
add a global variable to break the circular transpilation
Browse files Browse the repository at this point in the history
This is a dirty workaround, but I have no time now to make it proper.
The proper solution, btw, would be to make Jest understand query params
in imports jestjs/jest#6282
  • Loading branch information
Petr Leonov committed May 31, 2019
1 parent 1315ce0 commit 861a03d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions babel-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@ const STANDARD_BUILTINS = [
'_asyncToGenerator',
];

let hackyCount = undefined

const mergeIntoOptions = (options, opts) => {
if (opts.hackyCount !== undefined) {
if (hackyCount === undefined) {
hackyCount = opts.hackyCount
}
}

opts = Object.assign({}, opts);
const ignore = opts.ignore;
if (ignore) {
Expand All @@ -104,6 +112,9 @@ const mergeIntoOptions = (options, opts) => {
Object.assign(options, opts);
};

let howDeepIsYourLove = 0
let howDeepYourLoveMustBe = undefined

function processProgram({ types: t }, programPath, programOpts) {
const options = {
enable: isInASTExploler(),
Expand Down Expand Up @@ -398,6 +409,11 @@ function processProgram({ types: t }, programPath, programOpts) {
return false;
}

howDeepIsYourLove++
if (howDeepIsYourLove > hackyCount) {
return false;
}

const globalIds = toPairs(path.scope.globals)
.filter(([name, _]) => !options.ignore.has(name))
.map(([_, identifier]) => identifier);
Expand Down

0 comments on commit 861a03d

Please sign in to comment.