UNPKG

502 BJavaScriptView Raw
1"use strict";
2
3const t = require('@babel/types');
4
5module.exports = {
6 MemberExpression(path) {
7 // Inline process.browser
8 const isProcess = path.node.object.name === 'process';
9 const isBrowser = path.node.property.name === 'browser';
10 const isAssignment = path.parentPath.type === 'AssignmentExpression';
11
12 if (isProcess && isBrowser) {
13 if (isAssignment) {
14 path.parentPath.remove();
15 } else {
16 path.replaceWith(t.booleanLiteral(true));
17 }
18 }
19 }
20
21};
\No newline at end of file