From 84c2017a39e2b6dbbfd6b845f3e8b38b1e9b2b93 Mon Sep 17 00:00:00 2001 From: Yevhen Kyriukha Date: Wed, 25 Dec 2019 22:28:53 +0200 Subject: [PATCH] Support Babel v7. --- src/json.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/json.js b/src/json.js index 85a6ff5..c754ba9 100644 --- a/src/json.js +++ b/src/json.js @@ -1,4 +1,4 @@ -const template = require('babel-template'); +const template = require('@babel/template'); const fs = require('fs'); const path = require('path'); @@ -17,9 +17,8 @@ function createTransformPlugin(name, replace, code) { CallExpression: function(path, state) { if (path.get('callee').matchesPattern(replace)) { state[name] = true; - path.replaceWith( - template(`${defineName}($0)`)(path.node.arguments) + template.default(`${defineName}($0)`)(path.node.arguments) ); } }, @@ -30,7 +29,7 @@ function createTransformPlugin(name, replace, code) { exit(path, state) { if (!state[name]) return; const topNodes = []; - topNodes.push(template(`var ${defineName} = ${code}`)()); + topNodes.push(template.default(`var ${defineName} = ${code}`, { placeholderPattern: false })()); path.unshiftContainer('body', topNodes); }, },