Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/json.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const template = require('babel-template');
const template = require('@babel/template');
const fs = require('fs');
const path = require('path');

Expand All @@ -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)
);
}
},
Expand All @@ -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);
},
},
Expand Down