3

Problem:

After developing 4 LWC components then deploying to a scratch org via SFDX: Push Source to Default Scratch Org, the Salesforce CLI returns:

LWC1001: Unexpected compilation error: did not find a shallow_cmp function for AST_Chain

Some Details:

  • All 4 LWCs do not throw errors when deployed to Local Development Server
  • 1 LWC is a service component
  • 2 LWC components are child components
  • Running sfdx-cli/7.98.0
  • Each LWC is running API version 51.0
  • All are visible for each, except for service LWC
  • All targets are declared for each, except for service LWC

What I have tried:

  • Transfering LWCs to a new project and deploying them.
  • Deploying each LWC individually.
  • Updating sfdx

Result:

  • Deploying from a new project and updating sfdx still returns the same error.
  • But, after deploying each LWC individually, I discovered two of them cannot deploy by themselves. One of them, let's call it c-bar, cannot deploy because it references c-foo in its markup. However, when deploying just c-foo the CLI returns the same error--LWC1001: Unexpected compilation error: did not find a shallow_cmp function for AST_Chain--and VS Code points to its foo.js-meta.xml file. Therefore, presumably, c-foo is the cause so I commented both foo.html and foo.js files, as well as the c-foo reference in the bar.html markup then re-deployed c-foo. As a result, it was able to successfully deploy.
  • When commenting just its markup file (foo.html), leaving it just <template></template>, the CLI returns the same compilation error which leaves me to think the foo.js is the cause for some reason.

Any thoughts or suggestions why a compilation error can occur from foo.js, when all it mainly does is listening for and dispatching events?

2
  • Likely something in your .js that isn't being well handled by the tooling. Suggest you post the .js if possible and someone may recognise some unusual coding in it so you can work-around the tooling problem by changing your .js. PS nice work on narrowing this down.
    – Keith C
    Apr 25 at 11:43
  • @KeithC Yeah, it turns out that one of the SFDX compilation tools crashes when encountered ES2020 optional chaining or null coalescing syntax. After refactoring the code using those operators, it works. Thanks
    – celsius
    Apr 25 at 23:46
4

... it turns out that one of the SFDX compilation tools crashes when encountered ES2020 optional chaining or null coalescing syntax. After refactoring the code using those operators, it works ...

Using optional chaining throws:

LWC1001: Unexpected compilation error: did not find a shallow_cmp function for AST_Chain

While using null coalescing throws:

LWC1503: Parsing error: Unexpected token, expected ";"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.