UNPKG

575 BJavaScriptView Raw
1"use strict";
2
3module.exports = function (_ref) {
4 var t = _ref.types;
5
6 return {
7 name: "transform-node-env-inline",
8 visitor: {
9 MemberExpression(path) {
10 if (path.matchesPattern("process.env.NODE_ENV")) {
11 path.replaceWith(t.valueToNode(process.env.NODE_ENV));
12
13 if (path.parentPath.isBinaryExpression()) {
14 var evaluated = path.parentPath.evaluate();
15 if (evaluated.confident) {
16 path.parentPath.replaceWith(t.valueToNode(evaluated.value));
17 }
18 }
19 }
20 }
21 }
22 };
23};
\No newline at end of file