From 861a03d7fbcc9ccc601b19766fd5ba2679128fc2 Mon Sep 17 00:00:00 2001 From: Petr Leonov Date: Fri, 31 May 2019 14:30:48 +0200 Subject: [PATCH 1/3] add a global variable to break the circular transpilation 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 https://github.com/facebook/jest/pull/6282 --- babel-plugin.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/babel-plugin.js b/babel-plugin.js index a25e2a5..6de5728 100644 --- a/babel-plugin.js +++ b/babel-plugin.js @@ -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) { @@ -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(), @@ -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); From fb69d889c597fd1933f9d22001d115b549313a75 Mon Sep 17 00:00:00 2001 From: Petr Leonov Date: Fri, 31 May 2019 14:57:58 +0200 Subject: [PATCH 2/3] gc --- babel-plugin.js | 1 - 1 file changed, 1 deletion(-) diff --git a/babel-plugin.js b/babel-plugin.js index 6de5728..7847e03 100644 --- a/babel-plugin.js +++ b/babel-plugin.js @@ -113,7 +113,6 @@ const mergeIntoOptions = (options, opts) => { }; let howDeepIsYourLove = 0 -let howDeepYourLoveMustBe = undefined function processProgram({ types: t }, programPath, programOpts) { const options = { From 5caeebdb38217494440b86273440e55f023514cf Mon Sep 17 00:00:00 2001 From: Petr Leonov Date: Fri, 31 May 2019 15:36:58 +0200 Subject: [PATCH 3/3] fix query augmenting --- babel-plugin.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/babel-plugin.js b/babel-plugin.js index 7847e03..9635382 100644 --- a/babel-plugin.js +++ b/babel-plugin.js @@ -472,9 +472,6 @@ function processProgram({ types: t }, programPath, programOpts) { }; function test(path, statepath) { - if (!options.enable) { - return false; - } if (options.instrumentImports != 'query') return; const imports = path.node.body.filter(byType('ImportDeclaration'));