phenomejs / phenome

The ultimate cross-framework component compiler
http://phenomejs.org
MIT License
71 stars 8 forks source link

Remove pointless statements #36

Closed nolimits4web closed 6 years ago

nolimits4web commented 6 years ago

If we have the following code in our JSX components:

if (process.env.COMPILER === 'react') {
  console.log('i am in react');
}
if (process.env.COMPILER === 'vue') {
  console.log('i am in vue');
}

the compiled code in, for example, Vue component, will be:

if ('vue' === 'react') {
  console.log('i am in react');
}
if ('vue === 'vue') {
  console.log('i am in vue');
}

which doesn't make much sense. So we need to walk through such simple literal conditions and remove/modify them to:

in react we should have only:

console.log('i am in react');

and in vue:

console.log('i am in vue');
nolimits4web commented 6 years ago

Fixed in https://github.com/phenomejs/phenome/commit/2268a252c1205d396b9b99e34dad76b2227bd699