1 | "use strict";
|
2 |
|
3 | module.exports = function ({
|
4 | types: t
|
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 | const evaluated = path.parentPath.evaluate();
|
15 |
|
16 | if (evaluated.confident) {
|
17 | path.parentPath.replaceWith(t.valueToNode(evaluated.value));
|
18 | }
|
19 | }
|
20 | }
|
21 | }
|
22 |
|
23 | }
|
24 | };
|
25 | }; |
\ | No newline at end of file |