Skip to content

Commit

Permalink
Merge pull request #26 from zalando-incubator/fix-circullar-transpila…
Browse files Browse the repository at this point in the history
…tion

Fix circular transpilation
  • Loading branch information
peter-leonov committed May 31, 2019
2 parents 1315ce0 + 5caeebd commit 8fb4053
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 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,8 @@ const mergeIntoOptions = (options, opts) => {
Object.assign(options, opts);
};

let howDeepIsYourLove = 0

function processProgram({ types: t }, programPath, programOpts) {
const options = {
enable: isInASTExploler(),
Expand Down Expand Up @@ -398,6 +408,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 Expand Up @@ -457,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'));
Expand Down

0 comments on commit 8fb4053

Please sign in to comment.