Skip to content

Commit

Permalink
helper-module-transforms: dereference imported template tag (#10934)
Browse files Browse the repository at this point in the history
* Dereference imported template tag

* apply fix for OptionalCallExpression as well
  • Loading branch information
ajafff authored and JLHwung committed Dec 28, 2019
1 parent e9dc74e commit b91720c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Expand Up @@ -182,7 +182,9 @@ const rewriteReferencesVisitor = {
ref.loc = path.node.loc;

if (
path.parentPath.isCallExpression({ callee: path.node }) &&
(path.parentPath.isCallExpression({ callee: path.node }) ||
path.parentPath.isOptionalCallExpression({ callee: path.node }) ||
path.parentPath.isTaggedTemplateExpression({ tag: path.node })) &&
t.isMemberExpression(ref)
) {
path.replaceWith(t.sequenceExpression([t.numericLiteral(0), ref]));
Expand Down
Expand Up @@ -7,3 +7,5 @@ foo;
foo2;
foo3;
foo3();
foo3``;
foo3?.();
Expand Up @@ -5,3 +5,5 @@ foo4.default;
foo4.default;
foo4.foo3;
(0, foo4.foo3)();
(0, foo4.foo3)``;
(0, foo4.foo3)?.();
Expand Up @@ -2,6 +2,7 @@
"plugins": [
"external-helpers",
"syntax-object-rest-spread",
"syntax-optional-chaining",
[
"transform-modules-commonjs",
{ "strict": true, "mjsStrictNamespace": false }
Expand Down

0 comments on commit b91720c

Please sign in to comment.