I found your issue - this is a known Change Set limitation with LWC static resource dependencies. Change Sets validate all components simultaneously during the upload phase, before actual deployment. When the LWC is validated, it checks for static resource existence in the target org at validation time, not deployment time. Since the static resource isn’t deployed yet during validation, you get the cross-reference error.
SOLUTION - Three-step approach addressing all dependency issues:
1. Static Resource Dependency (CRITICAL):
You MUST deploy the static resource separately first, then deploy the LWC. But here’s the trick - don’t use Change Sets for both. Deploy the static resource via Change Set, let it complete fully (check in Setup > Static Resources to confirm it’s there), then wait 15-30 minutes for metadata cache refresh.
2. SFDX Project Structure Fix:
Verify your sfdx-project.json includes both paths:
"packageDirectories": [
{"path": "force-app", "default": true}
]
And check your .forceignore doesn’t exclude static resources. The resource-meta.xml and the actual .js file must both be in staticresources folder.
3. Change Set Component Inclusion (Best Practice):
For the LWC deployment after static resource is live, your Change Set needs these exact components:
- Lightning Web Component: sentimentDashboard
- LWC HTML: sentimentDashboard.html
- LWC JS: sentimentDashboard.js
- LWC meta.xml: sentimentDashboard.js-meta.xml
- Any related Apex controllers if used
DO NOT re-include the static resource in the LWC Change Set.
Alternative (Recommended for Production):
Switch to SFDX deployment for better dependency control:
sfdx force:source:deploy -p force-app/main/default/staticresources -u prodOrg
sfdx force:source:deploy -p force-app/main/default/lwc/sentimentDashboard -u prodOrg
This gives you explicit ordering and better error messages. The metadata cache refresh happens automatically between deploys.
Why This Happens:
Change Sets were designed before LWC existed. They use an older deployment API that doesn’t understand modern LWC dependency graphs. SFDX uses Metadata API 2.0 which properly handles component dependencies and deployment sequencing. For complex LWC deployments with external libraries, SFDX is always more reliable.
If you must use Change Sets (company policy, etc.), the separate deployment approach is your only option. Deploy static resource today, deploy LWC tomorrow after cache clears. I know it’s not ideal for CI/CD, but that’s the Change Set limitation with LWC static resources.