babel-plugin-inline-replace-variables
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,2 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
/** | ||
@@ -14,7 +17,17 @@ * Created at 16/5/18. | ||
exports.default = function (_ref) { | ||
var types = _ref.types; | ||
var t = _ref.types; | ||
return { | ||
visitor: { | ||
Identifier: function Identifier(path, state) { | ||
path.node.name = JSON.stringify(state.opts[path.node.name]) || path.node.name; | ||
var replacement = state.opts[path.node.name]; | ||
if (replacement !== undefined) { | ||
var type = typeof replacement === 'undefined' ? 'undefined' : _typeof(replacement); | ||
if (type === 'boolean') { | ||
path.replaceWith(t.booleanLiteral(replacement)); | ||
} else { | ||
// treat as string | ||
var str = String(replacement); | ||
path.replaceWith(t.stringLiteral(str)); | ||
} | ||
} | ||
} | ||
@@ -25,2 +38,2 @@ } | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
{ | ||
"name": "babel-plugin-inline-replace-variables", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "babel plugin to inline replace variables", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
4734
83