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 referencesc-foo
in its markup. However, when deploying justc-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 itsfoo.js-meta.xml
file. Therefore, presumably,c-foo
is the cause so I commented bothfoo.html
andfoo.js
files, as well as thec-foo
reference in thebar.html
markup then re-deployedc-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 thefoo.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?
.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.