babel-plugin-rewire icon indicating copy to clipboard operation
babel-plugin-rewire copied to clipboard

Error during transpilation: Property left of AssignmentExpression expected node to be of a type ["LVal"] but instead got "CallExpression"

Open mayeaux opened this issue 7 years ago • 3 comments

During transpilation I receive this error:

Property left of AssignmentExpression expected node to be of a type ["LVal"] but instead got "CallExpression"

With this file:

import { sendEmail } from '../lib/util/mailer';

sendEmail({
  to: process.argv[2],
  subject: process.argv[3],
  text: process.argv[4]
});

Any ideas?

mayeaux avatar Jan 06 '17 21:01 mayeaux

Btw, I was able to fix this via:

+const to = process.argv[2];
 +const subject = process.argv[3];
 +const text = process.argv[4];

Loading the variables into memory first, and then using those variables. Not sure how to make this not throw in babel-rewire though

mayeaux avatar Jan 10 '17 06:01 mayeaux

@mrmayfield Thanks for reporting this issue and sorry for the late reply. The issue will be tackled, but won't be fixed before mid of march.

speedskater avatar Feb 13 '17 12:02 speedskater

@mikesherov I got the same error with a salesforce lwc module :

function isRewireable(path, variableBinding) {
	var node = path.node,
		    parent = path.parent;

	return variableBinding.referencePaths !== null &&
		!(parent.type === 'VariableDeclarator' && parent.id == node) &&
		!(parent.type === 'ForInStatement' && parent.left == node) &&
		✅ !(parent.type === 'AssignmentExpression' && parent.left == node) &&
		!(parent.type === 'FunctionExpression' && parent.id === node) &&
		!(parent.type === 'MemberExpression' && parent.property === node) &&
		[...]
	}

Adding this line at src/babel-plugin-rewire.js among the return conditions of the function isRewireable fixed the error !

ETD-BIO avatar Aug 17 '23 19:08 ETD-BIO