Skip to content

Commit 8fb4053

Browse files
authored
Merge pull request #26 from zalando-incubator/fix-circullar-transpilation
Fix circular transpilation
2 parents 1315ce0 + 5caeebd commit 8fb4053

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

babel-plugin.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,15 @@ const STANDARD_BUILTINS = [
8888
'_asyncToGenerator',
8989
];
9090

91+
let hackyCount = undefined
92+
9193
const mergeIntoOptions = (options, opts) => {
94+
if (opts.hackyCount !== undefined) {
95+
if (hackyCount === undefined) {
96+
hackyCount = opts.hackyCount
97+
}
98+
}
99+
92100
opts = Object.assign({}, opts);
93101
const ignore = opts.ignore;
94102
if (ignore) {
@@ -104,6 +112,8 @@ const mergeIntoOptions = (options, opts) => {
104112
Object.assign(options, opts);
105113
};
106114

115+
let howDeepIsYourLove = 0
116+
107117
function processProgram({ types: t }, programPath, programOpts) {
108118
const options = {
109119
enable: isInASTExploler(),
@@ -398,6 +408,11 @@ function processProgram({ types: t }, programPath, programOpts) {
398408
return false;
399409
}
400410

411+
howDeepIsYourLove++
412+
if (howDeepIsYourLove > hackyCount) {
413+
return false;
414+
}
415+
401416
const globalIds = toPairs(path.scope.globals)
402417
.filter(([name, _]) => !options.ignore.has(name))
403418
.map(([_, identifier]) => identifier);
@@ -457,9 +472,6 @@ function processProgram({ types: t }, programPath, programOpts) {
457472
};
458473

459474
function test(path, statepath) {
460-
if (!options.enable) {
461-
return false;
462-
}
463475
if (options.instrumentImports != 'query') return;
464476

465477
const imports = path.node.body.filter(byType('ImportDeclaration'));

0 commit comments

Comments
 (0)